/* =========================================================
   1. GLOBAL VARIABLES & RESET
   ========================================================= */
/* RESET SCROLL UNTUK HALAMAN NON-APP */
body.scrollable {
  height: auto !important;
  min-height: 100vh !important;
  overflow-y: auto !important;
  display: block !important;
}
:root {
  --primary: #10b981;
  --primary-dark: #059669;
  --bg-workspace: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-stage: #334155;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  --font-sans: "Inter", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  outline: none;
}

/* Default Desktop: Layar Terkunci (Aplikasi) */
body {
  font-family: var(--font-sans);
  color: var(--text-main);
  background: var(--bg-workspace);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Desktop tidak scroll window utama */
}

/* Helper Class untuk halaman yang WAJIB scroll (Settings) */
body.scrollable {
  height: auto !important;
  overflow-y: auto !important;
}

/* Fix: Sembunyikan Tab Mobile di Desktop */
.mobile-tabs {
  display: none;
}

/* =========================================================
   2. HEADER & NAVIGATION
   ========================================================= */
.app-header {
  height: 60px;
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 50;
  flex-shrink: 0;
}

.header-left,
.header-right,
.header-center {
  display: flex;
  align-items: center;
  gap: 12px;
}
.home-btn {
  color: var(--text-muted);
  font-size: 1.2rem;
  text-decoration: none;
}
.home-btn:hover {
  color: var(--primary);
}
.divider-v {
  width: 1px;
  height: 24px;
  background: var(--border);
}
.doc-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.nav-item {
  background: transparent;
  border: none;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 6px;
}
.nav-item:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.btn-secondary {
  background: white;
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: 0.2s;
}
.btn-primary-header {
  background: var(--primary);
  border: none;
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: 0.2s;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

/* =========================================================
   3. WORKSPACE LAYOUT (DESKTOP)
   ========================================================= */
.workspace-container {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Sidebar Kiri */
.config-panel {
  width: 500px; /* Lebar Sidebar Desktop */
  min-width: 500px;
  background: var(--bg-workspace);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto; /* Scrollable internal */
}
.panel-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* Stage Kanan (Preview) */
.stage-panel {
  flex: 1;
  background: var(--bg-stage);
  display: flex;
  flex-direction: column;
  position: relative;
}
.stage-toolbar {
  height: 40px;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  color: #cbd5e1;
  font-size: 0.75rem;
  font-weight: 600;
}
.stage-content {
  flex: 1;
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 40px;
}

/* =========================================================
   4. COMPONENTS: INPUT CARDS
   ========================================================= */
.config-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.card-title {
  background: white;
  padding: 12px 15px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title.flex-between {
  justify-content: space-between;
}
.card-body {
  padding: 15px;
}
.card-body.no-pad {
  padding: 0;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.input-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.mt-3 {
  margin-top: 12px;
}

input,
textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-main);
  transition: 0.2s;
}
input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.input-group.suffix {
  position: relative;
}
.input-group.suffix::after {
  content: attr(data-suffix);
  position: absolute;
  right: 10px;
  bottom: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  pointer-events: none;
}

.tabs-fake {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  position: relative;
}
.tab-label {
  font-size: 0.6rem;
  font-weight: 700;
  color: #94a3b8;
  padding: 4px 8px;
  margin-bottom: 2px;
}
.input-ghost {
  border: none;
  background: transparent;
  padding: 6px 8px;
  font-size: 0.9rem;
  font-weight: 500;
}
.input-ghost:focus {
  box-shadow: none;
  background: white;
  border-radius: 4px;
}

.upload-area input {
  display: none;
}
.upload-label {
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 15px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transition: 0.2s;
}
.upload-label:hover {
  background: #f8fafc;
  border-color: var(--primary);
  color: var(--primary);
}

.item-row {
  display: grid;
  grid-template-columns: 1.5fr 0.6fr 1fr auto;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid #f1f5f9;
  align-items: center;
}
.item-row:last-child {
  border-bottom: none;
}
.btn-remove {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}
.btn-xs {
  background: #f1f5f9;
  border: 1px solid var(--border);
  font-size: 0.7rem;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
}

/* =========================================================
   5. INVOICE PAPER (A4)
   ========================================================= */
.a4-paper {
  width: 210mm;
  height: 296mm;
  background: white;
  padding: 15mm;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.invoice-header {
  display: flex;
  justify-content: space-between;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 15px;
  margin-bottom: 20px;
}
.sender-details h1 {
  font-size: 1.4rem;
  color: var(--primary);
  margin-bottom: 5px;
}
.sender-details p {
  font-size: 0.85rem;
  color: var(--text-muted);
  width: 250px;
  line-height: 1.4;
}
.invoice-meta {
  text-align: right;
}
.invoice-meta .title {
  font-size: 1.8rem;
  color: #cbd5e1;
  letter-spacing: 2px;
}
.meta-row {
  margin-top: 5px;
  font-size: 0.85rem;
}
.client-section {
  margin-bottom: 30px;
}
.client-section small {
  color: var(--text-muted);
  font-size: 0.75rem;
}
.client-section h3 {
  font-size: 1.1rem;
  margin-top: 5px;
}
.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 30px;
}
.invoice-table th {
  text-align: left;
  background: #f8fafc;
  padding: 8px 10px;
  font-size: 0.75rem;
  border-bottom: 1px solid #cbd5e1;
}
.invoice-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.text-right {
  text-align: right;
}
.invoice-footer {
  display: flex;
  justify-content: space-between;
  margin-top: auto;
}
.terbilang-box {
  width: 55%;
  font-size: 0.8rem;
}
.terbilang-text {
  background: #f0fdf4;
  color: #15803d;
  padding: 10px;
  border-radius: 6px;
  font-style: italic;
  margin-top: 5px;
  border-left: 3px solid var(--primary);
}
.totals-box {
  width: 40%;
  font-size: 0.85rem;
}
.total-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}
.grand-total {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--primary);
  border-top: 2px solid #cbd5e1;
  padding-top: 10px;
  margin-top: 10px;
}
.signature-section {
  margin-top: 40px;
  text-align: center;
}

