/* ═══════════════════════════════════════════
   Flashcard Styles — Thẻ Ôn Sai Lầm
   ═══════════════════════════════════════════ */

/* ── Container ── */
.flashcard-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 12px;
}

.flashcard-loading {
    text-align: center;
    padding: 40px;
    color: #888;
}

.flashcard-empty {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}
.flashcard-empty p {
    color: #777;
    font-size: 0.9em;
    margin: 8px 0 16px;
}

/* ── Header & Stats ── */
.fc-header {
    margin-bottom: 16px;
}

.fc-stats-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    justify-content: center;
}

.fc-stat {
    text-align: center;
    padding: 4px 12px;
    background: rgba(0,0,0,0.03);
    border-radius: 8px;
    min-width: 55px;
    border: 1px solid rgba(0,0,0,0.06);
}

.fc-stat-num {
    display: block;
    font-size: 0.95em;
    font-weight: 800;
    color: #1a1a2e;
}

.fc-stat-label {
    display: block;
    font-size: 0.65em;
    color: #999;
    margin-top: 1px;
}

/* ── Tabs ── */
.fc-tabs {
    display: flex;
    gap: 4px;
    background: rgba(0,0,0,0.04);
    border-radius: 12px;
    padding: 3px;
}

.fc-tab {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85em;
    cursor: pointer;
    color: #666;
    transition: all 0.2s;
}

.fc-tab.active {
    background: #fff;
    color: #1a1a2e;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.fc-tab-content {
    padding: 8px 0;
}

/* ── Progress ── */
.fc-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.fc-progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(0,0,0,0.06);
    border-radius: 3px;
    overflow: hidden;
}

.fc-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.fc-progress-text {
    font-size: 0.85em;
    font-weight: 700;
    color: #888;
    white-space: nowrap;
}

/* ── Card ── */
.fc-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    border: 1px solid rgba(0,0,0,0.06);
    overflow: hidden;
}

.fc-card--opening {
    border-color: rgba(59,130,246,0.2);
}

.fc-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(0,0,0,0.02);
    border-bottom: 1px solid rgba(0,0,0,0.04);
    flex-wrap: wrap;
}

.fc-card-badge {
    padding: 3px 10px;
    border-radius: 8px;
    color: #fff;
    font-size: 0.78em;
    font-weight: 700;
}

.fc-card-move-num {
    font-size: 0.85em;
    color: #666;
    font-weight: 600;
}

.fc-card-opening {
    font-size: 0.78em;
    color: #3b82f6;
    font-weight: 600;
    margin-left: auto;
}

/* ── Two-column layout ── */
.fc-card-layout {
    display: flex;
    gap: 16px;
    padding: 16px;
    align-items: flex-start;
}

.fc-card-left {
    flex: 0 0 auto;
    max-width: 400px;
    width: 55%;
}

.fc-card-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    justify-content: center;
}

.fc-board-container {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border: 2px solid rgba(0,0,0,0.1);
}

#fc-board {
    display: block;
}

/* ── Prompt & Result ── */
.fc-card-prompt {
    text-align: center;
    padding: 16px;
    background: rgba(99,102,241,0.05);
    border-radius: 12px;
    border: 1px dashed rgba(99,102,241,0.2);
}

.fc-result {
    padding: 16px;
    border-radius: 12px;
    text-align: center;
}

.fc-result--correct {
    background: rgba(74,222,128,0.08);
    border: 1px solid rgba(74,222,128,0.2);
}

.fc-result--wrong {
    background: rgba(248,113,113,0.08);
    border: 1px solid rgba(248,113,113,0.2);
}

.fc-result-icon {
    font-size: 2em;
    margin-bottom: 4px;
}

.fc-result-text {
    font-weight: 800;
    font-size: 1.1em;
    margin-bottom: 8px;
    color: #1a1a2e;
}

.fc-result-detail {
    font-size: 0.9em;
    color: #555;
    line-height: 1.7;
}

.fc-result-detail p {
    margin: 4px 0;
}

/* ── Explanation Panel (LLM-generated) ── */
.fc-explanation {
    margin-top: 12px;
    text-align: left;
}

.fc-explanation-text {
    background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(139,92,246,0.06));
    border: 1px solid rgba(99,102,241,0.15);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
}

