:root {
    --bg-dark: #161512;
    --bg-panel: #211f1c;
    --bg-card: #282521;
    --border-subtle: #38342e;
    --text-main: #f2efe9;
    --text-muted: #aba499;
    --accent-gold: #d4a359;
    --accent-gold-hover: #e3b56c;
    --accent-green: #629924;
    --danger-red: #d9534f;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
}

/* --- Écran de connexion --- */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: radial-gradient(circle at top, #28241e 0%, #161512 70%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 2.25rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
}

.login-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.chess-logo {
    font-size: 3rem;
    color: var(--accent-gold);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.login-header h1 {
    font-size: 1.65rem;
    font-weight: 700;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.92rem;
    margin-top: 0.25rem;
}

.form-group {
    margin-bottom: 1.15rem;
}

.form-group label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text-main);
}

.form-group input {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-size: 0.98rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-gold);
}

.alert-error {
    background-color: rgba(217, 83, 79, 0.15);
    border: 1px solid var(--danger-red);
    color: #ffb3b0;
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    font-size: 0.88rem;
    margin-bottom: 1rem;
}

/* --- Boutons --- */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--accent-gold);
    color: #161512;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 0.7rem 1.2rem;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.btn-primary:hover {
    background-color: var(--accent-gold-hover);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-subtle);
    font-weight: 600;
    font-size: 0.92rem;
    padding: 0.65rem 1.15rem;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
}

.btn-secondary:hover {
    border-color: var(--accent-gold);
}

.btn-full {
    width: 100%;
}

/* --- Layout principal avec Menu latéral --- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 265px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1.1rem;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 0.5rem 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.brand-icon {
    font-size: 2rem;
    color: var(--accent-gold);
}

.brand-title {
    display: block;
    font-size: 1.15rem;
    font-weight: 700;
}

.brand-tag {
    display: block;
    font-size: 0.76rem;
    color: var(--text-muted);
}

.sidebar-nav {
    margin-top: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
}

.nav-section-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin: 1rem 0.6rem 0.35rem;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.94rem;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
}

.nav-item.active {
    background-color: rgba(212, 163, 89, 0.15);
    color: var(--accent-gold);
    font-weight: 600;
}

.sidebar-footer {
    border-top: 1px solid var(--border-subtle);
    padding-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background-color: var(--accent-gold);
    color: #161512;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-name {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
}

.user-role {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-logout {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.84rem;
}

.btn-logout:hover {
    color: var(--text-main);
    border-color: var(--danger-red);
}

/* --- Contenu principal --- */
.main-content {
    flex: 1;
    padding: 2.5rem 3rem;
    max-width: 1180px;
}

.page-header {
    margin-bottom: 2.25rem;
}

.badge-pill {
    display: inline-block;
    background-color: rgba(212, 163, 89, 0.16);
    color: var(--accent-gold);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    margin-bottom: 0.6rem;
}

.page-header h1 {
    font-size: 1.9rem;
    margin-bottom: 0.5rem;
}

.page-lead {
    color: var(--text-muted);
    max-width: 720px;
    font-size: 1.02rem;
}

/* --- Grille des modules --- */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.module-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 1.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.module-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.module-step {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent-gold);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.module-emoji {
    font-size: 1.65rem;
}

.module-card h2 {
    font-size: 1.25rem;
}

.module-card p {
    color: var(--text-muted);
    font-size: 0.93rem;
    flex: 1;
}

.module-features {
    list-style: none;
    border-top: 1px solid var(--border-subtle);
    padding-top: 0.85rem;
    font-size: 0.86rem;
    color: var(--text-main);
}

.module-features li::before {
    content: "✓ ";
    color: var(--accent-gold);
    font-weight: bold;
}

.tips-banner {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-left: 4px solid var(--accent-gold);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.tips-icon {
    font-size: 1.6rem;
}

.tips-banner h3 {
    font-size: 1.02rem;
    margin-bottom: 0.25rem;
}

.tips-banner p {
    font-size: 0.92rem;
    color: var(--text-muted);
}

.placeholder-box {
    background-color: var(--bg-card);
    border: 1px dashed var(--border-subtle);
    border-radius: 12px;
    padding: 2.5rem;
    text-align: center;
    max-width: 640px;
}

.board-preview {
    display: inline-grid;
    grid-template-columns: repeat(8, 2rem);
    gap: 0.25rem;
    font-size: 1.4rem;
    margin-bottom: 1.25rem;
    color: var(--accent-gold);
}

.placeholder-box h2 {
    font-size: 1.25rem;
    margin-bottom: 0.6rem;
}

.placeholder-box p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* --- Échiquier Interactif & Espace d'Analyse (Phase 2) --- */
.compact-header {
    margin-bottom: 1.5rem;
}

.chess-workspace {
    display: grid;
    grid-template-columns: minmax(320px, 540px) minmax(300px, 1fr);
    gap: 2rem;
    align-items: start;
}

.board-column {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.board-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    padding: 0.6rem 1rem;
    border-radius: 10px;
}

.turn-badge {
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--accent-gold);
}