/* =========================================================
   6. DATA PAGES (HISTORY & CLIENTS)
   ========================================================= */
.page-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-workspace);
}
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 40px 20px;
}
.container-limit {
  max-width: 1000px;
  margin: 0 auto;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}
.page-head h1 {
  font-size: 1.8rem;
  color: var(--text-main);
  margin-bottom: 5px;
}
.page-head p {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.data-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.table-responsive {
  width: 100%;
  overflow-x: auto;
}
.modern-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}
.modern-table th {
  text-align: left;
  background: #f8fafc;
  padding: 15px 20px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.modern-table td {
  padding: 15px 20px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.9rem;
  color: var(--text-main);
}
.modern-table tr:hover td {
  background: #fcfcfc;
}
.badge-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-pill.green {
  background: #dcfce7;
  color: #166534;
}
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state i {
  font-size: 3rem;
  margin-bottom: 15px;
  color: #cbd5e1;
  display: block;
}

/* Tombol Aksi Kapsul */
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  text-decoration: none;
}
.btn-use {
  background-color: #ecfdf5;
  color: #059669;
  border-color: #d1fae5;
}
.btn-use:hover {
  background-color: #10b981;
  color: white;
  border-color: #10b981;
  transform: translateY(-2px);
  box-shadow: 0 2px 5px rgba(16, 185, 129, 0.2);
}
.btn-del {
  background-color: #fff;
  color: #ef4444;
  border-color: #fee2e2;
}
.btn-del:hover {
  background-color: #fef2f2;
  border-color: #ef4444;
  color: #dc2626;
}

