/* Base styles */
body {
    font-family: 'Cairo', sans-serif;
    background-color: #f8fafc; /* slate-50 */
    transition: background 0.5s ease-in-out;
    overflow-x: hidden;
}
html { scroll-behavior: smooth; }
.theme-bg-container { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: -1; display: none; transition: opacity 0.5s ease-in-out; opacity: 0; pointer-events: none; }
.theme-bg-container.active { display: block; opacity: 1; }
.theme-bg-container.interactive { pointer-events: auto; }

/* --- Header Styling & Animation --- */
header { 
    background-color: rgba(255, 255, 255, 0.8); 
    backdrop-filter: blur(10px); 
    border-color: #e2e8f0; 
    transition: transform 0.3s ease-in-out;
}
.header-hidden {
    transform: translateY(-100%);
}

.main-gradient-text { background: linear-gradient(to right, #3b82f6, #1e40af); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 0.5rem); background-color: white; border-radius: 0.75rem; box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); border: 1px solid #e5e7eb; z-index: 50; min-width: 220px; transition: all 0.3s ease-in-out; transform-origin: top right; }
.dropdown-menu.hidden { transform: scale(0.95); opacity: 0; pointer-events: none; }

/* Quiz-specific styles */
.quiz-card { background-color: white; border-radius: 1.5rem; padding: 2.5rem; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1); width: 100%; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.75rem 1.5rem; border-radius: 0.75rem; font-weight: 700; text-align: center; transition: all 0.2s ease-in-out; cursor: pointer; border: 2px solid transparent; }
.btn-primary { background-color: #3b82f6; color: white; }
.btn-primary:hover { background-color: #2563eb; }
.option-btn { display: block; width: 100%; text-align: right; padding: 1rem 1.5rem; border: 2px solid #e5e7eb; border-radius: 0.75rem; transition: all 0.2s ease-in-out; }
.option-btn:hover { border-color: #60a5fa; background-color: #eff6ff; }
.option-btn.selected { border-color: #3b82f6; background-color: #dbeafe; font-weight: 700; color: #1e3a8a;}
.remind-icon-btn { opacity: 0.6; transition: all 0.2s ease-in-out; }
.remind-icon-btn:hover { opacity: 1; transform: scale(1.1); }
.remind-icon-btn.active { opacity: 1; filter: drop-shadow(0 0 5px #facc15); }
.nav-box { display: grid; grid-template-columns: repeat(auto-fill, minmax(45px, 1fr)); gap: 0.75rem; padding: 1rem; background-color: #ffffff; border-radius: 1rem; border: 1px solid #e5e7eb; }
.nav-btn { width: 45px; height: 45px; border-radius: 0.5rem; font-weight: 600; transition: all 0.2s ease-in-out; border: 2px solid #d1d5db; }
.nav-btn.active { border-color: #3b82f6; background-color: #3b82f6; color: white; transform: scale(1.1); }
.nav-btn.answered { background-color: #dbeafe; border-color: #93c5fd; }
.nav-btn.reminded { background-color: #fef9c3; border-color: #facc15; }
.nav-btn.unanswered-error { background-color: #fee2e2; border-color: #f87171; animation: shake 0.5s; }
.progress-bar-bg { background-color: #e5e7eb; border-radius: 9999px; overflow: hidden; height: 0.625rem; width: 100%;}
.progress-bar { height: 100%; background-color: #3b82f6; transition: width 0.3s ease-in-out; border-radius: 9999px;}
.shake { animation: shake 0.5s; }

/* Keyframes */
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes nebula-flow { 0%{background-position:0% 50%} 50%{background-position:100% 50%} 100%{background-position:0% 50%} }
@keyframes wave-flow { 0%{transform:translateX(0)} 100%{transform:translateX(-50%)} }
@keyframes twinkle { 0%,100%{opacity:0} 50%{opacity:1} }
@keyframes shooting-star { 0% { transform: translateX(300vw) translateY(-50vh) rotate(225deg); opacity: 1; } 100% { transform: translateX(-50vw) translateY(100vh) rotate(225deg); opacity: 0; } }
@keyframes crystal-rotate { from { transform: rotate(0deg) scale(1); } to { transform: rotate(360deg) scale(1); } }
@keyframes dream-gradient { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }

/* --- Theme System --- */
html[class*="theme-"] body { color: #e5e5e5; }
html[class*="theme-"] header { background-color: rgba(18, 18, 18, 0.7); border-color: rgba(255, 255, 255, 0.1); }
html[class*="theme-"] .dropdown-menu { background-color: rgba(25, 25, 25, 0.8); border-color: rgba(255, 255, 255, 0.15); backdrop-filter: blur(10px); }
html[class*="theme-"] .dropdown-menu a, html[class*="theme-"] .dropdown-menu button, html[class*="theme-"] .dropdown-menu div { color: #d4d4d4; }
html[class*="theme-"] .dropdown-menu a:hover, html[class*="theme-"] .dropdown-menu button:hover { background-color: rgba(255, 255, 255, 0.05); }
html[class*="theme-"] #logout-btn:hover { color: #ef4444; background-color: rgba(239, 68, 68, 0.1); }
html[class*="theme-"] .text-slate-900, html[class*="theme-"] .text-slate-800, html[class*="theme-"] .text-slate-600, html[class*="theme-"] .text-slate-500, html[class*="theme-"] .font-semibold { color: #d4d4d4; }

/* Quiz Theme Adjustments */
html[class*="theme-"] .quiz-card, html[class*="theme-"] .nav-box { background-color: rgba(28, 28, 28, 0.6); border-color: rgba(255, 255, 255, 0.1); }
html[class*="theme-"] .option-btn { border-color: rgba(255, 255, 255, 0.2); color: #a3a3a3; }
html[class*="theme-"] .option-btn:hover { border-color: rgba(147, 197, 253, 0.5); background-color: rgba(59, 130, 246, 0.1); }
html[class*="theme-"] .option-btn.selected { border-color: #60a5fa; background-color: rgba(59, 130, 246, 0.2); color: #bfdbfe; }
html[class*="theme-"] .progress-bar-bg { background-color: rgba(255, 255, 255, 0.1); }
html[class*="theme-"] .btn.bg-slate-200 { background-color: #374151; color: #d1d5db; }
html[class*="theme-"] .nav-btn { border-color: #4b5563; color: #9ca3af; }
html[class*="theme-"] .nav-btn.answered { background-color: rgba(59, 130, 246, 0.2); border-color: #3b82f6; color: #93c5fd; }
html[class*="theme-"] .nav-btn.reminded { background-color: rgba(252, 211, 77, 0.2); border-color: #facc15; color: #fde047; }
html[class*="theme-"] .nav-btn.unanswered-error { background-color: rgba(239, 68, 68, 0.15); border-color: #ef4444; }
html[class*="theme-"] #summary-container { background-color: rgba(0,0,0,0.2); }
html[class*="theme-"] #summary-container .bg-green-100 { background-color: rgba(74, 222, 128, 0.1); color: #a7f3d0;}
html[class*="theme-"] #summary-container .text-green-800 { color: #a7f3d0;}
html[class*="theme-"] #summary-container .bg-red-100 { background-color: rgba(248, 113, 113, 0.1); color: #fecaca; }
html[class*="theme-"] #summary-container .text-red-800 { color: #fecaca; }
html[class*="theme-"] #start-screen .bg-slate-50 { background-color: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); }
html[class*="theme-"] #result-screen .bg-slate-50 { background-color: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); }

/* Theme: Golden Charcoal */
html.theme-golden-charcoal body { background-color: #121212; }
.theme-golden-charcoal #bg-golden-charcoal { background-image: radial-gradient(ellipse 80% 80% at 5% 50%,hsla(40,90%,55%,.15) 0,transparent 50%),radial-gradient(ellipse 80% 80% at 95% 50%,hsla(38,90%,55%,.15) 0,transparent 50%),url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIj48ZmlsdGVyIGlkPSJub2lzZSI+PGZlVHVyYnVsZW5jZSB0eXBlPSJmcmFjdGFsTm9pc2UiIGJhc2VGcmVxdWVuY3k9IjAuNzUiIG51bU9jdGF2ZXM9IjIiIHN0aXRjaFRpbGVzPSJzdGl0Y2giLz48L2ZpbHRlcj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWx0ZXI9InVybCgjbm9pc2UpIiBvcGFjaXR5PSIwLjAyNSIvPjwvc3ZnPg=='); }
.theme-golden-charcoal .main-gradient-text { background: linear-gradient(to right, #f59e0b, #fbbf24); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

/* Theme: Space */
html.theme-space body { background-color: #000; }
.theme-space #bg-space::before { content:''; position:absolute; width:200%; height:200%; top:-50%; left:-50%; z-index:1; background:radial-gradient(circle,hsla(260,100%,80%,.3) 0,hsla(330,100%,80%,.2) 40%,transparent 70%); animation:nebula-flow 45s linear infinite; }
.theme-space #bg-space::after { content:''; position:absolute; top:0; left:0; right:0; bottom:0; z-index:0; background-image:url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMDAwIiBoZWlnaHQ9IjIwMDAiPjxkZWZzPjxyYWRpYWxHcmFkaWVudCBpZD0iZ3JhZCIgY3g9IjUwJSIgY3k9IjUwJSIgcj0iNTAlIj48c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjZmZmZmZmIiBzdG9wLW9wYWNpdHk9IjEiLz48c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmZmZmZmYiIHN0b3Atb3BhY2l0eT0iMCIvPjwvcmFkaWFsR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9ImJsYWNrIi8+PGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMCwwKSI+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjIiIGhlaWdodD0iMiIgZmlsbD0idXJsKCNncmFkKSIvPjwvZz48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSg1MDAsMjAwKSI+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEuNSIgaGVpZ2h0PSIxLjUiIGZpbGw9InVybCgjZ3JhZCkiLz48L2c+PGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTUwMCwxODAwKSI+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkKSIvPjwvZz48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxMDAwLDEwMDApIj48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMS4yIiBoZWlnaHQ9IjEuMiIgZmlsbD0idXJsKCNncmFkKSIvPjwvZz48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSg4MDAsMTYwMCkiPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIwLjgiIGhlaWdodD0iMC44IiBmaWxsPSJ1clIoI2dyYWQpIi8+PC9nPjwvZz48L3N2Zz4=') }
.star { position:absolute; background-color:#fff; border-radius:50%; animation-name:twinkle; animation-timing-function:ease-in-out; animation-iteration-count:infinite }
.shooting-star { position:fixed; width:2px; height:100px; background:linear-gradient(to top,transparent,#fff); animation-name:shooting-star; animation-timing-function:linear; animation-iteration-count:infinite; z-index:0 }
.theme-space .main-gradient-text { background: linear-gradient(to right, #a78bfa, #f472b6); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

/* Theme: Ocean */
html.theme-ocean body { background-color: #020617; }
.wave { position:absolute; left:0; bottom:0; width:200%; height:100vh; background-repeat:repeat-x; background-position: bottom; }
#wave1 { background-image:url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjAwIDMwMCI+PHBhdGggZmlsbD0iIzA4MmY0OSIgb3BhY2l0eT0iMC41IiBkPSJNMCAyNTBDMzAwIDMwMCA0MDAgMjAwIDYwMCAyNDBDODAwIDI4MCA5MDAgMjIwIDEyMDAgMjUwVjMwMEgweiIvPjwvc3ZnPg=='); animation:wave-flow 25s linear infinite; }
#wave2 { background-image:url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjAwIDMwMCI+PHBhdGggZmlsbD0iIzBjNGE2ZSIgb3BhY2l0eT0iMC41IiBkPSJNMCAyNjBDMjgwIDMxMCA0MjAgMjEwIDYwMCAyNTBDNzgwIDI5MCA5MjAgMjMwIDEyMDAgMjYwVjMwMEgweiIvPjwvc3ZnPg=='); animation:wave-flow 20s linear infinite reverse; }
.theme-ocean .main-gradient-text { background: linear-gradient(to right, #38bdf8, #67e8f9); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

/* Fireflies Theme */
html.theme-fireflies body { background-color: #011422; }
.theme-fireflies .main-gradient-text { background: linear-gradient(to right, #fef08a, #fde047); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

/* Dream Theme */
html.theme-dream-garden body {
    background: linear-gradient(-45deg, #4c0d6b, #a4508b, #e9a8a8, #fbcfe8);
    background-size: 400% 400%;
    animation: dream-gradient 15s ease infinite;
}
.theme-dream-garden .main-gradient-text { background: linear-gradient(to right, #fbcfe8, #fce7f3); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.crystal-item { position: absolute; animation: crystal-rotate 30s linear infinite; filter: drop-shadow(0 0 15px white); transition: transform 0.3s; width: 60px; height: 60px; pointer-events: auto; }
.crystal-item:hover { transform: scale(1.2) rotate(15deg) !important; }

/* Focus Theme */
html.theme-focus-study body { background: #282a36; }
.theme-focus-study .main-gradient-text { background: linear-gradient(to right, #a5f3fc, #67e8f9); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

/* Mobile Improvements */
@media (max-width: 768px) {
    /* تحسين الهيدر للموبايل */
    header {
        transition: transform 0.3s ease-in-out;
    }
    
    header.header-hidden {
        transform: translateY(-100%);
    }
    
    /* تحسين الأزرار للموبايل */
    .control-btn {
        width: 2.5rem !important;
        height: 2.5rem !important;
        font-size: 1.5rem !important;
        margin: 0 0.25rem !important;
    }
    
    /* تحسين المسافات بين الأزرار */
    .flex.items-center.gap-3 {
        gap: 0.5rem !important;
    }
    
    .flex.items-center.gap-4 {
        gap: 0.75rem !important;
    }
    
    /* تحسين حجم النص في الأزرار */
    #total-questions-info,
    #time-limit-info {
        font-size: 1.5rem !important;
        min-width: 2.5rem !important;
    }
    
    /* تحسين الأزرار في quiz.html */
    #questions-decrease-btn,
    #questions-increase-btn,
    #time-decrease-btn,
    #time-increase-btn {
        width: 2.5rem !important;
        height: 2.5rem !important;
        font-size: 1.5rem !important;
    }
    
    /* تحسين المسافات في quiz.html */
    .grid.grid-cols-2.gap-4 {
        gap: 1rem !important;
    }
    
    /* جعل الأزرار تحت بعضها في الموبايل */
    .grid.grid-cols-2 {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }
    
    /* تحسين حجم النص في quiz.html */
    .text-2xl {
        font-size: 1.5rem !important;
    }
    
    /* تحسين عنوان المحاضرة في الموبايل */
    #quiz-header-title {
        font-size: 1rem !important;
        line-height: 1.2 !important;
        max-width: 200px !important;
        overflow-wrap: break-word !important;
        word-wrap: break-word !important;
        hyphens: auto !important;
    }
    
    /* تحسين الأزرار في mixer modal */
    #mixer-modal .control-btn {
        width: 2.5rem !important;
        height: 2.5rem !important;
        font-size: 1.5rem !important;
    }
    
    #mixer-modal .mixer-input {
        width: 3rem !important;
        font-size: 1.1rem !important;
    }
}