.turn-badge.status-alert {
    color: #ff7b76;
}

.arrow-toggle {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.86rem;
    color: var(--text-muted);
    cursor: pointer;
}

.board-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 6px solid #2b2722;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
}

.chessboard-grid {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    user-select: none;
}

.chess-square {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.sq-light {
    background-color: #f0d9b5;
}

.sq-dark {
    background-color: #b58863;
}

.sq-selected {
    background-color: rgba(98, 153, 36, 0.55) !important;
}

.sq-last-move {
    box-shadow: inset 0 0 0 999px rgba(212, 163, 89, 0.42);
}

.sq-check {
    background: radial-gradient(circle, rgba(217, 83, 79, 0.85) 0%, rgba(217, 83, 79, 0) 75%) !important;
}

.coord-rank,
.coord-file {
    position: absolute;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
}

.coord-rank {
    top: 4px;
    left: 5px;
}

.coord-file {
    bottom: 3px;
    right: 5px;
}

.sq-light .coord-rank,
.sq-light .coord-file {
    color: #b58863;
}

.sq-dark .coord-rank,
.sq-dark .coord-file {
    color: #f0d9b5;
}

.chess-piece {
    width: 84%;
    height: 84%;
    z-index: 2;
    transition: transform 0.1s ease;
}

.chess-piece:hover {
    transform: scale(1.05);
}

.chess-piece svg {
    width: 100%;
    height: 100%;
    display: block;
}

.legal-move-dot {
    width: 28%;
    height: 28%;
    border-radius: 50%;
    background-color: rgba(34, 85, 34, 0.48);
    z-index: 3;
    pointer-events: none;
}

.legal-capture-ring {
    position: absolute;
    inset: 6%;
    border: 4px solid rgba(34, 85, 34, 0.55);
    border-radius: 50%;
    z-index: 3;
    pointer-events: none;
}

.board-arrows-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 4;
}

.board-controls {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.analysis-column {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
}

.analysis-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 1.25rem 1.4rem;
}

.opening-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.5rem;
}

.eco-tag {
    background-color: var(--accent-gold);
    color: #161512;
    font-weight: 800;
    font-size: 0.78rem;
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
}

.opening-header h2 {
    font-size: 1.18rem;
}

.opening-explanation {
    color: var(--text-muted);
    font-size: 0.93rem;
}

.analysis-card h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.card-subtitle {
    color: var(--text-muted);
    font-size: 0.84rem;
    margin-bottom: 0.85rem;
}

.continuations-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.continuation-card {
    text-align: left;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 0.75rem 0.95rem;
    color: var(--text-main);
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.1s ease;
}

.continuation-card:hover {
    border-color: var(--accent-gold);
    transform: translateX(2px);
}

.cont-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.3rem;
}

.cont-san {
    background-color: rgba(98, 153, 36, 0.22);
    color: #9be04d;
    font-weight: 700;
    font-size: 0.88rem;
    padding: 0.15rem 0.5rem;
    border-radius: 5px;
    font-family: monospace;
}

.cont-opening {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--accent-gold);
}

.cont-desc {
    font-size: 0.84rem;
    color: var(--text-muted);
}

.move-history-box {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-family: monospace;
    font-size: 0.92rem;
    margin-top: 0.5rem;
}

.move-pair {
    display: inline-flex;
    gap: 0.35rem;
    background-color: var(--bg-panel);
    padding: 0.25rem 0.55rem;
    border-radius: 6px;
}

.move-num {
    color: var(--text-muted);
}

.move-san {
    color: var(--text-main);
    font-weight: 600;
}

.muted-note {
    color: var(--text-muted);
    font-size: 0.88rem;
}

@media (max-width: 960px) {
    .chess-workspace {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .app-layout {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
    }
    .main-content {
        padding: 1.5rem;
    }
}