/* =========================================================
   7. DRAWER & SWEETALERT
   ========================================================= */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: 0.3s;
}
.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}
.drawer-content {
  width: 280px;
  height: 100%;
  background: white;
  transform: translateX(-100%);
  transition: 0.3s;
  display: flex;
  flex-direction: column;
}
.drawer-overlay.open .drawer-content {
  transform: translateX(0);
}
.drawer-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.drawer-links {
  list-style: none;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.drawer-links a {
  text-decoration: none;
  color: var(--text-main);
  font-weight: 500;
  padding: 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: 0.2s;
}
.drawer-links a:hover {
  background: #f8fafc;
  color: var(--primary);
}
.drawer-links hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 5px 0;
}
.btn-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
}

div:where(.swal2-container) div:where(.swal2-popup) {
  font-family: "Inter", sans-serif !important;
  border-radius: 16px !important;
}
.swal2-confirm {
  background-color: #10b981 !important;
}

/* ... (Kode CSS lama Anda) ... */

/* [BARU] CSS untuk Layout Tanda Tangan 2 Kolom */
.signature-grid {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-top: 40px;
  padding-top: 20px;
  /* Pastikan tidak nabrak footer angka */
  width: 100%;
}

.sig-block {
  text-align: center;
  width: 45%; /* Bagi ruang jadi 2 */
}
.sig-block p {
  margin-bottom: 5px;
}

/* =========================================================
   9. PRINT MEDIA (UPDATE UNTUK SIGNATURE BARU)
   ========================================================= */
@media print {
  /* ... (Aturan @page dan body * hidden TETAP SAMA) ... */

  /* ... (Aturan .stage-panel dll TETAP SAMA) ... */

  /* Tambahkan aturan ini agar Grid Tanda Tangan tetap Flex saat diprint */
  .signature-grid {
    display: flex !important;
    justify-content: space-between !important;
    page-break-inside: avoid !important;
    width: 100% !important;
  }

  .sig-block {
    width: 40% !important; /* Sedikit dikecilkan agar aman marginnya */
    text-align: center !important;
    display: block !important;
  }

  /* ... (Sisanya biarkan sama) ... */
}

/* =========================================================
   8. MOBILE RESPONSIVE (FINAL FIX SCROLL - V2)
   ========================================================= */
