/* =========================================
   IMAT HERO - GLOBAL STYLES
   ========================================= */

:root {
    --primary: #4f46e5;       
    --primary-dark: #4338ca;  
    --secondary: #7e22ce;     
    --accent: #fbbf24;        
    --bg-body: #f8fafc;       
    --surface: #ffffff;
    --border: #e2e8f0;        
    --text-main: #0f172a;     
    --text-sub: #64748b;      
}

/* Dark Mode Variables */
body.dark-mode {
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --secondary: #c084fc;
    --accent: #fcd34d;
    --bg-body: #0a0a0f;
    --surface: #16161d;
    --surface-hover: #1e1e28;
    --border: #2a2a3a;
    --text-main: #f4f4f5;
    --text-sub: #a1a1aa;
    --shadow-color: rgba(0, 0, 0, 0.4);
}

body.dark-mode {
    background-color: var(--bg-body) !important;
    color: var(--text-main) !important;
}

/* Dark mode specific overrides */
body.dark-mode .bg-white {
    background-color: var(--surface) !important;
}

/* Glassmorphism Effect for Cards */
body.dark-mode .bg-white,
body.dark-mode .accordion-item,
body.dark-mode .video-player-card {
    background: linear-gradient(145deg, rgba(22, 22, 29, 0.9), rgba(30, 30, 40, 0.8)) !important;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
}

body.dark-mode .text-gray-900 {
    color: var(--text-main) !important;
}

body.dark-mode .text-gray-500,
body.dark-mode .text-gray-600,
body.dark-mode .text-gray-400 {
    color: var(--text-sub) !important;
}

body.dark-mode .border-gray-100,
body.dark-mode .border-gray-200 {
    border-color: var(--border) !important;
}

body.dark-mode .bg-gray-50,
body.dark-mode .bg-gray-100 {
    background-color: var(--surface) !important;
}

body.dark-mode .shadow-sm,
body.dark-mode .shadow-md,
body.dark-mode .shadow-lg,
body.dark-mode .shadow-xl,
body.dark-mode .shadow-2xl {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 4px 6px -1px rgba(0, 0, 0, 0.3) !important;
}

body.dark-mode footer.bg-gray-900 {
    background-color: #020617 !important;
    border-top-color: var(--surface) !important;
}

/* =========================================
   COMPREHENSIVE DARK MODE ENHANCEMENTS
   ========================================= */

/* 1. Navbar Dark Mode */
body.dark-mode nav,
body.dark-mode .bg-white\/95 {
    background: rgba(10, 10, 15, 0.95) !important;
    border-color: rgba(255, 255, 255, 0.05) !important;
}

/* 2. Enhanced hover effects for cards - base backgrounds handled by existing glassmorphism */
body.dark-mode .bg-white.rounded-2xl:hover,
body.dark-mode .bg-white.rounded-3xl:hover {
    border-color: rgba(129, 140, 248, 0.3) !important;
    box-shadow: 0 0 30px rgba(129, 140, 248, 0.1),
                0 10px 40px rgba(0, 0, 0, 0.3) !important;
}

/* 3. Leaderboard Cards - specific styling */

body.dark-mode #home-week1-list,
body.dark-mode #home-bio-list,
body.dark-mode #home-tissues-list {
    background: transparent !important;
}

body.dark-mode #home-week1-list > div,
body.dark-mode #home-bio-list > div,
body.dark-mode #home-tissues-list > div {
    background: rgba(30, 30, 40, 0.8) !important;
    border-color: rgba(255, 255, 255, 0.05) !important;
}

body.dark-mode .bg-yellow-50,
body.dark-mode .bg-orange-50 {
    background: rgba(251, 191, 36, 0.1) !important;
}

/* 4. Footer Enhancement */
body.dark-mode footer.bg-gray-900 {
    background: linear-gradient(180deg, #0a0a0f 0%, #050508 100%) !important;
}

body.dark-mode footer .text-gray-400 {
    color: #71717a !important;
}

body.dark-mode footer .text-white {
    color: #e4e4e7 !important;
}

/* 5. Modal Dark Mode */
body.dark-mode #reviewModal > div:last-child {
    background: linear-gradient(145deg, #16161d, #1e1e28) !important;
    border: 1px solid rgba(129, 140, 248, 0.2) !important;
}

body.dark-mode #reviewModal input,
body.dark-mode #reviewModal textarea {
    background: rgba(10, 10, 15, 0.8) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: var(--text-main) !important;
}

