/* ============================================
   style.css — Buku Gas v2.0
   Design system: light, clean, mobile-first
   ============================================ */

/* --- Reset & Base --- */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --white: #FFFFFF;
    --bg: #F5F5F5;
    --surface: #FFFFFF;
    --border: #E5E7EB;
    --text-primary: #1A1A1A;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;

    --blue: #2563EB;
    --blue-light: #EFF6FF;
    --blue-dark: #1D4ED8;
    --green: #16A34A;
    --green-light: #F0FDF4;
    --red: #DC2626;
    --red-light: #FEF2F2;
    --yellow: #D97706;
    --yellow-light: #FFFBEB;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.10);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

    --sidebar-width: 220px;
    --header-height: 56px;

    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* --- Typography --- */

h1 {
    font-size: 1.375rem;
    font-weight: 700;
    line-height: 1.3;
}

h2 {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.3;
}

h3 {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
}

h4 {
    font-size: 0.875rem;
    font-weight: 600;
}

p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

small {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-body {
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px 16px;
}

.login-wrap {
    width: 100%;
    max-width: 380px;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.login-logo h1 span {
    color: var(--blue);
}

.login-logo p {
    margin-top: 4px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.login-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    box-shadow: var(--shadow-md);
}

.login-card h2 {
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Alert login */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert-danger {
    background: var(--red-light);
    color: var(--red);
    border-color: #FECACA;
}

.alert-success {
    background: var(--green-light);
    color: var(--green);
    border-color: #BBF7D0;
}

.alert-warning {
    background: var(--yellow-light);
    color: var(--yellow);
    border-color: #FDE68A;
}

/* ============================================
   APP LAYOUT (sidebar + konten)
   ============================================ */

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */

.sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 200;
    transition: transform 0.25s ease;
    height: 100vh;
    min-height: 100%;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo h1 {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.sidebar-logo h1 span {
    color: var(--blue);
}

.sidebar-logo small {
    display: block;
    margin-top: 2px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    padding: 8px 16px 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 0;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}

.nav-link svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.nav-link:hover {
    background: var(--bg);
    color: var(--text-primary);
    text-decoration: none;
}

.nav-link.active {
    background: var(--blue-light);
    color: var(--blue);
    border-left-color: var(--blue);
    font-weight: 600;
}

.sidebar-user {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sidebar-user-info {
    overflow: hidden;
}

.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.btn-logout {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    font-size: 0.75rem;
    font-family: var(--font);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

.btn-logout:hover {
    background: var(--red-light);
    color: var(--red);
    border-color: var(--red);
}

/* --- Main Content --- */

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page-header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-header h1 {
    font-size: 1.1rem;
}

.page-header-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.page-body {
    padding: 24px;
    max-width: 960px;
}

/* Mobile hamburger */
.btn-hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--text-primary);
}

.btn-hamburger svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 199;
}

/* ============================================
   KOMPONEN UI
   ============================================ */

/* --- Card --- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
}

.card-title {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.card-value.green {
    color: var(--green);
}

.card-value.red {
    color: var(--red);
}

.card-value.blue {
    color: var(--blue);
}

.card-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* --- Stats Grid --- */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stats-grid .card {
    margin-bottom: 0;
}

/* --- Form --- */

.form-group {
    margin-bottom: 14px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-label .required {
    color: var(--red);
    margin-left: 2px;
}

.form-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: var(--font);
    color: var(--text-primary);
    background: var(--white);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

.form-input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input:disabled {
    background: var(--bg);
    color: var(--text-muted);
    cursor: not-allowed;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-error {
    font-size: 0.75rem;
    color: var(--red);
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

/* --- Button --- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.98);
}

.btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.btn-primary {
    background: var(--blue);
    color: var(--white);
    border-color: var(--blue);
}

.btn-primary:hover {
    background: var(--blue-dark);
    border-color: var(--blue-dark);
    text-decoration: none;
    color: var(--white);
}

.btn-secondary {
    background: var(--white);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--bg);
    text-decoration: none;
    color: var(--text-primary);
}

.btn-danger {
    background: var(--white);
    color: var(--red);
    border-color: var(--border);
}

.btn-danger:hover {
    background: var(--red-light);
    border-color: var(--red);
    text-decoration: none;
}

.btn-success {
    background: var(--green);
    color: var(--white);
    border-color: var(--green);
}

.btn-success:hover {
    opacity: 0.9;
    text-decoration: none;
    color: var(--white);
}

.btn-full {
    width: 100%;
    padding: 11px;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.8rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* --- Table --- */

.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    margin-bottom: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

thead tr {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

thead th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--bg);
}

tbody td {
    padding: 10px 14px;
    color: var(--text-primary);
    vertical-align: middle;
}

.td-muted {
    color: var(--text-muted);
    font-size: 0.8rem;
}

tfoot tr {
    background: var(--bg);
    border-top: 2px solid var(--border);
}

tfoot td {
    padding: 10px 14px;
    font-weight: 600;
    font-size: 0.85rem;
}

/* --- Badge --- */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 600;
}

.badge-green {
    background: var(--green-light);
    color: var(--green);
}

.badge-red {
    background: var(--red-light);
    color: var(--red);
}

.badge-blue {
    background: var(--blue-light);
    color: var(--blue);
}

.badge-yellow {
    background: var(--yellow-light);
    color: var(--yellow);
}

/* --- Section Header --- */

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 12px;
}

.section-header h2 {
    font-size: 0.95rem;
}

/* --- Divider --- */

.divider {
    height: 1px;
    background: var(--border);
    margin: 16px 0;
}

/* --- Empty State --- */

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* --- Filter Bar --- */

.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 6px 14px;
    border-radius: 100px;
    border: 1px solid var(--border);
    background: var(--white);
    font-size: 0.8rem;
    font-family: var(--font);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

.filter-btn.active {
    background: var(--blue);
    border-color: var(--blue);
    color: var(--white);
}

.filter-btn:hover:not(.active) {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

/* --- Toast --- */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    background: var(--text-primary);
    color: var(--white);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
    white-space: nowrap;
    z-index: 999;
    box-shadow: var(--shadow-lg);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* --- Preview Kalkulasi --- */

.kalkulasi-box {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 14px;
}

.kalkulasi-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    padding: 3px 0;
}

.kalkulasi-row.total {
    border-top: 1px solid var(--border);
    margin-top: 6px;
    padding-top: 8px;
    font-weight: 700;
    font-size: 0.95rem;
}

/* --- Setting Row --- */

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    gap: 16px;
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.setting-sub {
    font-size: 0.775rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* --- Rekap Box --- */

.rekap-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 16px;
}

.rekap-item {
    background: var(--white);
    padding: 14px 16px;
}

.rekap-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.rekap-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.rekap-value.green {
    color: var(--green);
}

.rekap-value.blue {
    color: var(--blue);
}

.rekap-value.red {
    color: var(--red);
}

/* ============================================
   RESPONSIVE — MOBILE
   ============================================ */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .btn-hamburger {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .page-body {
        padding: 16px;
    }

    .form-row,
    .form-row-3 {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .rekap-grid {
        grid-template-columns: 1fr 1fr;
    }

    .page-header {
        padding: 12px 16px;
    }

    .col-hide-mobile {
        display: none;
    }

    .page-body {
        max-width: 100%;
    }

    .section-header {
        flex-wrap: wrap;
    }

    .filter-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .filter-btn {
        flex-shrink: 0;
    }

    .btn-hapus {
        padding: 4px 8px;
        font-size: 0.72rem;
    }

    tbody td {
        padding: 8px 10px;
    }

    thead th {
        padding: 8px 10px;
    }
}

@media (max-width: 400px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .rekap-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* Tombol aksi di section header turun ke bawah */
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .section-header .btn {
        width: 100%;
        justify-content: center;
    }
}