@media (max-width: 900px) {
  /* 1. RESET BODY AGAR BISA SCROLL (GLOBAL FIX) */
  html {
    height: auto !important;
    overflow: auto !important;
  }

  body {
    height: auto !important;
    min-height: 100vh !important;
    overflow-y: auto !important; /* Wajib Auto */
    overflow-x: hidden !important;
    display: block !important;
    position: relative;
    padding-bottom: 50px; /* Tambahan ruang di paling bawah */
  }

  /* 2. Header & Tabs Sticky */
  .app-header {
    position: sticky;
    top: 0;
    padding: 0 15px;
    height: 55px;
    z-index: 1000;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  }

  .doc-title {
    display: none;
  }
  .header-left .home-btn {
    font-size: 1.1rem;
  }
  .nav-item {
    font-size: 0.75rem;
    padding: 5px 8px;
  }
  .btn-primary-header {
    padding: 6px 12px;
    font-size: 0.75rem;
  }
  .btn-secondary {
    padding: 6px 10px;
    font-size: 0.75rem;
  }

  /* ... (kode @media lainnya tetap sama) ... */

  /* UPDATE: Tambahkan transisi halus pada tabs */
  .mobile-tabs {
    display: flex;
    position: sticky;
    top: 55px;
    z-index: 900;
    background: white;
    padding: 8px 15px;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    /* Animasi Transisi */
    transition:
      transform 0.3s ease-in-out,
      opacity 0.3s ease-in-out;
  }

  /* LOGIKA BARU: Saat Menu Terbuka, Tabs Naik ke Atas & Menghilang */
  body.menu-open .mobile-tabs {
    transform: translateY(-120%); /* Geser ke atas (di balik header) */
    opacity: 0;
    pointer-events: none; /* Agar tidak bisa diklik saat sembunyi */
  }

  /* ... (sisa kode @media ke bawah tetap sama) ... */
  .tab-btn {
    flex: 1;
    padding: 8px;
    font-size: 0.85rem;
    background: #f1f5f9;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    box-shadow: none;
  }
  .tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 5px rgba(16, 185, 129, 0.3);
  }

  /* 3. Workspace Flow (App Editor) */
  .workspace-container {
    display: block !important;
    padding: 0;
    height: auto !important;
    overflow: visible !important;
  }

  /* Panel Kiri (Editor) */
  .config-panel {
    width: 100%;
    min-width: 100%;
    border-right: none;
    height: auto !important;
    overflow: visible !important;
    padding-bottom: 120px; /* Ruang ekstra di bawah tombol simpan */
    display: block;
  }
  .panel-content {
    padding: 15px;
    gap: 15px;
  }
  .config-card {
    border: 1px solid #e2e8f0;
    box-shadow: none;
  }
  .input-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* 4. Preview Stage */
  .stage-panel {
    display: none;
  }
  body.mode-preview .config-panel {
    display: none;
  }
  body.mode-preview .stage-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: calc(100vh - 110px);
    background: #334155;
    padding: 30px 0;
    overflow: hidden;
  }
  body.mode-preview .a4-paper {
    transform: scale(0.42);
    transform-origin: top center;
    margin-bottom: -160mm;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
    min-width: 210mm;
  }

  /* 5. FIX KHUSUS HALAMAN DATA & SETTINGS */
  /* Pastikan container halaman biasa tidak terkunci */
  .page-layout {
    height: auto !important;
    min-height: 100vh !important;
    display: block !important;
    overflow: visible !important;
  }

  .page-content {
    padding: 20px 15px 100px 15px; /* Padding bawah BESAR agar scroll tembus */
    overflow: visible !important;
    height: auto !important;
  }

  .container-limit {
    width: 100%;
    max-width: 100%;
  }

  /* 6. Komponen Lain */
  .page-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }
  .page-head h1 {
    font-size: 1.5rem;
  }
  .page-head button {
    width: 100%;
    justify-content: center;
  }

  .modern-table,
  .modern-table tbody,
  .modern-table tr,
  .modern-table td {
    display: block;
    width: 100%;
  }
  .modern-table {
    min-width: auto;
  }
  .modern-table thead {
    display: none;
  }
  .modern-table tr {
    background: white;
    margin-bottom: 15px;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  }
  .modern-table td {
    padding: 5px 0;
    border: none;
    text-align: left;
  }
  .modern-table td:nth-of-type(1)::before {
    content: "Main: ";
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    display: block;
  }
  .modern-table td:nth-of-type(2)::before {
    content: "Detail: ";
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    display: block;
  }
  .modern-table td:last-child {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
  }

  .hide-mobile {
    display: none !important;
  }

  /* 7. SweetAlert */
  div:where(.swal2-container) div:where(.swal2-popup) {
    width: 85% !important;
    padding: 1.2rem !important;
    border-radius: 12px !important;
  }
}

/* =========================================================
   9. PRINT MEDIA (FINAL & AGGRESSIVE FIX)
   ========================================================= */
@media print {
  /* 1. Atur Halaman Browser */
  @page {
    size: A4 portrait;
    margin: 0 !important; /* Hapus margin browser total */
  }

  /* 2. Sembunyikan SEMUA elemen web */
  body * {
    visibility: hidden; /* Sembunyikan visual */
    height: 0; /* Hilangkan ruang */
    overflow: hidden;
  }

  /* 3. Munculkan HANYA Kertas Invoice & Isinya */
  .stage-panel,
  .stage-content,
  #invoicePreview,
  #invoicePreview * {
    visibility: visible !important; /* Munculkan kembali */
    height: auto !important; /* Kembalikan tinggi */
    overflow: visible !important;
    display: block !important;
  }

  /* 4. Reset Posisi Kertas ke Pojok Kiri Atas (0,0) */
  #invoicePreview {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 210mm !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 10mm !important; /* Padding cetak aman */

    /* Hapus styling web */
    background: white !important;
    box-shadow: none !important;
    border: none !important;
    transform: none !important; /* Reset zoom preview */

    z-index: 9999 !important;
  }

  /* 5. Skala Konten Agar Muat (Fit to Page) */
  /* Jika konten terlalu lebar/panjang, kecilkan sedikit */
  .invoice-table,
  .invoice-header,
  .invoice-footer {
    width: 100% !important;
  }

  /* 6. Mencegah Page Break di Tengah Tabel/Tanda Tangan */
  tr,
  .signature-section {
    page-break-inside: avoid !important;
  }
}

