:root {
    --bg-color: #F5F5F7;
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.4);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.04);
    --text-main: #1D1D1F;
    --text-muted: #86868b;
    --primary: #0071e3;
    --danger: #ff3b30;
    --sidebar-width: 280px;
    --radius: 16px;
    --bottom-nav-height: 70px;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0; padding: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    position: relative;
}

/* Noise Texture */
body::before {
    content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0.06;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* Glass Component */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
}

/* Layout */
#app-layout { display: flex; width: 100%; height: 100%; position: relative; z-index: 1; }

/* Sidebar - Default untuk Desktop */
aside { 
    width: var(--sidebar-width); 
    padding: 40px 24px; 
    display: flex; 
    flex-direction: column; 
    background: rgba(245, 245, 247, 0.8); 
    border-right: 1px solid rgba(0,0,0,0.05); 
    z-index: 10;
    flex-shrink: 0; /* Jangan biarkan sidebar menyusut */
}

aside .brand { font-size: 1.5rem; font-weight: 700; margin-bottom: 35px; letter-spacing: -0.5px; }
aside nav a { display: flex; align-items: center; gap: 14px; padding: 14px 18px; color: var(--text-muted); text-decoration: none; border-radius: 12px; margin-bottom: 6px; transition: 0.2s; font-weight: 500; }
aside nav a:hover { background: rgba(0, 0, 0, 0.03); color: var(--text-main); transform: translateX(4px); }
aside nav a.active { background: var(--primary); color: white; box-shadow: 0 4px 15px rgba(0, 113, 227, 0.3); transform: none; }

main { flex: 1; overflow-y: auto; padding: 30px; }
header { padding: 15px 30px; margin-bottom: 25px; display: flex; justify-content: space-between; align-items: center; }

/* Forms & Inputs */
input, select, textarea { width: 100%; background: rgba(255,255,255,0.8); border: 1px solid #d2d2d7; color: var(--text-main); padding: 14px; border-radius: 12px; font-family: inherit; transition: 0.2s; margin-bottom: 15px; -webkit-appearance: none; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1); }
label { display: block; margin-bottom: 8px; font-weight: 600; font-size: 0.9rem; color: var(--text-main); }

/* Tables */
table { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
th { text-align: left; color: var(--text-muted); padding: 0 15px; font-size: 0.75rem; text-transform: uppercase; font-weight: 600; }
td { background: rgba(255,255,255,0.85); color: var(--text-main); padding: 16px; border: 1px solid transparent; box-shadow: 0 2px 5px rgba(0,0,0,0.02); }
td:first-child { border-left: 1px solid var(--glass-border); border-top-left-radius: 10px; border-bottom-left-radius: 10px; }
td:last-child { border-right: 1px solid var(--glass-border); border-top-right-radius: 10px; border-bottom-right-radius: 10px; }
tr:hover td { background: white; transform: scale(1.005); transition: 0.2s; }

/* --- BUTTONS --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 99px; /* Pill shape buttons sangat ala MacOS */
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: 0.2s;
    text-decoration: none; /* <--- INI YANG MENGHILANGKAN GARIS BAWAH */
    outline: none; /* Opsional: Hilangkan kotak biru saat di-klik */
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 113, 227, 0.2);
}
.btn-primary:hover {
    background: #0077ed;
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(0, 113, 227, 0.3);
}

.btn-glass {
    background: white;
    color: var(--text-main);
    border: 1px solid #e5e5e5;
}
.btn-glass:hover {
    background: #f9f9f9;
    border-color: #d1d1d6;
    text-decoration: none; /* Pastikan hover juga tidak ada garis bawah */
}

.btn-danger {
    background: rgba(255, 59, 48, 0.08);
    color: var(--danger);
}
.btn-danger:hover {
    background: rgba(255, 59, 48, 0.15);
}

.btn-sm {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
}

/* Utils */
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; } .gap-4 { gap: 20px; } .mb-2 { margin-bottom: 15px; } .text-muted { color: var(--text-muted); }
.form-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; } .full-width { grid-column: span 2; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; }
.stat-value { font-size: 2.2rem; font-weight: 700; color: var(--text-main); margin-top: 10px; }

/* Mobile Toggle Button - HIDDEN BY DEFAULT */
.mobile-toggle { 
    display: none;
    background: none; 
    border: none; 
    font-size: 1.4rem; 
    color: var(--text-main); 
    cursor: pointer;
    padding: 8px;
}

/* Bottom Navigation - HIDDEN BY DEFAULT */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    z-index: 9998;
    padding: 0;
}

/* Sidebar Overlay - HIDDEN BY DEFAULT */
.sidebar-overlay {
    display: none;
    position: fixed; 
    inset: 0; 
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    backdrop-filter: blur(3px);
}

.sidebar-overlay.active { 
    display: block; 
}

.bottom-nav-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 0 10px;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--text-muted);
    transition: all 0.2s ease;
    border-radius: 12px;
    flex: 1;
    max-width: 80px;
}

.bottom-nav-item i {
    font-size: 1.3rem;
    transition: transform 0.2s ease;
}

.bottom-nav-item span {
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
}

.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-item.active i {
    transform: scale(1.1);
}

.bottom-nav-item:active {
    transform: scale(0.95);
}

/* Bottom Nav Menu Toggle - untuk buka sidebar di mobile */
.bottom-nav-item.menu-toggle {
    cursor: pointer;
}

.bottom-nav-item.menu-toggle.active {
    color: var(--text-muted);
}

.bottom-nav-item.menu-toggle:active {
    color: var(--primary);
}

