:root {
    --primary: #FF6B35;
    --secondary: #4ECDC4;
    --accent: #FFE66D;
    --purple: #A55EEA;
    --dark: #2C3E50;
    --light: #F8F9FA;
    --success: #2ECC71;
    --danger: #E74C3C;
    --warning: #F39C12;
    --info: #3498DB;
    --kelas1: #FF6B6B;
    --kelas2: #FF8E53;
    --kelas3: #FFA947;
    --kelas4: #4ECDC4;
    --kelas5: #45B7D1;
    --kelas6: #A55EEA;
}

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

body {
    font-family: 'Nunito', 'Segoe UI', sans-serif;
    background: #f0f4ff;
    color: var(--dark);
}

/* NAVBAR */
.navbar {
    background: linear-gradient(135deg, var(--primary), #ff8c42);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 15px rgba(255,107,53,0.3);
    position: sticky;
    top: 0;
    z-index: 1000;
}
.navbar-brand {
    font-size: 1.5rem;
    font-weight: 900;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.navbar-brand span { font-size: 1.8rem; }
.navbar-menu { display:flex; align-items:center; gap:12px; }
.navbar-menu a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    padding: 7px 14px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all .2s;
}
.navbar-menu a:hover, .navbar-menu a.active {
    background: rgba(255,255,255,0.25);
    color: white;
}
.navbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-weight: 700;
}
.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    border: 2px solid rgba(255,255,255,0.5);
}

/* SIDEBAR */
.layout { display: flex; min-height: calc(100vh - 62px); }
.sidebar {
    width: 240px;
    background: white;
    box-shadow: 2px 0 10px rgba(0,0,0,0.08);
    padding: 20px 0;
    flex-shrink: 0;
}
.sidebar-section {
    padding: 8px 16px 4px;
    font-size: 0.7rem;
    font-weight: 800;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 10px;
}
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    color: #555;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
    transition: all .2s;
}
.sidebar-item:hover, .sidebar-item.active {
    background: #fff5f0;
    color: var(--primary);
    border-left-color: var(--primary);
}
.sidebar-item .icon { font-size: 1.2rem; width: 24px; text-align: center; }

/* MAIN CONTENT */
.main { flex: 1; padding: 28px; overflow-x: hidden; }

