/* ============================================================
   style.css - Input Belanja Harian (Purchase/Sales Invoice)
   Yayasan Bina Bangsa Mandiri Mulia
   (disamakan dengan style.css Aplikasi Pettycash / Sistem Presensi BGN)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=DM+Mono:wght@400;500&display=swap');

/* ── Design tokens ─────────────────────────────────────────── */
:root {
  --bg-top:       #7EC8E8;
  --bg-mid:       #5AB3D9;
  --bg-bot:       #3A9AC4;
  --navy:         #0D2158;
  --blue-dark:    #1A4480;
  --blue:         #1E5FAD;
  --blue-light:   #2E80C8;
  --accent:       #D4A847;
  --surface:      rgba(255,255,255,0.22);
  --surface-hov:  rgba(255,255,255,0.32);
  --surface-dark: rgba(13,33,88,0.18);
  --border:       rgba(255,255,255,0.35);
  --border-dark:  rgba(13,33,88,0.18);
  --text:         #0A1E4E;
  --text-light:   #1A4480;
  --muted:        rgba(10,30,78,0.55);
  --white:        #ffffff;
  --radius:       14px;
  --radius-sm:    9px;
  --shadow:       0 4px 24px rgba(13,33,88,0.13);
  --shadow-lg:    0 8px 40px rgba(13,33,88,0.18);
  --green:        #16a34a;
  --red:          #dc2626;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse 90% 60% at 15% 0%,   #A8DCEA 0%, transparent 55%),
    radial-gradient(ellipse 70% 70% at 85% 100%,  #3D9FC8 0%, transparent 55%),
    radial-gradient(ellipse 100% 100% at 50% 50%, #5AB3D9 0%, #4AA5CF 100%);
  background-attachment: fixed;
}

body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.25) 1px, transparent 0);
  background-size: 28px 28px;
  pointer-events: none;
}

/* ── Wrapper ────────────────────────────────────────────────── */
.wrapper {
  position: relative; z-index: 1;
  max-width: 1500px;
  margin: 0 auto;
  padding: 22px 22px 48px;
}

/* ── Navbar ─────────────────────────────────────────────────── */
.navbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 14px 0 12px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.navbar-brand {
  display: flex; align-items: center; gap: 14px;
  text-decoration: none; color: inherit;
}
.logo-circle {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 2.5px solid var(--accent);
  overflow: hidden;
  flex-shrink: 0;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 16px rgba(212,168,71,0.25), 0 0 0 4px rgba(255,255,255,0.3);
  font-size: 1.4rem;
}
.logo-circle img { width: 100%; height: 100%; object-fit: contain; }
.brand-text h1 {
  font-size: 1.15rem; font-weight: 800; color: var(--navy);
  letter-spacing: -.2px; line-height: 1.25;
}
.brand-text p {
  font-size: .78rem; color: var(--muted); margin-top: 3px; font-weight: 500;
}
.navbar-actions {
  margin-left: auto;
  display: flex; flex-wrap: wrap; gap: 10px;
  align-items: center;
}