/* =========================================================
   10. PRO TEMPLATE STYLES (DARK NAVY, WHITE TEXT, WIDE LABEL)
   ========================================================= */

/* --- DEFINISI WARNA (DARK THEME) --- */
:root {
  --pro-bg-dark: #001842; /* Latar Gelap Mewah */
}

.pro-template {
  font-family: "Roboto", sans-serif !important;
  color: #000;
  padding: 10mm !important;
}

/* --- HEADER STRIP --- */
.pro-header-strip {
  background-color: var(--pro-bg-dark);
  color: white; /* Teks Putih */
  text-align: center;
  font-weight: 700;
  font-size: 1.2rem;
  padding: 8px 0;
  margin-bottom: 15px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.pro-header-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
}
.pro-header-info h2 {
  font-size: 1rem;
  margin: 0 0 5px 0;
  font-weight: 800;
}
.pro-header-info div {
  font-size: 0.8rem;
  line-height: 1.3;
}

/* --- LOGO FRAME PLACEHOLDER --- */
.circle-logo-frame {
  width: 80px;
  height: 80px;
  background: var(--pro-bg-dark);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-weight: bold;
  font-size: 0.8rem;
}
.circle-logo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* GRID BOX */
.pro-grid-box {
  border: 1px solid #000;
  margin-bottom: 5px;
  font-size: 0.8rem;
}
.pg-row {
  display: flex;
}
.pg-col-left {
  flex: 6;
  padding: 5px;
}
.pg-col-right {
  flex: 4;
  padding: 5px;
}
.border-bottom {
  border-bottom: 1px solid #000;
}
.border-right {
  border-right: 1px solid #000;
}

/* [PERBAIKAN DISINI: LABEL DIPERLEBAR] */
.field-row {
  display: flex;
  margin-bottom: 2px;
}
.field-row .label {
  /* Ubah dari 110px menjadi 140px agar "CUSTOMER NAME" muat */
  width: 140px;
  font-weight: 600;
  /* Paksa teks tetap satu baris (tidak boleh turun) */
  white-space: nowrap;
}
.field-row .sep {
  width: 10px;
}
.field-row .val {
  flex: 1;
  font-weight: 500;
  text-transform: uppercase;
}

/* PRO TABLE */
.pro-table-wrapper {
  margin-bottom: 5px;
}
.pro-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #000;
  font-size: 0.8rem;
}
.pro-table th {
  background: var(--pro-bg-dark);
  color: white;
  text-align: center;
  padding: 5px;
  border: 1px solid #000;
  letter-spacing: 0.5px;
}
.pro-table td {
  border-left: 1px solid #000;
  border-right: 1px solid #000;
  padding: 4px 8px;
}
.pro-table tr {
  border-bottom: none;
}

/* FOOTER SECTION */
.pro-footer-section {
  display: flex;
  border: 1px solid #000;
  border-top: none;
  margin-bottom: 10px;
}
.pfs-left {
  flex: 6;
  padding: 5px;
  border-right: 1px solid #000;
  display: flex;
  align-items: flex-start;
}
.pfs-right {
  flex: 4;
}

.terbilang-box-pro {
  font-size: 0.75rem;
  font-weight: 700;
  font-style: italic;
  padding: 5px;
}
.uppercase {
  text-transform: uppercase;
}

