/* =====================================================
   GLOBAL — Reset & Variabel Warna
===================================================== */

/* Reset default browser: semua elemen pakai border-box, hilangkan margin & padding */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* Variabel warna global — bisa dipakai ulang dengan var(--nama) */
:root {
    --bg: #090B14;        /* Background utama halaman (gelap) */
    --panel: #111522;     /* Background panel/kartu */
    --panel2: #171B2B;    /* Background panel sekunder (lebih terang) */
    --card: #141827;      /* Background kartu */
    --border: #272D45;    /* Warna border default */
    --text: #F4F6FF;      /* Warna teks utama (putih) */
    --muted: #9AA3BC;     /* Warna teks sekunder (abu-abu) */
    --purple: #7C3AED;    /* Warna aksen ungu (primary) */
    --purple-h: #8B5CF6;  /* Ungu versi hover (lebih terang) */
    --blue: #3B82F6;      /* Warna biru */
    --cyan: #22D3EE;      /* Warna cyan */
    --green: #22C55E;     /* Warna hijau (sukses/online) */
    --red: #EF4444;       /* Warna merah (error/danger) */
    --yellow: #F59E0B;    /* Warna kuning (warning) */
}

/* html & body full height */
html, body { height: 100%; }

/* Body: background gelap, font Segoe UI, layout flex (sidebar + konten) */
body {
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Tahoma, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    display: flex;              /* Sidebar & main wrapper berdampingan */
    min-height: 100vh;
}

/* Link tidak bergaris bawah, ikut warna parent */
a { color: inherit; text-decoration: none; }

/* Utility class */
.muted { color: var(--muted); }   /* Teks abu-abu */
.center { text-align: center; }   /* Teks rata tengah */

/* =====================================================
   SIDEBAR — Menu navigasi kiri
===================================================== */

.sidebar {
    width: 245px;                    /* Lebar sidebar */
    background: #080B14;             /* Background lebih gelap dari body */
    display: flex;                   /* Flexbox vertikal */
    flex-direction: column;
    padding: 24px 0 0;               /* Padding atas saja */
    position: fixed;                 /* Tetap saat discroll */
    top: 0; left: 0; bottom: 0;      /* Menempel di kiri full tinggi */
    overflow-y: auto;                /* Bisa scroll kalau menu panjang */
}

/* Logo & nama aplikasi */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;                       /* Jarak icon & teks */
    padding: 0 22px 30px;            /* Padding bawah 30px */
}

/* ⭐ FIX: Brand icon — DEFINISI TUNGGAL (tidak duplikat) */
.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    color: #A78BFA;                  /* Warna ungu terang (untuk SVG currentColor) */
}

/* ⭐ FIX: SVG di dalam brand icon */
.brand-icon svg {
    width: 26px;
    height: 26px;
    display: block;
    stroke: currentColor;            /* Ikut warna parent */
}

