/* =====================================================
   KNSK Training Pro - Styles
   ===================================================== */

/* === LAYOUT === */
.training-wrapper {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    align-items: start;
}

.board-area {
    display: flex;
    gap: 8px;
    align-items: stretch;
    position: sticky;
    top: 80px;
    align-self: start;
}

#board {
    width: 500px !important;
    height: 500px !important;
}
#board .piece-417db { width: 12.5% !important; height: 12.5% !important; }
#board img { max-width: 100%; }
.board-b72b1 { border: 2px solid #0b1a22 !important; }

/* === SESSION STATUS BAR === */
.session-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #0b1a22;
    color: white;
    padding: 12px 24px;
    max-width: 1200px;
    margin: 0 auto 0;
    flex-wrap: wrap;
    gap: 12px;
}
.session-bar .session-title { font-weight: 800; font-size: 18px; }
.session-bar .session-meta { display: flex; gap: 16px; align-items: center; font-size: 14px; }
.session-bar .status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.status-dot.active { background: #4caf50; }
.status-dot.closed { background: #999; }
.session-bar .online-count { color: #81d4fa; }
.session-bar .timer { color: #ffcc80; font-family: monospace; }
.session-bar button {
    background: #c62828; color: white; border: none; padding: 6px 16px;
    font-weight: 700; cursor: pointer; font-size: 13px;
}
.session-bar button:hover { background: #b71c1c; }

/* === SIDE PANEL (PGN log + controls) === */
.side-panel {
    background: white;
    border: 2px solid #0b1a22;
    display: flex;
    flex-direction: column;
    min-width: 280px;
    max-width: 360px;
}
.side-panel h3 {
    background: #0b1a22; color: white;
    padding: 12px 16px; margin: 0;
    font-size: 15px; font-weight: 800;
}

/* PGN move list */
.pgn-log {
    padding: 16px;
    font-family: monospace;
    font-size: 14px;
    line-height: 1.8;
    min-height: 300px;
    max-height: 420px;
    overflow-y: auto;
    background: #fafafa;
}
.pgn-log .move-number { color: #999; margin-right: 4px; }
.pgn-log .move {
    display: inline-block; padding: 2px 6px; cursor: pointer;
    border-radius: 2px; transition: background 0.15s;
}
.pgn-log .move:hover { background: #e0e0e0; }
.pgn-log .move.active { background: #c62828; color: white; }

/* Controls */
.board-controls {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 12px 16px;
    border-top: 2px solid #f0f0f0;
    background: white;
}
.board-controls button {
    flex: 1; min-width: 60px;
    padding: 8px 12px; border: 2px solid #0b1a22;
    background: white; color: #0b1a22;
    font-weight: 700; font-size: 13px;
    cursor: pointer; transition: all 0.2s;
    text-align: center;
}
.board-controls button:hover { background: #0b1a22; color: white; }
.board-controls button.btn-danger { border-color: #c62828; color: #c62828; }
.board-controls button.btn-danger:hover { background: #c62828; color: white; }

/* FEN input */
.fen-input-row {
    display: flex; gap: 8px;
    padding: 8px 16px;
    border-top: 1px solid #f0f0f0;
}
.fen-input-row input {
    flex: 1; padding: 6px 10px; border: 2px solid #ddd;
    font-family: monospace; font-size: 12px;
}
.fen-input-row button {
    padding: 6px 14px; background: #0b1a22; color: white;
    border: none; font-weight: 700; cursor: pointer; font-size: 12px;
}

/* === EVAL BAR === */
.eval-bar {
    width: 28px;
    background: #333;
    position: relative;
    border: 2px solid #0b1a22;
    flex-shrink: 0;
}
.eval-fill {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: white;
    height: 50%;
    transition: height 0.4s ease;
}
.eval-text {
    position: absolute; bottom: 4px; left: 0; right: 0;
    text-align: center; font-size: 10px; font-weight: 900;
    color: #ccc; z-index: 1;
}

/* === ANALYSIS PANEL === */
.analysis-panel {
    background: white; border: 2px solid #0b1a22; padding: 16px;
}
.analysis-panel h3 { margin: 0 0 12px; font-size: 16px; font-weight: 800; }
.analysis-controls { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.analysis-controls label { font-size: 13px; font-weight: 600; }
.analysis-controls input[type="range"] { width: 120px; }
.analysis-controls button {
    padding: 8px 16px; background: #c62828; color: white;
    border: none; font-weight: 700; cursor: pointer;
}
.engine-output { font-family: monospace; font-size: 13px; line-height: 1.6; }
.engine-line { padding: 6px 0; border-bottom: 1px solid #f0f0f0; }
.engine-line .line-eval { font-weight: 900; color: #c62828; margin-right: 8px; }
.best-move-display { font-size: 18px; font-weight: 900; color: #c62828; margin-top: 12px; }

/* === EXERCISES === */
.exercise-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px; padding: 24px;
}
.exercise-card {
    background: white; border: 2px solid #0b1a22; padding: 24px;
    transition: all 0.2s; text-decoration: none; color: inherit;
    display: flex; flex-direction: column;
}
.exercise-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,0.1); }
.exercise-card h3 { font-size: 16px; margin-bottom: 8px; }
.exercise-card .meta { font-size: 13px; color: #666; margin-bottom: 12px; }
.exercise-mini-board { width: 100%; aspect-ratio: 1; background: #f5f5f5; margin-bottom: 12px; }
.difficulty-badge {
    display: inline-block; padding: 3px 10px; font-size: 11px;
    font-weight: 700; text-transform: uppercase;
}
.difficulty-badge.beginner { background: #e8f5e9; color: #2e7d32; }
.difficulty-badge.intermediate { background: #fff3e0; color: #e65100; }
.difficulty-badge.advanced { background: #fce4ec; color: #c62828; }
.theme-badge {
    display: inline-block; padding: 3px 10px; font-size: 11px;
    font-weight: 600; background: #e3f2fd; color: #1565c0; margin-left: 4px;
}

/* Exercise solve view */
.exercise-wrapper {
    display: grid; grid-template-columns: auto 1fr;
    gap: 24px; max-width: 1000px; margin: 0 auto; padding: 24px;
    align-items: start;
}
.exercise-info { background: white; border: 2px solid #0b1a22; padding: 24px; }
.exercise-info h2 { margin-bottom: 8px; }
.exercise-feedback {
    padding: 16px; font-weight: 700; font-size: 16px;
    text-align: center; margin-top: 12px;
}
.feedback-correct { background: #e8f5e9; color: #2e7d32; }
.feedback-wrong { background: #fce4ec; color: #c62828; }
.feedback-hint { background: #fff3e0; color: #e65100; }

/* Exercise stats */
.exercise-stats { display: flex; gap: 16px; margin: 16px 0; }
.exercise-stats .stat { text-align: center; }
.exercise-stats .stat-val { font-size: 24px; font-weight: 900; color: #c62828; }
.exercise-stats .stat-lbl { font-size: 11px; color: #666; font-weight: 600; }

/* === COMPETITION === */
.competition-header {
    background: #0b1a22; color: white; padding: 32px;
    text-align: center; max-width: 1200px; margin: 0 auto;
}
.competition-header h1 { font-size: 32px; font-weight: 900; margin-bottom: 8px; }
.competition-header .dates { font-size: 14px; opacity: 0.8; }
.leaderboard { max-width: 800px; margin: 24px auto; }
.leaderboard table { width: 100%; border-collapse: collapse; background: white; }
.leaderboard th { background: #0b1a22; color: white; padding: 12px 16px; text-align: left; font-size: 13px; }
.leaderboard td { padding: 12px 16px; border-bottom: 1px solid #f0f0f0; }
.leaderboard tr:nth-child(1) td { background: #fff8e1; }
.leaderboard tr:nth-child(2) td { background: #f5f5f5; }
.leaderboard tr:nth-child(3) td { background: #fff3e0; }
.rank-badge { font-weight: 900; font-size: 18px; }

/* === TACTIC RATING === */
.rating-display { font-size: 36px; font-weight: 900; color: #c62828; }
.rating-change { font-size: 14px; font-weight: 700; }
.rating-change.positive { color: #2e7d32; }
.rating-change.negative { color: #c62828; }

/* === NOTIFICATIONS === */
.training-notification {
    position: fixed; top: 80px; right: 24px;
    padding: 12px 20px; font-weight: 700; font-size: 14px;
    z-index: 1000; animation: slideIn 0.3s;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.training-notification.success { background: #2e7d32; color: white; }
.training-notification.error { background: #c62828; color: white; }
.training-notification.info { background: #1565c0; color: white; }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* === BOARD ERROR FALLBACK === */
.board-error {
    width: 500px; height: 500px; background: #f5f5f5;
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; border: 2px solid #ccc; text-align: center; padding: 32px;
}
.board-error h3 { margin-bottom: 12px; color: #c62828; }
.board-error button {
    padding: 10px 20px; background: #c62828; color: white;
    border: none; font-weight: 700; cursor: pointer; margin-top: 12px;
}

/* === RESPONSIVE === */
@media (max-width: 900px) {
    .training-wrapper, .exercise-wrapper { grid-template-columns: 1fr; }
    #board { width: 100% !important; height: auto !important; aspect-ratio: 1; }
    .side-panel { max-width: 100%; }
    .session-bar { padding: 8px 16px; }
    .eval-bar { display: none; }
}