/* inter-regular - latin */
@font-face {
    font-display: swap;
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    src: url('fonts/inter-v19-latin-regular.woff2') format('woff2');
}

/* inter-500 - latin */
@font-face {
    font-display: swap;
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    src: url('fonts/inter-v19-latin-500.woff2') format('woff2');
}

/* inter-600 - latin */
@font-face {
    font-display: swap;
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    src: url('fonts/inter-v19-latin-600.woff2') format('woff2');
}

/* inter-700 - latin */
@font-face {
    font-display: swap;
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    src: url('fonts/inter-v19-latin-700.woff2') format('woff2');
}

/* --- THEME VARIABLES --- */
:root {
    --bg-body: #f3f4f6;
    --text-main: #111827;
    --card-front-bg: #ffffff;
    --card-front-text: #111827;
    --card-back-bg: #1e40af;
    --card-back-text: #ffffff;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    transition: background-color 0.3s, color 0.3s;
}

/* --- THEME OVERRIDES FIX --- */
body.custom-theme h1,
body.custom-theme h2,
body.custom-theme h3,
body.custom-theme p,
body.custom-theme span,
body.custom-theme div:not(.flashcard-face):not(.face-content):not(.card-word):not(.card-definition):not(.card-answer-title):not(.favorite-star) {
    color: var(--text-main);
}

/* --- PROTECT WHITE INTERFACES --- */
body.custom-theme #quiz-interface h1,
body.custom-theme #quiz-interface h2,
body.custom-theme #quiz-interface h3,
body.custom-theme #quiz-interface p,
body.custom-theme #quiz-interface span,
body.custom-theme #quiz-interface div,
body.custom-theme #deck-editor-view h1,
body.custom-theme #deck-editor-view h2,
body.custom-theme #deck-editor-view p,
body.custom-theme #deck-editor-view span,
body.custom-theme #deck-editor-view div,
body.custom-theme #leaderboard-view h1,
body.custom-theme #leaderboard-view h2,
body.custom-theme #leaderboard-view p,
body.custom-theme #leaderboard-view span,
body.custom-theme #leaderboard-view div {
    color: #111827;
}

/* FORCE MODALS TEXT TO BE BLACK */
body.custom-theme .modal-content h1,
body.custom-theme .modal-content h2,
body.custom-theme .modal-content h3,
body.custom-theme .modal-content p,
body.custom-theme .modal-content label,
body.custom-theme .modal-content span,
body.custom-theme .modal-content div,
body.custom-theme .modal-content input,
body.custom-theme .modal-content textarea {
    color: #111827 !important;
}

/* --- RED TEXT EXCEPTION --- */
body.custom-theme .text-red-600,
body.custom-theme .text-red-500,
body.custom-theme [class*="text-red-"] {
    color: #dc2626 !important;
}

body.custom-theme .card-word {
    color: var(--card-front-text) !important;
}

body.custom-theme .card-definition,
body.custom-theme .card-answer-title {
    color: var(--card-back-text) !important;
}

body.custom-theme .set-button,
body.custom-theme .set-info-btn,
body.custom-theme .set-info-btn-mistakes,
body.custom-theme .category-button,
body.custom-theme .answer-btn,
body.custom-theme button[class*="bg-"] {
    color: initial;
}

body.custom-theme .set-button div,
body.custom-theme .set-info-btn span {
    color: inherit;
}


/* ============================================= */
/*        PREMIUM FLASHCARD STYLES               */
/* ============================================= */
.flashcard-container {
    position: relative;
    perspective: 1000px;
    height: 250px;
}

.flashcard {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    cursor: pointer;
}

.flashcard.is-flipped {
    transform: rotateY(180deg);
}

/* --- FLASHCARD FACE & SCROLL FIX --- */
.flashcard-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    text-align: center;
    overflow-y: auto;
    scrollbar-width: none;
}

.face-content {
    margin-top: auto;
    margin-bottom: auto;
    width: 100%;
}

/* Hide scrollbar for Webkit */
.flashcard-face::-webkit-scrollbar {
    display: none;
}

.flashcard-front {
    background-color: var(--card-front-bg);
    color: var(--card-front-text);
}

.flashcard-back {
    background-color: var(--card-back-bg);
    color: var(--card-back-text);
    transform: rotateY(180deg);
    padding: 1.75rem;
}

.card-word {
    font-size: 1.5rem;
    font-weight: 700;
}

.card-answer-title {
    font-size: 0.875rem;
    font-weight: 600;
    opacity: 0.8;
    margin-bottom: 0.5rem;
}

