/* ==================================================================
   Quotation Generator — antarmuka admin Rifariz.

   Palet diambil langsung dari logo Rifariz dan diredam seperlunya
   agar lolos kontras WCAG AA:

     navy  #0E0699 -> #12118C   struktur: topbar, judul, nilai otomatis
     merah #F91E17 -> #E11507   aksi utama dan tanda brand (4.87:1)
     crim  #CC0836 -> #A80A2E   hover dan aksi hapus
     kuning#F9F70D -> #F2C400   status draft (isian, bukan teks)
     hijau #36E728 -> #1E9E3A   status final

   Merah logo asli hanya 4.02:1 terhadap putih sehingga tidak dipakai
   untuk teks. Kuning dan hijau logo dipakai sebagai isian dengan teks
   gelap di atasnya.
   ================================================================== */

:root {
  /* permukaan — abu dingin berbias navy, bukan krem */
  --paper: #F3F4F9;
  --surface: #FFFFFF;
  --surface-2: #E8EAF3;
  --surface-3: #F7F8FC;

  /* teks */
  --ink: #14173A;
  --ink-2: #40476B;
  --muted: #5F6787;

  /* garis */
  --rule: #DCDFEC;
  --rule-strong: #BCC2D8;

  /* brand */
  --navy: #12118C;
  --navy-deep: #0C0A66;
  --navy-soft: #E6E7F7;
  --brand: #E11507;
  --brand-deep: #A80A2E;
  --brand-soft: #FDE7E4;

  /* status */
  --gold: #F2C400;
  --gold-ink: #7A5F00;
  --gold-soft: #FDF3CC;
  --green: #1E9E3A;
  --green-ink: #12712A;
  --green-soft: #DDF3E1;

  /* alias lama — dipakai lewat style inline di PHP, jangan dihapus */
  --auto: var(--navy);
  --auto-soft: var(--navy-soft);
  --manual: var(--gold-ink);
  --manual-soft: var(--gold-soft);
  --danger: var(--brand-deep);
  --danger-soft: var(--brand-soft);

  --focus: var(--navy);

  --radius-ctl: 5px;
  --radius-surface: 10px;

  --shadow: 0 1px 2px rgba(18, 17, 140, .06), 0 14px 34px -18px rgba(18, 17, 140, .30);
  --shadow-lift: 0 2px 4px rgba(18, 17, 140, .08), 0 22px 48px -20px rgba(18, 17, 140, .36);

  --font-display: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  /* angka pakai tabular-nums, bukan monospace */
  --font-mono: var(--font-body);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy); }

/* Angka uang dan nomor dokumen selalu rata lebar. */
.num, .stat b, input[readonly], td.mono, .item-no, table.data td.num {
  font-variant-numeric: tabular-nums;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ------------------------------------------------------------ topbar */

/* Satu-satunya elemen berani di aplikasi: navy pekat, logo Rifariz asli,
   dan garis merah brand di bawahnya. Sisanya sengaja tenang. */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 64px;
  background: var(--navy);
  border-bottom: 3px solid var(--brand);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar :focus-visible { outline-color: var(--gold); }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #fff;
}

/* Logo sudah bulat; wadahnya ikut bulat dan diberi cincin putih tipis
   supaya cincin merah logo tidak hilang di atas navy. */
.brand-mark {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  background: #fff;
  object-fit: contain;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .55);
  /* cadangan bila markup masih memakai teks "RB" */
  font-size: 0;
  color: transparent;
}

.brand-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  line-height: 1.15;
  letter-spacing: -.005em;
}

.brand-text em {
  display: block;
  font-style: normal;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 12px;
  letter-spacing: .01em;
  color: #C9CCEA;
}

.nav {
  margin-left: auto;
  display: flex;
  gap: 2px;
  align-items: center;
}

.nav a {
  padding: 8px 14px;
  border-radius: var(--radius-ctl);
  text-decoration: none;
  color: #C9CCEA;
  font-size: 14.5px;
  font-weight: 500;
}

.nav a:hover { background: rgba(255, 255, 255, .12); color: #fff; }

/* Halaman aktif ditandai isian putih, bukan sekadar warna teks. */
.nav a.on { background: #fff; color: var(--navy); font-weight: 600; }
.nav a.quiet { color: #A8ADE0; }
.nav a.quiet:hover { color: #fff; }

/* -------------------------------------------------------------- wrap */

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 34px 24px 72px;
}

.wrap.wide { max-width: 1400px; }

.pagefoot {
  border-top: 1px solid var(--rule);
  padding: 18px 24px 40px;
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--muted);
  max-width: 1400px;
  margin: 0 auto;
}

/* ------------------------------------------------------------ heading */

h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 31px;
  letter-spacing: -.021em;
  line-height: 1.15;
  margin: 0 0 7px;
}

h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -.012em;
  margin: 0 0 12px;
}