/* ── Stat cards ─────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  position: relative; overflow: hidden;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--navy), var(--accent));
}
.stat-card .label {
  font-size: .72rem; color: var(--muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: .9px;
}
.stat-card .value {
  font-size: 1.7rem; font-weight: 800; color: var(--navy); margin: 6px 0 2px; line-height: 1;
}
.stat-card .sub { font-size: .73rem; color: var(--muted); }
.stat-icon {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  font-size: 2.2rem; opacity: .13;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius-sm); border: 1.5px solid transparent;
  font-size: .82rem; font-weight: 700; cursor: pointer;
  transition: all .15s; font-family: inherit; white-space: nowrap;
  background: transparent; color: var(--text);
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: #fff; box-shadow: var(--shadow); border-color: var(--navy); }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-secondary,
.btn-outline-primary,
.btn-outline-secondary {
  background: rgba(255,255,255,0.5);
  border-color: var(--border-dark);
  color: var(--text-light);
}
.btn-outline-primary { color: var(--blue); border-color: var(--blue); background: rgba(255,255,255,.6); }
.btn-secondary:hover:not(:disabled),
.btn-outline-primary:hover:not(:disabled),
.btn-outline-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.8); }
.btn-outline-danger {
  background: rgba(220,38,38,.08);
  border-color: rgba(220,38,38,.35);
  color: #991b1b;
}
.btn-outline-danger:hover:not(:disabled) { background: rgba(220,38,38,.18); }
.btn-reset {
  background: rgba(255,255,255,0.45);
  border-color: var(--border-dark);
  color: var(--muted);
}
.btn-reset:hover:not(:disabled) { background: rgba(255,255,255,0.7); color: var(--text); }
.btn-link {
  background: none; border: none; color: var(--blue); padding: 2px 0;
  font-weight: 700; text-decoration: none;
}
.btn-link:hover:not(:disabled) { text-decoration: underline; }
.btn-sm { padding: 4px 11px; font-size: .74rem; border-radius: 7px; }

/* ── Compact inline inputs (dipakai di tabel sheet & baris kontak) */
.cell-input {
  width: 100%;
  background: rgba(255,255,255,0.7);
  border: 1.5px solid rgba(13,33,88,.15);
  border-radius: 7px;
  padding: 6px 9px;
  font-size: .8rem; font-family: inherit;
  color: var(--text); outline: none;
  transition: border-color .15s, background .15s;
}
.cell-input:focus { border-color: var(--blue); background: #fff; }
.cell-input[readonly] { background: rgba(13,33,88,.06); color: var(--muted); cursor: default; }
.cell-input.text-end { text-align: right; }
.cell-input::placeholder { color: rgba(10,30,78,.35); }

.cell-label {
  display: block; font-size: .74rem; font-weight: 700;
  color: var(--navy); margin-bottom: 5px;
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  padding: 3px 10px; border-radius: 20px;
  font-size: .72rem; font-weight: 700;
  display: inline-block; white-space: nowrap;
  text-decoration: none;
}
.badge-success { background: rgba(34,197,94,.15); color: #166534; }
.badge-success:hover { background: rgba(34,197,94,.28); }
.badge-danger  { background: rgba(239,68,68,.15);  color: #991b1b; }
.badge-secondary { background: rgba(100,116,139,.15); color: #374151; }
.badge-in  { background: rgba(34,197,94,0.15);  color: #166534; }
.badge-out { background: rgba(239,68,68,0.15);   color: #991b1b; }

/* ── Tag chip (Vendor/Pelanggan/Tag row) ───────────────────────── */
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background-color: rgba(30,95,173,.12);
  color: var(--blue-dark);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
}
.tag-chip .tag-chip-remove {
  cursor: pointer;
  font-weight: bold;
  line-height: 1;
}
.tag-chip .tag-chip-remove:hover { color: #b02a37; }

/* ── Autocomplete dropdown (produk/vendor/pelanggan/tag) ────────── */
.autocomplete-list {
  position: absolute;
  z-index: 1000;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  display: none;
  background: #fff;
  border: 1px solid var(--border-dark);
  border-radius: 9px;
  box-shadow: var(--shadow-lg);
  margin-top: 4px;
}
.autocomplete-list.show { display: block; }
.autocomplete-item {
  cursor: pointer;
  font-size: .8rem;
  padding: 7px 12px;
  color: var(--text);
  border-bottom: 1px solid rgba(13,33,88,.06);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.active { background-color: #EBF5FB; color: var(--blue); }
.autocomplete-status {
  padding: 7px 12px;
  font-size: .8rem;
  cursor: default;
}

/* ── Sheet table (input belanja harian) ────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  margin-bottom: 20px;
}

/* Panel Vendor/Pelanggan/Tag memakai .table-wrap yang sama, tapi TIDAK
   boleh overflow:hidden — itu bikin dropdown pencarian yang muncul di
   bawah field ikut kepotong. */
.table-wrap.contact-wrap {
  overflow: visible;
  position: relative;
  z-index: 20;
}
.table-wrap.contact-wrap .table-head { border-radius: var(--radius) var(--radius) 0 0; }

.table-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.15);
}
.table-head h2 { font-size: .92rem; font-weight: 800; color: var(--navy); }

.sheet-scroll { overflow-x: auto; }
table.sheet-table { width: 100%; border-collapse: collapse; background: rgba(255,255,255,.35); }
.sheet-table th, .sheet-table td {
  vertical-align: middle;
  font-size: 0.82rem;
  padding: 9px 10px;
  border-bottom: 1px solid rgba(13,33,88,.08);
}
.sheet-table thead th {
  background: rgba(13,33,88,0.08);
  text-align: center;
  font-size: .73rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-light);
  border-bottom: 1px solid var(--border-dark);
}

/* Pembeda warna antar kelompok kolom: Jumlah (Jml/Satuan) — abu kebiruan,
   Harga Supplier — kuning keemasan, Harga Dapur — hijau. Kolom Jumlah
   (selisih) di paling kanan tetap navy supaya tetap menonjol sebagai hasil
   akhir. */
.sheet-table thead th.col-group-jumlah  { background: rgba(100,116,139,.20); color: #334155; }
.sheet-table thead th.col-group-suplier { background: rgba(212,168,71,.28);  color: #7c5205; }
.sheet-table thead th.col-group-dapur   { background: rgba(34,197,94,.20);   color: #14532d; }
.sheet-table thead th.col-group-margin  { background: rgba(13,33,88,.20); }

.entry-row .cell-input.input-qty,
.entry-row .cell-input.input-satuan[readonly] {
  background: rgba(100,116,139,.12);
}
.entry-row .cell-input.input-qty:focus { background: #fff; }

.entry-row .cell-input.input-harga-suplier,
.entry-row td.cell-jml-suplier {
  background: rgba(212,168,71,.16);
}
.entry-row .cell-input.input-harga-suplier:focus { background: #fff; }

.entry-row .cell-input.input-harga-dapur,
.entry-row td.cell-jml-dapur {
  background: rgba(34,197,94,.14);
}
.entry-row .cell-input.input-harga-dapur:focus { background: #fff; }

.entry-row td.cell-jumlah { background: rgba(13,33,88,.08); }

.table-date-header td {
  background: rgba(30,95,173,.1);
  font-style: italic;
  padding-top: 12px; padding-bottom: 12px;
}
.table-date-header .date-label { color: var(--navy); font-size: .88rem; }

.table-contact-row td { background: rgba(255,255,255,.25); padding-top: 12px; padding-bottom: 14px; }

.table-subtotal td { background: rgba(255,255,255,.4); font-weight: 700; }

.table-grand-total td {
  background: rgba(13,33,88,.12);
  font-weight: 800; color: var(--navy);
}

.entry-row:hover td { background: rgba(255,255,255,.3); }

.empty-row-cell { text-align: center; color: var(--muted); padding: 40px 20px; }

/* ── Flex/spacing/text utilities (dipakai langsung di markup) ──── */
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.align-items-start { align-items: flex-start; }
.align-items-center { align-items: center; }
.justify-content-end { justify-content: flex-end; }
.gap-1 { gap: .25rem; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.gap-4 { gap: 1rem; }
.mb-1 { margin-bottom: .25rem; }
.mb-2 { margin-bottom: .5rem; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.ms-1 { margin-left: .25rem; }
.ms-2 { margin-left: .5rem; }
.p-0 { padding: 0; }
.text-end { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.text-danger { color: #991b1b; }
.text-success { color: #166534; }
.fw-bold { font-weight: 800; }
.fw-semibold { font-weight: 700; }
.small { font-size: .78rem; }
.position-relative { position: relative; }
.text-decoration-none { text-decoration: none; }

/* ── Alert / flash message ─────────────────────────────────────── */
.flash {
  border-radius: 10px; padding: 10px 16px;
  font-size: .83rem; font-weight: 600; margin-bottom: 16px;
  display: flex; gap: 10px; align-items: flex-start; justify-content: space-between;
}
.flash-ok  { background: rgba(34,197,94,.12);  border: 1px solid rgba(34,197,94,.3);  color: #14532d; }
.flash-err { background: rgba(220,38,38,.12);  border: 1px solid rgba(220,38,38,.3);  color: #7f1d1d; }
.flash-close {
  background: none; border: none; cursor: pointer; font-size: .85rem;
  color: inherit; opacity: .6; line-height: 1;
}
.flash-close:hover { opacity: 1; }

/* ── Modal overlay ──────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 8888;
  background: rgba(5,15,40,0.70);
  backdrop-filter: blur(5px);
  align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn .2s ease;
}
.modal-overlay.show { display: flex; }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes popIn { from { opacity:0; transform: scale(.88); } to { opacity:1; transform: scale(1); } }

.modal-box {
  background: #fff;
  border-radius: 18px;
  padding: 28px 26px 24px;
  width: 100%; max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
  animation: popIn .22s cubic-bezier(.34,1.56,.64,1);
  position: relative;
}
.modal-box.modal-lg { max-width: 760px; }
.modal-box h3 {
  font-size: 1rem; font-weight: 800; color: var(--navy);
  margin-bottom: 18px; padding-bottom: 12px;
  border-bottom: 1px solid rgba(13,33,88,.1);
}
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(13,33,88,.08); border: none;
  width: 30px; height: 30px; border-radius: 50%;
  cursor: pointer; font-size: .9rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.modal-close:hover { background: rgba(220,38,38,.15); color: #991b1b; }

.form-field label,
.modal-box label.cell-label { display: block; font-size: .76rem; font-weight: 700; color: var(--navy); margin-bottom: 5px; }
.form-field input,
.modal-box input[type="text"],
.modal-box input[type="date"] {
  width: 100%;
  background: rgba(13,33,88,.04);
  border: 1.5px solid rgba(13,33,88,.15);
  border-radius: 8px; padding: 9px 12px;
  font-size: .85rem; font-family: inherit;
  color: var(--text); outline: none;
  transition: border-color .2s;
}
.form-field input:focus,
.modal-box input:focus { border-color: var(--blue); background: #fff; }
.form-field .hint { font-size: .7rem; color: var(--muted); margin-top: 3px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* Table inside modal (laporan submit / item invoice) */
.modal-box table { width: 100%; border-collapse: collapse; margin-top: 4px; }
.modal-box thead th {
  text-align: left; font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-light);
  padding: 8px 10px; border-bottom: 1.5px solid var(--border-dark);
}
.modal-box tbody td { padding: 9px 10px; font-size: .82rem; border-bottom: 1px solid rgba(13,33,88,.07); }
.modal-box tbody tr:last-child td { border-bottom: none; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty { text-align: center; padding: 52px 20px; color: var(--muted); }
.empty .icon { font-size: 3rem; margin-bottom: 14px; }
.empty p { font-size: .9rem; font-weight: 600; }

/* ── Login ───────────────────────────────────────────────────── */
.login-page {
  position: relative; z-index: 1; min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  width: 400px; max-width: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 36px 32px; backdrop-filter: blur(14px);
}
.login-logo { display: flex; justify-content: center; margin-bottom: 16px; }
.login-logo .logo-circle { width: 70px; height: 70px; }
.login-title { text-align: center; font-size: 1.15rem; font-weight: 800; color: var(--navy); margin-bottom: 2px; }
.login-sub { text-align: center; font-size: .78rem; color: var(--muted); margin-bottom: 26px; }
.login-card label { display: block; font-size: .76rem; font-weight: 700; color: var(--navy); margin: 14px 0 5px; }
.login-card input {
  width: 100%; background: rgba(13,33,88,.04);
  border: 1.5px solid rgba(13,33,88,.15); border-radius: 9px;
  padding: 11px 13px; font-size: .88rem; font-family: inherit; color: var(--text); outline: none;
}
.login-card input:focus { border-color: var(--blue); background: #fff; }
.login-card button {
  width: 100%; margin-top: 22px; padding: 11px; border: none; border-radius: var(--radius-sm);
  background: var(--navy); color: #fff; font-weight: 700; font-size: .88rem; cursor: pointer; font-family: inherit;
  box-shadow: var(--shadow); transition: background .2s;
}
.login-card button:hover { background: var(--blue-dark); }

/* ── Footer ──────────────────────────────────────────────────── */
.footer {
  text-align: center; margin-top: 36px;
  font-size: .73rem; color: var(--muted); font-weight: 600;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .navbar-actions { width: 100%; }
  .brand-text h1 { font-size: 1rem; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; gap: 10px; }
  .stat-card .value { font-size: 1.4rem; }
}

/* ── Tabel "Daftar Belanja" jadi kartu per baris di layar sempit ────
   Daripada memaksa tabel 9 kolom muat dengan huruf kecil (susah dibaca)
   atau geser horizontal terus-menerus, tiap baris produk ditampilkan
   sebagai kartu dengan label di atas tiap nilainya. */
@media (max-width: 760px) {
  .sheet-scroll { overflow-x: visible; }
  .sheet-table, .sheet-table tbody { display: block; width: 100%; }
  .sheet-table thead, .sheet-table colgroup { display: none; }
  .sheet-table tfoot { display: block; width: 100%; }

  .sheet-table tr { display: block; width: 100%; }
  .sheet-table td { display: block; width: 100%; box-sizing: border-box; }
  .sheet-table td:empty { display: none; }

  .sheet-table tr.entry-row {
    border: 1px solid var(--border-dark);
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 10px 12px;
    background: rgba(255,255,255,.5);
  }
  .sheet-table tr.entry-row td {
    border-bottom: none;
    padding: 6px 0;
    text-align: left !important;
  }
  .sheet-table tr.entry-row td[data-label]::before,
  .sheet-table tr.table-subtotal td[data-label]::before,
  .sheet-table tr.table-grand-total td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: .68rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 3px;
  }
  .sheet-table tr.entry-row td[data-label="Aksi"] {
    text-align: right !important;
  }
  .sheet-table tr.entry-row td[data-label="Aksi"]::before {
    display: none;
  }

  .sheet-table tr.table-date-header,
  .sheet-table tr.table-subtotal,
  .sheet-table tr.table-grand-total {
    border-radius: 10px;
    margin-bottom: 4px;
    overflow: hidden;
  }
  .sheet-table tr.table-date-header td,
  .sheet-table tr.table-subtotal td,
  .sheet-table tr.table-grand-total td {
    padding: 8px 12px;
    text-align: left !important;
  }
}