.card-definition {
    font-size: 1rem;
    font-weight: 500;
}


/* ============================================= */
/*          BUTTON STYLES                        */
/* ============================================= */
.category-button {
    background: white;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
}

.category-button:hover {
    background: #eef2ff;
    border-color: #c7d2fe;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
    transform: translateY(-1px);
}

.category-button.active {
    background-color: #1d4ed8;
    color: white;
    font-weight: 700;
}

.set-button {
    background: #3b82f6;
    border: none;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
    transition: all 0.2s ease;
}

.set-button:hover {
    background: #2563eb;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.3);
    transform: translateY(-1px);
}

.set-button.active {
    background: #1d4ed8;
    color: white;
    font-weight: 700;
}

.question-btn {
    background-color: #E5E7EB;
    color: #374151;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.question-btn:hover {
    background-color: #d1d5db;
}

.question-btn.active {
    background-color: #1D4ED8;
    color: white;
}

/* --- QUIZ STYLES --- */
.answer-btn.correct {
    background-color: #22c55e !important;
    color: white !important;
    border-color: #16a34a !important;
}

.answer-btn.incorrect {
    background-color: #ef4444 !important;
    color: white !important;
    border-color: #dc2626 !important;
}

.answer-btn:disabled {
    cursor: not-allowed;
}

/* --- QUIZ EXIT BUTTON --- */
.quiz-exit-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.2s;
}

.quiz-exit-btn:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}


/* ============================================= */
/*          MODAL STYLES — PREMIUM               */
/* ============================================= */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.45);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

/* Theme modal: transparent backdrop for live preview */
#theme-modal.modal-backdrop {
    background-color: transparent;
}

.modal-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 1.25rem;
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 400px;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-backdrop.visible .modal-content {
    transform: scale(1) translateY(0);
}


/* ============================================= */
/*          LEGAL NOTICE                         */
/* ============================================= */
.legal-notice-banner {
    background-color: var(--bg-body);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 500;
    transition: background-color 0.3s, color 0.3s;
    opacity: 0.5;
}


/* ============================================= */
/*          SET INFO & STAR STYLES               */
/* ============================================= */
.set-info-btn {
    display: inline-flex;
    align-items: center;
    background-color: #1d4ed8;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 700;
    font-size: 1rem;
    border: 1px solid black;
    transition: background-color 0.2s ease-in-out;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    cursor: default;
}

.set-info-btn:hover {
    background-color: #1e40af;
}

.set-info-btn .card-count {
    color: #f87171;
    font-weight: 900;
    margin-left: 0.75rem;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 0.15rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.set-info-btn-mistakes {
    display: inline-flex;
    align-items: center;
    background-color: #dc2626;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 700;
    font-size: 1rem;
    border: 1px solid black;
    transition: background-color 0.2s ease-in-out;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    cursor: default;
}

.set-info-btn-mistakes:hover {
    background-color: #b91c1c;
}

.set-info-btn-mistakes .card-count {
    color: #fde047;
    font-weight: 900;
    margin-left: 0.75rem;
    background-color: rgba(255, 255, 255, 0.15);
    padding: 0.15rem 0.6rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
}

#review-mistakes-btn,
#take-quiz-btn,
#favorites-btn {
    border: 1px solid black;
}


/* ============================================= */
/*          FAVORITE STAR                        */
/* ============================================= */
.favorite-star {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 1.75rem;
    color: #cbd5e1;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
    z-index: 10;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.05));
}

.favorite-star:hover {
    transform: scale(1.15);
}

.favorite-star.favorited {
    color: #f59e0b;
}


/* ===== OFFLINE BANNER ===== */
.offline-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: #fbbf24;
    color: #78350f;
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
    animation: slide-up 0.4s ease-out;
}

@keyframes slide-up {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}


/* ============================================= */
/*  DARK MODE / CUSTOM THEME FIXES              */
/* ============================================= */

/* --- SRS Rating Buttons: protect internal colors --- */
body.custom-theme .srs-rating-btn.btn-hard,
body.custom-theme .srs-rating-btn.btn-hard span {
    color: #991b1b !important;
}

body.custom-theme .srs-rating-btn.btn-good,
body.custom-theme .srs-rating-btn.btn-good span {
    color: #1e40af !important;
}

body.custom-theme .srs-rating-btn.btn-easy,
body.custom-theme .srs-rating-btn.btn-easy span {
    color: #065f46 !important;
}

/* --- Due Badges: keep their colors --- */
body.custom-theme .due-badge-red {
    color: #dc2626 !important;
    background: #fef2f2 !important;
}