.sub {
  color: var(--muted);
  margin: 0 0 26px;
  font-size: 15px;
  max-width: 68ch;
}

.pagehead {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.pagehead .grow { flex: 1 1 260px; }
.pagehead .sub { margin: 0; }

/* -------------------------------------------------------------- flash */

.flash {
  border-left: 3px solid var(--green);
  background: var(--green-soft);
  color: var(--green-ink);
  padding: 12px 16px;
  border-radius: 0 var(--radius-ctl) var(--radius-ctl) 0;
  margin-bottom: 22px;
  font-size: 14.5px;
}

.flash.err {
  border-left-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-deep);
}

/* ------------------------------------------------------------ tombol */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-ctl);
  padding: 9px 15px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { background: var(--surface-2); border-color: var(--muted); }

/* Merah Rifariz hanya untuk aksi yang memajukan pekerjaan. */
.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}

.btn.primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); }

/* Hapus tetap crimson tapi tidak pernah solid, supaya tidak bersaing
   dengan tombol aksi utama. */
.btn.danger { color: var(--brand-deep); border-color: #E2B3BC; background: var(--surface); }
.btn.danger:hover { background: var(--brand-soft); border-color: var(--brand-deep); }

.btn.sm { padding: 5px 10px; font-size: 13px; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btnrow { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* -------------------------------------------------------------- kartu */

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-surface);
  padding: 24px;
  margin-bottom: 20px;
}

.card > h2 { margin-top: 0; }

.cardhead {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.008em;
  color: var(--ink-2);
  margin: 0 0 16px;
}

/* -------------------------------------------------------------- form */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px 18px;
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.span2 { grid-column: span 2; }

label, .lbl {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
}

/* Penanda wajib isi: kuning logo, cukup untuk terlihat tanpa berteriak. */
label .req { color: var(--gold-ink); font-weight: 600; }

input[type=text], input[type=password], input[type=date], input[type=number], select, textarea {
  font-family: var(--font-body);
  font-size: 14.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-ctl);
  padding: 9px 11px;
  width: 100%;
}

textarea { resize: vertical; min-height: 62px; line-height: 1.45; }

input:focus, select:focus, textarea:focus, [contenteditable]:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--focus);
}

/* Nilai yang dihitung sistem: navy, tidak bisa disunting. */
input[readonly] {
  background: var(--navy-soft);
  border-color: #CFD2F0;
  color: var(--navy);
  font-weight: 600;
}

.hint { font-size: 12.5px; color: var(--muted); }

/* --------------------------------------------------------- tabel data */

.tablewrap {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-surface);
  overflow-x: auto;
}

table.data { border-collapse: collapse; width: 100%; font-size: 14px; min-width: 760px; }

table.data th {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  padding: 13px 14px;
  border-bottom: 1px solid var(--rule-strong);
  white-space: nowrap;
  background: var(--surface-3);
}

table.data th:first-child { border-top-left-radius: var(--radius-surface); }
table.data th:last-child { border-top-right-radius: var(--radius-surface); }

table.data td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}

table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: var(--surface-3); }
table.data td.num { text-align: right; font-weight: 600; }
table.data td.mono { font-size: 14px; font-weight: 600; letter-spacing: .012em; color: var(--navy); }

.pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

/* Kuning dan hijau diambil dari logo; keduanya isian, teksnya digelapkan. */
.pill.draft { background: var(--gold-soft); color: var(--gold-ink); box-shadow: inset 0 0 0 1px #EBD98A; }
.pill.final { background: var(--green-soft); color: var(--green-ink); box-shadow: inset 0 0 0 1px #A8DCB5; }

.rowacts { display: flex; gap: 6px; justify-content: flex-end; }

.empty { padding: 64px 24px; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 16px; font-size: 15px; }

/* ---------------------------------------------------------- filterbar */

.filterbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-surface);
  padding: 16px 18px;
}

.filterbar .field { flex: 0 0 auto; }
.filterbar .field.grow { flex: 1 1 220px; }

/* ------------------------------------------------------------- statbar */

/* Satu strip utuh, bukan tiga kartu melayang: jumlahnya saling
   berhubungan, jadi dibaca sebagai satu baris. */
.statbar {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-surface);
  overflow: hidden;
}

.stat {
  padding: 14px 26px;
  min-width: 130px;
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
}

.stat:last-child { border-right: 0; }

