/* ============================================================
   EduTask - Sistem Pengurusan Tugasan Sekolah
   assets/css/style.css
   ============================================================ */

/* ── ROOT VARIABLES ─────────────────────────────────────── */
:root {
    --primary:      #1A56DB;
    --primary-dark: #1341B0;
    --primary-light:#EBF3FF;
    --secondary:    #6B7280;
    --success:      #10B981;
    --warning:      #F59E0B;
    --danger:       #EF4444;
    --info:         #3B82F6;

    --bg:           #F3F4F6;
    --surface:      #FFFFFF;
    --border:       #E5E7EB;
    --text:         #111827;
    --text-muted:   #6B7280;
    --text-light:   #9CA3AF;

    --sidebar-w:    260px;
    --header-h:     64px;
    --radius:       10px;
    --radius-sm:    6px;
    --shadow:       0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg:    0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);

    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── RESET ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; }
a { text-decoration: none; color: var(--primary); }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }

/* ── LOGIN PAGE ─────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1A56DB 0%, #0E3A8A 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-container { width: 100%; max-width: 420px; }
.login-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-logo {
    width: 72px; height: 72px;
    background: var(--primary-light);
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: var(--primary);
    margin-bottom: 16px;
}
.login-header h1 { font-size: 26px; font-weight: 700; color: var(--text); }
.login-header p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

.login-form .form-group { margin-bottom: 18px; }
.login-form label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--text); font-size: 13px; }
.login-form label i { margin-right: 6px; color: var(--primary); }
.login-form input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color .2s, box-shadow .2s;
    outline: none;
    color: var(--text);
}
.login-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.12); }
.input-group { position: relative; }
.input-group input { padding-right: 44px; }
.toggle-password {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: 15px;
}
.btn-login {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, transform .1s;
    margin-top: 4px;
}
.btn-login:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-login i { margin-right: 8px; }

.demo-accounts {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    text-align: center;
}
.demo-accounts > p { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.demo-btns { display: flex; gap: 8px; justify-content: center; margin-bottom: 8px; }
.demo-btn {
    padding: 6px 12px;
    border: 1.5px solid;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 600;
    background: transparent;
    transition: all .2s;
}
.demo-btn.pentadbir { border-color: var(--danger); color: var(--danger); }
.demo-btn.pentadbir:hover { background: var(--danger); color: #fff; }
.demo-btn.incharge { border-color: var(--primary); color: var(--primary); }
.demo-btn.incharge:hover { background: var(--primary); color: #fff; }
.demo-btn.guru { border-color: var(--success); color: var(--success); }
.demo-btn.guru:hover { background: var(--success); color: #fff; }
.demo-accounts small { color: var(--text-light); font-size: 11px; }
.login-footer { text-align: center; margin-top: 20px; }
.login-footer small { color: var(--text-light); font-size: 11px; }

/* ── LAYOUT ─────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-w);
    background: #0F172A;
    color: #E2E8F0;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform .3s;
}
.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-brand .brand-icon {
    width: 40px; height: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: #fff;
}
.sidebar-brand .brand-text h2 { font-size: 16px; font-weight: 700; color: #fff; }
.sidebar-brand .brand-text span { font-size: 11px; color: #94A3B8; }

.sidebar-user {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-user img {
    width: 40px; height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
}
.sidebar-user .user-info .name { font-size: 13px; font-weight: 600; color: #fff; }
.sidebar-user .user-info .role {
    font-size: 11px; color: #94A3B8;
    background: rgba(255,255,255,.08);
    padding: 1px 8px;
    border-radius: 10px;
    display: inline-block;
    margin-top: 2px;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.nav-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #475569;
    padding: 10px 20px 4px;
}
.nav-item { display: block; padding: 10px 20px; color: #94A3B8; font-size: 13px; font-weight: 500; border-radius: 0; transition: all .2s; display: flex; align-items: center; gap: 10px; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item i { width: 18px; text-align: center; }
.nav-item .badge-count { margin-left: auto; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-footer a { color: #94A3B8; font-size: 13px; display: flex; align-items: center; gap: 10px; }
.sidebar-footer a:hover { color: #fff; }

/* MAIN CONTENT */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* TOPBAR */
.topbar {
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-title { font-size: 18px; font-weight: 700; color: var(--text); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: transparent;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    position: relative;
    transition: all .2s;
}
.topbar-btn:hover { background: var(--bg); color: var(--text); }
.topbar-btn .notif-dot {
    position: absolute; top: 4px; right: 4px;
    width: 8px; height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid #fff;
}

/* PAGE CONTENT */
.page-content { flex: 1; padding: 24px; }

/* ── CARDS & STATS ──────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 700; }
.card-body { padding: 20px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.stat-icon.blue   { background: #EBF3FF; color: var(--primary); }
.stat-icon.green  { background: #D1FAE5; color: var(--success); }
.stat-icon.yellow { background: #FEF3C7; color: var(--warning); }
.stat-icon.red    { background: #FEE2E2; color: var(--danger); }
.stat-icon.purple { background: #EDE9FE; color: #7C3AED; }
.stat-info .label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-info .value { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1.2; }
.stat-info .sub   { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── TABLES ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 16px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); background: var(--bg); border-bottom: 1px solid var(--border); }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ── BADGES ─────────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-belum    { background: #F3F4F6; color: #6B7280; }
.badge-proses   { background: #DBEAFE; color: #1D4ED8; }
.badge-semakan  { background: #FEF3C7; color: #B45309; }
.badge-selesai  { background: #D1FAE5; color: #065F46; }
.badge-batal    { background: #FEE2E2; color: #991B1B; }
.badge-rendah   { background: #F3F4F6; color: #6B7280; }
.badge-sederhana{ background: #DBEAFE; color: #1D4ED8; }
.badge-tinggi   { background: #FEF3C7; color: #B45309; }
.badge-kritikal { background: #FEE2E2; color: #991B1B; }
.badge-ps       { background: #EDE9FE; color: #5B21B6; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; cursor: pointer; border: none; transition: all .2s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-warning { background: #D97706; color: #fff; }
.btn-warning:hover { background: #B45309; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }

/* ── FORMS ──────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color .2s;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.1); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── ALERTS ─────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.alert i { flex-shrink: 0; }
.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-danger  { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.alert-info    { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }

/* ── PROGRESS BAR ────────────────────────────────────────── */
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 3px; transition: width .4s ease; }
.progress-bar.blue   { background: var(--primary); }
.progress-bar.green  { background: var(--success); }
.progress-bar.yellow { background: var(--warning); }
.progress-bar.red    { background: var(--danger); }

