@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary:      #16a34a;
    --primary-dark: #15803d;
    --primary-light:#dcfce7;
    --accent:       #f59e0b;
    --accent-light: #fef3c7;
    --danger:       #ef4444;
    --bg:           #f8fafc;
    --white:        #ffffff;
    --text:         #0f172a;
    --text-muted:   #64748b;
    --border:       #e2e8f0;
    --shadow:       0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:    0 4px 12px rgba(0,0,0,0.10);
    --sidebar-w:    240px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
}

/* ── SIDEBAR ── */
.sidebar {
    width: var(--sidebar-w);
    background: #0f172a;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255,255,255,.07);
}

.brand-icon {
    width: 34px;
    height: 34px;
    background: var(--primary);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 15px;
    flex-shrink: 0;
}

.brand-name {
    font-size: 16px;
    font-weight: 700;
    color: white;
    letter-spacing: -.3px;
}

.brand-sub {
    font-size: 10px;
    color: #64748b;
    margin-top: 1px;
}

.nav-section {
    padding: 18px 14px 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #475569;
}

.nav-menu { list-style: none; padding: 4px 10px; }

.nav-menu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    transition: all .18s;
    margin-bottom: 2px;
}

.nav-menu li a i { width: 16px; text-align: center; font-size: 13px; }

.nav-menu li a:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }

.nav-menu li a.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(22,163,74,.35);
}

.sidebar-footer {
    margin-top: auto;
    padding: 12px 10px;
    border-top: 1px solid rgba(255,255,255,.07);
}

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

/* ── TOPBAR ── */
.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title h1 { font-size: 17px; font-weight: 700; color: var(--text); }
.topbar-title p  { font-size: 12px; color: var(--text-muted); }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.topbar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.page-content { padding: 24px 28px; flex: 1; }

