/* ==========================================================================
   Quiz Application - Modern Educational SaaS Stylesheet
   Pure CSS, Dark Mode, High Contrast & Responsive Mobile Design
   ========================================================================== */

/* Custom Animations and Transitions */
.fade-in {
    animation: fadeIn 0.3s ease-out forwards;
    opacity: 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.hover-lift {
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

/* Question transition animation */
.quiz-content-transition {
    transition: opacity 0.15s ease-out, transform 0.15s ease-out;
    opacity: 1;
    transform: translateY(0);
}

.quiz-content-exit {
    opacity: 0;
    transform: translateY(4px);
}

.quiz-content-enter {
    opacity: 0;
    transform: translateY(-4px);
}


/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 9999px;
}
.dark ::-webkit-scrollbar-thumb {
    background: #334155;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ==========================================================================
   Quiz Screen - Fixed Header & Bottom Navigation
   ========================================================================== */

.quiz-header-sticky {
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.quiz-bottom-bar-fixed {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 40;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 -4px 20px -2px rgba(0, 0, 0, 0.06);
}
.dark .quiz-bottom-bar-fixed {
    box-shadow: 0 -4px 20px -2px rgba(0, 0, 0, 0.35);
}

/* Safe area support for iOS devices with home bar indicator */
.safe-area-bottom {
    padding-bottom: env(safe-area-inset-bottom, 0.75rem);
}

/* Option Cards - Clickable, Animated & Modern */
.option-item {
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 52px;
    user-select: none;
    -webkit-user-select: none;
}

.option-item:hover:not(.locked) {
    transform: translateY(-1px);
}

.option-item.selected {
    border-color: #4F46E5 !important;
    background-color: rgba(79, 70, 229, 0.06) !important;
    box-shadow: 0 0 0 1px #4F46E5, 0 4px 12px -2px rgba(79, 70, 229, 0.12);
}
.dark .option-item.selected {
    border-color: #6366F1 !important;
    background-color: rgba(99, 102, 241, 0.15) !important;
    box-shadow: 0 0 0 1px #6366F1, 0 4px 12px -2px rgba(99, 102, 241, 0.25);
}

.option-item.correct {
    border-color: #10B981 !important;
    background-color: rgba(16, 185, 129, 0.08) !important;
    box-shadow: 0 0 0 1px #10B981;
}
.dark .option-item.correct {
    background-color: rgba(16, 185, 129, 0.18) !important;
}

.option-item.wrong {
    border-color: #F43F5E !important;
    background-color: rgba(244, 63, 94, 0.08) !important;
    box-shadow: 0 0 0 1px #F43F5E;
}
.dark .option-item.wrong {
    background-color: rgba(244, 63, 94, 0.18) !important;
}

/* Option Letter Badges (A, B, C, D) */
.option-key-badge {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
    transition: all 0.15s ease;
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}
.dark .option-key-badge {
    background: #334155;
    color: #cbd5e1;
    border-color: #475569;
}

.option-item.selected .option-key-badge {
    background: #4F46E5;
    color: #ffffff;
    border-color: #4F46E5;
}
.dark .option-item.selected .option-key-badge {
    background: #6366F1;
    color: #ffffff;
    border-color: #6366F1;
}

.option-item.correct .option-key-badge {
    background: #10B981;
    color: #ffffff;
    border-color: #10B981;
}

.option-item.wrong .option-key-badge {
    background: #F43F5E;
    color: #ffffff;
    border-color: #F43F5E;
}

/* ==========================================================================
   Question Navigator - Number Dots Grid & Legend
   ========================================================================== */

.navigator-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.5rem;
}
@media (min-width: 640px) {
    .navigator-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}
@media (min-width: 1024px) {
    .navigator-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}
@media (min-width: 1280px) {
    .navigator-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

.q-dot-btn {
    aspect-ratio: 1 / 1;
    min-height: 40px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 700;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    user-select: none;
}

/* States */
.q-dot-unanswered {
    background-color: #f8fafc;
    color: #64748b;
    border: 1.5px solid #e2e8f0;
}
.dark .q-dot-unanswered {
    background-color: #1e293b;
    color: #94a3b8;
    border-color: #334155;
}
.q-dot-unanswered:hover {
    border-color: #94a3b8;
    background-color: #f1f5f9;
    transform: translateY(-1px);
}
.dark .q-dot-unanswered:hover {
    border-color: #64748b;
    background-color: #334155;
}

.q-dot-answered {
    background-color: #e0e7ff;
    color: #4338ca;
    border: 1.5px solid #c7d2fe;
}
.dark .q-dot-answered {
    background-color: rgba(99, 102, 241, 0.25);
    color: #c7d2fe;
    border-color: rgba(99, 102, 241, 0.5);
}
.q-dot-answered:hover {
    background-color: #c7d2fe;
}
.dark .q-dot-answered:hover {
    background-color: rgba(99, 102, 241, 0.35);
}

.q-dot-current {
    border-color: #4F46E5 !important;
    background-color: #4F46E5 !important;
    color: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.3), 0 4px 12px -2px rgba(79, 70, 229, 0.4);
    transform: scale(1.06);
    z-index: 2;
}
.dark .q-dot-current {
    border-color: #6366F1 !important;
    background-color: #6366F1 !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35), 0 4px 12px -2px rgba(99, 102, 241, 0.5);
}

.q-dot-correct {
    background-color: #10B981 !important;
    color: #ffffff !important;
    border-color: #059669 !important;
}

.q-dot-wrong {
    background-color: #F43F5E !important;
    color: #ffffff !important;
    border-color: #E11D48 !important;
}

/* Bookmark badge on Dot */
.q-dot-star-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 15px;
    height: 15px;
    background-color: #F59E0B;
    color: #ffffff;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    border: 1.5px solid #ffffff;
    z-index: 3;
}
.dark .q-dot-star-badge {
    border-color: #1e293b;
}

/* ==========================================================================
   Unified Side Drawer for Question Navigator
   ========================================================================== */

.drawer-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.drawer-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.drawer-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 400px;
    z-index: 51;
    background-color: #ffffff;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    border-left: 1px solid #e2e8f0;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.05);
}

