@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Inter:wght@400;500;600&display=swap');

:root {
    --bg-primary: #f4f7fb;
    --bg-secondary: #e9eef8;
    --surface: rgba(255, 255, 255, 0.85);
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --accent: #4f46e5;
    --accent-dark: #3730a3;
    --accent-glow: rgba(79, 70, 229, 0.35);
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --border: rgba(15, 23, 42, 0.08);
    --shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 30px 60px -15px rgba(79, 70, 229, 0.2);
    --radius: 24px;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --glass-border: 1px solid rgba(255, 255, 255, 0.4);
}

[data-theme="dark"] {
    --bg-primary: #040816;
    --bg-secondary: #0f172a;
    --surface: rgba(15, 23, 42, 0.7);
    --card: rgba(30, 41, 59, 0.75);
    --text: #f8fafc;
    --muted: #94a3b8;
    --accent: #6366f1;
    --accent-dark: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.4);
    --border: rgba(255, 255, 255, 0.1);
    --shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.5);
    --shadow-hover: 0 30px 60px -15px rgba(99, 102, 241, 0.3);
    --glass-border: 1px solid rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }
html, body { overflow-x: hidden; scroll-behavior: smooth; }

/* Custom Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.25); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99, 102, 241, 0.6); }

body {
    margin: 0;
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.12), transparent 30%),
        radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.08), transparent 30%);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    transition: background-color 0.4s ease, color 0.4s ease;
}

h1, h2, h3, h4, h5, h6, .brand, .eyebrow {
    font-family: var(--font-heading);
}

/* Animations */
@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes rotateBg { 100% { transform: rotate(360deg); } }

.animate-in {
    animation: slideUpFade 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
}

a { color: inherit; text-decoration: none; transition: 0.3s ease; }
main { padding: 0 0 4rem; }

input, textarea, select, button {
    width: 100%;
    padding: 1rem 1.2rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-family: var(--font-body);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    width: 100%;
}
.form-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--muted);
    margin-left: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

button, .button-link {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    font-family: var(--font-heading);
    min-height: 52px;
    padding: 0.85rem 1.5rem;
    border-radius: 16px;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 14px 0 rgba(0, 0, 0, 0.1);
}
button:hover, .button-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px -5px var(--accent-glow);
}

.button-link.alt, .theme-toggle {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    backdrop-filter: blur(8px);
    box-shadow: none;
}
.button-link.alt:hover, .theme-toggle:hover {
    background: var(--surface);
    border-color: var(--accent);
}

.page-shell { max-width: 1280px; margin: 0 auto; padding: 1.5rem; width: 100%; }
.admin-page-shell { max-width: 1500px; }

/* Cards & Surfaces */
.site-header, .hero, .panel, .course-card, .auth-card, .support-card, .stat-card, .admin-sidebar, .lesson-action-panel {
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    background: var(--surface);
    border: var(--glass-border);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    transition: transform 0.4s ease, box-shadow 0.4s ease, border-color 0.4s ease;
}

.site-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.5rem; margin: 0 0 2rem; position: sticky; top: 0; z-index: 50;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border-top: none; border-left: none; border-right: none; border-top-left-radius: 0; border-top-right-radius: 0;
}
.site-header.scrolled {
    padding: 0.6rem 1.5rem;
    margin-bottom: 1.5rem;
    background: var(--card);
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    border-color: var(--accent);
}
.site-header h1 { font-size: 2.2rem; margin: 0; transition: font-size 0.4s ease; }
.site-header.scrolled h1 { font-size: 1.4rem; }
.site-header .eyebrow { transition: all 0.3s ease; margin-bottom: 0.4rem; }
.site-header.scrolled .eyebrow { opacity: 0; height: 0; margin: 0; padding: 0; overflow: hidden; }

