/* ============================================================
   1. VARIABLES & COLOR PALETTE (SOFT UI THEME)
   ============================================================ */
:root {
    /* Backgrounds */
    --bg-body: #f5f7fa;
    --bg-card: #ffffff;
    --bg-input: #f8fafc;

    /* Text Colors */
    --text-primary: #2c3e50;
    --text-muted: #64748b;

    /* Brand Colors */
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --sidebar-bg: #1e293b;

    /* Soft Accents */
    --soft-primary: #dbeafe;
    --soft-success: #dcfce7;
    --soft-info: #e0f2fe;
    --soft-danger: #fee2e2;
}

/* ============================================================
   2. GLOBAL RESET & TYPOGRAPHY
   ============================================================ */
body {
    font-family: 'Inter', 'Segoe UI', Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-primary);
    font-size: 0.9rem;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;

    /* Pola Titik-titik di Background Body */
    background-color: var(--bg-body);
    background-image: radial-gradient(#cbd5e1 1.5px, transparent 1.5px);
    background-size: 24px 24px;
}

a {
    text-decoration: none;
    transition: all 0.2s;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

/* ============================================================
   3. SIDEBAR NAVIGATION (MODIFIKASI UTAMA)
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 0;

    /* --- [STYLE BARU: GRADIENT BIRU + POLA DOT] --- */
    /* Layer 1: Pola Titik Putih Transparan */
    /* Layer 2: Gradient Biru Linear */
    background-image:
        radial-gradient(rgba(255, 255, 255, 0.15) 2px, transparent 2px),
        linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);

    background-size: 20px 20px, 100% 100%;
    /* ----------------------------------------------- */

    box-shadow: 4px 0 20px rgba(37, 99, 235, 0.3);
    /* Bayangan Biru Halus */
}

/* Link Sidebar */
.sidebar .nav-link {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    /* Putih agak transparan */
    padding: 12px 20px;
    margin: 6px 15px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
}

.sidebar .nav-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.15);
    /* Putih transparan saat hover */
    transform: translateX(3px);
}

.sidebar .nav-link.active {
    color: var(--primary-dark);
    /* Teks Biru Gelap */
    background-color: #fff;
    /* Background Putih Bersih */
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.sidebar .nav-link i {
    margin-right: 12px;
    width: 20px;
    text-align: center;
    font-size: 1.1em;
}

/* Judul/Header di Sidebar */
.sidebar-header h4 {
    color: #fff !important;
}

.sidebar-header small {
    color: rgba(255, 255, 255, 0.7) !important;
}

.sidebar-divider {
    border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
}

.sidebar-label {
    color: rgba(255, 255, 255, 0.6) !important;
}

/* ============================================================
   4. CARDS & WIDGETS
   ============================================================ */
.card {
    background-color: var(--bg-card);
    border: none;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-bottom: 24px;
}

.card-hover:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.1);
}

/* Active status filter card highlight */
.ring-active {
    box-shadow: 0 0 0 2px #6366f1, 0 6px 18px rgba(99, 102, 241, 0.15) !important;
    transform: translateY(-2px);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid #f1f5f9;
    font-weight: 700;
    color: var(--text-primary);
    padding: 20px 24px;
    border-radius: 16px 16px 0 0 !important;
}

.card-body {
    padding: 24px;
}

.bg-gradient-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
}