/* ── STAT CARDS ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

@media (max-width: 1100px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: box-shadow .2s, transform .2s;
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.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.green  { background: var(--primary-light); color: var(--primary-dark); }
.stat-icon.amber  { background: var(--accent-light);  color: #d97706; }
.stat-icon.blue   { background: #dbeafe; color: #1d4ed8; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }

.stat-val  { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1.1; }
.stat-lbl  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.stat-trend { font-size: 11px; font-weight: 600; margin-top: 4px; display: flex; align-items: center; gap: 3px; }
.stat-trend.up   { color: var(--primary); }
.stat-trend.down { color: var(--danger); }

/* ── PANEL ── */
.panel {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.panel-title { font-size: 15px; font-weight: 700; color: var(--text); }
.panel-sub   { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── TABLE ── */
table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 1px solid var(--border); }
th { padding: 9px 12px; color: var(--text-muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; text-align: left; }
td { padding: 12px; border-bottom: 1px solid #f1f5f9; font-size: 13.5px; color: var(--text); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }

/* ── BADGE ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge::before { content:''; width:6px; height:6px; border-radius:50%; }
.badge-success { background:#dcfce7; color:#15803d; border:1px solid #bbf7d0; }
.badge-success::before { background:#16a34a; }
.badge-warning { background:#fef9c3; color:#a16207; border:1px solid #fef08a; }
.badge-warning::before { background:#ca8a04; }
.badge-danger  { background:#fee2e2; color:#b91c1c; border:1px solid #fecaca; }
.badge-danger::before  { background:#ef4444; }
.badge-info    { background:#dbeafe; color:#1d4ed8; border:1px solid #bfdbfe; }
.badge-info::before    { background:#2563eb; }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 18px; border-radius: 9px; font-size: 13px; font-weight: 600; font-family: inherit; border: none; cursor: pointer; transition: all .18s; text-decoration: none; }
.btn-primary  { background: var(--primary);  color: white; box-shadow: 0 2px 8px rgba(22,163,74,.3); }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-secondary { background: var(--white); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn-danger   { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover   { background: #fecaca; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 7px; }

/* Icon action buttons */
.btn-icon { width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--border); background: white; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; transition: all .18s; }
.btn-icon.view  { color: #2563eb; } .btn-icon.view:hover  { background:#dbeafe; border-color:#93c5fd; }
.btn-icon.edit  { color: #d97706; } .btn-icon.edit:hover  { background:#fef3c7; border-color:#fde68a; }
.btn-icon.hapus { color: #dc2626; } .btn-icon.hapus:hover { background:#fee2e2; border-color:#fca5a5; }

/* ── FORM ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-control { width: 100%; padding: 9px 13px; border: 1px solid var(--border); border-radius: 8px; font-size: 13.5px; font-family: inherit; color: var(--text); background: var(--white); outline: none; transition: border-color .18s, box-shadow .18s; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22,163,74,.12); }
.form-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ── SEARCH / TOOLBAR ── */
.toolbar { display: flex; gap: 10px; margin-bottom: 18px; align-items: center; flex-wrap: wrap; }
.search-wrap { position: relative; flex: 1; min-width: 200px; }
.search-wrap i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13px; pointer-events: none; }
.search-input { width: 100%; padding: 9px 13px 9px 34px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: inherit; outline: none; background: #f8fafc; transition: border-color .18s; }
.search-input:focus { border-color: var(--primary); background: white; }
.filter-sel { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: inherit; color: var(--text); background: white; cursor: pointer; outline: none; }

/* ── MODAL ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 999; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal-box { background: white; border-radius: 16px; width: 480px; max-width: 95vw; overflow: hidden; box-shadow: 0 25px 60px rgba(0,0,0,.2); animation: modalIn .2s ease; }
@keyframes modalIn { from { opacity:0; transform:scale(.95) translateY(8px); } to { opacity:1; transform:scale(1) translateY(0); } }
.modal-head { padding: 18px 22px; display: flex; justify-content: space-between; align-items: center; }
.modal-head.green  { background: linear-gradient(135deg,#15803d,#16a34a); color: white; }
.modal-head.amber  { background: linear-gradient(135deg,#b45309,#d97706); color: white; }
.modal-head.danger { background: linear-gradient(135deg,#b91c1c,#dc2626); color: white; }
.modal-head h3 { font-size: 15px; font-weight: 700; margin: 0; }
.modal-close { background: rgba(255,255,255,.2); border: none; color: white; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; font-size: 15px; display: flex; align-items: center; justify-content: center; }
.modal-close:hover { background: rgba(255,255,255,.35); }
.modal-body { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.btn-cancel { padding: 9px 18px; border-radius: 8px; border: 1px solid var(--border); background: white; font-size: 13px; font-family: inherit; cursor: pointer; font-weight: 500; }

/* ── TOAST ── */
.toast { position: fixed; bottom: 24px; right: 24px; padding: 12px 18px; border-radius: 12px; font-size: 13px; font-weight: 600; color: white; display: flex; align-items: center; gap: 9px; box-shadow: 0 8px 24px rgba(0,0,0,.2); transform: translateY(70px); opacity: 0; transition: .3s cubic-bezier(.4,0,.2,1); z-index: 1000; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--primary); }
.toast.error   { background: var(--danger); }
.toast.info    { background: #2563eb; }

/* ── CHARTS ── */
.charts-row { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 1000px) { .charts-row { grid-template-columns: 1fr; } }
.chart-wrap { position: relative; height: 240px; }

/* ── LEADERBOARD ── */
.lb-podium { display: grid; grid-template-columns: 1fr 1.1fr 1fr; gap: 14px; margin-bottom: 22px; align-items: flex-end; }
.lb-card { background: white; border: 1px solid var(--border); border-radius: 14px; padding: 18px 14px; text-align: center; }
.lb-card.rank-1 { background: linear-gradient(145deg,#fffbea,#fef9c3); border-color: #fde047; box-shadow: 0 4px 16px rgba(250,204,21,.2); }
.lb-card.rank-2 { background: linear-gradient(145deg,#f8fafc,#f1f5f9); }
.lb-card.rank-3 { background: linear-gradient(145deg,#fff8f4,#fef0e6); border-color: #fed7aa; }
.lb-medal { font-size: 26px; margin-bottom: 6px; }
.lb-avatar { width: 52px; height: 52px; border-radius: 50%; margin: 0 auto 8px; border: 3px solid; display: block; }
.rank-1 .lb-avatar { border-color: #fde047; } .rank-2 .lb-avatar { border-color: #cbd5e1; } .rank-3 .lb-avatar { border-color: #fed7aa; }
.lb-name  { font-size: 13px; font-weight: 700; color: var(--text); }
.lb-dept  { font-size: 11px; color: var(--text-muted); margin: 2px 0 6px; }
.lb-score { font-size: 20px; font-weight: 800; color: var(--primary); }
.lb-pts   { font-size: 10px; color: var(--text-muted); }

.lb-list-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
.lb-list-row:last-child { border-bottom: none; }
.lb-rank-num { width: 26px; font-size: 12px; font-weight: 700; color: var(--text-muted); text-align: center; flex-shrink: 0; }
.lb-list-avatar { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; }
.lb-info { flex: 1; }
.lb-info-name { font-size: 13px; font-weight: 600; color: var(--text); }
.lb-info-dept { font-size: 11px; color: var(--text-muted); }
.lb-right { text-align: right; }
.lb-right-kg  { font-size: 13px; font-weight: 700; color: var(--text); }
.lb-right-pts { font-size: 11px; color: var(--primary); font-weight: 600; }

/* ── PROGRESS BAR ── */
.progress { background: #f1f5f9; border-radius: 6px; height: 8px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 6px; background: var(--primary); transition: width .6s ease; }

/* ── LOGIN ── */
.login-page { background: linear-gradient(135deg, #0f172a 0%, #1e3a2f 60%, #16a34a 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; width: 100%; }
.login-card { background: white; border-radius: 20px; padding: 44px 40px; width: 420px; max-width: 95vw; box-shadow: 0 25px 60px rgba(0,0,0,.25); }
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; justify-content: center; }
.login-logo-icon { width: 44px; height: 44px; background: var(--primary); border-radius: 12px; display: flex; align-items: center; justify-content: center; color: white; font-size: 20px; }
.login-logo-name { font-size: 22px; font-weight: 800; color: var(--text); }
.login-logo-sub  { font-size: 11px; color: var(--text-muted); }

/* ─────────────────────────────────────────
   HAMBURGER BUTTON  (hidden on desktop)
───────────────────────────────────────── */
.menu-btn {
    display: none;
    width: 36px; height: 36px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 8px;
    align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 15px;
    color: var(--text);
    flex-shrink: 0;
    margin-right: 10px;
    transition: background .18s, border-color .18s;
}
.menu-btn:hover { background: #f1f5f9; border-color: #cbd5e1; }

/* ─────────────────────────────────────────
   SIDEBAR OVERLAY  (mobile)
───────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 150;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ─────────────────────────────────────────
   TABLE SCROLL WRAPPER  (injected by JS)
───────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-wrap table { min-width: 500px; }

/* ─────────────────────────────────────────
   TABLET  (≤ 1024px)
───────────────────────────────────────── */
@media (max-width: 1024px) {
    :root { --sidebar-w: 220px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ─────────────────────────────────────────
   MOBILE  (≤ 768px)
───────────────────────────────────────── */
@media (max-width: 768px) {
    body { display: block; }

    /* Sidebar → off-canvas drawer */
    .sidebar {
        width: 260px;
        transform: translateX(-100%);
        transition: transform .28s cubic-bezier(.4,0,.2,1), box-shadow .28s;
        z-index: 200;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 6px 0 32px rgba(0,0,0,.3);
    }

    /* Main content: full width */
    .main-content { margin-left: 0; }

    /* Topbar */
    .topbar { padding: 0 14px; gap: 0; }
    .topbar-title p  { display: none; }
    .topbar-title h1 { font-size: 15px; }
    .topbar-right    { gap: 8px; }
    .menu-btn        { display: flex; }

    /* Page + panel padding */
    .page-content { padding: 14px; }
    .panel        { padding: 14px; }
    .panel-header { flex-wrap: wrap; gap: 10px; }

    /* Stats grid */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
    .stat-val   { font-size: 20px; }
    .stat-icon  { width: 40px; height: 40px; font-size: 16px; }
    .stat-card  { padding: 14px; gap: 12px; }

    /* Charts */
    .charts-row  { grid-template-columns: 1fr; gap: 14px; }
    .chart-wrap  { height: 200px; }

    /* Leaderboard podium: single column, centered */
    .lb-podium {
        grid-template-columns: 1fr;
        max-width: 280px;
        margin-left: auto; margin-right: auto;
    }

    /* Form */
    .form-row2 { grid-template-columns: 1fr; gap: 10px; }

    /* Toolbar */
    .toolbar    { flex-wrap: wrap; gap: 8px; }
    .filter-sel { flex: 1; min-width: 120px; }
}

/* ─────────────────────────────────────────
   TABLET INTERMEDIATE  (≤ 900px)
   Handles sidebar + cramped content area
───────────────────────────────────────── */
@media (max-width: 900px) {
    /* Podium: collapse to 1 col before content gets too cramped */
    .lb-podium {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 12px;
        max-width: 360px;
        margin-left: auto; margin-right: auto;
    }
    .lb-card { width: 100%; }
    /* Gold (rank-1) on top when stacked */
    .lb-card.rank-1 { order: 1; }
    .lb-card.rank-2 { order: 2; }
    .lb-card.rank-3 { order: 3; }
}

/* ─────────────────────────────────────────
   SMALL MOBILE  (≤ 480px)
───────────────────────────────────────── */
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-card  { padding: 12px 10px; gap: 8px; }
    .stat-val   { font-size: 18px; }
    .stat-lbl   { font-size: 11px; }

    .login-card { padding: 28px 18px; border-radius: 14px; }

    /* Topbar: prevent overflow, truncate title */
    .topbar         { padding: 0 10px; }
    .topbar-title   { flex: 1; min-width: 0; overflow: hidden; }
    .topbar-title h1 { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .topbar-right   { gap: 6px; flex-shrink: 0; }

    /* Hide button label text → icon-only */
    .topbar-right .btn-label    { display: none; }
    .topbar-right .btn          { padding: 8px; min-width: 34px; justify-content: center; }
    .topbar-right .btn-secondary { display: none; }

    .modal-box { border-radius: 12px; }

    .toolbar { flex-direction: column; align-items: stretch; }
    .search-wrap, .filter-sel { width: 100%; min-width: unset; }

    .page-content { padding: 10px; }
    .panel        { padding: 12px; }

    /* Toast: full-width on narrow screens */
    .toast { right: 10px; left: 10px; width: auto; max-width: calc(100vw - 20px); justify-content: center; }
}

/* ═══════════════════════════════════════════════════
   Greenverse.id Top Nav — Integration Overrides
   (nav height = 80px)
═══════════════════════════════════════════════════ */

/* Match background with main Greenverse.id site */
body { flex-direction: column; background-color: #051a14; }

/* Keep dashboard content area readable on dark body */
.main-content { background: var(--bg); }

/* Sidebar starts below greenverse nav */
.sidebar {
    top: 80px;
    height: calc(100vh - 80px);
    z-index: 200;
}

/* Dashboard inner topbar stays below greenverse nav when sticky */
.topbar { top: 80px; }

/* Login & Portal pages: nav full-width, card centered below */
body.login-page {
    align-items:      center;
    justify-content:  flex-start;
    padding-top:      0;
}
body.login-page > nav.gv-topnav {
    align-self: stretch;
    flex-shrink: 0;
}
body.login-page .login-card {
    margin-top: 48px;
}