.brand {
    font-size: 1.8rem; font-weight: 800;
    background: linear-gradient(to right, var(--accent), #38bdf8);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.main-nav { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; }
.main-nav a { color: var(--muted); font-weight: 500; font-family: var(--font-heading); }
.main-nav a:hover { color: var(--text); transform: translateY(-1px); }

/* Grid Layouts */
.hero, .detail-grid {
    display: grid; grid-template-columns: 1.4fr 1fr; gap: 2rem; padding: 3rem;
    position: relative; overflow: hidden;
}

.hero::before {
    content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle at center, var(--accent-glow), transparent 60%);
    opacity: 0.15; z-index: -1; animation: rotateBg 20s linear infinite;
}

.hero h1, .section-header h1, .auth-card h1, .panel-head h1, .lesson-player-head h1 {
    font-size: clamp(2.5rem, 5vw, 4rem); line-height: 1.1; margin: 0.5rem 0 1.2rem;
    letter-spacing: -0.03em; font-weight: 800;
}

.eyebrow {
    text-transform: uppercase; letter-spacing: 0.2em; color: var(--accent);
    font-size: 0.85rem; font-weight: 800; display: inline-block;
    padding: 0.4rem 1rem; background: rgba(99, 102, 241, 0.1); border-radius: 999px; margin-bottom: 1rem;
}

.hero-copy { font-size: 1.1rem; color: var(--muted); margin-bottom: 2rem; max-width: 600px; }
.hero-actions, .action-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.hero-card {
    background: var(--card); border-radius: var(--radius); padding: 2rem;
    border: 1px solid var(--border); display: flex; flex-direction: column; justify-content: center;
}

/* Course Grid */
.course-grid, .stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.5rem; }
.stat-card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; box-shadow: var(--shadow);
}
.stat-card strong { font-size: 2.5rem; font-weight: 800; font-family: var(--font-heading); color: var(--accent); line-height: 1; }
.stat-card span { color: var(--muted); font-weight: 600; font-size: 1.1rem; }
.course-card { padding: 1.5rem; display: flex; flex-direction: column; }
.course-card:hover { transform: translateY(-8px); box-shadow: var(--shadow-hover); border-color: var(--accent); }

.thumbnail, .placeholder-box {
    height: 180px; border-radius: 16px; display: grid; place-items: center; margin-bottom: 1.5rem;
    background: linear-gradient(135deg, var(--bg-secondary), var(--accent)); color: #fff;
    font-size: 2.5rem; font-weight: 800; font-family: var(--font-heading);
}
.course-image, .detail-image { width: 100%; object-fit: cover; border-radius: 16px; border: 1px solid var(--border); }
.course-image { height: 200px; margin-bottom: 1.5rem; }

.course-meta, .price-row { color: var(--accent); font-weight: 600; font-family: var(--font-heading); margin-bottom: 1rem; }
.price-row { display: flex; gap: 1rem; font-size: 1.2rem; }

/* Support & Auth Cards */
.support-card, .dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-top: 2rem; }
.auth-card { max-width: 500px; margin: 4rem auto; padding: 2.5rem; }
.support-card { padding: 2.5rem; align-items: center; }

/* Dashboard specifics */
.dashboard-hero {
    display: flex; justify-content: space-between; align-items: center;
    padding: 2.5rem; background: linear-gradient(135deg, var(--surface), rgba(99, 102, 241, 0.05));
    border-radius: var(--radius); margin-bottom: 2rem; border: var(--glass-border); box-shadow: var(--shadow);
}
.profile-summary {
    padding: 1.5rem; background: var(--card); border-radius: 20px; border: 1px solid var(--border);
    text-align: right; box-shadow: var(--shadow);
}
.profile-summary strong { display: block; font-size: 1.2rem; font-family: var(--font-heading); }
.panel { padding: 2.5rem; }
.panel.wide { grid-column: 1 / -1; }

.enrollment-card {
    background: var(--card); border: 1px solid var(--border); border-radius: 20px;
    padding: 2rem; margin-bottom: 1.5rem; transition: 0.3s ease;
}
.enrollment-card:hover { border-color: var(--accent); transform: scale(1.01); box-shadow: var(--shadow-hover); }
.enrollment-card h3 { margin-top: 0; font-size: 1.5rem; }

.progress-bar {
    width: 100%; height: 12px; background: rgba(148, 163, 184, 0.2);
    border-radius: 999px; overflow: hidden; margin: 1rem 0 0.5rem;
}
.progress-bar span {
    display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #38bdf8);
    border-radius: 999px; box-shadow: 0 0 10px var(--accent-glow);
}

