/* QIMS — gaya asas. Profesional, minimalis, mesra telefon. */
:root {
  --qi-primary: #1f3a5f;
  --qi-primary-600: #172d4a;
  --qi-accent: #e8a33d;
  --qi-bg: #f4f5f7;
  --qi-surface: #ffffff;
  --qi-border: #e3e6ea;
  --qi-text: #1d2430;
  --qi-muted: #6b7380;
  --qi-sidebar-w: 248px;
  --qi-bottom-h: 64px;
  --bs-body-font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-primary: var(--qi-primary);
  --bs-primary-rgb: 31, 58, 95;
  --bs-link-color: var(--qi-primary);
  --bs-link-hover-color: var(--qi-primary-600);
  --bs-border-color: var(--qi-border);
}

body { background: var(--qi-bg); color: var(--qi-text); }
.btn-primary { --bs-btn-bg: var(--qi-primary); --bs-btn-border-color: var(--qi-primary); --bs-btn-hover-bg: var(--qi-primary-600); --bs-btn-hover-border-color: var(--qi-primary-600); --bs-btn-active-bg: var(--qi-primary-600); --bs-btn-disabled-bg: var(--qi-primary); --bs-btn-disabled-border-color: var(--qi-primary); }
.btn-outline-primary { --bs-btn-color: var(--qi-primary); --bs-btn-border-color: var(--qi-primary); --bs-btn-hover-bg: var(--qi-primary); --bs-btn-hover-border-color: var(--qi-primary); --bs-btn-active-bg: var(--qi-primary); }
.form-control:focus, .form-select:focus { border-color: #7d93b2; box-shadow: 0 0 0 .2rem rgba(31,58,95,.15); }
.card { border-color: var(--qi-border); border-radius: .75rem; }
.card-header { border-color: var(--qi-border); }
.min-w-0 { min-width: 0; }

/* Brand */
.brand-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--qi-primary); color: #fff; display: grid; place-items: center; font-size: 1.35rem; flex-shrink: 0; }
.brand-mark.sm { width: 32px; height: 32px; border-radius: 9px; font-size: 1rem; background: var(--qi-accent); color: var(--qi-primary); }
.brand-name { font-weight: 700; font-size: 1.2rem; letter-spacing: .02em; }
.brand-tag { color: var(--qi-muted); font-size: .85rem; }

