/* ============================================================
   Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; padding: 0; }
table, th, td { text-align: center; }

/* ============================================================
   Action buttons (table rows)
   ============================================================ */
div.action-btn a {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 15px;
    background-color: #6c757d;
    line-height: 30px;
}
div.action-btn a:hover { background-color: #343a40; }

/* ============================================================
   Bootstrap SVG icons
   ============================================================ */
.bi {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    vertical-align: -.125em;
    fill: currentcolor;
}

/* ============================================================
   Sidebar  (YouTube-style rounded pill)
   ============================================================ */
@media (width >= 768px) {
    .sidebar .offcanvas-md,
    .sidebar .offcanvas-lg {
        position: static;
    }
}

/* Padding wrapper agar pill tidak mepet pinggir sidebar */
.sidebar .offcanvas-body > .nav,
.sidebar .offcanvas-body > ul.nav {
    padding: 8px 8px 4px;
}

/* ── Nav link utama ── */
.sidebar .nav-link {
    border-radius: 10px;
    padding: 8px 14px;
    min-height: 40px;
    font-size: .875rem;
    font-weight: 500;
    color: #111827;
    transition: background .12s ease;
}

.sidebar .nav-link:hover {
    background: rgb(0 0 0 / 6%);
    color: #111827;
}

.sidebar .nav-link.active {
    background: #e2e5e9;
    font-weight: 600;
    color: #111827;
}

/* Hapus garis biru kiri */
.sidebar .nav-link.active::before { display: none; }

.sidebar-heading { font-size: .75rem; }

/* ── Section toggle (Tagihan, Laporan, dst.) ── */
.sidebar-toggle {
    background: none;
    border: none;
    border-radius: 10px;
    padding: 8px 14px;
    min-height: 40px;
    color: #111827;
    font-size: .875rem;
    font-weight: 500;
    width: 100%;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background .12s ease;
}
.sidebar-toggle:hover { background: rgb(0 0 0 / 6%); color: #111827; }

.sidebar-toggle.active-section {
    background: rgb(0 0 0 / 6%);
    font-weight: 600;
    color: #111827;
}

.sidebar-toggle .chevron {
    margin-left: auto;
    flex-shrink: 0;
    transition: transform .2s ease;
}
.sidebar-toggle[aria-expanded="true"] .chevron { transform: rotate(90deg); }

/* ── Sub-nav item ── */
.sidebar .sub-nav .nav-link {
    font-size: .8125rem;
    font-weight: 400;
    min-height: 36px;
    padding: 6px 14px;
    border-radius: 8px;
}

.sidebar .sub-nav .nav-link.active {
    background: #e2e5e9;
    font-weight: 600;
    color: #111827;
}
.sidebar .sub-nav .nav-link.active::before { display: none; }

/* Label grup (tidak interaktif) */
.sidebar .sub-nav .nav-link[style*="cursor:default"] {
    background: none !important;
    cursor: default !important;
    min-height: unset;
    padding-top: 10px;
    padding-bottom: 2px;
    font-size: .72rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* ============================================================
   Navbar (topbar)
   ============================================================ */
.app-topbar {
    min-height: 72px;
    background: #212529;
    box-shadow: 0 3px 12px rgb(15 23 42 / 14%);
    z-index: 1030;
}

.navbar-brand {
    min-width: 0;
    padding: .5rem 1rem;
}

.brand-logo-frame {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    height: 40px;
}

.brand-logo {
    display: block;
    width: auto;
    height: auto;
    max-width: 160px;
    max-height: 40px;
    object-fit: contain;
}

.brand-name {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
}

/* ── Collapsible sidebar ─────────────────────────────── */
@media (width >= 768px) {
  .sidebar {
    overflow: hidden;
    transition: width .24s ease, flex-basis .24s ease, max-width .24s ease,
                padding .24s ease, border-color .24s ease;
  }

  body.sb-hidden .sidebar {
    width: 72px !important;
    flex: 0 0 72px !important;
    max-width: 72px !important;
    padding: 0 !important;
  }
  body.sb-hidden .sidebar .offcanvas-md { display: none !important; }

  body.sb-hidden main {
    max-width: calc(100% - 72px) !important;
    flex: 0 0 calc(100% - 72px) !important;
    margin-left: 0 !important;
  }
}

.sb-toggle-btn {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: rgb(255 255 255 / 75%);
  padding: 0;
  cursor: pointer;
  transition: color .15s ease, background-color .15s ease;
}

.sb-toggle-btn:hover {
  color: #fff;
  background: rgb(255 255 255 / 10%);
}

/* ============================================================
   Login page
   ============================================================ */
.form-signin { max-width: 380px; padding: 1.5rem; }
.form-signin .form-floating:focus-within { z-index: 2; }
.form-signin .form-floating + .form-floating { margin-top: -1px; }

.form-signin .form-floating:first-of-type input {
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 0;
}

.form-signin .form-floating:last-of-type input {
    border-top-right-radius: 0;
    border-top-left-radius: 0;
    margin-bottom: 10px;
}

/* ============================================================
   Forms — invalid feedback always visible when is-invalid set
   ============================================================ */
.was-validated .form-control:invalid ~ .invalid-feedback,
.form-control.is-invalid ~ .invalid-feedback,
.was-validated .form-select:invalid ~ .invalid-feedback,
.form-select.is-invalid ~ .invalid-feedback,
.was-validated .form-check-input:invalid ~ .invalid-feedback,
.form-check-input.is-invalid ~ .invalid-feedback { display: block; }

/* ============================================================
   Tables
   ============================================================ */
.table th {
  font-size: .8125rem;
  font-weight: 600;
  white-space: nowrap;
}
.table td { font-size: .875rem; vertical-align: middle; }

/* ============================================================
   Utility classes — text size
   ============================================================ */
.text-xs    { font-size: .75rem !important; }
.text-xxs   { font-size: .68rem !important; }
.text-micro { font-size: .65rem !important; }

/* ============================================================
   Utility classes — sticky table columns
   ============================================================ */
.table-sticky-col {
  position: sticky;
  left: 0;
  z-index: 1;
  background-color: var(--bs-body-bg);
}

.table-sticky-col-2 {
  position: sticky;
  left: 0;
  z-index: 1;
  background-color: var(--bs-table-bg, var(--bs-body-bg));
}

/* ============================================================
   Utility classes — report table
   ============================================================ */
.report-table th,
.report-table td { font-size: .78rem; vertical-align: middle; }

/* ============================================================
   Utility classes — KPI / stat card
   ============================================================ */
.kpi-val {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.15;
}

.kpi-label {
  font-size: .7rem;
  color: var(--bs-secondary-color);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ============================================================
   Utility classes — scroll panel
   ============================================================ */
.scroll-panel { overflow-y: auto; }
.scroll-panel-sm  { max-height: 240px; overflow-y: auto; }
.scroll-panel-md  { max-height: 360px; overflow-y: auto; }
.scroll-panel-lg  { max-height: 480px; overflow-y: auto; }

/* ============================================================
   Utility classes — soft badges (alternative to Bootstrap subtle)
   ============================================================ */
.badge-soft-primary   { background: #dbeafe; color: #1d4ed8; }
.badge-soft-success   { background: #dcfce7; color: #15803d; }
.badge-soft-warning   { background: #fef9c3; color: #92400e; }
.badge-soft-danger    { background: #fee2e2; color: #b91c1c; }
.badge-soft-secondary { background: #f1f5f9; color: #475569; }
.badge-soft-purple    { background: #ede9fe; color: #6d28d9; }

/* ============================================================
   Utility classes — truncate with ellipsis
   ============================================================ */
.text-truncate-col {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 0;
}

/* ============================================================
   Print styles (kwitansi)
   ============================================================ */
@media print {
  .sidebar, .navbar, .app-topbar, .no-print, footer, .btn { display: none !important; }
  main { margin: 0 !important; padding: 0 !important; }
  .col-md-9, .col-lg-10 { width: 100% !important; max-width: 100% !important; }
}

/* ── Kwitansi print view ──────────────────────────────────── */
.kwitansi-page {
  max-width: 680px;
  margin: 0 auto;
}

/* ── Kwitansi / Bukti Pembayaran (landscape, compact) ──────── */
.kwitansi-land {
  max-width: 1040px;
  margin: 0 auto;
  padding: 16px 22px;
  border: 1px solid #ccc;
  background: #fff;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  color: #000;
}
.kwitansi-land table { border-collapse: collapse; }

/* Header */
.kw-head { width: 100%; border-bottom: 2.5px solid #000; padding-bottom: 6px; }
.kw-head td { vertical-align: middle; }
.kw-brand { display: flex; align-items: flex-start; gap: 10px; }
.kw-brand img { max-width: 48px; height: auto; flex-shrink: 0; margin-top: 2px; }
.kw-brand-text { display: flex; flex-direction: column; }
.kw-school { font-weight: 900; font-size: 15px; }
.kw-unit { font-size: 12px; color: #000; font-weight: 700; }
.kw-title { text-align: right; }
.kw-doc { font-weight: 900; font-size: 19px; letter-spacing: 1.5px; }
.kw-no { color: #c00; font-weight: 900; font-size: 16px; }
.kw-date { font-size: 12px; font-weight: 700; }

/* Two-column grid */
.kw-grid { display: flex; gap: 24px; margin-top: 10px; }
.kw-col { flex: 1 1 0; min-width: 0; }

/* Sections + lines */
.kw-section { font-weight: 900; background: #ddd; padding: 2px 6px; margin: 8px 0 4px; }
.kw-section:first-child { margin-top: 0; }
.kw-line { display: flex; justify-content: space-between; gap: 12px; padding: 1px 2px; }
.kw-line .lbl { color: #000; flex-shrink: 0; }
.kw-line .val { text-align: right; }
.kw-amount { font-weight: 900; font-size: 16px; }
.kw-refund { color: #c00; font-weight: 900; }
.kw-item-paid  { background: #e6f4ea; }
.kw-item-partial { background: #fff8e1; }
.kw-check { color: #1a7f3c; font-weight: 900; margin-right: 3px; }

/* Invoice status stamp */
.inv-stamp {
  display: inline-block;
  border-width: 2.5px;
  border-style: solid;
  font-size: 13px;
  font-weight: 900;
  padding: 2px 10px;
  letter-spacing: 2px;
  margin-top: 4px;
  transform: rotate(-5deg);
}
.inv-stamp-lunas   { border-color: #1a7f3c; color: #1a7f3c; }
.inv-stamp-cicilan { border-color: #b45309; color: #b45309; }
.inv-stamp-overdue { border-color: #b91c1c; color: #b91c1c; }

/* History table */
.kw-hist { width: 100%; }

.kw-hist th, .kw-hist td {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 5px;
  border-bottom: 1px solid #999;
  text-align: left;
}
.kw-hist th { background: #ddd; font-weight: 900; }
.kw-hist .num { text-align: right; }
.kw-hist tr.current { font-weight: 900; }
.kw-hist tfoot td { border-top: 2px solid #000; font-weight: 900; }

/* Barcodes + QR */
.kw-barcodes {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.kw-qr { text-align: center; flex-shrink: 0; }

.kw-qr svg,
.kw-qr img { width: 116px; height: 116px; display: block; }
.kw-barcode-group { display: flex; flex-direction: column; gap: 8px; }
.kw-barcode { text-align: center; }
.kw-barcode svg { height: 32px; width: auto; max-width: 240px; display: block; }

.kw-barcode .code,
.kw-qr .code { font-size: 12px; font-weight: 700; letter-spacing: 1px; margin-top: 1px; }

/* Footer: signature + disclaimer */
.kw-foot {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 14px;
  align-items: flex-end;
}
.kw-sign { text-align: center; min-width: 190px; }
.kw-sign .line { margin-top: 26px; border-top: 1.5px solid #000; padding-top: 2px; }
.kw-disclaimer { font-size: 11px; font-weight: 700; line-height: 1.4; text-align: justify; color: #000; }

@media print {
  @page { size: a4 landscape; margin: 8mm; }
  body { background: #fff !important; }
  .kwitansi-land { border: none; max-width: 100%; padding: 0; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ── Rekap penerimaan table ───────────────────────────────── */
.rekap-table th, .rekap-table td {
  font-size: .78rem;
  padding: .3rem .4rem;
}
.rekap-table tfoot td { font-weight: 600; background-color: var(--bs-light); }

/* ── Billing row status colors ────────────────────────────── */
.row-lunas   { background-color: rgb(25 135 84 / 6%); }
.row-partial { background-color: rgb(255 193 7 / 8%); }
.row-unpaid  { background-color: rgb(220 53 69 / 4%); }

/* ── Utility ──────────────────────────────────────────────── */
.w-40 { width: 40%; }
.cursor-pointer { cursor: pointer; }
code { font-size: .85em; }
