/* --- GLOBAL & TYPOGRAPHY --- */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-family: 'Inter', sans-serif;
}

.font-bengali {
    font-family: 'Hind Siliguri', sans-serif;
}

/* --- BUTTONS & INTERACTIVE ELEMENTS --- */
.primary-btn {
    background-color: #4f46e5; /* indigo-600 */
    color: white;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    cursor: pointer;
}
.primary-btn:hover {
    background-color: #4338ca; /* indigo-700 */
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}
.primary-btn:active {
    transform: translateY(1px);
}
.primary-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Secondary Button (For Skip/Continue) */
.secondary-btn {
    background-color: #ffffff;
    color: #475569; /* slate-600 */
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    border: 2px solid #e2e8f0; /* slate-200 */
    cursor: pointer;
}
.secondary-btn:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
    color: #1e293b;
}
.dark .secondary-btn {
    background-color: #1e293b; /* slate-800 */
    color: #cbd5e1;
    border-color: #334155;
}
.dark .secondary-btn:hover {
    background-color: #334155;
    border-color: #475569;
}

/* Nav Items */
.nav-item {
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748b; /* slate-500 */
    border-radius: 0.5rem;
    transition: all 0.2s;
}
.nav-item:hover {
    color: #4f46e5;
    background-color: #f1f5f9;
}
.dark .nav-item { color: #94a3b8; }
.dark .nav-item:hover {
    color: #818cf8;
    background-color: #1e293b;
}
.nav-item.active {
    color: #4f46e5;
    background-color: #eef2ff;
}
.dark .nav-item.active {
    color: #c7d2fe;
    background-color: #3730a3;
}

/* Mobile Nav */
.mobile-nav-item {
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    font-weight: 500;
    color: #475569;
    border-radius: 0.5rem;
}
.mobile-nav-item:active { background-color: #f1f5f9; }
.dark .mobile-nav-item { color: #cbd5e1; }
.dark .mobile-nav-item:active { background-color: #1e293b; }


/* --- QUIZ OPTION CARDS --- */
.option-card {
    width: 100%;
    text-align: left;
    padding: 1rem 1.25rem;
    background-color: #ffffff;
    border: 2px solid #e2e8f0; /* slate-200 */
    border-radius: 1rem;
    color: #334155;
    transition: all 0.15s ease-out;
    position: relative;
    cursor: pointer;
}
.dark .option-card {
    background-color: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}
.option-card:hover {
    border-color: #94a3b8;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

/* Feedback UI (Practice) */
.option-card.correct-ui {
    border-color: #22c55e !important;
    background-color: #f0fdf4 !important;
    color: #15803d !important;
}
.dark .option-card.correct-ui {
    background-color: #064e3b !important;
    border-color: #059669 !important;
    color: #d1fae5 !important;
}
.option-card.wrong-ui {
    border-color: #ef4444 !important;
    background-color: #fef2f2 !important;
    color: #991b1b !important;
}
.dark .option-card.wrong-ui {
    background-color: #7f1d1d !important;
    border-color: #dc2626 !important;
    color: #fecaca !important;
}

/* Selection (Test Mode) */
.option-card.selected-test {
    border-color: #4f46e5 !important;
    background-color: #eef2ff !important;
    color: #312e81 !important;
    box-shadow: 0 0 0 1px #4f46e5;
}
.dark .option-card.selected-test {
    background-color: #3730a3 !important;
    border-color: #6366f1 !important;
    color: #e0e7ff !important;
    box-shadow: 0 0 0 1px #6366f1;
}
.option-card.disabled {
    pointer-events: none;
    opacity: 0.9;
}

/* Limit Buttons */
.limit-btn {
    padding: 0.5rem;
    font-size: 0.875rem;
    font-weight: 700;
    border-radius: 0.5rem;
    background-color: white;
    color: #64748b;
    border: 1px solid #e2e8f0;
    transition: all 0.2s;
    cursor: pointer;
}
.dark .limit-btn {
    background-color: #1e293b;
    color: #94a3b8;
    border-color: #334155;
}
.limit-btn:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
}
.dark .limit-btn:hover {
    background-color: #334155;
}
.limit-btn.active {
    background-color: #4f46e5;
    color: white;
    border-color: #4f46e5;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
}

/* Animations & Scrollbar */
.app-section { display: none; }
.app-section.active { display: block; animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.slide-up { animation: slideUp 0.5s ease-out; }
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.question-slide-in { animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}
.custom-scrollbar::-webkit-scrollbar { width: 6px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 20px; }
.dark .custom-scrollbar::-webkit-scrollbar-thumb { background-color: #475569; }

/* Prose */
.prose h3 { font-weight: 700; color: #1e293b; }
.dark .prose h3 { color: #f1f5f9; }
.prose p, .prose ul { color: #334155; }
.dark .prose p, .dark .prose ul { color: #cbd5e1; }

/* --- RESULTS SCREEN --- */
#results-section {
    display: none;
    height: 100%;
    padding-top: 1rem;
    padding-bottom: 1rem;
}

#results-section.active {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.results-container {
    background-color: #ffffff;
    border-radius: 1.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid #e2e8f0;
    width: 100%;
    max-width: 42rem; /* Increased max-width for better desktop view */
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%; /* Full height within its container */
    max-height: calc(100vh - 8rem); /* Adjust based on your header/footer height */
}

.dark .results-container {
    background-color: #1e293b; /* slate-800 */
    border-color: #334155;
}

.results-header {
    text-align: center;
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.dark .results-header { border-color: #334155; }

.results-trophy {
    background-color: #eef2ff; /* indigo-50 */
    color: #4f46e5; /* indigo-600 */
    border-radius: 50%;
    width: 4rem;
    height: 4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}
.dark .results-trophy {
    background-color: #3730a3; /* indigo-900/30 */
    color: #a5b4fc; /* indigo-400 */
}

.results-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex-grow: 1; /* Allows this section to fill available space */
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.results-score-card {
    background-color: #f8fafc; /* slate-50 */
    border: 1px solid #f1f5f9;
    border-radius: 1rem;
    padding: 1rem;
    text-align: center;
}
.dark .results-score-card {
    background-color: #1a2436; /* custom dark slate */
    border-color: #334155;
}

#words-to-review-list-wrapper {
    overflow-y: auto;
    flex-grow: 1; /* Critical for scrolling */
    max-height: 400px; /* Adjust as needed */
}

.continue-button-wrapper {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    background-color: #ffffff;
}
.dark .continue-button-wrapper {
    border-color: #334155;
    background-color: #1e293b;
}

/* --- MOBILE RESPONSIVENESS FOR RESULTS --- */
@media (max-width: 640px) {
    #results-section {
        padding: 0;
        height: 100%;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        margin-top: 5rem; /* Adjust to match your header height */
    }

    .results-container {
        border-radius: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        box-shadow: none;
        border: none;
    }

    .results-header { padding: 1rem; }
    .results-body { padding: 1rem; padding-bottom: 0; }
    .results-trophy { width: 3.5rem; height: 3.5rem; }
    .results-trophy i { width: 1.5rem; height: 1.5rem; }
    #results-header-text { font-size: 1.75rem; }

    #words-to-review-list-wrapper {
       /* The flex-grow property handles this now */
    }
    
    .continue-button-wrapper {
        padding: 1rem;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background-color: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border-top: 1px solid #e2e8f0;
    }
    .dark .continue-button-wrapper {
        background-color: rgba(30, 41, 59, 0.9);
        border-color: #334155;
    }
}

/* --- MOBILE RESPONSIVENESS FOR TEST/QUIZ --- */
@media (max-width: 640px) {
    #test-section .max-w-2xl {
        padding-left: 0;
        padding-right: 0;
        height: calc(100vh - 5rem); /* Full height minus header */
        display: flex;
        flex-direction: column;
    }

    #test-section .bg-white.dark\\:bg-slate-800\\.50 {
        flex-shrink: 0; /* Progress bar container */
    }

    #test-section .bg-white.dark\\:bg-slate-800 {
        border-radius: 0;
        flex-grow: 1;
        display: flex;
        flex-direction: column;
        overflow-y: auto; /* Allow scrolling for the main content */
    }

    #quiz-question, #quiz-question-bengali {
        font-size: 1.5rem; /* 24px */
        line-height: 2rem; /* 32px */
    }

    #test-section .p-8.sm\\:p-10 {
        padding: 1.5rem; /* 24px */
        flex-grow: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #test-section .min-h-\\[14rem\\] {
        min-height: 10rem; /* Give it some min-height back */
    }

    #quiz-options-container {
        padding: 1rem;
        flex-shrink: 0;
    }

    .option-card span {
        font-size: 1rem; /* 16px */
    }

    #next-question-button {
        padding-top: 1rem;
        padding-bottom: 1rem;
        font-size: 1rem;
        flex-shrink: 0;
    }
    
    #test-section .mt-8 {
        margin-top: auto; /* Pushes the button to the bottom */
        padding: 1rem;
        background-color: rgba(255, 255, 255, 0.8);
        -webkit-backdrop-filter: blur(8px);
        backdrop-filter: blur(8px);
        border-top: 1px solid #e2e8f0;
    }
    .dark #test-section .mt-8 {
        background-color: rgba(30, 41, 59, 0.8);
        border-color: #334155;
    }
}
