/* =========================================================
   IMP ESTIMASI MATERIAL - tampilan dokumen estimasi (RAB) standar.
   Tabel & wrapper pakai class sendiri (est-*) agar TIDAK terkena
   override global .table / .table-responsive-wrapper milik aplikasi.
   Scope: #tab-estimasi.
   ========================================================= */

#tab-estimasi {
  --est-ink: #1f2a3a;
  --est-muted: #6b7280;
  --est-line: #d5dde8;
  --est-line-strong: #9aa7b8;
  --est-accent: #12609e;
  --est-accent-soft: #eaf3fb;
  --est-head: #f1f5f9;
  --est-success: #157a51;
  --est-danger: #d23b34;
}

/* ---------- Toolbar atas ---------- */
#tab-estimasi .est-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Dokumen (yang diunduh PDF/JPG) ---------- */
#tab-estimasi .est-doc {
  background: #fff;
  border: 1px solid var(--est-line);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(31, 42, 58, .08);
  padding: 40px 28px;
  max-width: 1040px;
  margin: 0 auto;
  color: var(--est-ink);
}
#tab-estimasi .est-kop {
  border-bottom: 3px double #223;
  padding-bottom: 14px;
  margin-bottom: 20px;
  text-align: center;
}
#tab-estimasi .est-kop h2 {
  margin: 0;
  letter-spacing: .5px;
  text-transform: uppercase;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--est-ink);
  font-family: 'Space Grotesk', sans-serif;
}
#tab-estimasi .est-kop p { margin: 6px 0 0; color: var(--est-muted); font-size: .84rem; line-height: 1.5; }
#tab-estimasi .est-badge {
  display: inline-block;
  margin-top: 12px;
  padding: 6px 20px;
  border-radius: 6px;
  background: var(--est-accent);
  color: #fff;
  font-weight: 800;
  letter-spacing: .12em;
  font-size: .8rem;
}

/* ---------- Info dokumen (supplier / no / tanggal) ---------- */
#tab-estimasi .est-meta {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
#tab-estimasi .est-meta-left { flex: 1 1 300px; min-width: 240px; }
#tab-estimasi .est-meta-right { width: 300px; max-width: 100%; }
#tab-estimasi .est-meta-label {
  font-size: .72rem; font-weight: 800; color: var(--est-muted);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px;
}
#tab-estimasi .est-meta-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
#tab-estimasi .est-meta-k {
  width: 78px; flex: 0 0 78px; font-size: .82rem; font-weight: 800; color: var(--est-ink);
}
#tab-estimasi .est-inp {
  width: 100%;
  border: none;
  border-bottom: 1.5px solid var(--est-line-strong);
  background: transparent;
  padding: 6px 4px;
  font-size: .92rem;
  color: var(--est-ink);
  font-weight: 600;
  outline: none;
  transition: border-color .12s ease;
}
#tab-estimasi .est-inp:focus { border-bottom-color: var(--est-accent); }
#tab-estimasi .est-inp-lg { font-size: 1.05rem; font-weight: 800; }
#tab-estimasi .est-inp-ro { background: transparent; font-weight: 800; letter-spacing: .06em; }

/* ---------- Tabel material (gaya RAB, bordered) ---------- */
#tab-estimasi .est-tbl-wrap {
  width: calc(100% + 16px);
  margin: 0 -8px;
  overflow-x: visible;
}
#tab-estimasi .est-tbl {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: .9rem;
  background: #fff;
}
#tab-estimasi .est-tbl th,
#tab-estimasi .est-tbl td {
  border: 1px solid var(--est-line-strong);
  padding: 9px 11px;
  vertical-align: middle;
}
#tab-estimasi .est-tbl thead th {
  background: var(--est-head);
  color: var(--est-ink);
  font-size: .76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .03em;
  text-align: center;
}
#tab-estimasi .est-tbl tbody td { color: var(--est-ink); }
#tab-estimasi .est-tbl tbody tr:nth-child(even) td { background: #fafcfe; }
#tab-estimasi .est-tbl .est-c-no { width: 46px; text-align: center; }
#tab-estimasi .est-tbl .est-c-qty { width: 84px; }
#tab-estimasi .est-tbl .est-c-sat { width: 92px; }
#tab-estimasi .est-tbl .est-c-harga { width: 150px; text-align: left; }
#tab-estimasi .est-tbl td.est-money { text-align: left; }
#tab-estimasi .est-tbl .est-c-total { width: 160px; text-align: left; }
#tab-estimasi .est-tbl td.est-total-green { text-align: left; }
#tab-estimasi .est-tbl .est-c-tgl { width: 120px; }
#tab-estimasi .est-tbl .est-c-aksi { width: 66px; text-align: center; }
#tab-estimasi .est-tbl .est-money { font-variant-numeric: tabular-nums; }
#tab-estimasi .est-total-green { color: var(--est-success); font-weight: 800; }

