/* =====================================================
   🎨 style.css — VERSION STABLE
   - Charte graphique inchangée
   - Doublons supprimés
   - Aide IA visible sur cases occupées
   ===================================================== */

/* --- 🔧 BASE & RESET --- */
html, body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: #121212;
    color: #fff;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.main-layout {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    align-items: center;
    justify-content: flex-start;
    padding-top: 5px;
    box-sizing: border-box;
}

/* --- 🔝 HEADER --- */
.info-header {
    display: flex;
    width: 100%;
    height: 75px;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    box-sizing: border-box;
}

.header-side {
    width: 50px;
    display: flex;
    justify-content: center;
}

.header-center {
    flex: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header-center h1 {
    margin: 0;
    font-size: 0.9rem;
    color: #f0d9b5;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ⏱️ PENDULE */
#clock-display {
    margin-top: 5px;
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    font-size: 1.1rem;
    color: #ffcc00;
    background: #1a1a1a;
    padding: 4px 14px;
    border-radius: 6px;
    border: 1px solid #444;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.8);
}

.icon-btn-header {
    background: #2c2c2c;
    border: 1px solid #444;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- ♟️ CHESSBOARD --- */
#chessboard-container {
    width: 95vw;
    max-width: 380px;
    aspect-ratio: 1 / 1;
    background: #2c2c2c;
    padding: 5px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    margin-top: 5px;
}

#chessboard {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
}

/* --- 🎨 THÈMES --- */
#chessboard.classic .square.light { background: #f0d9b5; }
#chessboard.classic .square.dark  { background: #b58863; }

#chessboard.forest .square.light  { background: #ebecd0; }
#chessboard.forest .square.dark   { background: #779556; }

#chessboard.night .square.light   { background: #dee3e6; }
#chessboard.night .square.dark    { background: #8ca2ad; }

/* --- 📍 CASES --- */
.square {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Sélection utilisateur */
.square.selected {
    box-shadow: inset 0 0 0 5px rgba(255, 255, 0, 0.7);
}

/* Dernier coup */
.square.last-move {
    box-shadow: inset 0 0 0 4px rgba(155, 199, 0, 0.6);
}

/* --- 💡 AIDE IA --- */

/* Case de départ */
.square-hint-from::after {
    content: "";
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 0 3px rgba(0, 200, 255, 0.9);
    z-index: 20;
    pointer-events: none;
}

/* 🎯 Case de déplacement IA (vide) — version renforcée */
.square.target-move::after {
    content: "";
    position: absolute;
    inset: 22%;                /* ← plus grand */
    border: 4px solid rgba(0, 0, 0, 0.35);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25); /* léger remplissage */
    z-index: 20;
    pointer-events: none;
}

/* Case de capture (occupée) */
.square.target-capture::after {
    content: "";
    position: absolute;
    inset: 10%;
    border: 4px solid rgba(255, 120, 0, 0.95);
    border-radius: 50%;
    z-index: 20;
    pointer-events: none;
}

/* --- 🔴 ROI EN ÉCHEC (inchangé) --- */
.square-king-check {
    background:
        repeating-linear-gradient(
            45deg,
            rgba(255, 0, 0, 0.35),
            rgba(255, 0, 0, 0.35) 6px,
            rgba(255, 255, 255, 0.35) 6px,
            rgba(255, 255, 255, 0.35) 12px
        ) !important;
}

/* --- 🧩 PIÈCES --- */
.piece {
    position: absolute;
    inset: 0;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.piece img {
    width: 85%;
    height: 85%;
    object-fit: contain;
}

/* --- 🔄 FLIP --- */
#chessboard.flipped {
    transform: rotate(180deg);
}

#chessboard.flipped .piece {
    transform: rotate(180deg);
}

/* --- 🎛️ CONTROLS --- */
.theme-selector-container {
    margin: 8px 0;
    width: 90%;
    max-width: 320px;
}

#theme-select {
    width: 100%;
    padding: 8px;
    background: #2c2c2c;
    border: 1px solid #444;
    color: #fff;
    border-radius: 5px;
}

.controls-bar {
    display: flex;
    width: 95vw;
    max-width: 380px;
    justify-content: space-between;
    gap: 6px;
}

.icon-btn {
    flex: 1;
    height: 50px;
    background: #2c2c2c;
    border: 1px solid #444;
    border-radius: 12px;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#btn-assist.active {
    background: #a4de02;
    color: #000;
    border-color: #8dbd00;
}

/* --- 📢 STATUT --- */
#status-container {
    width: 95vw;
    max-width: 380px;
    margin-top: 15px;
    padding: 12px;
    background: rgba(34, 34, 34, 0.9);
    border-radius: 10px;
    border: 1px solid #333;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

#status {
    font-size: 1rem;
    font-weight: 500;
    color: #f0d9b5;
    min-height: 1.4rem;
    letter-spacing: 0.5px;
}

.status-mate  { color: #ff4444 !important; font-weight: bold; }
.status-check { color: #ffcc00 !important; }

/* --- 📦 POPUP OPTIONS --- */
.popup {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.popup-content {
    background: #222;
    border: 1px solid #444;
    padding: 25px;
    border-radius: 15px;
    width: 85%;
    max-width: 320px;
    color: #eee;
}

.hidden {
    display: none !important;
}

.popup-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.btn-primary {
    background: #4a7ab5 !important;
    color: #fff;
    border: none;
}

.btn-danger {
    background: #c62828 !important;
    color: #fff !important;
    font-weight: bold;
    border: none;
}

.popup-actions button {
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #555;
    background: #333;
    color: #eee;
    cursor: pointer;
}