/* ============================
   SainsTeraktif — Main Stylesheet
   ============================ */

:root {
    --primary:   #2563EB;
    --primary-d: #1D4ED8;
    --accent:    #F59E0B;
    --accent-d:  #D97706;
    --success:   #10B981;
    --danger:    #EF4444;
    --warning:   #F59E0B;
    --bg:        #F0F7FF;
    --surface:   #FFFFFF;
    --text:      #1E293B;
    --muted:     #64748B;
    --border:    #E2E8F0;
    --radius:    12px;
    --shadow:    0 2px 12px rgba(37,99,235,.10);
    --shadow-lg: 0 8px 32px rgba(37,99,235,.15);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Nunito', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- Layout ---- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.main-content { flex: 1; padding: 40px 0; }

/* ---- Typography ---- */
h1, h2, h3, h4 { font-weight: 800; line-height: 1.2; }
h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: 1.25rem; }
p { margin-bottom: .75rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Navbar ---- */
.navbar {
    background: var(--surface);
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.3rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
}
.nav-brand strong { color: var(--primary); }
.logo-icon { font-size: 1.6rem; }
.nav-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
}
.nav-link {
    padding: 6px 12px;
    border-radius: 8px;
    color: var(--text);
    font-weight: 600;
    transition: background .2s;
}
.nav-link:hover { background: var(--bg); text-decoration: none; }
.nav-user { display: flex; align-items: center; gap: 8px; }
.user-badge {
    font-size: .85rem;
    background: var(--bg);
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 700;
    color: var(--muted);
}
.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: var(--text);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    border-radius: var(--radius);
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all .2s;
    text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-d); border-color: var(--accent-d); }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-sm { padding: 6px 14px; font-size: .875rem; }
.btn-lg { padding: 14px 32px; font-size: 1.1rem; }
.btn-block { display: flex; width: 100%; justify-content: center; }

/* ---- Cards ---- */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow .2s, transform .2s;
}
.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.card-body { padding: 20px; }
.card-title { font-size: 1.05rem; font-weight: 800; margin-bottom: 6px; }
.card-meta { font-size: .8rem; color: var(--muted); }
.card-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 700;
    background: var(--bg);
    color: var(--primary);
    margin-bottom: 8px;
}

/* ---- Grid ---- */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

/* ---- Layout Sidebar ---- */
.content-sidebar-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 28px;
    align-items: start;
}

/* ---- Hero ---- */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, #7C3AED 100%);
    color: #fff;
    padding: 80px 0 60px;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Ccircle cx='30' cy='30' r='4'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.hero > * { position: relative; }
.hero h1 { color: #fff; margin-bottom: 16px; }
.hero p { font-size: 1.15rem; opacity: .9; max-width: 560px; margin: 0 auto 32px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero-badge {
    display: inline-block;
    background: rgba(255,255,255,.2);
    border: 1px solid rgba(255,255,255,.3);
    color: #fff;
    border-radius: 30px;
    padding: 6px 18px;
    font-size: .85rem;
    font-weight: 700;
    margin-bottom: 16px;
}

/* ---- Section ---- */
.section { padding: 60px 0; }
.section-header { text-align: center; margin-bottom: 40px; }
.section-header p { color: var(--muted); max-width: 520px; margin: 8px auto 0; }
.section-title { position: relative; display: inline-block; }
.section-title::after {
    content: '';
    display: block;
    height: 4px;
    width: 60%;
    background: var(--accent);
    border-radius: 2px;
    margin: 8px auto 0;
}

/* ---- Subject Cards ---- */
.subject-card {
    border-radius: var(--radius);
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: transform .2s, box-shadow .2s;
    color: #fff;
    text-decoration: none;
    display: block;
}
.subject-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); text-decoration: none; }
.subject-icon { font-size: 2.8rem !important; margin-bottom: 10px; display: block; line-height: 1; }
.material-icons-round { vertical-align: middle; font-size: inherit; }
.mi-sm { font-size: 1rem !important; vertical-align: text-bottom; }
.mi-lg { font-size: 2rem !important; vertical-align: middle; }
.subject-name { font-weight: 800; font-size: 1rem; color: #fff; }
.subject-count { font-size: .8rem; opacity: .85; color: #fff; }

/* ---- Forms ---- */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-weight: 700; margin-bottom: 6px; font-size: .9rem; }
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    transition: border-color .2s;
    background: var(--surface);
    color: var(--text);
}
.form-control:focus { outline: none; border-color: var(--primary); }
.form-control[readonly] { background: var(--bg); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 120px; }

