/* ============================================================
   assets/css/style.css
   Tema: dominan putih & biru tua, gaya administrasi perusahaan
   ============================================================ */

:root {
    --navy:        #0b2d5c;
    --navy-dark:   #071f42;
    --navy-soft:   #eaf0f8;
    --hijau:       #157347;
    --hijau-dark:  #0f5233;
    --merah:       #b02a37;
    --merah-dark:  #841f29;
    --abu-bg:      #f4f6fa;
    --border:      #e3e8f0;
}

body {
    background-color: var(--abu-bg);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #1f2937;
    font-size: 0.94rem;
}

/* ---------- Navbar ---------- */
.navbar-app {
    background-color: var(--navy);
    box-shadow: 0 2px 8px rgba(11, 45, 92, 0.18);
}
.brand-logo {
    height: 38px;               /* tinggi tetap seperti sebelumnya; lebar mengikuti proporsi logo */
    padding: 4px 7px;
    background: #ffffff;
    color: var(--navy);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.brand-logo img {
    height: 100%; width: auto;
    display: block;
}
.brand-nama { font-size: 0.95rem; letter-spacing: .3px; }
.brand-sub  { font-size: 0.7rem; color: rgba(255,255,255,.7); font-weight: 400; }

.navbar-app .nav-link {
    color: rgba(255,255,255,.82);
    font-size: .9rem;
    padding: .5rem .85rem;
    border-radius: 6px;
    margin-left: .15rem;
}
.navbar-app .nav-link:hover { color: #fff; background: rgba(255,255,255,.1); }
.navbar-app .nav-link.active { color: #fff; background: rgba(255,255,255,.18); font-weight: 600; }

/* ---------- Judul halaman ---------- */
.page-title {
    color: var(--navy);
    font-weight: 700;
    font-size: 1.3rem;
    margin-bottom: .15rem;
}
.page-sub { color: #6b7280; font-size: .85rem; }

/* ---------- Card ---------- */
.card {
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(11,45,92,.05);
}
.card-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--navy);
    padding: .85rem 1.1rem;
}

/* ---------- Card statistik ---------- */
.stat-card {
    border: none;
    color: #fff;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}
.stat-card .stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .6px; opacity: .85; }
.stat-card .stat-value { font-size: 1.45rem; font-weight: 700; margin-top: .25rem; line-height: 1.2; }
.stat-card .stat-note  { font-size: .75rem; opacity: .8; }
.stat-card .stat-icon  {
    position: absolute; right: 14px; top: 14px;
    font-size: 1.8rem; opacity: .22;
}
.stat-saldo      { background: linear-gradient(135deg, var(--navy), var(--navy-dark)); }
.stat-masuk      { background: linear-gradient(135deg, var(--hijau), var(--hijau-dark)); }
.stat-keluar     { background: linear-gradient(135deg, var(--merah), var(--merah-dark)); }
.stat-transaksi  { background: linear-gradient(135deg, #37517a, #23375a); }

/* ---------- Teks nominal ---------- */
.text-masuk  { color: var(--hijau); font-weight: 600; }
.text-keluar { color: var(--merah); font-weight: 600; }
.text-saldo  { color: var(--navy);  font-weight: 700; }

.badge-masuk  { background-color: var(--hijau) !important; font-weight: 500; }
.badge-keluar { background-color: var(--merah) !important; font-weight: 500; }

/* ---------- Tabel ---------- */
.table { font-size: .88rem; margin-bottom: 0; }
.table thead th {
    background-color: var(--navy);
    color: #fff;
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    vertical-align: middle;
    white-space: nowrap;
    border-color: var(--navy);
}
.table thead th a { color: #fff; text-decoration: none; }
.table thead th a:hover { text-decoration: underline; }
.table tbody tr:hover { background-color: var(--navy-soft); }
.table tfoot td { background-color: #f8fafc; font-weight: 600; }

/* ---------- Tombol ---------- */
.btn-navy { background-color: var(--navy); border-color: var(--navy); color: #fff; }
.btn-navy:hover, .btn-navy:focus { background-color: var(--navy-dark); border-color: var(--navy-dark); color: #fff; }
.btn-outline-navy { border-color: var(--navy); color: var(--navy); }
.btn-outline-navy:hover { background-color: var(--navy); color: #fff; }

/* ---------- Form ---------- */
.form-label { font-weight: 600; font-size: .85rem; color: #374151; margin-bottom: .3rem; }
.form-control:focus, .form-select:focus {
    border-color: var(--navy);
    box-shadow: 0 0 0 .18rem rgba(11,45,92,.12);
}
.wajib { color: var(--merah); }

/* ---------- Footer ---------- */
.footer-app {
    padding: 18px 0;
    margin-top: 30px;
    text-align: center;
    color: #6b7280;
    font-size: .8rem;
    border-top: 1px solid var(--border);
    background: #fff;
}

/* ---------- Kop laporan ---------- */
.kop-laporan {
    text-align: center;
    border-bottom: 3px double var(--navy);
    padding-bottom: 12px;
    margin-bottom: 22px;
}
.kop-laporan h3 { color: var(--navy); font-weight: 700; margin-bottom: 2px; font-size: 1.25rem; }
.kop-laporan .alamat { font-size: .82rem; color: #4b5563; margin-bottom: 8px; }
.kop-laporan .judul  { font-weight: 700; letter-spacing: 1px; margin-bottom: 0; }
.kop-laporan .periode{ font-size: .85rem; color: #4b5563; }

/* ---------- Tampilan cetak ---------- */
@media print {
    .no-print, .no-print * { display: none !important; }
    body { background: #fff !important; font-size: 11pt; }
    .container { max-width: 100% !important; width: 100% !important; padding: 0 !important; }
    .card { border: none !important; box-shadow: none !important; }
    .card-header { padding-left: 0; }
    .table thead th { background-color: #0b2d5c !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .stat-card { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .table { font-size: 10pt; }
    a { text-decoration: none !important; color: #000 !important; }
}

/* ---------- Responsif ---------- */
@media screen and (max-width: 767.98px) {
    .stat-card .stat-value { font-size: 1.2rem; }
    .brand-nama { font-size: .82rem; }
    .page-title { font-size: 1.1rem; }
}

/* =====================================================================
   TAMBAHAN: Halaman login, avatar, offcanvas, dan responsif mobile
   ===================================================================== */

/* ---------- Halaman login ---------- */
.halaman-login {
    background: linear-gradient(140deg, var(--navy) 0%, var(--navy-dark) 55%, #04152e 100%);
    min-height: 100vh;
}
.login-logo {
    width: 62px; height: 62px;
    margin: 0 auto;
    background: #fff;
    color: var(--navy);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.9rem;
    box-shadow: 0 6px 18px rgba(0,0,0,.25);
}
.halaman-login .card { border: none; border-radius: 12px; }

/* ---------- Avatar pengguna ---------- */
.avatar-bulat {
    width: 30px; height: 30px;
    background: rgba(255,255,255,.2);
    border: 1px solid rgba(255,255,255,.35);
    color: #fff;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .8rem; font-weight: 700;
    flex-shrink: 0;
}
.avatar-lg { width: 42px; height: 42px; font-size: 1rem; }
.avatar-tabel {
    width: 34px; height: 34px;
    background: var(--navy-soft);
    color: var(--navy);
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem;
}

/* ---------- Offcanvas menu mobile ---------- */
.offcanvas-app {
    background: var(--navy);
    color: #fff;
    width: 280px;
}
.offcanvas-app .offcanvas-header { border-bottom: 1px solid rgba(255,255,255,.15); }
.nav-mobile .nav-link {
    color: rgba(255,255,255,.85);
    padding: .7rem .8rem;
    border-radius: 8px;
    display: flex; align-items: center; gap: .7rem;
    font-size: .92rem;
}
.nav-mobile .nav-link i { width: 20px; text-align: center; font-size: 1.05rem; }
.nav-mobile .nav-link:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-mobile .nav-link.active { background: rgba(255,255,255,.2); color: #fff; font-weight: 600; }
.nav-mobile .text-danger-emphasis { color: #ffb3ba !important; }

/* ---------- Badge peran ---------- */
.badge-peran { font-size: .72rem; font-weight: 500; padding: .3em .6em; }

/* ---------- Tombol aksi melayang di mobile ---------- */
.fab-tambah {
    position: fixed;
    right: 18px;
    bottom: calc(18px + env(safe-area-inset-bottom));
    width: 54px; height: 54px;
    border-radius: 50%;
    background: var(--navy);
    color: #fff;
    display: none;
    align-items: center; justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 5px 16px rgba(11,45,92,.4);
    z-index: 1030;
    text-decoration: none;
}
.fab-tambah:hover, .fab-tambah:focus { color: #fff; background: var(--navy-dark); }

/* =====================================================================
   RESPONSIF MOBILE
   ===================================================================== */

/* ---------- Tablet ---------- */
@media (max-width: 991.98px) {
    .brand-nama { font-size: .85rem; max-width: 190px; }
}

/* ---------- Ponsel ---------- */
@media screen and (max-width: 767.98px) {

    body { font-size: .9rem; }

    .page-title { font-size: 1.05rem; }
    .page-sub   { font-size: .78rem; }

    .brand-logo { height: 34px; padding: 3px 6px; }
    .brand-nama { font-size: .8rem; max-width: 160px; }

    /* Kartu statistik lebih ringkas */
    .stat-card .stat-value { font-size: 1.1rem; }
    .stat-card .stat-label { font-size: .68rem; }
    .stat-card .stat-icon  { font-size: 1.3rem; top: 10px; right: 10px; }
    .stat-card .card-body  { padding: .8rem .9rem; }

    .card-header { padding: .7rem .85rem; font-size: .88rem; }
    .card-body   { padding: .9rem; }

    /* Tombol penuh di mobile */
    .btn-blok-mobile { width: 100%; }

    /* Tombol tambah melayang muncul */
    .fab-tambah { display: flex; }

    /* -------------------------------------------------------------
       TABEL RESPONSIF: berubah menjadi daftar kartu di layar kecil
       Setiap <td> memakai atribut data-label sebagai judul barisnya.
       ------------------------------------------------------------- */
    .tabel-responsif thead { display: none; }

    .tabel-responsif,
    .tabel-responsif tbody,
    .tabel-responsif tr,
    .tabel-responsif td { display: block; width: 100%; }

    .tabel-responsif tr {
        border: 1px solid var(--border);
        border-radius: 10px;
        margin-bottom: .7rem;
        padding: .3rem .1rem;
        background: #fff;
        box-shadow: 0 1px 3px rgba(11,45,92,.06);
    }
    .tabel-responsif tr:hover { background: #fff; }

    .tabel-responsif td {
        border: none !important;
        border-bottom: 1px dashed #eef1f6 !important;
        padding: .45rem .8rem !important;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 1rem;
        text-align: right;
        font-size: .86rem;
        max-width: none !important;
    }
    .tabel-responsif td:last-child { border-bottom: none !important; }

    .tabel-responsif td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        font-size: .76rem;
        text-transform: uppercase;
        letter-spacing: .3px;
        text-align: left;
        flex-shrink: 0;
        padding-top: 1px;
    }

    /* Kolom nominal ditonjolkan */
    .tabel-responsif td.kolom-nominal {
        background: #fafbfd;
        font-size: .98rem;
    }

    /* Kolom aksi: tombol sejajar kanan */
    .tabel-responsif td.kolom-aksi {
        justify-content: flex-end;
        gap: .4rem;
        padding-top: .6rem !important;
    }
    .tabel-responsif td.kolom-aksi::before { margin-right: auto; }
    .tabel-responsif td.kolom-aksi .btn { padding: .3rem .7rem; }

    /* Sembunyikan kolom nomor urut di mobile */
    .tabel-responsif td.kolom-no { display: none; }

    /* Baris "tidak ada data" tetap normal */
    .tabel-responsif td.kosong {
        display: block;
        text-align: center;
        border: none !important;
    }
    .tabel-responsif td.kosong::before { content: none; }

    /* Pagination lebih ringkas */
    .pagination { flex-wrap: wrap; justify-content: center; }

    /* Filter: label lebih rapat */
    .form-label { font-size: .8rem; margin-bottom: .2rem; }

    /* Grafik lebih tinggi agar terbaca */
    #grafikCashflow { min-height: 240px; }
}

/* ---------- Ponsel kecil ---------- */
@media (max-width: 400px) {
    .brand-sub { display: none; }
    .brand-nama { max-width: 130px; font-size: .75rem; }
    .stat-card .stat-value { font-size: 1rem; }
}

/* =====================================================================
   BUKTI TRANSAKSI (upload gambar)
   ===================================================================== */
/* Lebar kolom Bukti dikunci supaya tabel tidak melar */
th.kolom-bukti,
td.kolom-bukti { width: 92px; }

/* Thumbnail dibatasi KERAS (width/height + max-width/max-height) sehingga
   ukuran asli file tidak pernah menentukan tinggi baris tabel. */
.bukti-thumb {
    width: 70px;
    height: 70px;
    max-width: 70px;
    max-height: 70px;
    min-width: 0;
    object-fit: contain;
    object-position: center;
    display: block;
    margin: 0 auto;
    flex: 0 0 auto;          /* aman saat td menjadi flex di mode mobile */
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    padding: 2px;
    cursor: pointer;
    vertical-align: middle;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.bukti-thumb:hover {
    border-color: var(--navy, #0b2d5c);
    box-shadow: 0 0 0 2px rgba(11,45,92,.12);
}
.bukti-preview-form {
    width: 140px;
    height: 140px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fafbfd;
    padding: 4px;
}
/* Di dalam modal gambar ditampilkan BESAR, aspect ratio tetap, tidak terpotong */
#modalBukti .modal-dialog { max-width: min(90vw, 1100px); }
.bukti-modal-img {
    max-width: 80vw;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}
@media screen and (max-width: 767.98px) {
    th.kolom-bukti,
    td.kolom-bukti { width: auto; }
    .bukti-thumb {
        width: 60px;
        height: 60px;
        max-width: 60px;
        max-height: 60px;
        margin: 0;
    }
    #modalBukti .modal-dialog { max-width: 94vw; }
    .bukti-modal-img { max-width: 88vw; max-height: 72vh; }
}

/* ============================================================
   Modul Finance: label grup menu mobile & status invoice
   ============================================================ */
.nav-mobile-label {
    color: rgba(255,255,255,.55);
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .6px;
    padding: .35rem 1rem 0;
}


/* =====================================================================
   PERBAIKAN RESPONSIF MOBILE (tambahan)
   ===================================================================== */
@media screen and (max-width: 767.98px) {

    /* Cegah iOS/Android otomatis zoom saat menyentuh kolom isian (perlu >= 16px) */
    input.form-control, select.form-select, textarea.form-control,
    input.form-control-sm, select.form-select-sm {
        font-size: 16px;
    }
    .form-control, .form-select { min-height: 42px; }

    /* Tombol aksi di header halaman: pecah rata, mudah disentuh */
    .btn { --bs-btn-padding-y: .45rem; }
    .btn-group-mobile-full > .btn { flex: 1 1 auto; }

    /* Baris total (tfoot) pada tabel kartu */
    .tabel-responsif tfoot { display: block; }
    .tabel-responsif tfoot td:empty { display: none; }
    .tabel-responsif tfoot tr {
        background: #f8fafc;
        border-color: var(--border);
    }
    .tabel-responsif tfoot td[colspan] {
        justify-content: flex-end;
        font-weight: 700;
    }
    .tabel-responsif tfoot th {
        display: block; width: auto; border: none;
        padding: .4rem .8rem; text-align: right;
    }
    .tabel-responsif tfoot tr:has(th) {
        display: flex; justify-content: space-between; align-items: center;
    }
    .tabel-responsif tfoot tr:has(th) th[colspan] { flex: 1; }

    /* Tabel detail (label : isi) tidak boleh terlalu sempit */
    .tabel-detail th { width: 38% !important; white-space: normal; font-size: .8rem; }
    .tabel-detail td { word-break: break-word; }

    /* -------- Tabel item invoice (form) menjadi kartu per baris -------- */
    .tabel-item-form thead { display: none; }
    .tabel-item-form,
    .tabel-item-form tbody { display: block; width: 100%; }
    .tabel-item-form tr.baris-item {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: .55rem .6rem;
        align-items: end;
        margin: .7rem;
        padding: .8rem;
        border: 1px solid var(--border);
        border-radius: 10px;
        background: #fff;
        box-shadow: 0 1px 3px rgba(11,45,92,.06);
    }
    .tabel-item-form td {
        display: block;
        width: auto !important;
        border: none !important;
        padding: 0 !important;
        text-align: left !important;
    }
    .tabel-item-form td[data-label]::before {
        content: attr(data-label);
        display: block;
        margin-bottom: .2rem;
        font-size: .72rem;
        font-weight: 600;
        color: #6b7280;
        text-transform: uppercase;
        letter-spacing: .3px;
    }
    .tabel-item-form td:nth-child(1),
    .tabel-item-form td:nth-child(4) { grid-column: 1 / -1; }
    .tabel-item-form td.subtotal-baris { font-weight: 700; color: var(--navy); font-size: 1rem; }
    .tabel-item-form td:last-child { text-align: right !important; }
    .tabel-item-form td:last-child .btn { padding: .4rem .8rem; }

    /* Kartu ringkasan tidak lengket di mobile */
    .sticky-lg-top { position: static !important; }

    /* Modal gambar/konfirmasi penuh lebar */
    .modal-dialog { margin: .6rem; }
}

/* Canvas grafik tidak melebihi lebar layar */
canvas { max-width: 100%; }

/* Layar sangat kecil: rapatkan container */
@media (max-width: 575.98px) {
    .container { padding-left: .8rem; padding-right: .8rem; }
}