body.custom-theme .due-badge-green {
    color: #16a34a !important;
    background: #f0fdf4 !important;
}

/* --- Mastered count text near Study Now --- */
body.custom-theme .text-green-600 {
    color: #16a34a !important;
}

/* --- SRS Study View Header --- */
body.custom-theme #srs-session-title {
    color: var(--text-main) !important;
}

body.custom-theme #srs-session-counter {
    color: var(--text-main) !important;
    opacity: 0.7;
}

body.custom-theme #srs-study-view .kbd {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-main) !important;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1);
}

body.custom-theme #srs-study-view>.flex>.flex>span {
    color: var(--text-main) !important;
    opacity: 0.7;
}

/* --- SRS Progress Track in dark mode --- */
body.custom-theme .srs-progress-track {
    background: rgba(255, 255, 255, 0.15);
}

/* --- SRS Session Complete Screen --- */
body.custom-theme #srs-finished h2 {
    color: var(--text-main) !important;
}

body.custom-theme #srs-finished p {
    color: var(--text-main) !important;
    opacity: 0.7;
}

body.custom-theme #srs-finished .stat-card {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
}

body.custom-theme #srs-finished .stat-card .text-xs {
    color: var(--text-main) !important;
    opacity: 0.6;
}

/* Keep stat number colors (blue, green, red) */
body.custom-theme #srs-stat-total {
    color: #60a5fa !important;
}

body.custom-theme #srs-stat-easy {
    color: #34d399 !important;
}

body.custom-theme #srs-stat-hard {
    color: #f87171 !important;
}

/* --- SRS Card Front face text visibility --- */
body.custom-theme .srs-face-front {
    background: var(--card-front-bg) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

body.custom-theme .srs-face-front span,
body.custom-theme .srs-face-front h2,
body.custom-theme .srs-face-front p {
    color: var(--card-front-text) !important;
}

/* --- Grid card box dot text on dark backgrounds --- */
body.custom-theme .flashcard-container span[title] {
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3);
}

/* --- Helper text --- */
body.custom-theme #helper-text {
    color: var(--text-main) !important;
    opacity: 0.6;
}

/* --- Search bar dark mode --- */
body.custom-theme .search-bar {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text-main);
}

body.custom-theme .search-icon {
    color: rgba(255, 255, 255, 0.4);
}

/* --- Fix: Category buttons text visibility in dark/custom themes --- */
body.custom-theme .category-button,
body.custom-theme .category-button span {
    color: #1f2937 !important;
}

body.custom-theme .category-button:hover,
body.custom-theme .category-button:hover span {
    color: #312e81 !important;
}

body.custom-theme .category-button.active,
body.custom-theme .category-button.active span {
    color: #ffffff !important;
}

/* --- Fix: Top nav buttons (Public Decks, My Decks, Stats) in dark/custom themes --- */
body.custom-theme #public-decks-btn,
body.custom-theme #my-decks-btn,
body.custom-theme #stats-btn,
body.custom-theme #stats-btn span {
    color: #374151 !important;
}

/* --- Fix: Profile dropdown text in dark/custom themes --- */
body.custom-theme #profile-dropdown,
body.custom-theme #profile-dropdown p,
body.custom-theme #profile-dropdown div {
    color: #374151 !important;
}

body.custom-theme #profile-dropdown #logout-btn {
    color: #dc2626 !important;
}

/* --- Dark mode flashcard card styling --- */
body.custom-theme .flashcard-front {
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

body.custom-theme .flashcard-container:hover .flashcard-front {
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.15), 0 2px 8px rgba(0, 0, 0, 0.15);
}

body.custom-theme .flashcard-back {
    border-color: rgba(255, 255, 255, 0.1);
}

/* --- Dark mode background fix --- */
body.custom-theme {
    background-image: none;
}

/* --- Sign-up banner override in dark --- */
body.custom-theme .signup-banner-glass {
    background: #1d4ed8 !important;
}

/* --- Empty state dark mode --- */
body.custom-theme .empty-state-container {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}

body.custom-theme .empty-state-container h3,
body.custom-theme .empty-state-container p {
    color: var(--text-main) !important;
}

/* --- Header bar dark mode --- */
body.custom-theme .header-bar {
    background: #111827 !important;
    border-color: #1f2937 !important;
}

body.custom-theme .header-bar button {
    border-color: rgba(255, 255, 255, 0.1) !important;
}

/* --- Stat card glass in dark mode --- */
body.custom-theme .stat-card {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
}