#tab-estimasi .est-grand-row td { background: var(--est-head); font-weight: 800; }
#tab-estimasi .est-grand-label { text-align: right; letter-spacing: .04em; }
#tab-estimasi .est-grand-val { text-align: left; color: var(--est-success); font-size: 1rem; font-variant-numeric: tabular-nums; }

#tab-estimasi .est-note { margin-top: 14px; color: var(--est-muted); font-size: .78rem; font-style: italic; }

/* Tombol aksi baris (hapus) */
#tab-estimasi .est-icon-btn {
  border: none; width: 30px; height: 30px; border-radius: 8px;
  font-size: .8rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: transform .12s ease, background .12s ease;
}
#tab-estimasi .est-icon-btn:hover { transform: translateY(-1px); }
#tab-estimasi .est-icon-btn.est-del { background: #fdecea; color: var(--est-danger); }
#tab-estimasi .est-icon-btn.est-del:hover { background: #f7d9d5; }

/* Petunjuk kosong */
#tab-estimasi .est-empty-hint {
  text-align: center; color: var(--est-muted); font-size: .9rem; padding: 14px;
  margin-top: 10px; border: 1px dashed var(--est-line-strong); border-radius: 10px; background: #fbfdff;
}

/* ---------- Modal input ---------- */
#modalEstInput { z-index: 1080; }
#estModalBackdrop { z-index: 1070; }
.est-modal { border: none; border-radius: 18px; overflow: hidden; box-shadow: 0 24px 70px rgba(31, 42, 58, .22); }
.est-modal .modal-header { padding: 16px 20px; }
.est-modal .modal-title { font-weight: 800; font-size: 1.02rem; }
.est-modal .modal-body { padding: 20px; }
.est-modal .est-field label {
  display: block; font-size: .76rem; font-weight: 800; color: #6b7280;
  text-transform: uppercase; letter-spacing: .03em; margin-bottom: 5px;
}
.est-modal .modal-footer { padding: 14px 20px; }

/* ---------- Riwayat estimasi ---------- */
#tab-estimasi .est-history { border-radius: 16px; }
#tab-estimasi .est-history-title { font-weight: 800; color: var(--est-ink); font-size: 1.02rem; display: flex; align-items: center; }
#tab-estimasi .est-history-title i { color: var(--est-accent); }
#tab-estimasi .est-search { position: relative; min-width: 240px; }
#tab-estimasi .est-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--est-muted); font-size: .85rem; pointer-events: none; }
#tab-estimasi .est-search input {
  width: 100%; padding: 9px 12px 9px 34px; border: 1px solid var(--est-line); border-radius: 10px;
  background: #fbfdff; font-size: .9rem; outline: none; transition: border-color .12s ease, box-shadow .12s ease;
}
#tab-estimasi .est-search input:focus { border-color: var(--est-accent); box-shadow: 0 0 0 3px rgba(18, 96, 158, .12); }

/* Filter tanggal riwayat */
#tab-estimasi .est-filter {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; margin-bottom: 14px;
  background: linear-gradient(180deg, #f8fbff, #eef4fb);
  border: 1px solid var(--est-line); border-radius: 12px;
}
#tab-estimasi .est-filter-group { display: flex; flex-direction: column; gap: 4px; }
#tab-estimasi .est-filter-group label {
  font-size: .7rem; font-weight: 800; color: var(--est-muted);
  text-transform: uppercase; letter-spacing: .04em;
}
#tab-estimasi .est-filter-group input {
  border: 1px solid var(--est-line); border-radius: 9px; padding: 8px 10px;
  font-size: .88rem; background: #fff; color: var(--est-ink); outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}
#tab-estimasi .est-filter-group input:focus { border-color: var(--est-accent); box-shadow: 0 0 0 3px rgba(18, 96, 158, .12); }
#tab-estimasi .est-filter-clear {
  border: 1px solid var(--est-line); background: #fff; color: var(--est-danger);
  border-radius: 9px; padding: 8px 14px; font-size: .82rem; font-weight: 700;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s ease, transform .12s ease;
}
#tab-estimasi .est-filter-clear:hover { background: #fdecea; transform: translateY(-1px); }