.stat b {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--navy);
  line-height: 1.1;
}

.stat span {
  font-size: 13px;
  color: var(--muted);
}

/* Draft dan final memakai warna statusnya sendiri. */
.stat:nth-child(2) b { color: var(--gold-ink); }
.stat:nth-child(3) b { color: var(--green-ink); }

/* -------------------------------------------------------- editor item */

.items-editor { display: flex; flex-direction: column; gap: 14px; }

.item-card {
  border: 1px solid var(--rule);
  border-radius: var(--radius-surface);
  background: var(--surface);
  overflow: hidden;
}

.item-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface-3);
  border-bottom: 1px solid var(--rule);
}

.item-no {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
}

.item-head .spacer { flex: 1; }

.item-body { padding: 18px; display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; }

.item-nums { display: flex; flex-direction: column; gap: 12px; }

.qtyrow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* --------------------------------------------------------- rich editor */

.rt-toolbar {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  padding: 5px;
  border: 1px solid var(--rule-strong);
  border-bottom: none;
  border-radius: var(--radius-ctl) var(--radius-ctl) 0 0;
  background: var(--surface-3);
}

.rt-btn {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 4px;
  width: 30px;
  height: 28px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink-2);
  display: grid;
  place-items: center;
}

.rt-btn:hover { background: var(--surface); border-color: var(--rule-strong); color: var(--navy); }
.rt-btn.wide { width: auto; padding: 0 10px; font-size: 12.5px; }
.rt-btn b { font-weight: 700; }
.rt-btn i { font-style: italic; }
.rt-btn u { text-decoration: underline; }

.rt-area {
  border: 1px solid var(--rule-strong);
  border-radius: 0 0 var(--radius-ctl) var(--radius-ctl);
  padding: 11px 13px;
  min-height: 150px;
  max-height: 460px;
  overflow-y: auto;
  background: var(--surface);
  font-size: 14px;
  line-height: 1.5;
}

.rt-area:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.rt-area p { margin: 0 0 7px; }
.rt-area ul, .rt-area ol { margin: 7px 0; padding-left: 22px; }
.rt-area li { margin: 0 0 3px; }
.rt-area img { max-width: 100%; height: auto; display: block; margin: 8px 0; border: 1px solid var(--rule); }

/* --------------------------------------------------------- preview A4 */

.previewbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.sheetscroll { overflow-x: auto; padding-bottom: 12px; }

.a4sheet {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  background: #fff;
  box-shadow: var(--shadow-lift);
  border: 1px solid var(--rule-strong);
  padding: 8mm 10mm;
  position: relative;
}

/* Tinggi tabel hanya dipasang di preview browser; di mPDF tinggi baris
   filler dihitung PdfRenderer. Lihat catatan di quotation-print.css. */
.a4sheet .items { height: 175mm; }

@media print {
  .topbar, .pagefoot, .previewbar, .flash { display: none !important; }
  body { background: #fff; }
  .wrap { padding: 0; max-width: none; }
  .sheetscroll { overflow: visible; }
  .a4sheet { box-shadow: none; border: 0; margin: 0; width: auto; padding: 0; }
  @page { size: A4 portrait; margin: 8mm 10mm; }
}

/* ---------------------------------------------------------- halaman login */

.loginwrap {
  min-height: calc(100vh - 67px);
  display: grid;
  place-items: center;
  padding: 40px 24px;
}

.loginbox {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-surface);
  padding: 32px;
  box-shadow: var(--shadow);
  /* garis brand tipis di tepi atas kotak masuk */
  border-top: 3px solid var(--brand);
}

.loginbox h1 { font-size: 24px; margin-bottom: 5px; }
.loginbox .sub { margin-bottom: 22px; font-size: 14px; }
.loginbox .field { margin-bottom: 14px; }
.loginbox .btn { width: 100%; justify-content: center; margin-top: 8px; }

/* ------------------------------------------------------------ dialog */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 23, 58, .5);
  display: grid;
  place-items: center;
  z-index: 60;
  padding: 24px;
}

.modal[hidden] { display: none; }

.modalbox {
  background: var(--surface);
  border-radius: var(--radius-surface);
  padding: 26px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lift);
}

.modalbox h2 { margin-top: 0; }

@media (max-width: 860px) {
  .item-body { grid-template-columns: 1fr; }
  .field.span2 { grid-column: auto; }
  .topbar { height: auto; padding: 10px 16px; flex-wrap: wrap; }
  .nav { width: 100%; margin-left: 0; overflow-x: auto; }
  .stat { flex: 1 1 33%; min-width: 0; padding: 12px 16px; }
  .loginwrap { min-height: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
