/* Style Global */
body {
    background-color: #2b2d31; 
    color: #dbdee1;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    margin: 0;
    padding: 20px;
    height: 100vh;
    box-sizing: border-box;
}

#main-container {
    display: flex;
    gap: 20px;
    height: 100%;
}

h2 { margin-top: 0; color: #fff; }

/* --- NOUVEAU : En-têtes Sticky (Fixes) --- */
.sticky-header, .sticky-tools {
    position: sticky;
    top: -20px; /* Compense le padding du parent */
    background-color: #1e1f22;
    z-index: 10;
    padding: 20px 0 10px 0;
    margin-top: -20px;
    border-bottom: 1px solid #383a40;
    margin-bottom: 15px;
}

.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#btn-export {
    background-color: #5865F2;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

#btn-export:hover { background-color: #4752C4; }

/* Zone Tier List */
#tierlist-container {
    flex: 3;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    background-color: #1e1f22;
    padding: 20px;
    border-radius: 8px;
}

.tier-row {
    display: flex;
    background-color: #2b2d31;
    min-height: 120px;
    border-radius: 5px;
    overflow: hidden;
    flex-shrink: 0;
}

/* NOUVEAU : Label qui revient à la ligne + Compteur */
.tier-label {
    width: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    color: #111;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.3);
    text-align: center;
    word-wrap: break-word;
    padding: 5px;
    box-sizing: border-box;
}

.tier-label span {
    font-size: 14px;
    opacity: 0.8;
    margin-top: 5px;
}

.tier-dropzone {
    flex: 1;
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 10px;
    align-items: flex-start;
}

/* Zone Droite (Séries & Recherche) */
#pool-container {
    flex: 1;
    background-color: #1e1f22;
    padding: 20px;
    border-radius: 8px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

#search-bar {
    width: 100%;
    padding: 12px;
    border-radius: 5px;
    border: none;
    background-color: #383a40;
    color: white;
    font-size: 14px;
    box-sizing: border-box;
}
#search-bar:focus { outline: 2px solid #5865F2; }

#search-results-chars {
    background-color: #2b2d31;
    border-radius: 5px;
    margin-bottom: 5px;
}

/* Accordéons des séries */
.serie-wrapper {
    margin-bottom: 5px;
}

.serie-header {
    background-color: #383a40;
    padding: 12px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    user-select: none;
    transition: background 0.2s;
}

.serie-header:hover { background-color: #404249; }

.serie-content {
    display: none; 
    padding: 10px;
    background-color: #2b2d31;
    border-radius: 0 0 5px 5px;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 40px; 
}

.serie-content.active { display: flex; }

/* Les Personnages */
.character {
    width: 80px;
    height: 80px;
    background-color: #4f545c;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background-size: cover;
    background-position: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.char-name {
    background: rgba(0, 0, 0, 0.75);
    width: 100%;
    text-align: center;
    font-size: 11px;
    padding: 4px 0;
    font-weight: bold;
    pointer-events: none;
}

/* NOUVEAU : Le badge de Rang pour la recherche */
.tier-badge {
    position: absolute;
    top: 3px;
    right: 3px;
    color: #111;
    padding: 2px 5px;
    font-size: 11px;
    border-radius: 4px;
    font-weight: 900;
    z-index: 2;
    border: 1px solid rgba(0,0,0,0.3);
    text-transform: uppercase;
}

/* Boutons de contrôle de ligne */
.tier-controls {
    display: flex;
    flex-direction: column;
    width: 40px;
    background-color: #202225;
    border-left: 2px solid #1e1f22;
}

.tier-controls button {
    flex: 1;
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.tier-controls button:hover { background-color: #383a40; }
.tier-controls button:active { background-color: #5865F2; }

/* Le Menu Paramètres (Modal) */
#tier-modal {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background-color: #2b2d31;
    padding: 20px;
    border-radius: 8px;
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}

.modal-content h3 { 
    margin: 0;
    border-bottom: 1px solid #4f545c;
    padding-bottom: 10px; 
}

.modal-body { 
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
}

.modal-body label { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    font-weight: bold; 
}

.modal-body input[type="text"] { 
    background-color: #1e1f22; 
    border: 1px solid #4f545c; 
    color: white; 
    padding: 5px; 
    border-radius: 3px; 
}

.modal-body input[type="color"] { 
    border: none; 
    width: 40px; 
    height: 30px; 
    cursor: pointer; 
    background: none; 
}

.modal-actions-vertical { 
    display: flex; 
    flex-direction: column; 
    gap: 5px; 
    border-bottom: 1px solid #4f545c; 
    padding-bottom: 15px;
}

.modal-actions-vertical button, .modal-actions-bottom button {
    background-color: #5865F2; 
    border: none; 
    color: white; 
    padding: 8px; 
    border-radius: 3px; 
    cursor: pointer; 
    font-weight: bold; 
    transition: opacity 0.2s;
}

.modal-actions-vertical button:hover, .modal-actions-bottom button:hover { 
    opacity: 0.8; 
}

.modal-actions-bottom { 
    display: flex; 
    justify-content: space-between; 
    margin-top: 5px;
}

.filter-btn {
    background-color: #383a40;
    color: white;
    border: 1px solid #4f545c;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.filter-btn:hover { background-color: #4f545c; }

.filter-btn.active {
    background-color: #5865F2;
    border-color: #5865F2;
    font-weight: bold;
}

.character.hidden-by-filter {
    display: none !important;
}