.bg-pattern {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    opacity: 0.15;
    background-image: radial-gradient(#fff 2px, transparent 2px);
    background-size: 20px 20px;
}

.avatar-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bg-soft-primary {
    background-color: var(--soft-primary);
    color: #1e40af;
}

.bg-soft-success {
    background-color: var(--soft-success);
    color: #166534;
}

.bg-soft-info {
    background-color: var(--soft-info);
    color: #075985;
}

.bg-soft-danger {
    background-color: var(--soft-danger);
    color: #991b1b;
}

.progress {
    background-color: #e9ecef;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* ============================================================
   5. FORMS & INPUTS
   ============================================================ */
.form-control,
.form-select {
    background-color: var(--bg-input);
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px 15px;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.form-control:focus,
.form-select:focus {
    background-color: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.input-group-text {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
    color: var(--text-muted);
}

/* ============================================================
   6. TABLES
   ============================================================ */
.table {
    margin-bottom: 0;
}

.table thead th {
    background-color: #f8fafc;
    border-bottom: none;
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 14px 16px;
}

.table tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-primary);
}

/* ============================================================
   7. LOGIN PAGE
   ============================================================ */
body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: #e2e8f0;
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 24px 24px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.card-header-custom {
    /* Login Header ikut tema Biru */
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    background-image: radial-gradient(rgba(255, 255, 255, 0.15) 2px, transparent 2px), linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    background-size: 20px 20px, 100% 100%;
    color: #fff;
    padding: 35px 30px;
    text-align: center;
}

.brand-icon {
    font-size: 2.5rem;
    color: #fff;
    margin-bottom: 10px;
}

/* ============================================================
   8. PREVIEW PAGE & PRINT
   ============================================================ */
body.preview-page {
    background-color: #525659 !important;
    background-image: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px;
}

.preview-nav {
    background: #fff;
    padding: 10px 20px;
    border-radius: 50px;
    margin-bottom: 30px;
    display: flex;
    gap: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.paper {
    width: 210mm;
    min-height: 297mm;
    background: #fff;
    padding: 10mm 15mm;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
}

/* Print Utilities */
.print-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10pt;
    font-family: Arial, sans-serif;
    color: #000;
}

.print-table td,
.print-table th {
    padding: 4px 6px;
    vertical-align: top;
}

.b-all,
.b-all th,
.b-all td {
    border: 1px solid #000;
}

.b-none {
    border: none !important;
}

.b-top-none {
    border-top: none !important;
}

.b-bot-none {
    border-bottom: none !important;
}

.b-x-none {
    border-left: none !important;
    border-right: none !important;
}

.bg-grey {
    background-color: #f0f0f0 !important;
    font-weight: bold;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

@media print {
    @page {
        size: A4 portrait;
        margin: 0 !important;
    }

    html,
    body {
        width: 210mm;
        height: 297mm;
        background-color: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
        background-image: none;
    }

    .sidebar,
    .navbar,
    .preview-nav,
    .no-print {
        display: none !important;
    }

    .paper {
        width: 100%;
        max-width: 210mm;
        margin: 0 auto;
        padding: 10mm 15mm;
        box-shadow: none;
        border: none;
        overflow: hidden;
        page-break-after: always;
    }

    body * {
        visibility: hidden;
    }

    .paper,
    .paper * {
        visibility: visible;
    }

    .print-table {
        width: 100% !important;
    }

    .sig-row td {
        height: 45px !important;
    }
}

/* ============================================================
   SIDEBAR MINIMIZE / COLLAPSE LOGIC (PERBAIKAN)
   ============================================================ */

/* Transisi halus */
.sidebar,
main,
.nav-link,
.nav-link span,
.logo-text,
.company-subtitle,
.sidebar-label,
.logout-btn {
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* KETIKA MINIMIZED (BODY CLASS ADDED VIA JS) */
body.sidebar-minimized .sidebar {
    width: 80px !important;
    flex: 0 0 80px !important;
    max-width: 80px !important;
    padding-top: 60px;
    /* Beri jarak atas agar toggle tidak numpuk */
}

/* Konten Utama Melebar */
body.sidebar-minimized main {
    width: calc(100% - 80px) !important;
    flex: 0 0 calc(100% - 80px) !important;
    max-width: calc(100% - 80px) !important;
    margin-left: auto !important;
}

/* 1. SEMBUNYIKAN TEKS (Termasuk Logout & Judul) */
body.sidebar-minimized .nav-link span,
body.sidebar-minimized .sidebar-label,
body.sidebar-minimized .company-subtitle,
body.sidebar-minimized .logo-text span,
body.sidebar-minimized .logout-btn span {
    display: none !important;
    opacity: 0;
    width: 0;
}

/* 2. RAPIKAN HEADER LOGO */
body.sidebar-minimized .sidebar-header {
    padding-bottom: 0 !important;
    margin-bottom: 10px !important;
    border-bottom: none !important;
}

body.sidebar-minimized .logo-icon {
    margin-right: 0 !important;
    font-size: 1.8rem;
    /* Perbesar Ikon Logo */
}

/* 3. TENGAHKAN IKON MENU */
body.sidebar-minimized .nav-link {
    justify-content: center !important;
    padding: 12px 0;
    margin: 4px 10px;
    text-align: center;
}

body.sidebar-minimized .nav-link i {
    margin-right: 0 !important;
    font-size: 1.3rem;
}

/* 4. POSISI TOMBOL TOGGLE (GARIS TIGA) */
body.sidebar-minimized #sidebarToggle {
    left: 50%;
    transform: translateX(-50%);
    top: 15px;
    right: auto;
    position: absolute;
}

/* 5. TOMBOL LOGOUT JADI BULAT */
body.sidebar-minimized .logout-btn {
    width: 46px !important;
    height: 46px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    /* Tengah */
}

body.sidebar-minimized .logout-btn i {
    margin: 0 !important;
}

/* ============================================================
   STICKY TABLE COLUMN (Agar Tombol Aksi Selalu Terlihat)
   ============================================================ */
.sticky-end {
    position: sticky;
    right: 0;
    z-index: 1;
    box-shadow: -5px 0 10px rgba(0, 0, 0, 0.05);
    /* Bayangan pemisah */
}

/* ============================================================
   9. NEW UTILITIES (REFACTORED)
   ============================================================ */
.text-xs {
    font-size: 0.75rem !important;
}

/* ~12px */
.text-xxs {
    font-size: 0.625rem !important;
}

/* ~10px */
.ls-1 {
    letter-spacing: 1px;
}

.avatar-40 {
    width: 40px;
    height: 40px;
}

.progress-xs {
    height: 8px !important;
}

.spinner-xs {
    width: 8px;
    height: 8px;
}

.sidebar-toggle-btn {
    z-index: 1050;
}

/* Print Layout Components */
.sys-error {
    padding: 20px;
    color: red;
}

.company-name {
    margin: 0;
    font-size: 14pt;
}

.company-address {
    font-size: 9pt;
}

.voucher-title {
    margin: 0;
}


/* Mobile Responsiveness */
@media (max-width: 767.98px) {
    body {
        padding-top: 60px;
        /* Jarak untuk mobile header */
    }

    /* Fixed mobile header space */
    .sidebar {
        position: fixed;
        top: 60px;
        left: 0;
        width: 100% !important;
        height: auto;
        z-index: 1040;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
        max-height: calc(100vh - 60px);
        overflow-y: auto;
    }

    main {
        padding-top: 10px !important;
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
    }

    /* Tabel di Mobile: kurangi tinggi agar tidak memenuhi layar */
    .table-scroll-container {
        max-height: 450px !important;
    }

    .card {
        margin-bottom: 15px;
    }

    .card-body {
        padding: 15px;
    }

    .h2 {
        font-size: 1.5rem;
    }

    /* Toolbar tombol agar rapi di mobile */
    .btn-toolbar {
        flex-direction: column;
        align-items: stretch !important;
        gap: 8px !important;
    }

    .btn-toolbar form {
        width: 100%;
    }

    .btn-toolbar .btn {
        width: 100%;
        margin-left: 0 !important;
    }

    /* Memungkinkan teks membungkus (wrap) di mobile agar tidak terlalu lebar */
    .table-scroll-container .table td {
        white-space: normal !important;
        min-width: 120px;
    }

    .table-scroll-container .table .ps-3 {
        min-width: 150px;
        /* Untuk kolom Invoice */
    }

    /* Pastikan kolom Aksi tetap terlihat atau memiliki ruang yang cukup */
    .table-scroll-container .table th:last-child,
    .table-scroll-container .table td:last-child {
        position: sticky;
        right: 0;
        background: inherit;
        z-index: 5;
        box-shadow: -2px 0 5px rgba(0, 0, 0, 0.05);
    }
}

/* Tablet / Medium Devices */
@media (min-width: 768px) and (max-width: 991.98px) {
    .table-scroll-container {
        max-height: 600px;
    }
}

/* ============================================================
   Form-specific Styles (from buat-voucher.php)
   ============================================================ */
.input-nominal::-webkit-inner-spin-button,
.input-nominal::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-nominal {
    -moz-appearance: textfield;
    /* Firefox */
    appearance: textfield;
    /* Standard */
}

#tabel-item input:focus {
    box-shadow: none;
    background-color: #f8f9fa !important;
    border-radius: 4px;
}

/* ============================================================
   10. TABLE SCROLL & FREEZE HEADER (MIRROR EXCEL FREEZE)
   ============================================================ */
.table-scroll-container {
    max-height: 800px;
    overflow-y: auto;
    position: relative;
    border-bottom: 1px solid #f1f5f9;
}

.table-scroll-container::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.table-scroll-container::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 10px;
}

.table-scroll-container::-webkit-scrollbar-track {
    background: transparent;
}

.sticky-thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #FFFFFF !important;
    /* Gunakan warna solid agar tidak tembus saat scroll */
    box-shadow: inset 0 -1px 0 #e2e8f0;
}

/* Settings Page Utilities */
.hover-light:hover {
    background-color: rgba(59, 130, 246, 0.05) !important;
    transition: background-color 0.2s ease;
}

.ls-1 {
    letter-spacing: 1px;
}

/* Row Selection Feature */
.table-selectable tbody tr {
    cursor: pointer;
}

.table-selectable tbody tr.row-selected {
    background-color: #e7f3ff !important;
    /* Soft DodgerBlue tint */
}

/* Ensure hover still works but selected row stays highlighted */
.table-selectable tbody tr.row-selected td {
    background-color: #e7f3ff !important;
}