.brand-title { font-size: 15px; font-weight: bold; letter-spacing: 0.5px; }  /* Nama aplikasi */
.brand-sub { font-size: 8px; font-weight: bold; color: #65708A; letter-spacing: 0.8px; }  /* Subtitle kecil */

/* Label kecil di atas menu (misal: "MENU UTAMA") */
.menu-label {
    font-size: 9px; font-weight: bold; color: #56617A;
    padding: 0 25px 8px; letter-spacing: 1px;
}

/* Container menu — flex vertikal */
.menu { display: flex; flex-direction: column; padding: 0 10px; gap: 2px; }

/* Item menu individual */
.menu-item {
    display: flex; align-items: center; gap: 12px;   /* Icon & teks sejajar */
    padding: 13px 18px; border-radius: 6px;          /* Rounded corners */
    color: #AAB4CB; font-weight: bold; font-size: 13px;
    transition: all 0.2s ease;                       /* Animasi halus */
}
.menu-item:hover { background: #171C2C; color: white; }        /* Hover: background terang */
.menu-item.active { background: #261A49; color: white; }       /* Aktif: background ungu gelap */

/* ⭐ FIX: Icon menu — DEFINISI TUNGGAL */
.menu-item .icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;                  /* Jangan mengecil */
    color: inherit;                  /* Ikut warna menu-item */
}

/* ⭐ FIX: SVG di dalam icon menu */
.menu-item .icon svg {
    width: 18px;
    height: 18px;
    display: block;
    stroke: currentColor;            /* Ikut warna parent */
}

/* Kotak user di bawah sidebar */
.user-box {
    margin-top: auto;                /* Dorong ke paling bawah */
    padding: 20px 18px;
    border-top: 1px solid #1C2232;   /* Garis pemisah atas */
}

/* Info user (nama + status) */
.user-info {
    display: flex; align-items: center; gap: 8px;
    background: #111522; border: 1px solid #252C40;
    border-radius: 6px; padding: 10px 12px;
    font-size: 12px; font-weight: bold; margin-bottom: 12px;
}
.user-info small { font-weight: normal; font-size: 10px; }

/* ⭐ FIX: Dot user — ganti karakter ● jadi lingkaran CSS */
.user-info .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;              /* Bulat sempurna */
    background: var(--green);        /* Hijau */
    flex-shrink: 0;
    /* Catatan: JANGAN pakai font-size:0 kalau ada SVG di dalamnya */
}

/* Tombol logout */
.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #32151D; 
    color: #FFB4C0;                  /* Merah gelap */
    text-align: center; 
    padding: 12px; 
    border-radius: 6px;
    font-weight: bold; 
    font-size: 13px; 
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
}
.logout-btn:hover { background: #7F1D1D; color: white; }        /* Hover: merah pekat */

/* ⭐ FIX: SVG di dalam tombol logout */
.logout-btn svg {
    width: 16px;
    height: 16px;
    display: block;
    stroke: currentColor;
}

/* =====================================================
   MAIN WRAPPER & TOPBAR — Konten utama & header
===================================================== */

.main-wrapper {
    margin-left: 245px;              /* Geser karena sidebar fixed 245px */
    flex: 1;                         /* Isi sisa lebar */
    display: flex; 
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar — header atas */
.topbar {
    background: #0C101C;
    border-bottom: 1px solid #171D2E;
    padding: 14px 30px;
    display: flex; 
    align-items: center; 
    justify-content: space-between;
    position: sticky; 
    top: 0; 
    z-index: 10;                     /* Menempel saat scroll */
}
.topbar h2 { font-size: 13px; font-weight: bold; letter-spacing: 1px; }  /* Judul halaman */
.topbar .muted { font-size: 10px; color: #65708A; }                       /* Subtitle */
.topbar-right { display: flex; align-items: center; gap: 12px; }          /* Kanan topbar */

/* Badge — label status */
.badge {
    padding: 7px 12px; 
    border-radius: 20px;             /* Pill shape */
    font-size: 10px; 
    font-weight: bold; 
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* ⭐ FIX: Badge online — pakai struktur yang lebih bersih */
.badge.online { 
    background: #102018; 
    color: #6EE7A0; 
}

/* ⭐ FIX: Titik hijau di badge online (sebelum teks) */
.badge.online::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6EE7A0;
    flex-shrink: 0;
}

.badge.user { background: #151A29; color: #C9D1E8; }     /* Abu-abu (user) */

/* =====================================================
   CONTENT — Area konten utama
===================================================== */

.content { padding: 30px 35px 40px; flex: 1; }
.content h1 { font-size: 26px; font-weight: bold; margin-bottom: 6px; }
.content > p.muted { margin-bottom: 22px; font-size: 13px; }

/* =====================================================
   STATS — Grid kartu statistik
===================================================== */

.stats-grid {
    display: grid; 
    grid-template-columns: repeat(4, 1fr);   /* 4 kolom sama lebar */
    gap: 14px; 
    margin-bottom: 22px;
}

/* Kartu statistik */
.stat-card {
    background: var(--panel); 
    border: 1px solid var(--border);
    border-radius: 10px; 
    padding: 16px 18px;
    position: relative; 
    overflow: hidden;                /* Supaya ::before tidak keluar */
    transition: transform 0.2s ease;
}
/* Garis vertikal di kiri kartu */
.stat-card::before {
    content: ""; 
    position: absolute;
    top: 0; 
    left: 0; 
    bottom: 0; 
    width: 4px;
}
/* Warna garis sesuai modifier */
.stat-card.purple::before { background: var(--purple); }
.stat-card.blue::before { background: var(--blue); }
.stat-card.cyan::before { background: var(--cyan); }
.stat-card.green::before { background: var(--green); }
.stat-card:hover { transform: translateY(-2px); }   /* Efek naik saat hover */

.stat-title {
    display: block; 
    font-size: 9px; 
    font-weight: bold;
    color: var(--muted); 
    letter-spacing: 1px; 
    margin-bottom: 6px;
}
.stat-value { display: block; font-size: 26px; font-weight: bold; margin-bottom: 4px; }  /* Angka besar */
.stat-sub { display: block; font-size: 10px; color: #64708A; }  /* Subtext kecil */

/* =====================================================
   CARD — Kartu konten umum
===================================================== */

.card {
    background: var(--panel); 
    border: 1px solid var(--border);
    border-radius: 10px; 
    padding: 22px 24px; 
    margin-bottom: 22px;
}
.card h3 { font-size: 16px; font-weight: bold; margin-bottom: 4px; }
.card > p.muted { font-size: 12px; margin-bottom: 16px; }

/* =====================================================
   QUICK ACTIONS & NOTE
===================================================== */

.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }

/* Note — kotak info dengan titik hijau */
.note {
    background: #0E1220; 
    border: 1px solid #252B40;
    color: #AAB4CB; 
    padding: 12px 16px; 
    border-radius: 8px;
    font-size: 12px; 
    font-weight: bold;
    display: flex; 
    align-items: center; 
    gap: 8px;
}

/* ⭐ FIX: Note — titik hijau via CSS */
.note::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    flex-shrink: 0;
}

/* =====================================================
   BUTTONS — Tombol
===================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px; 
    border-radius: 6px;
    border: none; 
    font-family: inherit; 
    font-size: 12px; 
    font-weight: bold;
    letter-spacing: 0.5px; 
    cursor: pointer; 
    text-align: center;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn.primary { background: var(--purple); color: white; }              /* Ungu (aksi utama) */
.btn.primary:hover { background: var(--purple-h); }
.btn.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--border); }  /* Transparan */
.btn.ghost:hover { background: #20263A; }
.btn.danger { background: #7F1D1D; color: white; }                     /* Merah (danger) */
.btn.danger:hover { background: var(--red); }
.btn.small { padding: 6px 12px; font-size: 11px; }                     /* Versi kecil */

/* ⭐ FIX: SVG di dalam tombol */
.btn svg {
    width: 14px;
    height: 14px;
    display: block;
    flex-shrink: 0;
    stroke: currentColor;
}

/* =====================================================
   FORM — Input, select, textarea
===================================================== */

form label {
    display: block; 
    font-size: 11px; 
    font-weight: bold;
    color: #C9D1E8; 
    letter-spacing: 0.5px;
    margin-bottom: 6px; 
    margin-top: 4px;
}

/* Semua input/select/textarea styling */
form input[type="text"],
form input[type="password"],
form input[type="number"],
form input[type="date"],
form select,
form textarea {
    width: 100%; 
    background: #0D1020; 
    color: var(--text);
    border: 1px solid var(--border); 
    border-radius: 6px;
    padding: 10px 12px; 
    font-family: inherit; 
    font-size: 13px;
    outline: none; 
    transition: border 0.2s ease;
}

/* Saat fokus → border ungu */
form input:focus, form select:focus, form textarea:focus {
    border-color: var(--purple);
}

/* Select custom: sembunyikan panah default, pakai icon SVG */
form select {
    appearance: none; 
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239AA3BC' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;    /* Ruang untuk icon */
}

/* Grid form — 3 kolom */
.form-grid {
    display: grid; 
    grid-template-columns: repeat(3, 1fr);
    gap: 14px 18px; 
    align-items: end;
}
/* Baris aksi form (tombol) — full width */
.form-grid .form-actions {
    grid-column: 1 / -1;    /* Span semua kolom */
    display: flex; 
    gap: 10px; 
    margin-top: 6px;
}
.form-grid .form-actions .btn { margin-top: 0; }

/* =====================================================
   TABLE — Tabel data
===================================================== */

.table-wrap {
    overflow-x: auto; 
    border-radius: 8px; 
    border: 1px solid var(--border);  /* Scroll horizontal */
}
table { width: 100%; border-collapse: collapse; font-size: 12px; }
table thead th {
    background: #1A2033; 
    color: #C9D1E8; 
    text-align: left;
    padding: 12px 14px; 
    font-weight: bold; 
    font-size: 11px;
    letter-spacing: 0.5px; 
    white-space: nowrap;    /* Header tidak wrap */
}
table tbody td {
    padding: 11px 14px; 
    border-top: 1px solid #1B2135; 
    color: var(--text);
}
table tbody tr:hover { background: #12162A; }                        /* Hover baris */
table tbody tr:nth-child(even) { background: #0E1220; }              /* Zebra stripe */
table tbody tr:nth-child(even):hover { background: #12162A; }        /* Zebra + hover */
td.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* =====================================================
   ALERT — Notifikasi
===================================================== */

.alert {
    padding: 12px 16px; 
    border-radius: 6px; 
    font-size: 12px;
    font-weight: bold; 
    margin-bottom: 16px;
}
.alert.success { background: #102018; color: #6EE7A0; border: 1px solid #1B4030; }  /* Hijau */
.alert.error { background: #2A1018; color: #FCA5A5; border: 1px solid #4C1D1D; }    /* Merah */

/* =====================================================
   BADGE ROLE — Label role user
===================================================== */

.badge-role {
    display: inline-block; 
    padding: 4px 10px; 
    border-radius: 20px;
    font-size: 10px; 
    font-weight: bold; 
    letter-spacing: 0.8px;
}
.badge-role.admin { background: #2A1A49; color: #C4B5FD; border: 1px solid #4C1D95; }       /* Ungu (admin) */
.badge-role.peminjam { background: #102018; color: #6EE7A0; border: 1px solid #1B4030; }    /* Hijau (peminjam) */
.badge-role.ditolak { background: #2A1018; color: #FCA5A5; border: 1px solid #4C1D1D; }     /* Merah (ditolak) */

/* =====================================================
   LOGIN / REGISTER — Halaman auth
===================================================== */

/* Body khusus halaman login */
body.login-page {
    display: flex; 
    align-items: center; 
    justify-content: center;
    min-height: 100vh; 
    padding: 30px;
    /* Background gradien radial (efek cahaya) */
    background:
        radial-gradient(circle at 72% 18%, #17133B 0%, transparent 45%),
        radial-gradient(circle at 10% 90%, #111B35 0%, transparent 50%),
        var(--bg);
}

/* Wrapper login — 2 kolom (brand kiri, card kanan) */
.login-wrapper {
    width: 100%; 
    max-width: 1050px;
    display: grid; 
    grid-template-columns: 1.2fr 1fr;
    gap: 40px; 
    align-items: center;
}

/* Panel brand (kiri) */
.brand-panel { padding: 30px 20px; }
.brand-tag {
    font-size: 13px; 
    font-weight: bold; 
    color: #A78BFA;
    letter-spacing: 2px; 
    margin-bottom: 22px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ⭐ FIX: SVG di brand tag (halaman login/register) */
.brand-tag svg {
    width: 16px;
    height: 16px;
    display: block;
    flex-shrink: 0;
    stroke: currentColor;
}

.brand-panel h1 {
    font-size: 42px; 
    font-weight: bold; 
    line-height: 1.1;
    margin-bottom: 18px; 
    letter-spacing: -0.5px;
}
.brand-panel p {
    color: var(--muted); 
    font-size: 15px;
    line-height: 1.6; 
    max-width: 420px;
}
.brand-foot {
    margin-top: 40px; 
    font-size: 10px; 
    font-weight: bold;
    color: #64748B; 
    letter-spacing: 1.5px;
}

/* Card login (kanan) */
.login-card {
    background: var(--panel); 
    border: 1px solid var(--border);
    border-radius: 12px; 
    padding: 38px 38px 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);   /* Shadow dalam */
    margin-bottom: 0;
}
.login-card h2 { font-size: 24px; font-weight: bold; margin-bottom: 6px; }
.login-card > p.muted { font-size: 12px; margin-bottom: 22px; }
.login-card form {
    display: flex; 
    flex-direction: column; 
    gap: 4px; 
    margin-bottom: 18px;
}
.login-card form label { margin-top: 10px; }
.login-card .btn { margin-top: 18px; padding: 12px; }
.login-card .btn.ghost { margin-top: 0; display: flex; width: 100%; }

/* =====================================================
   RESPONSIVE — Media queries
===================================================== */

/* Tablet besar (≤1100px) */
@media (max-width: 1100px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }   /* Stats jadi 2 kolom */
    .form-grid { grid-template-columns: repeat(2, 1fr); }    /* Form jadi 2 kolom */
}

/* Tablet (≤900px) */
@media (max-width: 900px) {
    body.login-page { padding: 20px; }
    .login-wrapper { grid-template-columns: 1fr; gap: 20px; }  /* Login jadi 1 kolom */
    .brand-panel { padding: 10px 0; }
    .brand-panel h1 { font-size: 30px; }
    .sidebar { width: 70px; }                                   /* Sidebar mengecil */
    
    /* Sembunyikan teks di sidebar, sisakan icon */
    .sidebar .brand-title,
    .sidebar .brand-sub,
    .sidebar .menu-label,
    .sidebar .menu-item span:not(.icon),
    .sidebar .user-info span:not(.dot) { display: none; }
    
    .sidebar .menu-item { justify-content: center; padding: 14px 0; }  /* Icon center */
    .main-wrapper { margin-left: 70px; }                        /* Sesuaikan margin */
    .form-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr; }
    
    /* ⭐ FIX: SVG tetap tampil di mobile */
    .sidebar .menu-item .icon {
        display: inline-flex !important;
        width: 22px;
        height: 22px;
    }
    .sidebar .menu-item .icon svg {
        width: 20px;
        height: 20px;
    }
}

/* Mobile (≤600px) */
@media (max-width: 600px) {
    .content { padding: 20px 18px; }
    .topbar { padding: 12px 18px; }
    .content h1 { font-size: 20px; }
    .stat-value { font-size: 22px; }
}

/* =====================================================
   USER ONLINE BOX (Sidebar)
===================================================== */

.online-box {
    margin: 10px 12px 0;
    padding: 12px 10px 10px;
    background: #0E1220;
    border: 1px solid #1C2232;
    border-radius: 8px;
}

.online-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 9px;
    font-weight: bold;
    color: #65708A;
    letter-spacing: 1px;
    padding: 0 4px 8px;
    border-bottom: 1px solid #1C2232;
    margin-bottom: 8px;
}

.online-count {
    background: #261A49;
    color: #C4B5FD;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: bold;
}

/* ⭐ LIST SCROLLABLE */
.online-list {
    max-height: 180px;              /* Batas tinggi */
    overflow-y: auto;                /* Scroll vertikal */
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 4px;
}

/* Scrollbar custom (webkit) */
.online-list::-webkit-scrollbar {
    width: 5px;
}
.online-list::-webkit-scrollbar-track {
    background: transparent;
}
.online-list::-webkit-scrollbar-thumb {
    background: #272D45;
    border-radius: 5px;
}
.online-list::-webkit-scrollbar-thumb:hover {
    background: #3B4260;
}

/* Firefox scrollbar */
.online-list {
    scrollbar-width: thin;
    scrollbar-color: #272D45 transparent;
}

/* Item user */
.online-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: bold;
    color: #C9D1E8;
    transition: background 0.15s ease;
}

.online-item:hover {
    background: #171C2C;
}

.online-item.is-me {
    background: #1A1533;
    border-left: 2px solid #7C3AED;
}

.online-item.is-me .online-name {
    color: #C4B5FD;
}

/* Titik hijau (online) */
.online-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22C55E;
    flex-shrink: 0;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);  /* Glow */
    animation: pulse-online 2s infinite;
}

@keyframes pulse-online {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.6; }
}

.online-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;    /* Nama panjang → titik-titik */
}

.online-name small {
    font-weight: normal;
    font-size: 9px;
    color: #7C3AED;
    margin-left: 2px;
}

/* Badge role kecil (A=admin / P=peminjam) */
.online-role {
    font-size: 8px;
    font-weight: bold;
    padding: 2px 5px;
    border-radius: 3px;
    background: #261A49;
    color: #C4B5FD;
    flex-shrink: 0;
}

/* Responsive: sembunyikan di sidebar mini */
@media (max-width: 900px) {
    .online-box {
        display: none;
    }
}