/* === Dark Theme Variables === */
:root {
    --bg-body: #1a1a2e;
    --bg-card: #16213e;
    --bg-navbar: #0f1729;
    --accent-primary: #0f3460;
    --accent-success: #4CAD53;
    --accent-danger: #E74C3C;
    --accent-warning: #F39C12;
    --accent-info: #3498DB;
    --text-primary: #e0e0e0;
    --text-muted: #8892a0;

    /* Heatmap colors */
    --heat-0: #1a1a2e;
    --heat-1: #0d3b1e;
    --heat-2: #166d34;
    --heat-3: #26a641;
    --heat-4: #39d353;
}

/* === Base === */
body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
}

/* === Navbar === */
.bg-navbar {
    background-color: var(--bg-navbar) !important;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.xp-bar-mini {
    width: 80px;
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
}

.xp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-info), var(--accent-success));
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* === Cards === */
.bg-card {
    background-color: var(--bg-card) !important;
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
}

.card {
    border-radius: 12px;
}

/* === Badges === */
.bg-level {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-info)) !important;
}

.bg-streak {
    background: linear-gradient(135deg, #E74C3C, #F39C12) !important;
}

.bg-xp {
    background: linear-gradient(90deg, var(--accent-info), var(--accent-success)) !important;
}

/* === Avatar === */
.avatar-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

/* === Mode Selection Cards === */
.mode-card {
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: default;
}

.mode-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

/* === Flashcard 3D Flip === */
.flashcard-container {
    perspective: 1200px;
    max-width: 600px;
    margin: 0 auto;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    min-height: 280px;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.flashcard-inner.is-flipped {
    transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 280px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--bg-card);
    border: 2px solid rgba(255,255,255,0.1);
    cursor: pointer;
}

.flashcard-back {
    transform: rotateY(180deg);
    background: linear-gradient(135deg, var(--bg-card), var(--accent-primary));
}

.flashcard-word {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    word-break: break-word;
}

.flashcard-example {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-top: 1rem;
    text-align: center;
    font-style: italic;
}

/* === Rating Buttons === */
.btn-rate {
    min-width: 100px;
    font-weight: 600;
    border-radius: 10px;
    transition: transform 0.15s, box-shadow 0.15s;
}

.btn-rate:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.btn-rate-0 { background-color: #c0392b; border-color: #c0392b; color: white; }
.btn-rate-1 { background-color: #e67e22; border-color: #e67e22; color: white; }
.btn-rate-3 { background-color: #f1c40f; border-color: #f1c40f; color: #333; }
.btn-rate-4 { background-color: #27ae60; border-color: #27ae60; color: white; }
.btn-rate-5 { background-color: #2ecc71; border-color: #2ecc71; color: white; }

/* === Exam === */
.exam-card {
    background: var(--bg-card);
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.exam-input {
    max-width: 400px;
    margin: 0 auto;
    font-size: 1.3rem;
    text-align: center;
}

/* === Timer === */
.timer-warning { color: #f1c40f !important; }
.timer-danger { color: #e74c3c !important; animation: pulse 0.5s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* === Combo === */
.combo-bump {
    animation: comboBump 0.3s ease;
}

@keyframes comboBump {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* === XP Float Animation === */
.xp-float {
    position: fixed;
    pointer-events: none;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-warning);
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
    animation: xpFloat 1.5s ease-out forwards;
    z-index: 9999;
}

@keyframes xpFloat {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-80px); }
}

/* === Pause Overlay === */
.pause-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === Heatmap === */
.heatmap-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.heatmap-cell {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    background: var(--heat-0);
    border: 1px solid rgba(255,255,255,0.03);
}

.heatmap-cell[data-level="1"] { background: var(--heat-1); }
.heatmap-cell[data-level="2"] { background: var(--heat-2); }
.heatmap-cell[data-level="3"] { background: var(--heat-3); }
.heatmap-cell[data-level="4"] { background: var(--heat-4); }

/* === Achievement === */
.achievement-icon {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.achievement-icon-sm {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.achievement-unlocked {
    animation: achievementGlow 2s ease-in-out;
}

@keyframes achievementGlow {
    0% { box-shadow: 0 0 0 rgba(243, 156, 18, 0); }
    50% { box-shadow: 0 0 20px rgba(243, 156, 18, 0.4); }
    100% { box-shadow: 0 0 0 rgba(243, 156, 18, 0); }
}

.opacity-60 {
    opacity: 0.6;
}

/* === Inline Editing (Admin) === */
.editable {
    cursor: pointer;
    position: relative;
}

.editable:hover {
    background: rgba(255,255,255,0.05);
}

.editable input {
    background: var(--bg-body);
    border: 2px solid var(--accent-info);
    color: var(--text-primary);
    padding: 2px 6px;
    width: 100%;
    border-radius: 4px;
}

/* === Toast (Achievement Notifications) === */
.toast-achievement {
    background: var(--bg-card) !important;
    border: 1px solid var(--accent-warning);
    color: var(--text-primary);
}

/* === Irregular Verb Inputs === */
.irregular-input {
    font-size: 1.2rem;
    text-align: center;
}

.irregular-input.is-correct {
    border-color: var(--accent-success) !important;
    box-shadow: 0 0 0 3px rgba(76,173,83,0.25);
}

.irregular-input.is-wrong {
    border-color: var(--accent-danger) !important;
    box-shadow: 0 0 0 3px rgba(231,76,60,0.25);
}

/* === Progress Bar === */
.progress {
    background-color: rgba(255,255,255,0.1);
    border-radius: 10px;
}

/* === Login === */
.login-card {
    background: var(--bg-card);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 16px;
}

.login-wrapper {
    background: linear-gradient(135deg, var(--bg-body) 0%, var(--accent-primary) 100%);
    margin: -1rem;
    padding: 1rem;
    min-height: calc(100vh - 60px);
}

/* === Tables === */
.table-dark {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: rgba(255,255,255,0.03);
}

/* === Form controls in dark theme === */
.form-control:focus, .form-select:focus {
    border-color: var(--accent-info);
    box-shadow: 0 0 0 3px rgba(52,152,219,0.25);
}

/* === Result feedback === */
.result-correct {
    border-left: 4px solid var(--accent-success);
    background: rgba(76,173,83,0.1);
}

.result-incorrect {
    border-left: 4px solid var(--accent-danger);
    background: rgba(231,76,60,0.1);
}

/* === Responsive === */
@media (max-width: 768px) {
    .flashcard-word {
        font-size: 1.8rem;
    }

    .flashcard-front,
    .flashcard-back {
        min-height: 200px;
        padding: 1.5rem;
    }

    .btn-rate {
        min-width: 60px;
        font-size: 0.85rem;
        padding: 0.5rem;
    }

    .heatmap-cell {
        width: 10px;
        height: 10px;
    }
}

/* === Streak badge animation === */
.streak-badge {
    text-align: center;
}

/* === Session header === */
.session-header {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid rgba(255,255,255,0.05);
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.25);
}