body.dark-mode #reviewModal input::placeholder,
body.dark-mode #reviewModal textarea::placeholder {
    color: #71717a !important;
}

body.dark-mode #reviewModal input:focus,
body.dark-mode #reviewModal textarea:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 10px rgba(129, 140, 248, 0.2) !important;
}

/* 6. Text Colors - Additional color variants */
body.dark-mode .text-gray-800,
body.dark-mode .text-gray-700 {
    color: #f4f4f5 !important;
}

body.dark-mode .text-indigo-600,
body.dark-mode .text-indigo-700 {
    color: #a5b4fc !important;
}

body.dark-mode .text-teal-600 {
    color: #5eead4 !important;
}

body.dark-mode .text-red-600 {
    color: #fca5a5 !important;
}

/* 7. Additional Border Colors - maintain semantic meaning */
body.dark-mode .border-gray-50 {
    border-color: rgba(255, 255, 255, 0.05) !important;
}

body.dark-mode .border-indigo-50 {
    border-color: rgba(129, 140, 248, 0.2) !important;
}

body.dark-mode .border-red-50 {
    border-color: rgba(239, 68, 68, 0.2) !important;
}

body.dark-mode .border-teal-50 {
    border-color: rgba(20, 184, 166, 0.2) !important;
}

/* 8. Shadows - handled by existing rules at lines 71-77 */

/* 9. Buttons Neon Glow */
body.dark-mode .bg-indigo-600:hover,
body.dark-mode .bg-purple-600:hover {
    box-shadow: 0 0 25px rgba(129, 140, 248, 0.4) !important;
}

body.dark-mode .bg-red-600:hover {
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.4) !important;
}

body.dark-mode .bg-teal-600:hover {
    box-shadow: 0 0 25px rgba(20, 184, 166, 0.4) !important;
}

/* 10. Special Elements */
/* Quiz cards icon boxes - maintain semantic colors */
body.dark-mode .bg-indigo-50 {
    background: rgba(99, 102, 241, 0.15) !important;
}

body.dark-mode .bg-teal-50 {
    background: rgba(20, 184, 166, 0.15) !important;
}

body.dark-mode .bg-red-100 {
    background: rgba(239, 68, 68, 0.15) !important;
}

/* Arabic language button - uses existing .bg-gray-100 rule */

/* Reviews section */
body.dark-mode .bg-white\/50 {
    background: rgba(22, 22, 29, 0.5) !important;
}

/* Selection color */
body.dark-mode ::selection {
    background: rgba(129, 140, 248, 0.3) !important;
    color: #fff !important;
}

/* 11. Loading States - Enhanced pulse for loading text */
body.dark-mode .animate-pulse.text-gray-400 {
    color: #71717a !important;
}

body.dark-mode .bg-white.animate-pulse {
    /* Specific gradient colors for animated pulse effect */
    background: linear-gradient(90deg, rgba(30, 30, 40, 0.8), rgba(40, 40, 50, 0.8), rgba(30, 30, 40, 0.8)) !important;
    background-size: 200% 100%;
    animation: pulse-dark 1.5s ease-in-out infinite !important;
}

@keyframes pulse-dark {
    0%, 100% { background-position: 200% 0; }
    50% { background-position: 0 0; }
}

/* ========================================= */

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Smooth Transitions for All Elements */
body,
body *:not(iframe):not(img):not(video) {
    transition: background-color 0.3s ease,
                color 0.3s ease,
                border-color 0.3s ease,
                box-shadow 0.3s ease;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    scroll-behavior: smooth;
}

.font-arabic { 
    font-family: 'Cairo', sans-serif; 
}

.fade-in { 
    animation: fadeIn 0.3s ease-out; 
}

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

/* Scrollbar Styles */
::-webkit-scrollbar { 
    width: 8px; 
}

::-webkit-scrollbar-track { 
    background: #f1f5f9; 
}

body.dark-mode ::-webkit-scrollbar-track {
    background: var(--bg-body);
}