.fc-explanation-header {
    font-weight: 700;
    font-size: 0.9em;
    color: #6366f1;
    margin-bottom: 6px;
}

.fc-explanation-text p {
    font-size: 0.88em;
    line-height: 1.6;
    color: #444;
    margin: 0;
}

.fc-concept-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.fc-concept-tag {
    display: inline-block;
    padding: 3px 10px;
    background: rgba(99,102,241,0.08);
    border: 1px solid rgba(99,102,241,0.15);
    border-radius: 20px;
    font-size: 0.75em;
    font-weight: 600;
    color: #6366f1;
    white-space: nowrap;
}

/* ── Actions ── */
.fc-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.fc-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s;
}

.fc-btn--correct {
    background: linear-gradient(135deg, #4ade80, #22c55e);
    color: #fff;
}

.fc-btn--wrong {
    background: linear-gradient(135deg, #f87171, #ef4444);
    color: #fff;
}

.fc-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ── Account Tab ── */
.fc-import-section {
    padding: 16px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    border: 1px solid rgba(0,0,0,0.06);
}

.fc-import-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.fc-import-card {
    background: rgba(0,0,0,0.02);
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.fc-import-icon {
    font-size: 2em;
}

.fc-import-title {
    font-weight: 700;
    color: #1a1a2e;
}

.fc-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 8px;
    font-size: 0.9em;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}

.fc-input:focus {
    border-color: #6366f1;
}

select.fc-input {
    text-align: left;
    cursor: pointer;
}

.fc-input-board-wrap {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    border: 2px solid rgba(0,0,0,0.08);
}

.btn-primary {
    padding: 8px 20px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.2s;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

/* ═══ Admin Flashcard Styles ═══ */
.afc-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 12px;
    min-height: 600px;
}

.afc-user-list {
    border: 1px solid var(--border-primary, rgba(0,0,0,0.12));
    border-radius: 12px;
    background: var(--bg-secondary, rgba(0,0,0,0.02));
    overflow: hidden;
}

.afc-user-list-header {
    padding: 10px 12px;
    font-weight: 700;
    font-size: 0.85em;
    border-bottom: 1px solid var(--border-primary, rgba(0,0,0,0.12));
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-tertiary, rgba(0,0,0,0.03));
}

.afc-user-search {
    width: 100%;
    padding: 6px 10px;
    border: none;
    border-bottom: 1px solid var(--border-primary, rgba(0,0,0,0.12));
    background: var(--bg-secondary, rgba(0,0,0,0.02));
    color: inherit;
    font-size: 0.82em;
    outline: none;
}

.afc-user-items {
    max-height: 540px;
    overflow-y: auto;
}

.afc-user-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-primary, rgba(0,0,0,0.08));
    transition: background 0.15s;
    font-size: 0.85em;
}

.afc-user-item:hover {
    background: rgba(108,92,231,0.1);
}

.afc-user-item.active {
    background: rgba(108,92,231,0.15);
    border-left: 3px solid #6c5ce7;
}