.dark .drawer-panel {
    background-color: #161F30; /* matches bg-carddark */
    border-left-color: #1E293B; /* matches border-slate-800 */
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.3);
}

.drawer-panel.active {
    transform: translateX(0);
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */

.toast-enter {
    animation: slideInRight 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.toast-leave {
    animation: fadeOutRight 0.2s ease-in forwards;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* ==========================================================================
   Responsive & Accessibility Enhancements
   ========================================================================== */

/* Focus outlines for keyboard navigation */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible {
    outline: 2px solid #4F46E5;
    outline-offset: 2px;
}
.dark button:focus-visible,
.dark a:focus-visible,
.dark [role="button"]:focus-visible {
    outline-color: #818CF8;
}

/* Canvas styling */
canvas {
    max-width: 100%;
}

/* ==========================================================================
   Mobile-First Polish & Content Overflow Guards
   ========================================================================== */

@media (max-width: 639px) {
    .option-item {
        padding: 0.75rem 0.875rem !important;
        gap: 0.75rem !important;
        min-height: 48px;
        border-radius: 0.875rem;
    }
    
    .option-key-badge {
        width: auto !important;
        min-width: 28px !important;
        height: 28px !important;
        padding-left: 6px;
        padding-right: 6px;
        font-size: 0.8125rem;
        border-radius: 8px;
    }

    /* Immersive reading: edge-to-edge layout on mobile */
    .mobile-edge-to-edge {
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-top: none !important;
        box-shadow: none !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
}

/* ==========================================================================
   Question Text Typography & Responsive Wrapping
   ========================================================================== */
.question-text-content {
    overflow-wrap: break-word;
    word-break: break-word;
    line-break: normal;
}

.question-text-content p {
    margin-bottom: 0.75rem;
}

.question-text-content p:last-child {
    margin-bottom: 0;
}

/* Ensure table in question content is horizontally scrollable without overflowing page */
.question-text-content table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
    margin: 0.75rem 0;
}

.question-text-content pre,
.question-text-content code {
    max-width: 100%;
    overflow-x: auto;
    word-break: break-word;
}

.question-text-content img {
    max-width: 100%;
    height: auto;
}

#explanation-text {
    white-space: pre-line;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* ==========================================================================
   Utility Classes & Dark Mode Contrast Polish
   ========================================================================== */

/* Hide scrollbar for clean horizontal track selector */
.scrollbar-none {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.scrollbar-none::-webkit-scrollbar {
    display: none;
}

/* Dark mode typography and surface contrast refinements */
.dark body {
    background-color: #0B0F17;
    color: #F1F5F9;
}

.dark .bg-carddark {
    background-color: #161F30;
}

.dark .border-slate-800 {
    border-color: #243045;
}

/* Quick Search Dialog Styling */
#quick-search-backdrop.active {
    display: flex;
}

#quick-search-backdrop.active #quick-search-box {
    transform: scale(1);
    opacity: 1;
}

.quick-search-item {
    transition: all 0.15s ease;
    border-radius: 0.75rem;
}

.quick-search-item:hover,
.quick-search-item.active {
    background-color: rgba(79, 70, 229, 0.08);
}

.dark .quick-search-item:hover,
.dark .quick-search-item.active {
    background-color: rgba(99, 102, 241, 0.18);
}

/* Micro-interaction for primary CTA buttons */
.btn-primary-pulse:hover {
    box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.35), 0 8px 10px -6px rgba(79, 70, 229, 0.2);
}