/* ── TASK CARDS ─────────────────────────────────────────── */
.task-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 16px;
    margin-bottom: 12px;
    transition: box-shadow .2s, transform .2s;
}
.task-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.task-card.overdue { border-left: 4px solid var(--danger); }
.task-card.hampir  { border-left: 4px solid var(--warning); }
.task-card.selesai { border-left: 4px solid var(--success); opacity: .8; }
.task-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.task-title { font-weight: 700; font-size: 14px; color: var(--text); }
.task-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.task-meta span { display: flex; align-items: center; gap: 4px; }
.task-meta i { font-size: 11px; }

/* ── POINTS & REWARDS ────────────────────────────────────── */
.points-badge {
    display: inline-flex; align-items: center; gap: 6px;
    background: #FEF3C7; color: #92400E;
    padding: 4px 12px; border-radius: 20px;
    font-size: 12px; font-weight: 700;
}
.points-badge i { color: #F59E0B; }

.reward-card {
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    transition: all .2s;
    cursor: pointer;
}
.reward-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.reward-card .reward-icon { font-size: 36px; margin-bottom: 12px; }
.reward-card h4 { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.reward-card .points-needed { color: var(--warning); font-weight: 700; font-size: 15px; }

/* ── LEADERBOARD ─────────────────────────────────────────── */
.leaderboard-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.leaderboard-item:last-child { border-bottom: none; }
.rank { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; }
.rank.r1 { background: #FEF3C7; color: #92400E; }
.rank.r2 { background: #F3F4F6; color: #374151; }
.rank.r3 { background: #FEE2E2; color: #991B1B; }
.rank.rn { background: var(--bg); color: var(--text-muted); }

/* ── DUE DATE INDICATORS ─────────────────────────────────── */
.due-ok      { color: var(--success); font-weight: 600; }
.due-warning { color: var(--warning); font-weight: 600; }
.due-danger  { color: var(--danger); font-weight: 600; }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: .3; }
.empty-state h3 { font-size: 16px; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 13px; }

/* ── GRID HELPERS ────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.mt-4  { margin-top: 16px; }
.mb-4  { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex  { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center  { display: flex; align-items: center; }

/* ── MODAL ───────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--surface);
    border-radius: 16px;
    width: 100%; max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════
   RESPONSIVE CSS — EduTask
═══════════════════════════════════════════════════ */

/* Sidebar overlay — semua saiz */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 998;
    cursor: pointer;
}
.sidebar.open ~ .sidebar-overlay { display: block; }

/* ════════════════════════════
   MOBILE  ≤ 768px
════════════════════════════ */
@media (max-width: 768px) {

    /* Elak overflow keseluruhan */
    body { overflow-x: hidden; }

    /* Layout sidebar */
    .sidebar {
        transform: translateX(-100%);
        position: fixed !important;
        z-index: 999;
        top: 0; left: 0; bottom: 0;
        transition: transform .25s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,.35);
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; width: 100% !important; }

    /* Topbar */
    #menu-btn { display: flex !important; }
    .topbar { padding: 10px 12px; position: sticky; top: 0; z-index: 100; gap: 8px; }
    .topbar-title { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50vw; }
    .topbar-actions { gap: 6px; flex-shrink: 0; }

    /* Page content */
    .page-content { padding: 10px 12px; }

    /* Grids */
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; gap: 10px; }

    /* Tables — scroll dalam kotak, bukan whole page */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-wrap table { min-width: 480px; font-size: 12px; }
    .table-wrap th, .table-wrap td { padding: 7px 10px !important; white-space: nowrap; }

    /* Tabs */
    .tabs { overflow-x: auto; flex-wrap: nowrap !important; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .tabs::-webkit-scrollbar { display: none; }
    .tab { flex-shrink: 0; padding: 7px 12px; font-size: 12px; white-space: nowrap; }
    .tab-nav { overflow-x: auto; flex-wrap: wrap; gap: 4px; }
    .tab-nav-btn { font-size: 12px; padding: 7px 10px; }

    /* Butang */
    .btn { padding: 8px 12px; font-size: 13px; }
    .btn-sm { padding: 6px 10px; font-size: 12px; }

    /* Forms */
    .form-control, select.form-control { font-size: 14px; }
    .form-group { margin-bottom: 12px; }

    /* Modal — bottom sheet style */
    .modal-overlay { padding: 0; align-items: flex-end; }
    .modal {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        border-radius: 16px 16px 0 0 !important;
        max-height: 88vh;
        overflow-y: auto;
    }
    .modal-body { padding: 14px; }
    .modal-footer { padding: 12px 14px; gap: 8px; }

    /* Reward grid */
    .reward-grid { grid-template-columns: 1fr 1fr !important; gap: 8px; }
    .reward-item { padding: 12px 10px; }
    .reward-item .ikon { font-size: 28px; margin-bottom: 6px; }
    .reward-item h4 { font-size: 12px; }
    .reward-item .pts { font-size: 18px; }

    /* Card */
    .card-header { padding: 10px 14px; flex-wrap: wrap; gap: 6px; }

    /* Alert */
    .alert { font-size: 13px; padding: 10px 12px; }

    /* Assignee */
    #assignee-list { max-height: 220px; }

    /* Hide columns */
    .hide-mobile { display: none !important; }
}

/* ════════════════════════════
   TABLET  769–1024px
════════════════════════════ */
@media (min-width: 769px) and (max-width: 1024px) {
    :root { --sidebar-w: 220px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .reward-grid { grid-template-columns: repeat(2, 1fr) !important; }
    .page-content { padding: 16px 18px; }
}

/* ════════════════════════════
   TOUCH — min tap 44px
════════════════════════════ */
@media (hover: none) and (pointer: coarse) {
    .btn { min-height: 40px; }
    .btn-sm { min-height: 36px; }
    input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; }
    .nav-item { min-height: 44px; display: flex; align-items: center; }
    select.form-control { min-height: 44px; }
}