#tab-estimasi .est-tbl-riwayat thead th { background: var(--est-head); }
#tab-estimasi .est-tbl-riwayat .est-c-nama { text-align: left; }
#tab-estimasi .est-tbl-riwayat .est-c-nopo { width: 160px; white-space: nowrap; text-align: left; }
#tab-estimasi .est-tbl-riwayat tbody td { font-size: .88rem; }
/* No PO ditampilkan penuh 1 baris (mis. PO-2026-0001) */
#tab-estimasi .est-tbl-riwayat tbody td:first-child {
  white-space: nowrap; font-weight: 800; color: var(--est-accent);
  letter-spacing: .02em; font-variant-numeric: tabular-nums;
}
#tab-estimasi .est-hist-row { cursor: pointer; transition: background .12s ease; }
#tab-estimasi .est-hist-row:hover td { background: var(--est-accent-soft) !important; }
#tab-estimasi .est-hist-row.est-hist-active td { background: #e9f6ef !important; }
#tab-estimasi .est-hist-row.est-hist-active td:first-child { box-shadow: inset 3px 0 0 var(--est-success); }
#tab-estimasi .est-hist-empty { text-align: center; color: var(--est-muted); font-size: .9rem; padding: 16px; }

/* ---------- Ekspor: sembunyikan tombol & kolom Aksi ---------- */
#tab-estimasi.est-printing .est-no-print { display: none !important; }
#tab-estimasi.est-printing .est-col-aksi { display: none !important; }
#tab-estimasi.est-printing .est-doc { box-shadow: none; border-color: #c3ccd8; }

/* ---------- Responsif ---------- */
@media (max-width: 820px) {
  #tab-estimasi .est-doc { padding: 22px 18px; }
  #tab-estimasi .est-meta { flex-direction: column; }
  #tab-estimasi .est-meta-right { width: 100%; }
  #tab-estimasi .est-tbl { min-width: 640px; }
}

/* ============ v7: polish + role-based (scoped #tab-estimasi, tanpa menimpa CSS global) ============ */
/* Sembunyikan kolom aksi hapus riwayat untuk selain Admin (mis. Produksi) */
body:not(.role-admin) #tab-estimasi .est-col-aksi-riwayat { display: none !important; }

/* Aksen atas dokumen: lebih keren tapi ringan */
#tab-estimasi .est-doc { position: relative; overflow: hidden; }
#tab-estimasi .est-doc::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px;
  background: linear-gradient(90deg, var(--est-accent), #2f8fd6 55%, #23b892);
}
#tab-estimasi .est-kop h2 { color: var(--est-accent); }

/* ---------- Tabel tampilan keren ---------- */
#tab-estimasi .est-tbl-wrap {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid #dbe3ee;
  box-shadow: 0 12px 30px rgba(31, 42, 58, .10);
}
#tab-estimasi .est-tbl thead th {
  background: linear-gradient(135deg, #12609e, #2f8fd6 60%, #23b892) !important;
  color: #fff !important;
  border-color: rgba(255, 255, 255, .18);
}
#tab-estimasi .est-tbl tbody tr { transition: background .15s ease; }
#tab-estimasi .est-tbl tbody tr:hover td { background: #eaf5ff; }
#tab-estimasi .est-tbl tbody tr:nth-child(even) td { background: #f7fbfe; }
#tab-estimasi .est-grand-row td {
  background: linear-gradient(135deg, #e9fbf3, #d5f5e6) !important;
  border-top: 2px solid var(--est-success);
}
#tab-estimasi .est-grand-val { font-size: 1.05rem; }

/* ---------- Tombol Baru / Reset berwarna ---------- */
#tab-estimasi .btn-est-reset {
  border: none;
  color: #fff;
  font-weight: 700;
  border-radius: 12px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  box-shadow: 0 6px 16px rgba(249, 115, 22, .35);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
#tab-estimasi .btn-est-reset:hover {
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(249, 115, 22, .48);
  filter: brightness(1.04);
}
#tab-estimasi .btn-est-reset:active { transform: translateY(0); }

/* Cetak PDF/JPG: bersih, tajam, warna akurat */
#tab-estimasi.est-printing .est-doc { border-radius: 0; box-shadow: none; }
#tab-estimasi.est-printing .est-tbl thead th,
#tab-estimasi.est-printing .est-tbl td,
#tab-estimasi.est-printing .est-badge,
#tab-estimasi.est-printing .est-doc::before {
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
