/**
 * Level Selector UI — charte Emergence
 * Dark / net / pro · zéro emoji · valeurs de données en vert néon (--hud-value)
 * Bleu proscrit ; accents = blanc (focus/onglet actif) + vert néon (données).
 * ⚠️ Le contrat DOM (ids/classes lus par LevelSelectorUI.js) est préservé.
 */

/* ============================================
   OVERLAY
   ============================================ */

.level-selector-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: var(--z-modal, 1000);
    display: none;
    align-items: center;
    justify-content: center;
}

.level-selector-overlay.visible {
    display: flex;
}

/* ============================================
   MODAL
   ============================================ */

.level-selector-modal {
    background: #0d1117;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    width: 90%;
    max-width: 1100px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
    animation: lsSlideIn 0.3s ease-out;
}

@keyframes lsSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============================================
   HEADER
   ============================================ */

.level-selector-header {
    padding: 24px 28px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.level-selector-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #f0f6fc;
}

.level-selector-subtitle {
    margin: 4px 0 0;
    font-size: 13px;
    color: #8b949e;
}

.level-selector-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #8b949e;
    cursor: pointer;
    transition: all 0.15s ease;
}

.level-selector-close:hover {
    background: rgba(248, 81, 73, 0.15);
    border-color: rgba(248, 81, 73, 0.3);
    color: #f85149;
}

/* ============================================
   TABS (monochrome : actif = blanc + soulignement)
   ============================================ */

.level-selector-tabs {
    display: flex;
    gap: 4px;
    padding: 16px 28px 0;
    background: #161b22;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.level-selector-tab {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #8b949e;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-bottom: -1px;
}

.level-selector-tab:hover {
    color: #c9d1d9;
}

.level-selector-tab.active {
    color: #f0f6fc;
    border-bottom-color: #f0f6fc;
}

/* ============================================
   TOOLBAR (import)
   ============================================ */

.level-selector-toolbar {
    padding: 16px 28px;
    background: #161b22;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    gap: 12px;
}

/* ============================================
   GRILLE SCROLLABLE
   ============================================ */

.level-grid-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.level-section-title {
    margin: 0 0 16px 0;
    color: #8b949e;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.level-empty {
    color: #8b949e;
    text-align: center;
    white-space: pre-line;
    padding: 2rem;
    line-height: 1.6;
}

/* ============================================
   CARTE DE NIVEAU
   ============================================ */

.level-item {
    background: #161b22;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.level-item:hover {
    background: #21262d;
    border-color: rgba(255, 255, 255, 0.18);
    transform: translateY(-2px);
}

.level-item.selected {
    border-color: var(--hud-value);
    box-shadow: 0 0 0 1px var(--hud-value-glow), 0 0 18px var(--hud-value-glow);
}

/* Focus clavier/manette */
.level-item:focus-visible {
    outline: none;
    border-color: #f0f6fc;
    box-shadow: 0 0 0 2px rgba(240, 246, 252, 0.5);
    transform: translateY(-2px);
}

.level-card-thumb {
    width: 100%;
    border-radius: 8px;
    background: var(--grid-bg, rgb(100, 130, 145));
    margin-bottom: 12px;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    display: block;
}

.level-card-name {
    font-weight: 600;
    color: #f0f6fc;
    font-size: 15px;
    margin-bottom: 4px;
}

.level-card-sub {
    font-size: 12px;
    color: #8b949e;
    margin-bottom: 8px;
}

.level-card-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: #6e7681;
}

/* ============================================
   BARRE DE PRÉVISUALISATION (bas)
   ============================================ */

.level-preview-bar {
    padding: 20px 28px;
    background: #161b22;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.level-preview-bar.visible {
    display: flex;
}

.level-preview-left {
    display: flex;
    gap: 20px;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.level-preview-thumb {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: var(--grid-bg, rgb(100, 130, 145));
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    flex-shrink: 0;
}

.level-preview-info {
    flex: 1;
    min-width: 0;
}

.level-preview-name {
    margin: 0 0 0.75rem 0;
    color: #f0f6fc;
    font-size: 1.25rem;
    font-weight: 600;
}

.level-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.35rem 1.25rem;
    font-size: 0.85rem;
}

.level-stat {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
}

.level-stat-label {
    color: #8b949e;
}

/* Valeurs de données → vert néon mono (charte HUD). Classe scopée pour
   éviter la fuite globale de .stat-value (StatsUI/AIPanel). */
.level-stat-value {
    color: var(--hud-value);
    font-family: var(--font-mono);
    font-weight: 600;
}

.level-preview-actions {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

/* ============================================
   BOUTONS D'ACTION
   ============================================ */

.level-action-btn {
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.level-action-btn.primary {
    background: #238636;
    border: 1px solid #238636;
    color: #fff;
}

.level-action-btn.primary:hover {
    background: #2ea043;
    border-color: #2ea043;
}

.level-action-btn.secondary {
    background: #21262d;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #c9d1d9;
}

.level-action-btn.secondary:hover {
    background: #30363d;
    border-color: rgba(255, 255, 255, 0.15);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .level-selector-modal {
        max-width: 100%;
        max-height: 100%;
        width: 100%;
        border-radius: 0;
    }

    .level-preview-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .level-preview-actions .level-action-btn {
        flex: 1;
    }
}
