/* ============================================
   OAFINDO-STYLE — Sidebar gelap + chrome korporat
   Dimuat paling akhir agar meng-override main.css.
   Mudah dibalik: hapus 1 <link> di index.html.
   ============================================ */

/* ---------- Sidebar gelap ---------- */
.sidebar {
    background: #0f172a !important;
    border-right: 1px solid rgba(255, 255, 255, 0.07) !important;
}

.sidebar-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar-logo {
    color: #ffffff;
}

/* Logo gambar dipaksa putih agar kontras di sidebar gelap */
.sidebar-logo-full,
.sidebar-logo-icon {
    filter: brightness(0) invert(1);
    opacity: 0.96;
}

/* Label section "MENU" */
.nav-label {
    color: #64748b;
    font-weight: 600;
    letter-spacing: 0.6px;
}

/* Item menu */
.nav-link {
    color: #cbd5e1;
    font-weight: 500;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}

/* Active: pill hijau halus + ikon hijau terang, tanpa bar kiri */
.nav-item.active .nav-link {
    background: rgba(34, 197, 94, 0.15);
    color: #ffffff;
}

.nav-item.active .nav-link i {
    color: #4ade80;
}

.nav-link::before {
    display: none !important;
}

.nav-link i {
    color: #94a3b8;
}

.nav-link:hover i,
.nav-item.active .nav-link:hover i {
    color: inherit;
}

/* Badge counter di item menu (mis. Approval) tetap kontras */
.nav-link .badge,
#approval-badge,
#pengajuan-badge {
    margin-left: auto;
}

/* ---------- Footer user di sidebar ---------- */
.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.user-name {
    color: #f1f5f9;
}

.user-role {
    color: #94a3b8;
}

.btn-logout {
    color: #94a3b8;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.9);
    color: #ffffff;
}