/* Guest */
.guest-body { min-height: 100vh; background: linear-gradient(180deg, #e9edf3 0%, var(--qi-bg) 40%); }
.guest-wrap { max-width: 460px; margin: 0 auto; padding: 48px 16px; }
.guest-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.guest-card { box-shadow: 0 10px 30px rgba(20,35,60,.07); }

/* App shell */
.app-sidebar { background: var(--qi-primary); color: #fff; }
.app-sidebar .offcanvas-header { color: #fff; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-inner { display: flex; flex-direction: column; height: 100%; padding: 16px 12px; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 600; padding: 4px 8px 16px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 12px; }
.sidebar-nav .nav-link { color: rgba(255,255,255,.75); border-radius: 8px; padding: 10px 12px; display: flex; gap: 12px; align-items: center; font-weight: 500; }
.sidebar-nav .nav-link i { font-size: 1.1rem; }
.sidebar-nav .nav-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.sidebar-nav .nav-link.active { color: var(--qi-primary); background: #fff; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 4px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-foot .lang-switch .btn-outline-secondary { color: rgba(255,255,255,.75); border-color: rgba(255,255,255,.35); }
.sidebar-foot .lang-switch .btn-dark { background: #fff; color: var(--qi-primary); border-color: #fff; }

.app-topbar { position: sticky; top: 0; z-index: 1020; background: rgba(255,255,255,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--qi-border); padding: 12px 16px; display: flex; align-items: center; min-height: 56px; }
.app-content { padding: 16px 16px calc(var(--qi-bottom-h) + 24px); max-width: 1200px; }

@media (min-width: 992px) {
  .app-sidebar { position: fixed; inset: 0 auto 0 0; width: var(--qi-sidebar-w); }
  .app-main { margin-left: var(--qi-sidebar-w); }
  .app-topbar { padding: 14px 28px; }
  .app-content { padding: 24px 28px 40px; }
}

/* Bottom navigation (telefon) */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; height: calc(var(--qi-bottom-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: #fff; border-top: 1px solid var(--qi-border); display: flex; box-shadow: 0 -4px 16px rgba(20,35,60,.06); }
.bn-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .7rem; color: var(--qi-muted); text-decoration: none; background: none; border: 0; padding: 6px 2px; min-width: 0; }
.bn-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bn-item i { font-size: 1.3rem; }
.bn-item.active { color: var(--qi-primary); font-weight: 600; }

/* Komponen */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--qi-surface); border: 1px solid var(--qi-border); border-radius: .75rem; padding: 16px; height: 100%; }
.stat-label { color: var(--qi-muted); font-size: .8rem; margin-bottom: 4px; }
.stat-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.temp-box { background: #fff; border: 1px dashed #c9a24a; border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

button[disabled].is-loading { position: relative; color: transparent !important; }
button[disabled].is-loading::after { content: ""; position: absolute; inset: 0; margin: auto; width: 1rem; height: 1rem; border: 2px solid #fff; border-right-color: transparent; border-radius: 50%; animation: qispin .7s linear infinite; }
.btn-outline-secondary[disabled].is-loading::after { border-color: var(--qi-muted); border-right-color: transparent; }
@keyframes qispin { to { transform: rotate(360deg); } }

@media print {
  .app-sidebar, .app-topbar, .bottom-nav, .no-print { display: none !important; }
  .app-main { margin: 0 !important; }
  body { background: #fff; }
}

/* ===== Peringkat 2–5 ===== */
.sidebar-nav { overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.sidebar-nav .nav-link { padding: 8px 12px; }
.sidebar-sep { border-color: rgba(255,255,255,.18); margin: 8px 4px; opacity: 1; }
.app-topbar { gap: 6px; }
.topbar-search { width: 260px; }

.stat-link { display: block; text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s; }
.stat-link:hover { border-color: #b8c4d4; box-shadow: 0 2px 10px rgba(20,35,60,.06); color: inherit; }
.stat-grid .stat-card { padding: 12px 14px; }
.stat-grid .stat-value { font-size: 1.35rem; }
.money-card { background: var(--qi-surface); border: 1px solid var(--qi-border); border-left: 4px solid var(--qi-primary); border-radius: .75rem; padding: 14px 16px; height: 100%; color: inherit; }
.money-card.success { border-left-color: #198754; }
.money-card.danger { border-left-color: #dc3545; }
.money-value { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 575px) { .money-value { font-size: 1.15rem; } }

.empty-state { text-align: center; color: var(--qi-muted); padding: 40px 16px; }
.empty-state i { font-size: 2.2rem; display: block; margin-bottom: 8px; opacity: .6; }
.search-bar { flex: 1 1 320px; max-width: 640px; }
.filter-bar { padding: 12px; }
.sticky-actions { position: sticky; bottom: calc(var(--qi-bottom-h) + env(safe-area-inset-bottom)); z-index: 1010; background: rgba(244,245,247,.95); backdrop-filter: blur(4px); padding: 10px 0; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; border-top: 1px solid var(--qi-border); margin-top: 8px; }
@media (min-width: 992px) { .sticky-actions { bottom: 0; } }
.img-thumb { max-height: 56px; max-width: 160px; border: 1px solid var(--qi-border); border-radius: 6px; padding: 3px; background: #fff; }
.dl-compact dt { font-weight: 500; color: var(--qi-muted); font-size: .78rem; margin-top: 6px; }
.dl-compact dd { margin-bottom: 0; }
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.badge-status { font-weight: 600; }
.cat-list .list-group-item.active { background: var(--qi-primary); border-color: var(--qi-primary); color: #fff; }
.cat-list .list-group-item.active a { color: #fff !important; }
.report-tabs .nav-link { border-radius: 999px; padding: 6px 14px; font-size: .9rem; }
.report-tabs .nav-link.active { background: var(--qi-primary); }

/* Borang dokumen */
.step { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--qi-primary); color: #fff; font-size: .75rem; margin-right: 6px; }
.customer-chosen { background: #f6f8fb; border: 1px solid var(--qi-border); border-radius: 8px; padding: 10px 12px; }
.ac-menu { position: absolute; left: 0; right: 0; top: 100%; z-index: 1050; background: #fff; border: 1px solid var(--qi-border); border-radius: 8px; box-shadow: 0 8px 24px rgba(20,35,60,.12); max-height: 300px; overflow-y: auto; margin-top: 4px; }
.ac-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px; border-bottom: 1px solid #f1f3f5; }
.ac-item:hover, .ac-item:focus { background: #f1f5fb; }
.ac-empty { padding: 10px 12px; color: var(--qi-muted); font-size: .85rem; }

.item-row { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; padding: 10px 0; border-bottom: 1px dashed var(--qi-border); }
.item-row:last-child { border-bottom: 0; }
.item-num { font-weight: 700; color: var(--qi-muted); padding-top: 6px; text-align: center; }
.item-desc { resize: vertical; min-height: 54px; }
.item-grid { display: grid; grid-template-columns: 1.4fr .8fr .9fr 1.1fr .7fr 1.1fr; gap: 6px; margin-top: 6px; }
.item-grid label { font-size: .7rem; color: var(--qi-muted); margin-bottom: 1px; display: block; }
.item-amount { font-weight: 700; padding: 4px 0; text-align: right; }
.item-actions { display: flex; flex-direction: column; gap: 3px; }
.item-actions .btn { padding: 2px 7px; }
@media (max-width: 767px) {
  .item-row { grid-template-columns: 1fr; position: relative; padding-top: 34px; }
  .item-num { position: absolute; left: 0; top: 8px; padding: 0; }
  .item-actions { position: absolute; right: 0; top: 4px; flex-direction: row; }
  .item-grid { grid-template-columns: 1fr 1fr 1fr; }
  .item-grid .ig-cat { grid-column: 1 / -1; }
  .item-grid .ig-amt { grid-column: 2 / -1; }
}
.totals-preview td { padding: 4px 6px; }
.totals-preview .total-row td { font-weight: 700; font-size: 1.1rem; border-top: 2px solid var(--qi-primary); color: var(--qi-primary); }
.terms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 14px; }
.term-item summary { cursor: pointer; font-size: .88rem; padding: 4px 0; color: var(--qi-text); }
.term-item[open] summary { font-weight: 600; }
.doc-actions { justify-content: flex-end; }
.qi-toast { position: fixed; left: 50%; bottom: calc(var(--qi-bottom-h) + 30px); transform: translateX(-50%); background: #1d2430; color: #fff; padding: 8px 16px; border-radius: 999px; font-size: .85rem; z-index: 2000; box-shadow: 0 6px 20px rgba(0,0,0,.2); }

/* Paparan dokumen */
.doc-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.doc-preview { overflow-x: auto; }
.text-decoration-line-through-soft .num { text-decoration: line-through; }

/* Bootstrap .offcanvas-lg menjadikan latar lutsinar pada skrin besar — paksa warna sidebar */
.app-sidebar .sidebar-inner { background: var(--qi-primary); color: #fff; min-height: 100%; }
@media (min-width: 992px) {
  .app-sidebar.offcanvas-lg { background-color: var(--qi-primary) !important; }
  .app-sidebar .sidebar-inner { height: 100vh; }
}

/* Panel Admin */
.admin-tabs .nav-link { border-radius: 999px; padding: 6px 14px; font-size: .9rem; }
.admin-tabs .nav-link.active { background: var(--qi-primary); }
.error-log { max-height: 70vh; overflow: auto; font-size: .75rem; line-height: 1.5; padding: 12px; background: #1d2430; color: #e9ecef; border-radius: .75rem; white-space: pre-wrap; word-break: break-word; }
tr[role="button"] { cursor: pointer; }