::-webkit-scrollbar-thumb { 
    background: #cbd5e1; 
    border-radius: 5px; 
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #4f46e5, #7e22ce);
    border-radius: 10px;
    border: 2px solid var(--bg-body);
}

body.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #6366f1, #a855f7);
}

/* Star Rating CSS */
.star-rating label:hover,
.star-rating label:hover ~ label,
.star-rating input:checked ~ label { 
    color: #fbbf24; 
}

/* Dark Mode Toggle Button */
.dark-mode-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    color: #6b7280;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.dark-mode-toggle i {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.dark-mode-toggle span {
    transition: opacity 0.3s ease;
}

/* Dark mode toggle animations */
.dark-mode-toggle.toggling {
    transform: scale(0.95);
}

.dark-mode-toggle i.icon-rotating {
    transform: rotate(180deg) scale(0);
}

.dark-mode-toggle span.text-fading {
    opacity: 0;
}

.dark-mode-toggle:hover {
    background: #e5e7eb;
    color: #4f46e5;
}

body.dark-mode .dark-mode-toggle {
    background: linear-gradient(145deg, #1e1e28, #16161d);
    border: 1px solid rgba(129, 140, 248, 0.3);
    color: #fcd34d;
    box-shadow: 0 0 15px rgba(129, 140, 248, 0.2),
                inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

body.dark-mode .dark-mode-toggle:hover {
    background: linear-gradient(145deg, #1e1e28, #16161d);
    color: #fcd34d;
    box-shadow: 0 0 20px rgba(129, 140, 248, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Mobile Menu Styles */
.mobile-menu-btn {
    display: none;
    padding: 0.5rem;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.2s;
}

.mobile-menu-btn:hover {
    background: #e5e7eb;
    color: #4f46e5;
}

body.dark-mode .mobile-menu-btn {
    background: #334155;
    border-color: #475569;
    color: #cbd5e1;
}

body.dark-mode .mobile-menu-btn:hover {
    background: #475569;
}

.mobile-menu {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 40;
    animation: slideDown 0.3s ease-out;
}

body.dark-mode .mobile-menu {
    background: #1e293b;
    border-bottom-color: #334155;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mobile-menu.active {
    display: block;
}

.mobile-menu-links {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 0.5rem;
}

.mobile-menu-links a {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    color: #6b7280;
    text-decoration: none;
    transition: all 0.2s;
}

.mobile-menu-links a:hover {
    background: #f3f4f6;
    color: #4f46e5;
}

body.dark-mode .mobile-menu-links a {
    color: #94a3b8;
}

body.dark-mode .mobile-menu-links a:hover {
    background: #334155;
    color: #a5b4fc;
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .desktop-nav {
        display: none !important;
    }
}

/* Header */
.main-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 15px 0;
    position: sticky; top: 0; z-index: 100;
}

/* Header Glassmorphism (Dark Mode) */
body.dark-mode .main-header,
body.dark-mode header {
    background: rgba(10, 10, 15, 0.85) !important;
    backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}
.header-content { max-width: 900px; margin: 0 auto; padding: 0 20px; display: flex; justify-content: space-between; align-items: center; }
.back-home-btn { text-decoration: none; color: var(--text-sub); font-weight: 600; display: flex; gap: 8px; align-items: center; transition: 0.2s; }
.back-home-btn:hover { color: var(--primary); }
.logo-text h1 { font-size: 1.25rem; font-weight: 900; color: var(--secondary); letter-spacing: -1px; }

/* Layout */
.main-container { max-width: 900px; margin: 0 auto; padding: 25px 20px 80px; }

/* Tabs */
.weeks-nav { display: flex; gap: 10px; padding-bottom: 25px; overflow-x: auto; scrollbar-width: none; }
.weeks-nav::-webkit-scrollbar { display: none; }

.tab-btn {
    background: var(--surface); border: 1px solid var(--border);
    padding: 10px 20px; border-radius: 50px;
    font-family: 'Inter', sans-serif; font-weight: 600; color: var(--text-sub);
    cursor: pointer; transition: all 0.2s; white-space: nowrap; display: flex; gap: 8px; align-items: center;
}
.tab-btn:hover { border-color: var(--primary); color: var(--primary); }
.tab-btn.active { background: var(--primary); color: white; border-color: var(--primary); box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3); }

/* Header Card */
.week-header-card {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--primary-dark) 100%);
    border-radius: 20px; padding: 30px; color: white; margin-bottom: 30px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1); position: relative; overflow: hidden;
}
.week-header-card::after { content: ''; position: absolute; top: -50px; right: -50px; width: 250px; height: 250px; background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%); border-radius: 50%; }
.header-info { display: flex; justify-content: space-between; margin-bottom: 20px; position: relative; z-index: 2; }
.header-info h2 { font-size: 1.8rem; font-weight: 800; }
.badge { background: rgba(255,255,255,0.2); padding: 5px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.progress-bar-container { height: 8px; background: rgba(255,255,255,0.15); border-radius: 10px; margin-bottom: 10px; overflow: hidden; position: relative; z-index: 2; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 10px; }
.progress-text { font-size: 0.9rem; opacity: 0.9; position: relative; z-index: 2; }

/* Glowing Progress Bar (Dark Mode) */
body.dark-mode .progress-fill {
    background: linear-gradient(90deg, var(--accent), #f59e0b) !important;
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

/* Accordion */
.accordion-item { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; margin-bottom: 15px; overflow: hidden; transition: 0.3s; }
.accordion-item:hover { transform: translateY(-2px); border-color: #c7d2fe; }
.accordion-item.open { border-color: var(--primary); box-shadow: 0 4px 15px -3px rgba(79, 70, 229, 0.1); }

/* Glow Effect on Hover (Dark Mode) */
body.dark-mode .accordion-item:hover,
body.dark-mode .video-item:hover {
    box-shadow: 0 0 20px rgba(129, 140, 248, 0.15),
                0 8px 32px rgba(0, 0, 0, 0.3) !important;
    border-color: rgba(129, 140, 248, 0.3) !important;
}

.accordion-header { padding: 20px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; background: white; }
.subject-info { display: flex; align-items: center; gap: 15px; }
.icon-box { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: white; }
.subject-text div:first-child { font-weight: 700; font-size: 1.1rem; }
.subject-text div:last-child { font-size: 0.85rem; color: var(--text-sub); }
.toggle-icon { color: #94a3b8; transition: 0.3s; }
.accordion-item.open .toggle-icon { transform: rotate(180deg); color: var(--primary); }

.accordion-body { max-height: 0; overflow: hidden; transition: max-height 0.4s ease; background: #f8fafc; }
.video-list { padding: 10px; }
.video-item { display: flex; align-items: center; gap: 12px; padding: 12px 15px; border-radius: 10px; cursor: pointer; transition: 0.2s; border: 1px solid transparent; }
.video-item:hover { background: white; border-color: var(--border); box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.play-icon-small { width: 32px; height: 32px; background: #e0e7ff; color: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; flex-shrink: 0; }
.vid-title { font-size: 0.95rem; font-weight: 600; color: #334155; flex: 1; }
.vid-duration { font-size: 0.7rem; font-weight: 700; background: #e2e8f0; color: #475569; padding: 4px 8px; border-radius: 6px; }

/* PLAYER VIEW STYLES (NEW) */
.back-to-course-btn {
    background: white; border: 1px solid var(--border); padding: 10px 20px; border-radius: 50px;
    color: var(--text-sub); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; margin-bottom: 20px; transition: 0.2s; font-family: 'Inter', sans-serif;
}
.back-to-course-btn:hover { color: var(--primary); border-color: var(--primary); box-shadow: 0 4px 10px rgba(0,0,0,0.05); }

.video-player-card { background: white; border-radius: 20px; overflow: hidden; box-shadow: 0 10px 30px -5px rgba(0,0,0,0.1); border: 1px solid var(--border); }
.video-frame-container-large { position: relative; padding-bottom: 56.25%; height: 0; background: black; }
.video-frame-container-large iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; }
.video-info-area { padding: 30px; }
.video-info-area h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 15px; color: var(--text-main); }
.video-meta-tags { display: flex; gap: 10px; }
.meta-tag { background: #f1f5f9; color: var(--text-sub); padding: 6px 12px; border-radius: 8px; font-size: 0.85rem; font-weight: 600; display: flex; align-items: center; gap: 6px; }

.fade-in { animation: fadeIn 0.4s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