/* ---------- Toggle collapse ---------- */
.sidebar-toggle {
    color: #94a3b8;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

/* ---------- Top bar lebih bersih ---------- */
.top-bar {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

/* ---------- Konten: latar abu lembut ala SaaS ---------- */
body {
    background-color: #f1f5f9 !important;
}

/* Kartu sedikit lebih lembut (radius + border halus) */
.card,
.stat-card,
.dashboard-card,
.data-card {
    border: 1px solid #e9eef4;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    border-radius: 14px;
}

/* ---------- Tabel ala Oafindo (clean, lapang) ---------- */
.reports-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.reports-table thead th {
    background: #f8fafc;
    color: #64748b;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    padding: 12px 16px !important;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

.reports-table tbody td {
    padding: 14px 16px !important;
    border-bottom: 1px solid #f1f5f9 !important;
    color: #334155;
    vertical-align: middle;
}

.reports-table tbody tr {
    transition: background 0.12s ease;
    border-bottom: none !important;
}

.reports-table tbody tr:hover {
    background: #f8fafc;
}

.reports-table tbody tr:last-child td {
    border-bottom: none !important;
}

/* Pill/badge dalam tabel sedikit lebih rapi */
.reports-table .badge,
.reports-table .status-badge {
    font-weight: 600;
    border-radius: 999px;
    padding: 3px 11px;
    font-size: 11.5px;
}

/* ============================================
   POLISH SIDEBAR — jarak, font, ikon rapi
   (override main.css, dimuat paling akhir)
   ============================================ */

/* Header & logo: padding lega, logo proporsional */
.sidebar-header {
    padding: 18px 20px;
    min-height: 68px;
}
.sidebar-logo-full { height: 30px; }
.sidebar-logo-icon { height: 30px; }

/* Area nav: ritme vertikal lebih rapat & teratur */
.sidebar-nav {
    padding: 12px 0 16px;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}
.nav-section { margin-bottom: 18px; }
.nav-section:last-child { margin-bottom: 4px; }

/* Label section: kecil, kalem, jarak konsisten */
.nav-label {
    padding: 0 20px;
    margin-bottom: 8px;
    font-size: 10.5px;
    letter-spacing: 0.7px;
}

/* Item menu: padding seimbang, font 14px, ikon sejajar */
.nav-list { padding: 0 12px; }
.nav-item { margin-bottom: 3px; }
.nav-link {
    gap: 12px;
    padding: 9px 12px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
}
.nav-link i {
    font-size: 16px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}
.nav-link span { font-size: 14px; }

/* Active pill sedikit lebih tegas */
.nav-item.active .nav-link { font-weight: 600; }

/* Footer user: rapi, sejajar */
.sidebar-footer { padding: 14px 16px; }
.user-name { font-size: 13.5px; }
.user-role { font-size: 11.5px; }

/* ---------- RAIL MODE (collapsed) ---------- */
.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}
.sidebar.collapsed .nav-list { padding: 0 10px; }
.sidebar.collapsed .nav-link {
    justify-content: center;
    gap: 0;
    padding-left: 0;
    padding-right: 0;
    position: relative;
}
.sidebar.collapsed .nav-link i { width: auto; }

/* Label jadi tooltip mengambang saat hover (bukan badge ber-id) */
.sidebar.collapsed .nav-link > span:not([id]) {
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    width: auto;
    height: auto;
    padding: 6px 11px;
    background: #0f172a;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 7px;
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3);
    transition: opacity 0.15s ease;
    z-index: 300;
}
.sidebar.collapsed .nav-link:hover > span:not([id]) { opacity: 1; }

/* Badge counter jadi titik kecil di pojok ikon saat collapsed */
.sidebar.collapsed .nav-link > span[id] {
    position: absolute;
    top: 6px;
    right: 14px;
    min-width: 9px;
    width: 9px;
    height: 9px;
    padding: 0;
    margin: 0 !important;
    font-size: 0;
    line-height: 0;
    border-radius: 50%;
}

/* Footer collapsed: avatar di tengah, sisanya disembunyikan */
.sidebar.collapsed .user-profile { justify-content: center; }
.sidebar.collapsed .btn-logout { display: none; }

/* Active state di collapsed tetap kebaca: pill penuh */
.sidebar.collapsed .nav-item.active .nav-link {
    background: rgba(34, 197, 94, 0.16);
}

/* ============================================
   TOP BAR — satu baris ringkas (toggle + judul + jam)
   ============================================ */
.top-bar {
    padding-top: 12px;
    padding-bottom: 12px;
    min-height: 60px;
}
/* .top-bar-left tak punya style di main.css → tombol & <h1> menumpuk ke bawah. Jadikan 1 baris. */
.top-bar-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}
.page-title {
    font-size: 19px;
    line-height: 1.2;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.current-time { line-height: 1.15; }
.current-time .time { font-size: 15px; }

/* ============================================
   COLLAPSE lebih mulus (kurangi reflow saat menyempit)
   ============================================ */
.sidebar {
    transition: width 0.22s ease;
    will-change: width;
}
.main-content,
.sidebar.collapsed ~ .main-content {
    transition: margin-left 0.22s ease;
}
/* Teks menu tak membungkus saat sidebar menyempit = sumber utama "ngadat" hilang */
.nav-link { white-space: nowrap; overflow: hidden; }
.nav-link span { white-space: nowrap; }

/* ============================================
   DASHBOARD — elegant corporate (gaya Oafindo)
   ============================================ */
.oaf-welcome {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin: 4px 0 24px;
}
.oaf-welcome h1 {
    margin: 0;
    font-size: 30px;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.8px;
    line-height: 1.15;
}
.oaf-welcome-sub { margin: 8px 0 0; font-size: 14.5px; color: #64748b; }
.oaf-welcome-date { margin: 3px 0 0; font-size: 12px; color: #94a3b8; }
.oaf-refresh {
    background: #fff;
    color: #475569;
    border: 1px solid #e2e8f0;
    padding: 9px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.oaf-refresh:hover { background: #f8fafc; border-color: #cbd5e1; color: #15803d; }

.oaf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}
.oaf-stat {
    background: #fff;
    border: 1px solid #e9eef4;
    border-radius: 16px;
    padding: 22px 24px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
    transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.oaf-stat:hover { box-shadow: 0 12px 26px -12px rgba(15, 23, 42, 0.18); transform: translateY(-1px); }
.oaf-stat.clickable { cursor: pointer; }
.oaf-stat-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.oaf-stat-label { font-size: 13.5px; font-weight: 600; color: #64748b; }
.oaf-stat-ico {
    width: 44px;
    height: 44px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.oaf-stat-value {
    font-size: 27px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.05;
    letter-spacing: -0.6px;
}
.oaf-stat-value small { font-size: 14px; font-weight: 600; color: #94a3b8; letter-spacing: 0; }
.oaf-stat-value.warn { color: #ea580c; }
.oaf-stat-value.good { color: #15803d; }
.oaf-stat-desc { font-size: 12.5px; color: #94a3b8; margin-top: 9px; }
.oaf-stat-desc.link { color: #15803d; font-weight: 500; }

@media (max-width: 640px) {
    .oaf-welcome h1 { font-size: 24px; }
    /* HP: kartu dashboard 2 per baris (lebih rapi & ringkas) */
    .oaf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
    .oaf-stat { padding: 14px 13px; border-radius: 14px; }
    .oaf-stat-head { margin-bottom: 8px; }
    .oaf-stat-label { font-size: 12px; }
    .oaf-stat-ico { width: 32px; height: 32px; border-radius: 10px; font-size: 14px; }
    .oaf-stat-value { font-size: 23px; letter-spacing: -0.4px; }
    .oaf-stat-value small { font-size: 11px; }
    .oaf-stat-desc { font-size: 11px; margin-top: 5px; }
}

/* ============================================
   PENGATURAN — hub kartu (gaya Kledo)
   ============================================ */
.set-group-title {
    font-size: 12px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin: 18px 0 12px;
}
.set-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 16px;
    margin-bottom: 6px;
}
.set-card {
    background: #fff;
    border: 1px solid #e9eef4;
    border-radius: 16px;
    padding: 22px 20px;
    cursor: pointer;
    transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}
.set-card:hover {
    box-shadow: 0 12px 26px -12px rgba(15, 23, 42, 0.16);
    transform: translateY(-2px);
    border-color: #dbe3ec;
}
.set-card-ico {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    margin-bottom: 14px;
}
.set-card h4 { margin: 0; font-size: 14.5px; font-weight: 700; color: #0f172a; }
.set-card p { margin: 5px 0 0; font-size: 12px; color: #94a3b8; line-height: 1.4; }
#set-back:hover { background: #f8fafc; border-color: #cbd5e1; color: #15803d; }

/* ============================================
   PENGINGAT PIUTANG — tabel responsif (kurangi scroll horizontal)
   Kolom kurang penting otomatis hilang & sel mengecil di layar sempit.
   Prioritas tetap tampil: Customer, Sisa Tagihan, Status, Tindakan.
   ============================================ */
#piutang-tbl .pi-aksi-sel { min-width: 150px; }
#piutang-tbl .pi-aksi-inp { min-width: 130px; }

/* Layar makin sempit → sembunyikan bertahap dari yang paling kurang penting */
@media (max-width: 1300px) {
    #piutang-tbl .pi-c-ket { display: none; }          /* Keterangan (input lebar) */
}
@media (max-width: 1080px) {
    #piutang-tbl .pi-c-inv { display: none; }           /* No. Invoice (customer jadi penanda utama) */
}
@media (max-width: 920px) {
    #piutang-tbl .pi-c-date { display: none; }          /* Tgl Jatuh Tempo (Umur & Status sudah mewakili) */
}
@media (max-width: 760px) {
    #piutang-tbl .pi-c-umur { display: none; }          /* Umur (badge Status sudah menunjukkan kategori) */
    #piutang-tbl th, #piutang-tbl td { padding: 9px 8px !important; }
    #piutang-tbl .pi-aksi-sel, #piutang-tbl .pi-aksi-inp { min-width: 0; font-size: 11px; padding: 5px 6px; }
    #piutang-tbl { font-size: 12px; }
}
