/* --- Structure Principale --- */
.main-container {
    display: flex; flex-direction: column;
    height: calc(100vh - 110px);
    margin-top: 60px; padding: 10px; gap: 10px;
}
.top-bar { flex-shrink: 0; }
.main-content {
    flex: 1; min-height: 0; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 80px; padding-top: 10px;
}

/* --- Top Resource Bar --- */
.top-resource-bar {
    position: fixed; top: 0; left: 0; width: 100%; height: 60px;
    background: rgba(15, 15, 20, 0.98);
    border-bottom: 2px solid var(--theme-accent);
    z-index: 8000;
    display: flex; align-items: center; padding: 0 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.8);
    overflow-x: auto; white-space: nowrap; gap: 15px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch; box-sizing: border-box;
}
.top-resource-bar::-webkit-scrollbar { display: none; }

.top-res-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-width: 60px; padding: 0 5px; border-right: 1px solid #333; position: relative;
}
.top-res-item:last-child { border-right: none; }
.top-res-icon { font-size: 1.2em; margin-bottom: 2px; }
.top-res-val { font-weight: bold; font-size: 0.9em; color: #fff; }
.top-res-rate { font-size: 0.7em; color: #888; }

/* --- Bottom Toolbar --- */
/* Transformation en Menu Vertical Flottant */
.bottom-toolbar {
    position: fixed; bottom: 70px; left: 10px; /* Au-dessus du bouton */
    width: 220px; height: auto; max-height: 0; /* Caché par défaut */
    background: rgba(15, 15, 20, 0.98); 
    border: 1px solid var(--theme-accent); border-radius: 8px;
    display: flex; flex-direction: column-reverse; /* Pile verticale */
    justify-content: flex-end; align-items: stretch;
    z-index: 6000; box-shadow: 0 -5px 20px rgba(0,0,0,0.8);
    overflow: hidden; opacity: 0; pointer-events: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0; gap: 0;
    transform-origin: bottom left;
    transform: scale(0.9) translateY(20px);
    backdrop-filter: blur(10px);
}
.bottom-toolbar.menu-open {
    max-height: 70vh; opacity: 1; pointer-events: auto;
    padding: 5px; transform: scale(1) translateY(0);
    overflow-y: auto;
}

/* Bouton Déclencheur (FAB) */
.menu-trigger {
    position: fixed; bottom: 10px; left: 10px;
    width: 50px; height: 50px;
    background: #111; border: 2px solid var(--theme-accent);
    border-radius: 50%; color: var(--theme-accent);
    font-size: 1.5em; z-index: 7000;
    cursor: pointer; box-shadow: 0 0 15px rgba(0,0,0,0.8);
    display: flex; justify-content: center; align-items: center;
    transition: all 0.2s;
}
.menu-trigger:active, .menu-trigger.active {
    background: var(--theme-accent); color: #000; transform: scale(0.95);
}

/* --- Grille d'affichage (Panneaux) --- */
.display-panel {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px; width: 100%; box-sizing: border-box; margin-bottom: 10px;
    background: transparent; border: none; box-shadow: none; padding: 5px;
}

/* --- Mobile & Responsive --- */
@media (max-width: 768px) {
    /* Utilisation de dvh pour gérer la barre d'adresse mobile */
    body { height: 100dvh; overflow: hidden; }
    .main-container { height: 100dvh; margin-top: 0; padding: 45px 5px 55px 5px; gap: 5px; }

    /* Top Bar Mobile */
    .top-resource-bar { height: 40px; padding: 0 5px; gap: 4px; border-bottom-width: 1px; }
    .top-res-item { min-width: 45px; padding: 0 2px; border-right: none; flex-grow: 1; flex-basis: 0; }
    .top-res-icon { font-size: 1em; margin-bottom: 0; }
    .top-res-val { font-size: 0.65em; white-space: nowrap; overflow: hidden; }
    .top-res-rate { display: none; } /* On cache le taux dans la topbar sur mobile pour gagner de la place */
    
    h1, .subtitle { padding: 0 10px; font-size: 1.2em; }
    .subtitle { font-size: 0.8em; }
    .main-content { padding-bottom: 10px; padding-top: 5px; }

    /* Layout Mobile */
    .display-panel { width: 100%; padding: 0; gap: 6px; grid-template-columns: repeat(2, 1fr); }
    
    /* Toolbar Mobile (Adaptation Menu Vertical) */
    .bottom-toolbar {
        width: 200px; left: 10px; bottom: 70px;
        border-top: 1px solid var(--theme-accent); /* Reset border logic */
    }

    /* FIX: Position XP bar correctly on mobile, below the top bar */
    .xp-strip-container {
        /* The top bar is 40px, main container padding-top is 45px. This -5px margin
           pulls the bar up to sit exactly at the 40px mark. */
        margin: -5px -5px 5px -5px;
        width: calc(100% + 10px); /* Compensate for parent's horizontal padding */
        border-top: 1px solid #333;
    }
}

/* --- Compact Header Styles --- */
.compact-header {
    background: #151515; border: 1px solid #333; border-radius: 6px;
    padding: 4px 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    display: flex; flex-direction: column; gap: 4px;
}

/* Ligne 1 : Titre + Cycle + Boutons */
.header-row-top {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid #222; padding-bottom: 4px;
}
.header-info-group { display: flex; align-items: baseline; gap: 8px; overflow: hidden; }
#header-title { font-size: 1em; font-weight: 900; color: var(--theme-accent); letter-spacing: 1px; white-space: nowrap; }
#header-faction { font-size: 0.7em; color: #666; text-transform: uppercase; white-space: nowrap; }
.subtitle.hidden { display: none; }

.cycle-display {
    font-size: 0.75em; color: #aaa; background: #222; padding: 1px 6px;
    border-radius: 4px; border: 1px solid #333; white-space: nowrap;
}

.header-config-btns { display: flex; gap: 5px; }
.btn-header-icon {
    background: transparent; border: 1px solid #444; color: #888;
    width: 24px; height: 24px; padding: 0; display: flex; align-items: center; justify-content: center;
    border-radius: 4px; cursor: pointer; font-size: 0.9em;
}
.btn-header-icon:hover { border-color: var(--theme-accent); color: var(--theme-accent); }

/* Ligne 2 : Serviteurs + XP */
.header-row-bot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.servitor-compact-bar { display: flex; align-items: center; gap: 8px; flex: 1; overflow: hidden; }
.serv-stats { font-size: 0.8em; color: #ddd; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.serv-controls { display: flex; gap: 3px; align-items: center; }

.btn-serv-action {
    background: linear-gradient(to bottom, #333, #222); border: 1px solid #555; color: #ccc;
    font-size: 0.7em; padding: 2px 6px; border-radius: 3px; cursor: pointer;
    min-width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center; /* Centrage parfait */
}
.btn-serv-action:hover { border-color: #fff; color: #fff; }

/* Nouvelle Barre XP Fine */
.xp-strip-container {
    width: calc(100% + 20px); /* Compense le padding du parent */
    margin: -10px -10px 5px -10px; /* Colle aux bords et remonte */
    height: 16px; background: #000;
    border-bottom: 1px solid #333; position: relative;
}
#commander-xp-bar { height: 100%; background: linear-gradient(90deg, #004d40, #00bcd4); width: 0%; transition: width 0.5s; }
.xp-strip-text {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7em; color: rgba(255,255,255,0.8); text-shadow: 1px 1px 1px #000; 
    pointer-events: none; letter-spacing: 1px; line-height: 6px;
}

/* Mobile Tweaks */
@media (max-width: 480px) {
    #header-title { font-size: 0.9em; }
    #header-faction { display: none; } /* Trop petit sur mobile */
    .cycle-display { font-size: 0.7em; padding: 1px 4px; }
    .serv-stats span[title="Inactifs"] { display: none; } /* Cache les inactifs si trop petit */
}