.afc-user-name {
    font-weight: 700;
    color: var(--text-primary, #1a1a2e);
}

.afc-user-meta {
    font-size: 0.75em;
    color: var(--text-muted, #888);
    margin-top: 2px;
}

.afc-main {
    border: 1px solid var(--border-primary, rgba(0,0,0,0.12));
    border-radius: 12px;
    background: var(--bg-secondary, rgba(0,0,0,0.02));
    padding: 12px;
    overflow: hidden;
}

.afc-sub-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    background: var(--bg-tertiary, rgba(0,0,0,0.04));
    border-radius: 10px;
    padding: 3px;
}

.afc-sub-tab {
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: inherit;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.82em;
    cursor: pointer;
    transition: all 0.2s;
}

.afc-sub-tab.active {
    background: rgba(108,92,231,0.2);
    color: #6c5ce7;
}

.afc-card-viewer {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.afc-board-container {
    width: 300px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    border: 2px solid var(--border-primary, rgba(0,0,0,0.12));
}

.afc-card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.afc-card-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.afc-card-nav button {
    padding: 6px 14px;
    border: 1px solid var(--border-primary, rgba(0,0,0,0.15));
    background: var(--bg-secondary, rgba(0,0,0,0.04));
    color: inherit;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.15s;
}

.afc-card-nav button:hover {
    background: rgba(108,92,231,0.12);
    border-color: #6c5ce7;
}

/* ── Game Table with proper borders ── */
.afc-game-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82em;
    border: 1px solid var(--border-primary, rgba(0,0,0,0.12));
    border-radius: 8px;
    overflow: hidden;
}

.afc-game-table th {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 2px solid var(--border-primary, rgba(0,0,0,0.15));
    font-weight: 700;
    font-size: 0.85em;
    color: var(--text-primary, #1a1a2e);
    background: var(--bg-tertiary, rgba(0,0,0,0.04));
}

.afc-game-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-primary, rgba(0,0,0,0.08));
    color: var(--text-primary, #333);
}

.afc-game-table tr:hover {
    background: rgba(108,92,231,0.04);
}

/* ── Responsive ── */
@media (max-width: 700px) {
    .fc-card-layout {
        flex-direction: column;
        align-items: center;
    }
    
    .fc-card-left {
        width: 100%;
        max-width: 360px;
    }

    .fc-card-right { width: 100%; }

    .fc-card-actions { flex-direction: column; }
    .fc-btn { width: 100%; }
    .fc-import-grid { grid-template-columns: 1fr; }

    .afc-layout { grid-template-columns: 1fr; }
    .afc-card-viewer { flex-direction: column; }
    .afc-board-container { width: 100%; max-width: 300px; }

    .tree-editor-layout { grid-template-columns: 1fr; }
    .tree-editor-board-col { max-width: 400px; margin: 0 auto; }
}

/* ═══ Tree Editor Styles (ChessBase-style) ═══ */
.tree-editor-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    min-height: 500px;
}

.tree-editor-board-col {
    display: flex;
    flex-direction: column;
}

.tree-board-container {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border: 2px solid var(--border-primary, rgba(0,0,0,0.12));
}

.tree-controls {
    display: flex;
    gap: 4px;
    margin-top: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.tree-controls button {
    padding: 6px 12px;
    border: 1px solid var(--border-primary, rgba(0,0,0,0.12));
    background: var(--bg-secondary, rgba(0,0,0,0.03));
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85em;
    transition: all 0.15s;
    color: inherit;
}

.tree-controls button:hover {
    background: rgba(108,92,231,0.12);
    border-color: #6c5ce7;
}

.tree-editor-moves-col {
    border: 1px solid var(--border-primary, rgba(0,0,0,0.12));
    border-radius: 12px;
    background: #1a1d23;
    color: #e0e0e0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.tree-moves-header {
    padding: 10px 14px;
    font-weight: 700;
    font-size: 0.9em;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
}

.tree-moves-panel {
    padding: 8px 4px;
    overflow-y: auto;
    max-height: 520px;
    line-height: 1.4;
    font-size: 0.85em;
    font-family: 'Consolas', 'SF Mono', monospace;
}

/* Each row = one branch line */
.tree-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    padding: 2px 0;
    border-left: 2px solid rgba(255,255,255,0.08);
    margin-left: 4px;
}

.tree-row:hover {
    background: rgba(255,255,255,0.03);
}

/* Collapse/expand button */
.tree-toggle {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.85em;
    color: #888;
    border-radius: 50%;
    flex-shrink: 0;
    transition: all 0.15s;
    margin-right: 2px;
}

.tree-toggle:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

.tree-toggle-spacer {
    width: 20px;
    height: 20px;
    display: inline-block;
    flex-shrink: 0;
    margin-right: 2px;
}

/* Individual move in tree */
.tree-move {
    display: inline;
    padding: 1px 4px;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.1s;
    color: #c8ccd0;
    white-space: nowrap;
}

.tree-move:hover {
    background: rgba(108,92,231,0.25);
    color: #fff;
}

.tree-move-active {
    background: rgba(108,92,231,0.4) !important;
    color: #a78bfa !important;
    font-weight: 700;
}

/* Color tab active state */
.tree-color-active {
    background: linear-gradient(135deg, #6c5ce7, #a78bfa) !important;
    color: #fff !important;
    border: none !important;
}