.lesson-list { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.list-row { display: flex; justify-content: space-between; align-items: center; padding: 1rem 0; border-bottom: 1px solid var(--border); gap: 1rem; flex-wrap: wrap; }
.list-row form { margin: 0; }
.activity-item { display: flex; justify-content: space-between; align-items: center; padding: 1rem 0; border-bottom: 1px solid var(--border); gap: 1rem; }
.quick-links { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-bottom: 1.5rem; }
.quick-links a {
    padding: 0.8rem 1rem; border: 1px solid var(--border); border-radius: 12px; background: rgba(99, 102, 241, 0.05); font-weight: 600;
}
.quick-links a:hover { background: var(--accent); color: white; border-color: var(--accent); }

/* Lesson Player */
.lesson-player-shell { display: grid; gap: 1.5rem; }
.lesson-player-head {
    padding: 2.5rem; background: var(--surface); border-radius: var(--radius);
    border: var(--glass-border); display: flex; justify-content: space-between; align-items: center;
}
.lesson-player-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; }
.lesson-video-frame {
    aspect-ratio: 16/9; border-radius: 20px; overflow: hidden; box-shadow: var(--shadow); background: #000;
}
.lesson-video-frame iframe { width: 100%; height: 100%; border: none; }
.lesson-side-panel { display: flex; flex-direction: column; gap: 1rem; }
.lesson-action-panel {
    background: linear-gradient(135deg, var(--accent-dark), var(--accent)); color: white;
    padding: 3rem; border-radius: 24px; display: flex; flex-direction: column; justify-content: center;
}
.lesson-action-panel h2 { color: white; }

/* Course Outline (Curriculum) */
.course-outline { display: grid; gap: 1rem; margin-top: 1.5rem; }
.module-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.module-summary {
    padding: 1.2rem; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
    font-family: var(--font-heading); font-weight: 600; font-size: 1.1rem;
}
.module-summary::-webkit-details-marker { display: none; }
.module-body { padding: 1.2rem; border-top: 1px solid var(--border); background: var(--bg-primary); }
.topic-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.8rem; }
.topic-item {
    display: flex; justify-content: space-between; padding: 1rem;
    background: var(--card); border: 1px solid var(--border); border-radius: 12px;
}

/* Modals & Alerts */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(2, 6, 23, 0.8); backdrop-filter: blur(8px);
    display: none; place-items: center; z-index: 1000;
}
.modal-backdrop.active { display: grid; }
.modal-card {
    background: var(--card); padding: 2.5rem; border-radius: 24px; width: min(100%, 500px);
    border: 1px solid var(--border); box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
    animation: slideUpFade 0.4s ease-out forwards;
}

.flash-wrapper { position: fixed; top: 1.5rem; right: 1.5rem; z-index: 1100; display: grid; gap: 0.5rem; width: min(100%, 400px); }
.flash {
    padding: 1.2rem; border-radius: 16px; background: var(--card); border-left: 4px solid var(--accent);
    box-shadow: var(--shadow); font-weight: 600; animation: slideUpFade 0.3s ease-out forwards;
}
.flash-success { border-left-color: var(--success); }
.flash-danger { border-left-color: var(--danger); }
.flash-warning { border-left-color: var(--warning); }

/* Mobile Sidebar */
.mobile-sidebar {
    position: fixed; top: 0; right: -100%; width: 320px; max-width: 100vw; height: 100vh;
    background: var(--card); z-index: 100; transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 1.5rem; overflow-y: auto; border-left: 1px solid var(--border); box-shadow: -10px 0 30px rgba(0,0,0,0.2);
}
.mobile-sidebar.open { right: 0; }
.mobile-nav-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 90;
    opacity: 0; pointer-events: none; transition: 0.3s ease; backdrop-filter: blur(4px);
}
.mobile-nav-backdrop.active { opacity: 1; pointer-events: auto; }
.mobile-nav-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
.mobile-sidebar-nav { display: grid; gap: 0.8rem; }
.mobile-sidebar-nav a { display: block; padding: 0.8rem; border-radius: 12px; }
.mobile-sidebar-nav a:hover { background: var(--bg-secondary); color: var(--accent); }
.mobile-nav-group summary { padding: 0.8rem; cursor: pointer; font-weight: bold; list-style: none; }
.mobile-nav-group summary::-webkit-details-marker { display: none; }
.mobile-nav-subnav { padding-left: 1rem; display: grid; gap: 0.5rem; }

