/* assets/css/style.css
   Tema ResiKu -- dipakai bareng Bootstrap 5.
   Struktur: variabel warna -> layout shell (sidebar+main) -> komponen umum.
*/

:root {
    --purple: #7C6FE0;
    --purple-deep: #635BC4;
    --purple-light: #F0EDFC;
    --purple-soft: #E4DFF9;
    --bg: #F7F7FA;
    --card: #FFFFFF;
    --ink: #2B2740;
    --ink-soft: #6F6B85;
    --line: #ECEAF3;
    --green: #4FBF8B;
    --green-bg: #E9F8F1;
    --red: #E2685F;
    --red-bg: #FCEBEA;
    --red-deep: #B8443C;
    --tiktok: #23213B;
    --shopee: #EE7B34;
    --wa: #25D366;
    --offline: #9C97AE;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
h1, h2, h3, h4, h5, h6, .brand { font-family: 'Plus Jakarta Sans', sans-serif; }

/* ---------- Layout shell: sidebar + main ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 232px;
    background: var(--card);
    border-right: 1px solid var(--line);
    padding: 28px 16px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; padding: 0 8px; }
.brand-mark {
    width: 32px; height: 32px; border-radius: 10px;
    background: linear-gradient(135deg, var(--purple), var(--purple-deep));
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 800; font-size: 14px;
}
.text-accent { color: var(--purple); }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; border-radius: 10px;
    color: var(--ink-soft); text-decoration: none;
    font-size: 13.5px; font-weight: 600;
}
.nav a:hover { background: var(--bg); }
.nav a.active { background: var(--purple-light); color: var(--purple-deep); }
.nav-label {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
    color: #B7B3C9; font-weight: 700; padding: 10px 12px 0;
}

.role-card {
    margin-top: auto; display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
}
.role-avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--purple-soft);
    color: var(--purple-deep); display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12.5px; font-family: 'Plus Jakarta Sans'; flex-shrink: 0;
}
.role-card .name { font-size: 13px; font-weight: 700; line-height: 1.2; }
.role-card .role { font-size: 11px; color: var(--ink-soft); }
.role-card .logout-link {
    margin-left: auto; color: var(--ink-soft); text-decoration: none;
    font-size: 16px; padding: 4px; border-radius: 6px; flex-shrink: 0;
}
.role-card .logout-link:hover { background: var(--red-bg); color: var(--red-deep); }

.main { flex: 1; padding: 28px 34px 60px; max-width: 1180px; }

/* ---------- Mobile: top bar & bottom nav (disembunyikan di desktop) ---------- */
.mobile-topbar, .mobile-bottomnav { display: none; }

@media (max-width: 767px) {
    .sidebar { display: none; }
    .main { padding: 76px 16px 84px; max-width: 100%; }

    .mobile-topbar {
        display: flex; align-items: center; justify-content: space-between;
        position: fixed; top: 0; left: 0; right: 0; height: 58px;
        background: var(--card); border-bottom: 1px solid var(--line);
        padding: 0 16px; z-index: 1030;
    }
    .mobile-topbar .logout-link { color: var(--ink-soft); padding: 6px; }

    .mobile-bottomnav {
        display: flex; position: fixed; bottom: 0; left: 0; right: 0;
        background: var(--card); border-top: 1px solid var(--line);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        z-index: 1030;
    }
    .mobile-bottomnav a {
        flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
        color: var(--ink-soft); text-decoration: none; font-size: 10.5px; font-weight: 600;
        padding: 6px 2px; border-radius: 10px;
    }
    .mobile-bottomnav a.active { color: var(--purple-deep); background: var(--purple-light); }
}

/* ---------- Topbar ---------- */
.topbar { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; gap: 14px; flex-wrap: wrap; }
.topbar h1, .topbar h4 { font-size: 20px; font-weight: 800; margin-bottom: 3px; }
.topbar p { color: var(--ink-soft); font-size: 13px; margin: 0; }
.breadcrumb { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 8px; }
.breadcrumb b { color: var(--purple-deep); }

/* ---------- Card umum ---------- */
.card { border: 1px solid var(--line); border-radius: 16px; }
.card-body-pad { padding: 22px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.card-head .num {
    width: 24px; height: 24px; border-radius: 7px; background: var(--purple-light);
    color: var(--purple-deep); font-size: 12px; font-weight: 800;
    display: flex; align-items: center; justify-content: center; font-family: 'Plus Jakarta Sans'; flex-shrink: 0;
}
.card-head h3, .card-head h6 { font-size: 14.5px; font-weight: 700; margin: 0; }
.card-head span.card-head-note { font-size: 12px; color: var(--ink-soft); margin-left: auto; }

/* ---------- Form umum ---------- */
label.form-label { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.form-control, .form-select { border: 1px solid var(--line); background: #FBFBFD; border-radius: 10px; font-size: 13.5px; }
.form-control:focus, .form-select:focus { border-color: var(--purple); box-shadow: 0 0 0 .15rem var(--purple-light); }
.form-text { font-size: 11.5px; color: var(--ink-soft); }

/* Channel segmented buttons */
.segmented { display: flex; gap: 8px; flex-wrap: wrap; }
.seg-btn {
    display: flex; align-items: center; gap: 8px; padding: 9px 15px; border-radius: 11px;
    border: 1.5px solid var(--line); background: #FBFBFD; font-size: 13px; font-weight: 700;
    color: var(--ink-soft); cursor: pointer; user-select: none;
}
.seg-btn .dot { width: 8px; height: 8px; border-radius: 50%; }
.seg-btn.active, .seg-btn:hover { border-color: var(--purple); background: var(--purple-light); color: var(--purple-deep); }

/* Order builder table */
.order-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); font-weight: 700; padding: 0 8px 8px; border: none; }
.order-table td { padding: 6px 8px; vertical-align: middle; border: none; }
.qty-input { width: 70px; text-align: center; }
.subtotal-cell { font-weight: 700; font-size: 13px; white-space: nowrap; text-align: right; padding-right: 8px !important; }
.remove-btn {
    width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: #FBFBFD;
    color: var(--red); font-size: 15px; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
}
.custom-badge {
    display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; color: var(--purple-deep);
    background: var(--purple-light); padding: 2px 8px; border-radius: 20px; margin-left: 6px;
}
.add-line-btn { font-size: 13px; font-weight: 700; }

/* Summary total */
.summary-card {
    background: linear-gradient(135deg, var(--purple-deep), var(--purple));
    border-radius: 16px; padding: 22px; color: white;
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;
}
.summary-card .label { font-size: 12.5px; opacity: .85; font-weight: 600; }
.summary-card .value { font-size: 26px; font-weight: 800; font-family: 'Plus Jakarta Sans'; margin-top: 4px; }
.summary-card .breakdown { font-size: 11.5px; opacity: .8; margin-top: 6px; }

/* Filter chip / period toggle */
.chip-toggle .btn { border-radius: 20px !important; font-weight: 700; font-size: 12.5px; }

/* Badge channel */
.ch-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 20px; }
.ch-badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.ch-badge.tiktok { background: #EAEAF4; color: var(--tiktok); }
.ch-badge.shopee { background: #FDECE0; color: #B85B1F; }
.ch-badge.whatsapp { background: #E4F9EC; color: #1E8E4F; }
.ch-badge.offline { background: #EFEEF3; color: #68627F; }

.code-tag {
    font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700;
    background: var(--purple-light); color: var(--purple-deep); padding: 4px 9px; border-radius: 8px;
}

.status-pill { background: var(--purple-light); color: var(--purple-deep); font-size: 11.5px; font-weight: 700; padding: 5px 12px; border-radius: 20px; }

/* Table umum */
.table-clean thead th { border: none; background: #FAFAFC; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); font-weight: 700; padding: 13px 20px; }
.table-clean tbody td { padding: 13px 20px; font-size: 13.5px; border-color: var(--line); vertical-align: middle; }

/* Buttons */
.btn-primary { background-color: var(--purple); border-color: var(--purple); }
.btn-primary:hover, .btn-primary:focus { background-color: var(--purple-deep); border-color: var(--purple-deep); }
.btn-outline-primary { color: var(--purple-deep); border-color: var(--purple-soft); }
.btn-outline-primary:hover { background-color: var(--purple); border-color: var(--purple); }
.btn-outline-secondary { color: var(--ink-soft); border-color: var(--line); }
.btn-outline-danger { color: var(--red-deep); border-color: #F3D3D0; }

/* KPI icon lingkaran soft */
.kpi-icon {
    width: 38px; height: 38px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
}

/* Avatar bulat inisial nama, dipakai di daftar Resi per Designer */
.name-avatar {
    width: 26px; height: 26px; border-radius: 50%; color: white;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; font-family: 'Plus Jakarta Sans'; flex-shrink: 0;
}
.alert-success { background: var(--green-bg); color: #1E8E4F; border: none; }
.alert-danger { background: var(--red-bg); color: var(--red-deep); border: none; }

/* Kamera scan barcode -- frame + garis merah beranimasi */
.reader-frame {
    position: relative; border-radius: 16px; overflow: hidden;
    border: 1.5px solid var(--line); background: #000;
    width: 100%; height: 220px; /* tinggi tetap -- lebih reliable daripada aspect-ratio CSS */
}
.reader-frame #reader { width: 100%; height: 100%; }
/* HANYA <video>, bukan canvas/div lain -- canvas dipakai library buat proses
   internal, kalau ikut dipaksa CSS malah bisa bikin videonya nggak muncul. */
.reader-frame video {
    width: 100% !important; height: 100% !important; object-fit: cover !important;
}
.scan-line-overlay {
    position: absolute; inset: 0; pointer-events: none;
}
.scan-line-overlay.d-none { display: none; }
.scan-line {
    position: absolute; left: 6%; right: 6%; height: 2px;
    background: #FF4D4D; box-shadow: 0 0 8px 2px rgba(255,77,77,0.7);
    animation: scanGerak 1.8s ease-in-out infinite;
}
@keyframes scanGerak {
    0%   { top: 20%; }
    50%  { top: 80%; }
    100% { top: 20%; }
}

/* Submenu dropdown di sidebar (khusus menu Laporan) */
.nav-parent { cursor: pointer; }
.nav-chevron { transition: transform 0.2s ease; }
.submenu.show ~ .nav-parent .nav-chevron,
a.nav-parent.active .nav-chevron { transform: rotate(180deg); }
.submenu {
    max-height: 0; overflow: hidden; transition: max-height 0.2s ease;
    display: flex; flex-direction: column; padding-left: 40px;
}
.submenu.show { max-height: 220px; }
.submenu a {
    padding: 8px 12px; font-size: 13px; color: var(--ink-soft); text-decoration: none;
    border-radius: 8px; font-weight: 600;
}
.submenu a:hover { background: var(--bg); }
.submenu a.active { color: var(--purple-deep); font-weight: 700; }

/* Print / Export PDF -- sembunyikan semua yang nggak perlu pas di-print,
   biar hasil "Save as PDF" cuma nampilin laporannya doang. */
@media print {
    .sidebar, .mobile-topbar, .mobile-bottomnav, .no-print { display: none !important; }
    .app-shell { display: block !important; }
    .main { padding: 0 !important; max-width: 100% !important; }
    body { background: white !important; }
    .card { border: 1px solid #ddd !important; break-inside: avoid; }
}
