/* style.css - Premium SaaS Invoice Theme (Final Version) */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

html {
    /* Ini pastikan ruang scrollbar sentiasa ada, jadi layout tak melompat */
    scrollbar-gutter: stable; 
}

:root {
    /* --- COLOR PALETTE --- */
    --sidebar-bg: #0f172a;    /* Dark Navy (Slate 900) */
    --sidebar-text: #94a3b8;  /* Slate 400 */
    --sidebar-hover: #1e293b; /* Slate 800 */
    --brand-color: #3b82f6;   /* Blue 500 */

    --bg-body: #f3f4f6;       /* Light Gray Background */
    --bg-card: #ffffff;       /* Pure White */
    
    --text-main: #111827;     /* Almost Black */
    --text-muted: #6b7280;    /* Gray Text */
    --border: #e5e7eb;        /* Light Border */
    
    --primary: #2563eb;       /* Action Blue */
    --danger: #ef4444;        /* Red */
    --success: #10b981;       /* Green */
    
    --radius: 8px;            /* Standard Corner Radius */
    --sidebar-w: 260px;       /* Fixed Sidebar Width */
    
    /* --- PENTING: Lebar Content Standard --- */
    --content-width: 1250px; 
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    display: flex;
    min-height: 100vh;
    font-size: 0.92rem;
}

/* --- 1. SIDEBAR NAVIGATION --- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    height: 100vh;
    display: flex; flex-direction: column; 
    z-index: 50; 
    transition: transform 0.3s ease;
}

.brand { 
    padding: 24px; 
    font-weight: 700; 
    font-size: 1.1rem; 
    color: white; 
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex; align-items: center; gap: 10px;
}

.nav-menu { flex: 1; padding: 20px 12px; display: flex; flex-direction: column; gap: 4px; }

.nav-item { 
    padding: 12px 16px; 
    text-decoration: none; 
    color: var(--sidebar-text); 
    font-weight: 500; 
    border-radius: 6px; 
    transition: 0.2s; 
    display: flex; align-items: center; gap: 12px; 
}

.nav-item:hover { background: var(--sidebar-hover); color: white; }
.nav-item.active { background: var(--brand-color); color: white; font-weight: 600; box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3); }

/* --- USER PROFILE (REDESIGNED) --- */
.user-profile {
    margin-top: auto; /* Tolak ke paling bawah sidebar */
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s;
}

.user-profile:hover {
    background: rgba(255, 255, 255, 0.05); /* Effect bila mouse lalu */
}

/* Avatar Bulat */
.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--brand-color); /* Guna warna biru brand */
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.1);
}

/* Info Text Wrapper */
.user-info {
    flex: 1; /* Ambil ruang tengah */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: var(--sidebar-text);
    margin-top: 2px;
}

/* Butang Logout (Icon Style) */
.btn-logout-icon {
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 1.2rem;
    padding: 8px;
    border-radius: 6px;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-logout-icon:hover {
    background: rgba(239, 68, 68, 0.1); /* Merah cair background */
    color: #ef4444; /* Merah terang icon */
}

/* --- 2. MAIN CONTENT AREA --- */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 30px 40px;
    width: calc(100% - var(--sidebar-w));
    display: flex;
    flex-direction: column;
    align-items: center; /* PENTING: Centerkan semua content */
}

/* Page Header (Title + Buttons) */
.page-header {
    width: 100%; 
    max-width: var(--content-width); /* Follow Standard Width */
    display: flex; justify-content: space-between; align-items: flex-end;
    margin-bottom: 30px;
}
.page-title { font-size: 1.75rem; font-weight: 700; color: #111827; margin: 0; letter-spacing: -0.02em; }
.page-desc { color: var(--text-muted); margin-top: 5px; font-size: 0.95rem; }

/* --- 3. CARDS & CONTAINERS --- */

/* Standard Card (Dashboard, Tables, Client List) */
.card {
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    padding: 25px;
    width: 100%; 
    max-width: var(--content-width); /* KUNCI KONSISTENSI */
    margin-bottom: 24px;
}

/* Special Invoice Paper (Create Invoice / Print) */
.invoice-paper {
    background: white;     /* Masih putih supaya teks jelas */
    border-radius: 8px;    /* Radius sikit */
    border: none;          /* BUANG BORDER KOTAK */
    box-shadow: none;      /* BUANG BAYANG KOTAK */
    padding: 20px;         /* Kurangkan padding supaya lebih luas */
    width: 100%;           /* Pakai lebar penuh */
    max-width: 100%;       /* Pastikan tiada had lebar */
    margin-bottom: 24px;
}

/* --- 4. DASHBOARD GRID --- */
.dashboard-grid {
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); 
    gap: 20px; 
    width: 100%; 
    max-width: var(--content-width); /* Follow Standard Width */
    margin-bottom: 30px;
}
.stat-card {
    background: white; padding: 24px; border-radius: 10px;
    border: 1px solid var(--border);
    display: flex; flex-direction: column; justify-content: space-between;
}
.stat-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: #111827; margin-top: 8px; }