/* Floating Elements */
.floating-whatsapp {
    position: fixed; bottom: 1.5rem; right: 1.5rem; background: #25D366; color: white;
    padding: 1rem 1.5rem; border-radius: 999px; font-weight: 700; box-shadow: 0 10px 25px rgba(37, 211, 102, 0.4);
    z-index: 80; transition: 0.3s;
}
.floating-whatsapp:hover { transform: translateY(-4px) scale(1.05); }

/* Admin Grid Fix */
body:has(.admin-page-shell) { overflow: hidden; }
.admin-page-shell { max-width: 100%; padding: 0; height: 100vh; }
.admin-shell { display: grid; grid-template-columns: 280px 1fr; gap: 0; height: 100vh; overflow: hidden; }
.admin-sidebar {
    height: 100vh; padding: 1.5rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem;
    border-right: 1px solid var(--border); border-radius: 0; position: static; box-shadow: none; border-top: none; border-bottom: none; border-left: none;
}
.admin-main {
    height: 100vh; overflow-y: auto; padding: 1.5rem 2rem;
}
.admin-sidebar-nav { display: grid; gap: 0.5rem; }
.admin-sidebar-group summary, .admin-sidebar-link {
    padding: 0.8rem 1rem; border-radius: 12px; margin-bottom: 0.2rem; cursor: pointer; list-style: none; font-weight: 600;
    display: flex; align-items: center; justify-content: space-between; width: 100%;
}
.admin-sidebar-group summary::-webkit-details-marker { display: none; }
.admin-sidebar-link:hover, .admin-sidebar-group summary:hover { background: var(--bg-secondary); }
.admin-sidebar-link.is-active { background: var(--accent); color: white; }
.admin-sidebar-subnav { padding-left: 1rem; padding-top: 0.5rem; }
.admin-sidebar-footer { margin-top: auto; display: grid; gap: 0.8rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.admin-topbar { margin-top: 0; }

.admin-course-item {
    display: flex; justify-content: space-between; padding: 1.2rem;
    border: 1px solid var(--border); border-radius: 16px; margin-bottom: 1rem;
    background: var(--card); align-items: center; flex-wrap: wrap; gap: 1rem;
}
.publish-badge { padding: 0.4rem 0.8rem; border-radius: 999px; font-size: 0.85rem; font-weight: 700; }
.publish-badge.live { background: rgba(16, 185, 129, 0.15); color: #059669; }
.publish-badge.draft { background: rgba(148, 163, 184, 0.15); color: var(--muted); }
.admin-input-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem;}

.mini-course, .payment-item {
    display: flex; justify-content: space-between; align-items: center; padding: 1rem 0; border-bottom: 1px solid var(--border);
}

.text-toggle { color: var(--accent); font-weight: bold; background: none; border: none; padding: 0; width: auto; box-shadow: none; min-height: auto; }
.text-toggle:hover { background: none; color: var(--accent-dark); box-shadow: none; transform: none; text-decoration: underline; }
.course-description-preview.collapsed { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }

/* Responsive adjustments */
.mobile-nav-toggle, .mobile-nav-close { display: none; }
@media (max-width: 900px) {
    .hero, .detail-grid, .support-card, .dashboard-grid, .lesson-player-grid, .admin-shell {
        grid-template-columns: 1fr;
    }
    .main-nav { display: none; }
    .mobile-nav-toggle, .mobile-nav-close { display: inline-flex; width: auto; min-width: 80px; }
    .dashboard-hero { flex-direction: column; text-align: center; gap: 1.5rem; }
    .profile-summary { text-align: center; min-width: 100%; }
    .admin-sidebar { display: none; }
    .site-header { flex-wrap: wrap; }
    .lesson-player-head { flex-direction: column; text-align: center; }
}