/* ---- Alert ---- */
.alert {
    padding: 12px 18px;
    border-radius: 10px;
    font-weight: 600;
    margin-bottom: 18px;
    border-left: 4px solid;
}
.alert-success { background: #D1FAE5; color: #065F46; border-color: var(--success); }
.alert-danger  { background: #FEE2E2; color: #991B1B; border-color: var(--danger); }
.alert-warning { background: #FEF3C7; color: #92400E; border-color: var(--warning); }
.alert-info    { background: #DBEAFE; color: #1E40AF; border-color: var(--primary); }

/* ---- Auth Pages ---- */
.auth-wrapper {
    min-height: calc(100vh - 64px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}
.auth-card {
    background: var(--surface);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 460px;
}
.auth-title { text-align: center; margin-bottom: 28px; }
.auth-title .icon { font-size: 3rem; display: block; margin-bottom: 8px; }

/* ---- Dashboard ---- */
.dashboard-header {
    background: linear-gradient(135deg, var(--primary) 0%, #7C3AED 100%);
    color: #fff;
    padding: 40px 0;
    margin-bottom: 40px;
}
.dashboard-header h1 { color: #fff; font-size: 1.8rem; }
.dashboard-header p { opacity: .85; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 14px;
}
.stat-icon { font-size: 2rem; }
.stat-value { font-size: 1.8rem; font-weight: 900; color: var(--primary); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 600; }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-weight: 800; background: var(--bg); font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
tr:hover td { background: #F8FAFC; }

/* ---- Badge ---- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 700;
}
.badge-blue    { background: #DBEAFE; color: #1D4ED8; }
.badge-green   { background: #D1FAE5; color: #065F46; }
.badge-yellow  { background: #FEF3C7; color: #92400E; }
.badge-red     { background: #FEE2E2; color: #991B1B; }
.badge-purple  { background: #EDE9FE; color: #5B21B6; }

/* ---- Quiz ---- */
.quiz-question-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.quiz-question-number {
    font-size: .8rem;
    font-weight: 800;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 10px;
}
.quiz-question-text { font-size: 1.05rem; font-weight: 700; margin-bottom: 16px; }
.option-list { display: grid; gap: 10px; }
.option-item { display: flex; align-items: center; }
.option-item input[type="radio"] { display: none; }
.option-label {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all .2s;
}
.option-label:hover { border-color: var(--primary); background: #EFF6FF; }
.option-item input:checked + .option-label { border-color: var(--primary); background: #EFF6FF; color: var(--primary); }
.option-letter {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800;
    font-size: .85rem;
    flex-shrink: 0;
    transition: all .2s;
}
.option-item input:checked + .option-label .option-letter { background: var(--primary); color: #fff; }
.option-correct .option-label { border-color: var(--success); background: #D1FAE5; color: #065F46; }
.option-wrong   .option-label { border-color: var(--danger); background: #FEE2E2; color: #991B1B; }

/* ---- Score Result ---- */
.score-circle {
    width: 160px; height: 160px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #7C3AED);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: #fff;
    margin: 0 auto 24px;
    box-shadow: 0 8px 32px rgba(37,99,235,.3);
}
.score-number { font-size: 3rem; font-weight: 900; line-height: 1; }
.score-label { font-size: .8rem; opacity: .85; font-weight: 700; }

/* ---- Material Content ---- */
.material-content {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
    line-height: 1.8;
}
.material-content h2 { margin: 24px 0 12px; color: var(--primary); }
.material-content h3 { margin: 20px 0 10px; }
.material-content ul, .material-content ol { padding-left: 24px; margin-bottom: 16px; }
.material-content li { margin-bottom: 6px; }
.material-content strong { color: var(--primary-d); }
.video-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: var(--radius); margin: 24px 0; }
.video-container iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; border-radius: var(--radius); }

/* ---- Admin Sidebar Layout ---- */
.admin-layout { display: flex; min-height: calc(100vh - 64px); }
.sidebar {
    width: 240px;
    background: var(--surface);
    box-shadow: 2px 0 8px rgba(0,0,0,.06);
    padding: 24px 0;
    flex-shrink: 0;
}
.sidebar-menu { list-style: none; }
.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: var(--text);
    font-weight: 700;
    transition: all .2s;
    border-right: 3px solid transparent;
}
.sidebar-menu li a:hover, .sidebar-menu li a.active {
    background: var(--bg);
    color: var(--primary);
    border-right-color: var(--primary);
    text-decoration: none;
}
.admin-main { flex: 1; padding: 32px; }
.page-title { margin-bottom: 28px; }
.page-title h2 { font-size: 1.6rem; }
.page-title p { color: var(--muted); }

/* ---- Breadcrumb ---- */
.breadcrumb {
    display: flex; gap: 6px; align-items: center; font-size: .85rem; color: var(--muted); margin-bottom: 20px;
    white-space: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Hide scrollbar for Firefox */
}
.breadcrumb::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome/Safari */
}
.breadcrumb a { color: var(--primary); font-weight: 600; flex-shrink: 0; }
.breadcrumb span { color: var(--muted); flex-shrink: 0; }

/* ---- Pagination ---- */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 32px; }
.page-link {
    padding: 8px 14px;
    border-radius: 8px;
    border: 2px solid var(--border);
    font-weight: 700;
    color: var(--text);
    transition: all .2s;
}
.page-link:hover, .page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); text-decoration: none; }

/* ---- Filter Bar ---- */
.filter-bar {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 28px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.filter-bar .form-group { margin: 0; flex: 1; min-width: 160px; }

.filter-actions {
    align-self: flex-end;
    display: flex;
    gap: 8px;
}

.detail-title { font-size: 1.8rem; margin-bottom: 8px; line-height: 1.3; }
.detail-meta { color: var(--muted); font-size: .85rem; margin: 0; }

/* ---- Footer ---- */
.footer { background: #1E293B; color: #94A3B8; margin-top: auto; }
.footer-inner {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 40px;
    padding: 48px 0 32px;
}
.footer-brand { color: #E2E8F0; }
.footer-brand .logo-icon { font-size: 2rem; }
.footer-brand strong { color: #fff; font-size: 1.2rem; }
.footer-brand p { margin-top: 8px; font-size: .85rem; line-height: 1.5; }
.footer-links h4 { color: #fff; font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 16px; }
.footer-links ul { list-style: none; }
.footer-links li { margin-bottom: 8px; }
.footer-links a { color: #94A3B8; font-size: .9rem; transition: color .2s; }
.footer-links a:hover { color: #fff; text-decoration: none; }
.footer-bottom { border-top: 1px solid #334155; padding: 16px 0; text-align: center; font-size: .8rem; }

/* ---- Utilities ---- */
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; } .mb-4 { margin-bottom: 32px; }
.d-flex { display: flex; } .align-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state .empty-icon { font-size: 4rem; margin-bottom: 16px; display: block; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .nav-toggle { display: block; }
    .nav-menu {
        display: none;
        position: absolute;
        top: 64px; left: 0; right: 0;
        background: var(--surface);
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
        box-shadow: 0 8px 16px rgba(0,0,0,.1);
        gap: 4px;
    }
    .nav-menu.open { display: flex; }
    .nav-menu li { width: 100%; }
    .nav-link { display: block; }
    .nav-user { flex-direction: column; align-items: flex-start; }
    .footer-inner { grid-template-columns: 1fr; gap: 24px; }
    .admin-layout { flex-direction: column; }
    .sidebar { width: 100%; }
    .filter-bar { flex-direction: column; align-items: stretch; }
        .filter-actions { align-self: stretch; }
        .filter-actions .btn { flex: 1; justify-content: center; }
    .hero-actions { flex-direction: column; align-items: center; }
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
        .content-sidebar-layout { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    h1 { font-size: clamp(1.4rem, 3vw, 2rem); }
    h2 { font-size: clamp(1.1rem, 2.5vw, 1.6rem); }
    .container { padding: 0 16px; }
    .main-content { padding: 24px 0; }
    .navbar { position: relative; }
    .nav-inner { height: 56px; }
    .nav-brand { font-size: 1.1rem; }
    .nav-toggle { display: block; }
    .nav-menu { gap: 0; }
    .nav-link { padding: 10px 12px; font-size: .9rem; }
    .user-badge { font-size: .75rem; padding: 3px 8px; }
    .stat-cards { grid-template-columns: 1fr; gap: 12px; }
    .hero-actions { padding: 0 16px; }
    .hero-actions a { width: 100%; }
    .filter-bar { gap: 12px; }
    .filter-bar .form-group { margin-bottom: 12px; }
    .card { border-radius: 8px; }
        .detail-title { font-size: 1.4rem; }
    .btn { padding: 10px 16px; font-size: .9rem; }
    .btn-block { width: 100%; }
    .form-control { font-size: 16px; padding: 10px 12px; }
    .form-label { font-size: .85rem; }
    .badge { font-size: .7rem; padding: 3px 8px; }
    .table-wrap { font-size: .85rem; }
    table th, table td { padding: 8px 6px; }
    .breadcrumb { font-size: .85rem; }
    .section { padding: 24px 0; }
    .empty-state { padding: 40px 16px; }
    .empty-state .empty-icon { font-size: 3rem; }
    
    /* Mobile-friendly grid overrides for inline styles */
    div[style*="grid-template-columns: repeat(3"] { grid-template-columns: 1fr !important; }
    div[style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }
    div[style*="grid-template-columns: 1fr 300px"] { grid-template-columns: 1fr !important; }
    div[style*="grid-template-columns: 2fr 1fr 1fr"] { grid-template-columns: 1fr !important; }
}