/* --- 5. FORMS & INPUTS --- */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 6px; color: #374151; }

.form-control {
    width: 100%; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 6px;
    font-size: 0.9rem; font-family: inherit; outline: none; transition: 0.2s;
    background: #fff;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

/* Transparent Inputs (Inside Tables) */
.table-input {
    width: 100%; 
    padding: 8px; /* Padding lebih selesa */
    border: 1px solid #cbd5e1; 
    border-radius: 4px;
    background: #f8fafc;
    font-size: 0.9rem; 
    outline: none; 
    transition: 0.2s;
    
    /* INI PENTING: Pastikan input tak tolak layout */
    box-sizing: border-box; 
    display: block; 
    height: 38px; /* Tetapkan ketinggian supaya seragam */
}
.table-input:hover { background: #f9fafb; }
.table-input:focus { background: white; border-color: var(--primary); }

/* --- 6. TABLES (FIXED GRID OUTLINE) --- */
.table-responsive { 
    width: 100%; 
    overflow-x: auto; 
    border-radius: 8px; 
    /* Pastikan ada border di sini */
    border: 1px solid #cbd5e1; 
    overflow: hidden; 
    margin-bottom: 20px;
}

.table { 
    width: 100%; 
    border-collapse: collapse; 
    background: white; 
    /* Pastikan ini hidden supaya tidak bergaduh dengan border luar */
    border-style: hidden;
}

.table th {
    text-align: left; padding: 12px 16px;
    background: #f1f5f9; 
    border: 1px solid #cbd5e1; /* Border penuh kelabu gelap sikit */
    color: #475569; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
}

.table td { 
    padding: 8px; 
    border: 1px solid #cbd5e1; /* Border penuh kelabu gelap sikit */
    vertical-align: middle; 
}

/* INI PEMBETULANNYA: Paksa baris akhir ADA border bawah */
.table tr:last-child td { 
    border-bottom: 1px solid #cbd5e1 !important; 
}

.table tr:hover td { 
    background: #f8fafc; 
}

/* --- 7. BUTTONS & BADGES --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    height: 40px;        /* TETAPKAN KETINGGIAN */
    padding: 0 20px;     /* Padding hanya kiri-kanan, atas-bawah auto center */
    border-radius: 6px; font-weight: 500; font-size: 0.9rem;
    cursor: pointer; border: none; text-decoration: none; gap: 8px; transition: 0.2s;
    line-height: 1;      /* Pastikan teks duduk tengah elok */
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #1d4ed8; }

.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover { background: #fecaca; }

.btn-accent { background: #e0e7ff; color: #4338ca; }
.btn-accent:hover { background: #c7d2fe; }

/* --- STATUS BADGES (Fixed Width Update) --- */
.badge { 
    padding: 6px 12px; 
    border-radius: 99px; 
    font-size: 0.75rem; 
    font-weight: 700; 
    text-transform: uppercase; 
    
    /* Tambahan baru untuk elak bergerak: */
    min-width: 90px;          /* Lebar minimum tetap */
    text-align: center;       /* Teks duduk tengah */
    display: inline-block;    /* Supaya width berfungsi */
    letter-spacing: 0.5px;
}

.badge-paid { background: #d1fae5; color: #047857; }
.badge-unpaid { background: #fee2e2; color: #b91c1c; }

/* --- 8. MODAL / POPUP STYLE --- */
.modal-overlay {
    display: none; 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(4px);
    z-index: 100;
    justify-content: center; align-items: center;
}
.modal-overlay.active { display: flex; }

.modal-card {
    background: white;
    width: 100%; max-width: 500px;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    position: relative;
    animation: slideUp 0.3s ease-out;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 15px; margin-bottom: 20px;
}
.modal-title { font-size: 1.25rem; font-weight: 700; color: #111827; margin: 0; }
.btn-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #6b7280; }
.btn-close:hover { color: #ef4444; }

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* --- 9. MOBILE RESPONSIVE --- */
.mobile-topbar { display: none; width: 100%; justify-content: space-between; align-items: center; margin-bottom: 20px; }

@media (max-width: 900px) {
    /* 1. Sidebar & Layout Mobile */
    .sidebar { transform: translateX(-100%); width: 260px; box-shadow: 10px 0 30px rgba(0,0,0,0.1); }
    .sidebar.open { transform: translateX(0); }
    
    .main-content { margin-left: 0; width: 100%; padding: 15px; } /* Padding kecil sikit utk mobile */
    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    
    .mobile-topbar { display: flex; }
    .dashboard-grid { grid-template-columns: 1fr; }

    /* 2. TABLE SLIDING MAGIC (Ini yang buat dia boleh slide) */
    .table-responsive {
        overflow-x: auto;              /* Benarkan scroll kiri-kanan */
        -webkit-overflow-scrolling: touch; /* Scroll laju (smooth) utk iPhone/Android */
        margin-bottom: 15px;
    }

    .table th, 
    .table td {
        white-space: nowrap;  /* PENTING: Paksa teks jadi sebaris, jangan turun bawah */
        font-size: 0.85rem;   /* Kecilkan sikit font supaya nampak kemas di HP */
        padding: 10px 12px;   /* Jarak selesa utk jari touch */
    }

    /* Pilihan: Kecilkan sikit saiz butang dalam table supaya tak makan ruang */
    .table .btn {
        padding: 4px 10px;
        font-size: 0.75rem;
        height: 30px;
    }
    
    /* Pilihan: Sembunyikan column yang kurang penting jika perlu (Optional) 
       Contoh: kalau nak hide column 'Date' di mobile, uncomment bawah ni:
       .table th:nth-child(2), .table td:nth-child(2) { display: none; } 
    */
}

/* --- 10. PRINT STYLE --- */
@media print {
    .sidebar, .mobile-topbar, .btn, .no-print { display: none !important; }
    .main-content { margin: 0; padding: 0; width: 100%; }
    .invoice-paper { box-shadow: none; border: none; padding: 0; max-width: 100%; }
    .card { border: none; shadow: none; padding: 0; }
    body { background: white; -webkit-print-color-adjust: exact; }
    
    .form-control, .table-input { border: none; padding: 0; }
}
/* --- DOCUMENT SWITCHER TABS --- */
.doc-switcher {
    display: flex;
    background: #e2e8f0; /* Kelabu cair background */
    padding: 4px;
    border-radius: 8px;
    margin-right: 20px; /* Jarak sikit dari tajuk */
}

.switch-btn {
    display: inline-flex; align-items: center; justify-content: center;
    height: 32px;       /* UBAH: Jadi 32px supaya total height termasuk padding jadi 40px */
    padding: 0 16px;    /* UBAH: Kecilkan sikit padding kiri-kanan */
    text-decoration: none;
    font-size: 0.85rem; /* UBAH: Kecilkan sikit font supaya seimbang */
    font-weight: 600;
    color: #64748b;
    border-radius: 6px;
    transition: all 0.2s;
}

.switch-btn:hover {
    color: #1e293b;
    background: rgba(255,255,255,0.5);
}

/* Bila butang tu aktif */
.switch-btn.active {
    background: white;
    color: var(--primary); /* Biru */
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* --- ICON BUTTONS (Untuk Quotation Actions) --- */
.btn-group {
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Susun ke kanan */
    gap: 6px; /* Jarak antara butang */
}

.btn-icon {
    width: 32px;       /* Petak sekata */
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    text-decoration: none;
    font-size: 1rem;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn-icon:hover { transform: translateY(-2px); }

/* Warna Butang Approve (Hijau Lembut) */
.btn-success-soft { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.btn-success-soft:hover { background: #bbf7d0; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }

/* Warna Butang Reject (Merah Lembut) */
.btn-danger-soft { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.btn-danger-soft:hover { background: #fecaca; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }

/* Warna Butang Print (Ungu Lembut) */
.btn-accent-soft { background: #e0e7ff; color: #4338ca; border: 1px solid #c7d2fe; }
.btn-accent-soft:hover { background: #c7d2fe; }

/* --- HILANGKAN SPINNER (Arrow Atas/Bawah) PADA INPUT NUMBER --- */
/* Untuk Chrome, Safari, Edge, Opera */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Untuk Firefox */
input[type=number] {
    -moz-appearance: textfield;
}

/* Warna Badge Status Baru */
.badge-refunded { background: #e0f2fe; color: #0284c7; border: 1px solid #bae6fd; } /* Biru Langit */
.badge-forfeited { background: #f3f4f6; color: #374151; border: 1px solid #9ca3af; text-decoration: line-through; } /* Kelabu Potong */