/* TOTALS TABLE */
.pro-totals-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.pro-totals-table td {
  padding: 4px 8px;
  border: 1px solid #000;
}
.head-blue {
  background: var(--pro-bg-dark);
  color: white;
  text-align: center;
  font-weight: 700;
  width: 40%;
}
.val-cell {
  text-align: right;
  font-weight: 700;
}

/* NOTES & SIGNATURES */
.pro-notes-box {
  border: 1px solid #000;
  padding: 5px;
  font-size: 0.75rem;
  min-height: 50px;
  margin-bottom: 20px;
}

.pro-signatures {
  display: flex;
  justify-content: space-between;

  /* [UPDATE JARAK] Diubah dari 20px menjadi 60px agar lebih lega & ideal */
  margin-top: 60px;

  padding: 0 10px;
  font-family: "Roboto", sans-serif;
}

/* SETTING UNTUK SEMUA KOTAK TANDA TANGAN */
.sig-box {
  width: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  overflow: visible !important;
  position: relative;
  z-index: 10;
}

.sig-space {
  height: 70px;
  width: 100%;
  position: relative;
  z-index: 20;
}

.sig-title {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.85rem;
  margin-bottom: 5px;
  white-space: nowrap;
}

.underline {
  text-decoration: underline;
  font-weight: 700;
}

.sig-job {
  font-size: 0.8rem;
  margin-top: 2px;
}

/* Garis Manual (Khusus Customer) */
.line-sig {
  border-bottom: 1px solid #000;
  width: 100%;
  height: 20px;
  margin-top: 0;
  display: block;
}

/* =========================================
   MODERN INTERACTIVE SIGNATURE (FIX LAYER)
   ========================================= */

/* Wrapper Gambar (Area Interaktif) */
.sig-wrapper {
  position: absolute;
  cursor: grab;
  border: 1px dashed transparent;
  padding: 2px;
  transition: border-color 0.2s;
  user-select: none;
}

/* Saat mouse hover / sedang aktif dragging */
.sig-wrapper:hover,
.sig-wrapper.active {
  border-color: #3b82f6;
}

/* Kursor saat menahan klik (dragging) */
.sig-wrapper:active {
  cursor: grabbing;
}

/* Titik Resize di Pojok Kanan Bawah */
.resize-handle {
  width: 12px;
  height: 12px;
  background-color: #3b82f6;
  border: 2px solid white;
  border-radius: 50%;
  position: absolute;
  bottom: -6px;
  right: -6px;
  cursor: nwse-resize;
  display: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 101;
}

/* Tampilkan titik resize saat hover */
.sig-wrapper:hover .resize-handle,
.sig-wrapper.active .resize-handle {
  display: block;
}

/* Sembunyikan semua alat bantu saat Print */
@media print {
  .sig-wrapper {
    border: none !important;
  }
  .resize-handle {
    display: none !important;
  }

  .stage-panel,
  .stage-content,
  #invoicePreview,
  #invoicePreviewPro,
  #invoicePreviewPro * {
    visibility: visible !important;
    height: auto !important;
    display: block !important;
  }
  #invoicePreviewPro {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 210mm !important;
    margin: 0 !important;
    padding: 10mm !important;
    background: white !important;
    z-index: 9999;
  }
  .a4-paper {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}

/* =========================================
   FIX PDF TEXT RENDERING (ANTI-DEMPET)
   ========================================= */

.pro-template,
.pro-template * {
  letter-spacing: 0.5px !important;
  word-spacing: 2px !important;
  text-rendering: optimizeLegibility !important;
  -webkit-font-smoothing: antialiased;
}

.pro-header-info h2 {
  letter-spacing: 1px !important;
  word-spacing: 3px !important;
  margin-bottom: 8px !important;
}

.pro-table td {
  padding: 6px 8px !important;
  line-height: 1.4 !important;
}

.terbilang-box-pro {
  line-height: 1.5 !important;
  word-spacing: 4px !important;
  letter-spacing: 0.5px !important;
}

.val-cell,
.text-right {
  letter-spacing: 0.5px !important;
}