/* =========================================
   RESPONSIVE DESIGN (TABLET & MOBILE)
   ========================================= */

/* Tablet & Mobile (Lebar < 900px) */
@media (max-width: 900px) {
    
    /* HIDE Mobile Toggle Button di Header - Tidak perlu lagi karena ada bottom nav */
    #mobile-toggle-btn { 
        display: none !important;
    }
    
    /* SHOW Bottom Navigation */
    .bottom-nav {
        display: block;
    }
    
    /* FORCE Hide Sidebar di Mobile - Jangan tampilkan sama sekali */
    aside {
        display: none !important;
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        width: 280px;
        z-index: 10000; 
        background: #ffffff; 
        box-shadow: 5px 0 25px rgba(0,0,0,0.15);
        transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding: 30px 20px;
        overflow-y: auto;
    }
    
    /* Saat aktif (diklik dari bottom nav "Lainnya"), tampilkan sidebar */
    aside.active { 
        display: flex !important;
        flex-direction: column;
        left: 0;
    }
    
    aside nav { flex: 1; }
    
    /* Main Content - Full Width tanpa sidebar */
    main { 
        width: 100% !important;
        margin-left: 0 !important;
        padding: 20px;
        padding-bottom: calc(var(--bottom-nav-height) + 20px);
    }
    
    /* App Layout - Stack vertically */
    #app-layout {
        flex-direction: column;
    }
    
    /* Sembunyikan menu utama yang sudah ada di bottom nav, kecuali Produk */
    aside nav a[href*="dashboard.php"],
    aside nav a[href*="invoice_list.php"],
    aside nav a[href*="invoice_create.php"],
    aside nav a[href*="customers.php"] {
        display: none !important;
    }
    
    /* Menu Settings & Produk tetap tampil di sidebar mobile */
    aside nav a[href*="settings.php"],
    aside nav a[href*="products.php"] {
        display: flex !important;
    }
    
    /* Overlay - Hanya muncul saat sidebar active */
    .sidebar-overlay.active { 
        display: block; 
    }

    /* Header */
    header { padding: 15px 20px; }

    /* Table Responsive */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Grid Stacking */
    .stats-grid, .form-grid { grid-template-columns: 1fr; }
    
    div[style*="grid-template-columns: 320px 1fr"],
    div[style*="grid-template-columns: 2fr 1fr"] {
        display: flex !important;
        flex-direction: column !important;
    }
}

/* Mobile Kecil (HP < 600px) */
@media (max-width: 600px) {
    .brand-text { display: block; } 
    input, select, textarea { font-size: 16px; }
    aside nav a { font-size: 0.95rem; padding: 15px 10px; }
    
    /* Bottom nav items smaller text */
    .bottom-nav-item span {
        font-size: 0.65rem;
    }
    
    .bottom-nav-item i {
        font-size: 1.2rem;
    }
}

/* =========================================
   BREATHABLE DESIGN SYSTEM (LEBIH NYAMAN DIPANDANG)
   ========================================= */

/* 1. Kartu yang lebih luas (Padding Lebih Besar) */
.card-spacious {
    padding: 40px; /* Padding standar 20px -> 40px agar lebih lega */
    background: var(--glass-bg);
    border-radius: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--glass-border);
}

/* 2. Tabel dengan Baris Mengambang (Floating Rows) */
.table-breath {
    width: 100%;
    border-collapse: separate; /* Kunci untuk spacing antar baris */
    border-spacing: 0 12px; /* Jarak 12px antar baris (Breath) */
}

.table-breath th {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 20px;
    text-align: left;
}

.table-breath td {
    background: rgba(255, 255, 255, 0.8); /* Putih transparan */
    border: 1px solid rgba(0,0,0,0.03);
    padding: 20px; /* Padding dalam baris tabel diperbesar */
    border-radius: 12px; /* Sudut membulat agar lembut */
    color: var(--text-main);
    font-size: 0.95rem;
    transition: all 0.2s;
}
/* Membuat efek hover yang lembut */
.table-breath tr:hover td {
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transform: translateY(-2px);
    border-color: rgba(0,0,0,0.08);
}

/* 3. Form Input yang lebih nyaman */
.input-breath {
    padding: 16px 18px; /* Input lebih tinggi */
    font-size: 0.95rem;
    background: white;
    border: 1px solid #e5e7eb; /* Abu-abu lembut */
    border-radius: 12px;
    margin-bottom: 20px; /* Jarak antar input lebih lega */
}

/* 4. Layout Split yang Responsif */
.layout-split {
    display: grid;
    grid-template-columns: 350px 1fr; /* Kiri lebar tetap 350px */
    gap: 30px;
    align-items: start;
}

/* 5. Utility Header yang lembut */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(0,0,0,0.05); /* Border sangat tipis */
}
.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
}
.section-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 5px;
    font-weight: 400;
}

/* Print (A4 Single Page) */
@media print {
    body::before, aside, header, .mobile-toggle, .sidebar-overlay, .bottom-nav, .no-print, .btn { display: none !important; }
    body { background: white; color: black; height: auto; overflow: visible; display: block; }
    #app-layout { display: block; height: auto; }
    main { padding: 0; overflow: visible; }
    .glass { background: none; border: none; box-shadow: none; backdrop-filter: none; }
    table { width: 100%; border-collapse: collapse; border-spacing: 0; }
    th, td { border: 1px solid #000; background: white !important; color: black; padding: 10px; box-shadow: none !important; }
    td:first-child, td:last-child { border-radius: 0; }
    tr:hover td { transform: none; }
    @page { size: A4; margin: 0; }
}