/* CARDS */
.card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.07);
    margin-bottom: 20px;
}
.card-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--dark);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* STAT CARDS */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: white;
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.07);
    text-align: center;
    transition: transform .2s;
}
.stat-card:hover { transform: translateY(-3px); }
.stat-card .stat-icon { font-size: 2rem; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 900; color: var(--dark); }
.stat-card .stat-label { font-size: 0.8rem; color: #888; font-weight: 600; }

/* MISI CARD */
.misi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}
.misi-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 3px 15px rgba(0,0,0,0.08);
    transition: transform .2s, box-shadow .2s;
    cursor: pointer;
}
.misi-card:hover { transform: translateY(-5px); box-shadow: 0 8px 25px rgba(0,0,0,0.15); }
.misi-header {
    padding: 20px;
    color: white;
    position: relative;
}
.misi-kelas-1 .misi-header { background: linear-gradient(135deg, #FF6B6B, #FF8E53); }
.misi-kelas-2 .misi-header { background: linear-gradient(135deg, #FF8E53, #FFA947); }
.misi-kelas-3 .misi-header { background: linear-gradient(135deg, #FFA947, #FFD93D); }
.misi-kelas-4 .misi-header { background: linear-gradient(135deg, #4ECDC4, #45B7D1); }
.misi-kelas-5 .misi-header { background: linear-gradient(135deg, #45B7D1, #6C63FF); }
.misi-kelas-6 .misi-header { background: linear-gradient(135deg, #A55EEA, #6C63FF); }
.misi-emoji { font-size: 2.5rem; margin-bottom: 8px; }
.misi-judul { font-size: 1rem; font-weight: 800; }
.misi-kelas-tag {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255,255,255,0.3);
    color: white;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}
.misi-body { padding: 15px; }
.misi-desc { font-size: 0.85rem; color: #666; margin-bottom: 12px; line-height: 1.5; }
.misi-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}
.badge-xp {
    background: linear-gradient(135deg, #FFD93D, #FF6B35);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
}
.badge-level {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}
.badge-level.mudah { background: #d4edda; color: #155724; }
.badge-level.sedang { background: #fff3cd; color: #856404; }
.badge-level.sulit { background: #f8d7da; color: #721c24; }
.badge-status { padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; }
.badge-status.selesai { background: #d4edda; color: #155724; }
.badge-status.sedang { background: #cce5ff; color: #004085; }
.badge-status.belum { background: #f0f0f0; color: #666; }

/* KATEGORI BADGE */
.badge-kategori { padding: 3px 8px; border-radius: 20px; font-size: 0.72rem; font-weight: 700; }
.badge-kategori.logika { background: #e3d9fb; color: #6f42c1; }
.badge-kategori.kreasi { background: #fce4ec; color: #c2185b; }
.badge-kategori.puzzle { background: #e8f5e9; color: #2e7d32; }
.badge-kategori.animasi { background: #fff8e1; color: #f57f17; }
.badge-kategori.game { background: #e3f2fd; color: #1565c0; }
.badge-kategori.robotik { background: #fce4ec; color: #880e4f; }

/* PROGRESS BAR */
.progress-wrap { background: #eee; border-radius: 10px; height: 10px; overflow: hidden; }
.progress-bar { height: 10px; border-radius: 10px; background: linear-gradient(90deg, var(--primary), var(--secondary)); transition: width .5s; }

/* XP BAR */
.xp-bar-wrap { background: #eee; border-radius: 10px; height: 14px; overflow: hidden; margin: 6px 0; }
.xp-bar { height: 14px; border-radius: 10px; background: linear-gradient(90deg, #FFD93D, #FF6B35); transition: width .5s; }

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 25px;
    border: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all .2s;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn-primary { background: linear-gradient(135deg, var(--primary), #ff8c42); color: white; box-shadow: 0 3px 10px rgba(255,107,53,0.3); }
.btn-secondary { background: linear-gradient(135deg, var(--secondary), #38beb5); color: white; }
.btn-success { background: linear-gradient(135deg, var(--success), #27ae60); color: white; }
.btn-danger { background: linear-gradient(135deg, var(--danger), #c0392b); color: white; }
.btn-purple { background: linear-gradient(135deg, var(--purple), #8e44ad); color: white; }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* FORM */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 700; font-size: 0.9rem; color: #555; margin-bottom: 6px; }
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border .2s;
}
.form-control:focus { border-color: var(--primary); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

/* TABLE */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th {
    background: #f8f9fa;
    padding: 10px 14px;
    text-align: left;
    font-weight: 800;
    color: #555;
    border-bottom: 2px solid #eee;
}
.table td { padding: 10px 14px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.table tr:hover td { background: #fafafa; }

/* ALERT */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 600; font-size: 0.9rem; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-info { background: #cce5ff; color: #004085; border: 1px solid #b8daff; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

/* KELAS FILTER */
.kelas-filter { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:20px; }
.kelas-btn {
    padding: 7px 16px;
    border-radius: 20px;
    border: 2px solid #ddd;
    background: white;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all .2s;
}
.kelas-btn.active, .kelas-btn:hover { border-color: var(--primary); background: var(--primary); color: white; }
.kelas-btn.k1 { border-color: #FF6B6B; } .kelas-btn.k1.active { background: #FF6B6B; color:white; }
.kelas-btn.k2 { border-color: #FF8E53; } .kelas-btn.k2.active { background: #FF8E53; color:white; }
.kelas-btn.k3 { border-color: #FFA947; } .kelas-btn.k3.active { background: #FFA947; color:white; }
.kelas-btn.k4 { border-color: #4ECDC4; } .kelas-btn.k4.active { background: #4ECDC4; color:white; }
.kelas-btn.k5 { border-color: #45B7D1; } .kelas-btn.k5.active { background: #45B7D1; color:white; }
.kelas-btn.k6 { border-color: #A55EEA; } .kelas-btn.k6.active { background: #A55EEA; color:white; }

/* LEADERBOARD */
.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 12px;
    margin-bottom: 8px;
    background: #f8f9fa;
    transition: background .2s;
}
.leaderboard-item:hover { background: #f0f4ff; }
.leaderboard-item .rank { font-size: 1.3rem; font-weight: 900; width: 30px; text-align: center; }
.leaderboard-item .rank.gold { color: #f39c12; }
.leaderboard-item .rank.silver { color: #95a5a6; }
.leaderboard-item .rank.bronze { color: #a0522d; }
.leaderboard-item .info { flex: 1; }
.leaderboard-item .name { font-weight: 700; font-size: 0.9rem; }
.leaderboard-item .xp { font-size: 0.8rem; color: #888; }

/* HERO BANNER */
.hero-banner {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 20px;
    padding: 28px;
    color: white;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}
.hero-banner::before {
    content: '🚀';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 6rem;
    opacity: 0.2;
}
.hero-banner h2 { font-size: 1.6rem; font-weight: 900; margin-bottom: 6px; }
.hero-banner p { opacity: 0.85; font-size: 0.95rem; }

/* LOGIN PAGE */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}
.login-box {
    background: white;
    border-radius: 24px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    text-align: center;
}
.login-logo { font-size: 3.5rem; margin-bottom: 8px; }
.login-title { font-size: 1.5rem; font-weight: 900; color: var(--dark); margin-bottom: 4px; }
.login-subtitle { color: #888; font-size: 0.9rem; margin-bottom: 28px; }
.login-box .form-control { padding: 12px 16px; font-size: 1rem; }
.login-kelas-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 8px 0;
}
.kelas-pill {
    padding: 8px;
    border-radius: 10px;
    border: 2px solid #eee;
    cursor: pointer;
    text-align: center;
    font-weight: 700;
    font-size: 0.8rem;
    transition: all .2s;
}
.kelas-pill:hover { border-color: var(--primary); color: var(--primary); }
.kelas-pill.selected { border-color: var(--primary); background: var(--primary); color: white; }

/* MODAL */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal-box {
    background: white;
    border-radius: 20px;
    padding: 28px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-title { font-size: 1.2rem; font-weight: 800; margin-bottom: 20px; display: flex; align-items: center; gap: 8px; }

/* QUIZ */
.quiz-wrap { max-width: 600px; margin: 0 auto; }
.quiz-question { font-size: 1.1rem; font-weight: 700; margin-bottom: 20px; color: var(--dark); }
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option {
    padding: 14px 18px;
    border-radius: 12px;
    border: 2px solid #eee;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all .2s;
    text-align: left;
    background: white;
}
.quiz-option:hover { border-color: var(--primary); background: #fff5f0; }
.quiz-option.correct { border-color: var(--success); background: #d4edda; color: #155724; }
.quiz-option.wrong { border-color: var(--danger); background: #f8d7da; color: #721c24; }
.quiz-progress { margin-bottom: 20px; }

/* PROFIL BADGE */
.profile-badge {
    background: linear-gradient(135deg, var(--primary), var(--purple));
    color: white;
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    margin-bottom: 16px;
}
.profile-badge .badge-icon { font-size: 3rem; margin-bottom: 8px; }
.profile-badge .badge-name { font-size: 1.1rem; font-weight: 800; }
.profile-badge .badge-xp { font-size: 0.9rem; opacity: 0.85; }

/* RESPONSIVE */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main { padding: 16px; }
    .misi-grid { grid-template-columns: 1fr 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .navbar-menu { display: none; }
}
@media (max-width: 480px) {
    .misi-grid { grid-template-columns: 1fr; }
}

/* ANIMASI */
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }
@keyframes fadeIn { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }
.animate-bounce { animation: bounce 1s infinite; }
.animate-fadein { animation: fadeIn .4s ease; }

/* PAGE TITLE */
.page-title { font-size: 1.4rem; font-weight: 900; color: var(--dark); margin-bottom: 6px; }
.page-subtitle { color: #888; font-size: 0.9rem; margin-bottom: 24px; }

/* NOTIFICATION DOT */
.notif-dot {
    display: inline-block;
    width: 8px; height: 8px;
    background: var(--danger);
    border-radius: 50%;
    margin-left: 4px;
    vertical-align: middle;
}

/* ===== TAMBAHAN & PERBAIKAN ===== */
.btn-warning { background: linear-gradient(135deg, #F39C12, #e67e22); color: white; box-shadow: 0 3px 10px rgba(243,156,18,0.3); }
.btn-info    { background: linear-gradient(135deg, #3498DB, #2980b9); color: white; }
.btn-light   { background: #f8f9fa; color: #555; border: 2px solid #eee; }

/* Misi card hover animasi lebih smooth */
.misi-card { transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .25s; }

/* Improved table row hover */
.table tbody tr { transition: background .15s; }

/* Input focus ring */
.form-control:focus { box-shadow: 0 0 0 3px rgba(255,107,53,.15); }

/* Card shadow hover */
.card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.1); }

/* Badge animasi XP */
.badge-xp { animation: none; }
.badge-xp:hover { transform: scale(1.05); }

/* Sidebar scrollable pada layar kecil */
.sidebar { overflow-y: auto; max-height: calc(100vh - 62px); }

/* Responsive grid fix */
@media (max-width: 900px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; max-height: none; padding: 8px 0; display: flex; flex-wrap: wrap; overflow: visible; }
    .sidebar-item { padding: 8px 12px; font-size: 0.82rem; }
    .sidebar-section { display: none; }
    .profile-badge { display: none; }
}
@media (max-width: 600px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .misi-grid { grid-template-columns: 1fr; }
    .main { padding: 12px; }
    .page-title { font-size: 1.2rem; }
}

/* Alert dismiss button */
.alert { position: relative; }

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* Loading spinner */
.spinner { width: 20px; height: 20px; border: 3px solid #eee; border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Tooltip */
[title] { cursor: help; }

/* Misi status ring */
.misi-card.selesai { box-shadow: 0 0 0 3px #2ecc71 !important; }
.misi-card.sedang  { box-shadow: 0 0 0 3px #3498db !important; }

/* Sticky header */
.navbar { position: sticky; top: 0; z-index: 1000; }

/* Print media */
@media print {
    .sidebar, .navbar, .btn { display: none !important; }
    .main { padding: 0; }
}
