/* Google Fonts: Kanit (Headings) & Sarabun (Body) */
@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700;800&family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #059669;
    --primary-dark: #047857;
    --primary-light: #10b981;
    --secondary: #d97706;
    --accent: #2563eb;
    --bg-main: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
}

.dark {
    --bg-main: #090d16;
    --card-bg: #111827;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #1f2937;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4, h5, h6, .font-heading {
    font-family: 'Kanit', sans-serif;
}

/* 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: #374151;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Glassmorphism Glass Panels */
.glass-card {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.dark .glass-card {
    background: rgba(17, 24, 39, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(31, 41, 55, 0.8);
}

/* Tab indicator animations */
.tab-btn {
    position: relative;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn.active {
    color: #059669;
    font-weight: 700;
}

.dark .tab-btn.active {
    color: #34d399;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #059669, #10b981);
    border-radius: 9999px;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

/* Video Player container aspect ratio */
.video-responsive-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
    background-color: #000;
    border-radius: 1rem;
    box-shadow: 0 12px 30px -8px rgba(0, 0, 0, 0.2), 0 4px 12px -2px rgba(0, 0, 0, 0.1);
}

.video-responsive-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Ambient Video Glow in Dark Mode */
.dark .video-responsive-container {
    box-shadow: 0 0 40px -10px rgba(16, 185, 129, 0.18), 0 12px 30px -8px rgba(0, 0, 0, 0.6);
}

/* PDF Viewer container */
.pdf-responsive-container {
    height: 680px;
    width: 100%;
    border-radius: 1rem;
    overflow: hidden;
    background-color: #f1f5f9;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.pdf-responsive-container iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

/* Lesson list item active state */
.lesson-item {
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.lesson-item:hover {
    transform: translateY(-1px);
}

.lesson-item.active {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.14), rgba(16, 185, 129, 0.04));
    border-color: #10b981;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.12);
}

.dark .lesson-item.active {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.22), rgba(16, 185, 129, 0.06));
    border-color: #059669;
    box-shadow: 0 4px 14px rgba(5, 150, 105, 0.2);
}

/* Category Filter Pill */
.category-pill {
    transition: all 0.2s ease;
}
.category-pill.active {
    background: #059669;
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(5, 150, 105, 0.3);
}

/* Quiz Option styling */
.quiz-option {
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

.quiz-option:hover:not(.disabled) {
    border-color: #10b981;
    background-color: rgba(16, 185, 129, 0.06);
    transform: translateX(3px);
}

.quiz-option.selected {
    border-color: #059669;
    background-color: rgba(5, 150, 105, 0.1);
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.15);
}

.quiz-option.correct {
    border-color: #10b981 !important;
    background-color: rgba(16, 185, 129, 0.18) !important;
    color: #065f46 !important;
}

.dark .quiz-option.correct {
    color: #a7f3d0 !important;
    background-color: rgba(16, 185, 129, 0.28) !important;
}

.quiz-option.incorrect {
    border-color: #ef4444 !important;
    background-color: rgba(239, 68, 68, 0.14) !important;
    color: #991b1b !important;
}

.dark .quiz-option.incorrect {
    color: #fecaca !important;
    background-color: rgba(239, 68, 68, 0.28) !important;
}

/* Pulse badge animation */
@keyframes softPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.pulse-soft {
    animation: softPulse 2.2s infinite ease-in-out;
}

/* Float Glow Animation */
@keyframes floatGlow {
    0%, 100% { transform: translateY(0px); filter: drop-shadow(0 4px 8px rgba(245, 158, 11, 0.3)); }
    50% { transform: translateY(-3px); filter: drop-shadow(0 8px 16px rgba(245, 158, 11, 0.5)); }
}

.float-glow {
    animation: floatGlow 3s infinite ease-in-out;
}

/* Certificate Styles */
.certificate-frame {
    background: #ffffff;
    border: 12px double #065f46;
    box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.25);
    position: relative;
    border-radius: 0.5rem;
}

.certificate-inner {
    border: 2px solid #d97706;
    padding: 3rem;
    position: relative;
    background: radial-gradient(circle at center, #ffffff 55%, #fefce8 100%);
}

.certificate-seal {
    width: 95px;
    height: 95px;
    border-radius: 50%;
    background: linear-gradient(135deg, #d97706, #fbbf24, #b45309);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 6px 14px rgba(217, 119, 6, 0.45);
}

/* Confetti Canvas Container */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* Print Styles for Certificate */
@media print {
    body * {
        visibility: hidden;
    }
    #certificate-modal, #certificate-printable, #certificate-printable * {
        visibility: visible;
    }
    #certificate-modal {
        position: absolute;
        left: 0;
        top: 0;
        width: 100vw;
        height: 100vh;
        background: #fff;
        padding: 0;
        margin: 0;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    #certificate-printable {
        width: 100%;
        max-width: 1000px;
        box-shadow: none;
        page-break-inside: avoid;
    }
    .no-print {
        display: none !important;
    }
    @page {
        size: A4 landscape;
        margin: 1cm;
    }
}
