/* ==========================================================================
   office-docs.css — Shared Stylesheet & A4 Print Layout for Dokumen Kantor
   Bantukerjain.com — Standar Human-Crafted Anti-AI-Slop & Print A4 Portrait
   ========================================================================== */

/* Override #results hidden default from legacy style.css on document pages */
body.terbilang-page #results,
body.doc-page #results {
  display: block;
}

.doc-page [hidden] {
  display: none !important;
}

.doc-page .wrap {
  max-width: 1200px;
}

/* --- Workspace Layout (Task-First Above the Fold) --- */
.doc-workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin: 14px 0 28px;
  align-items: start;
}

@media (min-width: 1024px) {
  .doc-workspace {
    grid-template-columns: minmax(0, 0.94fr) minmax(0, 1.06fr);
    gap: 24px;
  }

  .doc-preview-pane {
    position: sticky;
    top: 76px;
  }
}

/* --- Form Pane --- */
.doc-form-pane {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 20px;
  min-width: 0;
}

@media (max-width: 639px) {
  .doc-form-pane {
    padding: 16px;
  }
}

.doc-form-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid #E2E8F0;
}

.doc-form-head h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0F172A;
  margin: 0;
}

.doc-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.doc-fieldset-block {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid #E2E8F0;
}

.doc-fieldset-block:last-of-type {
  border-bottom: 0;
  margin-bottom: 8px;
  padding-bottom: 4px;
}

.doc-section-label {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
  margin: 0 0 12px;
}

.doc-field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 640px) {
  .doc-field-grid--2 {
    grid-template-columns: 1fr 1fr;
  }
}

.doc-field {
  min-width: 0;
}

.doc-field label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: #0F172A;
  margin-bottom: 5px;
}

.doc-req {
  color: #DC2626;
  font-weight: 700;
}

.doc-input,
.doc-select,
.doc-textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-height: 44px;
  padding: 10px 12px;
  font-size: 16px;
  font-family: inherit;
  line-height: 1.45;
  color: #0F172A;
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.doc-textarea {
  min-height: 76px;
  resize: vertical;
}

.doc-input:focus,
.doc-select:focus,
.doc-textarea:focus {
  outline: none;
  border-color: #2563EB;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.doc-input[aria-invalid="true"],
.doc-select[aria-invalid="true"],
.doc-textarea[aria-invalid="true"] {
  border-color: #DC2626;
  background: #FEF2F2;
}

.doc-input:disabled,
.doc-select:disabled,
.doc-textarea:disabled {
  background: #F1F5F9;
  color: #64748B;
  cursor: not-allowed;
}

.doc-hint {
  display: block;
  font-size: 0.8rem;
  color: #64748B;
  margin-top: 4px;
  line-height: 1.4;
}

.doc-error {
  font-size: 0.82rem;
  font-weight: 600;
  color: #DC2626;
  margin-top: 4px;
  min-height: 0;
}

.doc-error:empty {
  display: none;
}

.doc-check-row {
  display: flex;
  align-items: center;
  min-height: 44px;
  margin-top: 4px;
}

.doc-check-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #1E293B;
  cursor: pointer;
  margin: 0;
}

.doc-check-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: #2563EB;
  cursor: pointer;
}

.doc-terbilang-live {
  margin-top: 6px;
  padding: 8px 12px;
  background: #F8FAFC;
  border-left: 3px solid #2563EB;
  font-size: 0.86rem;
  font-weight: 600;
  color: #0F172A;
  overflow-wrap: anywhere;
}

.doc-compliance-note {
  margin-top: 8px;
  padding: 10px 12px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-left: 3px solid #64748B;
  border-radius: 6px;
  font-size: 0.82rem;
  color: #334155;
  line-height: 1.5;
}

/* --- File Upload Controls (Local-Only) --- */
.doc-file-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.doc-file-input {
  width: 100%;
  max-width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  font-size: 16px;
  font-family: inherit;
  color: #0F172A;
  background: #F8FAFC;
  border: 1px dashed #CBD5E1;
  border-radius: 8px;
  cursor: pointer;
}

.doc-file-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  padding: 6px 10px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 6px;
  font-size: 0.8rem;
  color: #334155;
}

.doc-file-meta[hidden] {
  display: none;
}

/* --- Dynamic Invoice Line Items --- */
.doc-items-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.doc-item-row {
  padding: 12px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
}

.doc-item-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.doc-item-num {
  font-size: 0.82rem;
  font-weight: 700;
  color: #475569;
  font-variant-numeric: tabular-nums;
}

.doc-item-subgrid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 8px;
}

@media (min-width: 520px) {
  .doc-item-subgrid {
    grid-template-columns: 110px 1fr;
  }
}

.doc-item-total-line {
  margin-top: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #0F172A;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* --- Buttons --- */
.doc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  font-size: 0.94rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.doc-btn--primary {
  background: #0F172A;
  color: #FFFFFF;
}

.doc-btn--primary:hover:not(:disabled) {
  background: #1E293B;
}

.doc-btn--secondary {
  background: #FFFFFF;
  color: #0F172A;
  border-color: #CBD5E1;
}

.doc-btn--secondary:hover:not(:disabled) {
  background: #F1F5F9;
}

.doc-btn--danger-ghost {
  background: transparent;
  color: #B91C1C;
  border-color: #FECACA;
  padding: 6px 12px;
  font-size: 0.84rem;
}

.doc-btn--danger-ghost:hover:not(:disabled) {
  background: #FEF2F2;
}

.doc-btn--sm {
  padding: 8px 12px;
  font-size: 0.84rem;
}

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

.doc-form-footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

/* --- Preview Pane & Actions --- */
.doc-preview-pane {
  min-width: 0;
}

.doc-actions {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.doc-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.doc-actions-row .doc-btn--primary {
  flex: 1 1 220px;
}

.doc-print-note {
  margin: 8px 0 0;
  font-size: 0.78rem;
  color: #475569;
  line-height: 1.45;
}

.doc-validation-banner {
  margin-top: 10px;
  padding: 10px 12px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #B91C1C;
}

.doc-validation-banner[hidden] {
  display: none;
}

/* --- A4 Sheet Preview (.doc-sheet) --- */
.doc-sheet {
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #0F172A;
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  border-radius: 6px;
  padding: 26px 28px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  line-height: 1.5;
  font-size: 0.9rem;
}

@media (max-width: 639px) {
  .doc-sheet {
    padding: 16px;
    font-size: 0.84rem;
  }
}

.doc-sheet .doc-num,
.doc-sheet td.num,
.doc-sheet th.num {
  font-variant-numeric: tabular-nums;
}

.doc-sheet-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 2px solid #0F172A;
}

.doc-sheet-brand {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  flex: 1 1 220px;
}

.doc-logo-img {
  max-width: 120px;
  max-height: 56px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.doc-logo-img[hidden] {
  display: none;
}

.doc-sheet-title-wrap {
  text-align: right;
  flex: 0 1 auto;
}

@media (max-width: 520px) {
  .doc-sheet-title-wrap {
    text-align: left;
  }
}

.doc-sheet-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #0F172A;
  margin: 0;
}

.doc-sheet-number {
  font-size: 0.86rem;
  color: #334155;
  margin: 4px 0 0;
  font-weight: 600;
}

/* Kuitansi Key-Value Table */
.doc-kv-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.doc-kv-row {
  display: grid;
  grid-template-columns: 155px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  padding-bottom: 8px;
  border-bottom: 1px dashed #E2E8F0;
}

@media (max-width: 520px) {
  .doc-kv-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

.doc-kv-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: #475569;
}

.doc-kv-value {
  font-size: 0.92rem;
  font-weight: 600;
  color: #0F172A;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.doc-terbilang-box {
  background: #F8FAFC;
  border: 1px solid #CBD5E1;
  border-left: 4px solid #0F172A;
  padding: 8px 12px;
  font-weight: 700;
  font-style: italic;
  color: #0F172A;
  overflow-wrap: anywhere;
}

/* Kuitansi Footer: Amount + Signatures */
.doc-kuitansi-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-top: 20px;
}

.doc-amount-box {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 16px;
  background: #F8FAFC;
  border: 2px solid #0F172A;
  font-size: 1.15rem;
  font-weight: 800;
  color: #0F172A;
  font-variant-numeric: tabular-nums;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.doc-amount-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
}

/* Invoice Metadata & Parties */
.doc-invoice-meta-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

@media (min-width: 520px) {
  .doc-invoice-meta-grid {
    grid-template-columns: 1.2fr 0.8fr;
  }
}

.doc-party-block h3 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748B;
  margin: 0 0 4px;
}

.doc-party-name {
  font-weight: 700;
  font-size: 0.96rem;
  color: #0F172A;
  margin: 0;
}

.doc-party-detail {
  font-size: 0.84rem;
  color: #334155;
  white-space: pre-wrap;
  margin: 2px 0 0;
}

.doc-meta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.doc-meta-table td {
  padding: 3px 0;
  border: 0;
  vertical-align: top;
}

.doc-meta-table td:first-child {
  color: #475569;
  font-weight: 600;
  padding-right: 10px;
}

.doc-meta-table td:last-child {
  text-align: right;
  font-weight: 600;
  color: #0F172A;
}

/* Invoice Items Table */
.doc-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.doc-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 0.84rem;
  table-layout: fixed;
}

.doc-items-table th,
.doc-items-table td {
  padding: 8px 6px;
  border-bottom: 1px solid #E2E8F0;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.doc-items-table th {
  background: #F8FAFC;
  border-top: 1px solid #CBD5E1;
  border-bottom: 1px solid #CBD5E1;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #334155;
}

.doc-items-table th.num,
.doc-items-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.doc-col-no { width: 32px; }
.doc-col-desc { width: auto; }
.doc-col-qty { width: 48px; }
.doc-col-price { width: 105px; }
.doc-col-total { width: 112px; }

@media (max-width: 520px) {
  .doc-col-no { width: 26px; }
  .doc-col-qty { width: 40px; }
  .doc-col-price { width: 82px; }
  .doc-col-total { width: 88px; }
}

/* Invoice Totals */
.doc-totals {
  margin-left: auto;
  width: 100%;
  max-width: 320px;
  margin-bottom: 14px;
}

.doc-total-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  font-size: 0.86rem;
  border-bottom: 1px solid #F1F5F9;
}

.doc-total-row.is-grand {
  border-top: 2px solid #0F172A;
  border-bottom: 2px solid #0F172A;
  padding: 8px 0;
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 800;
  color: #0F172A;
}

.doc-notes-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 14px;
}

.doc-note-block h4 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #475569;
  margin: 0 0 4px;
}

.doc-note-block p {
  margin: 0;
  font-size: 0.84rem;
  color: #1E293B;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Signature & Meterai Area */
.doc-signature-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 24px;
  margin-top: 24px;
}

.doc-signature-box {
  min-width: 180px;
  max-width: 240px;
  text-align: center;
}

.doc-signature-date {
  font-size: 0.84rem;
  color: #334155;
  margin: 0 0 4px;
}

.doc-signature-role {
  font-size: 0.84rem;
  font-weight: 600;
  color: #0F172A;
  margin: 0 0 8px;
}

.doc-signature-visual {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}

.doc-meterai-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 78px;
  height: 52px;
  border: 1px dashed #64748B;
  font-size: 0.68rem;
  line-height: 1.2;
  color: #475569;
  text-align: center;
  padding: 4px;
  flex-shrink: 0;
}

.doc-meterai-box[hidden] {
  display: none;
}

.doc-sig-img {
  max-width: 140px;
  max-height: 64px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.doc-sig-img[hidden] {
  display: none;
}

.doc-signature-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: #0F172A;
  border-top: 1px solid #0F172A;
  padding-top: 4px;
  margin: 0;
}

.doc-signature-title {
  font-size: 0.78rem;
  color: #475569;
  margin: 2px 0 0;
}

.doc-is-muted {
  color: #64748B;
  font-style: italic;
  font-weight: 400;
}

/* --- Below the Fold Guide & FAQ --- */
.doc-guide-section {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 20px;
}

.doc-guide-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0F172A;
  margin: 0 0 12px;
}

.doc-guide-section details {
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  margin-bottom: 10px;
  background: #FFFFFF;
  overflow: hidden;
}

.doc-guide-section details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.94rem;
  color: #0F172A;
  cursor: pointer;
  background: #F8FAFC;
}

.doc-guide-section details[open] summary {
  border-bottom: 1px solid #E2E8F0;
  background: #F1F5F9;
}

.doc-faq-body {
  padding: 14px 16px;
  font-size: 0.9rem;
  color: #334155;
  line-height: 1.6;
}

.doc-faq-body p {
  margin: 0 0 8px;
}

.doc-faq-body p:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   Aturan Cetak A4 Portrait Wajib
   ========================================================================== */
@page {
  size: A4 portrait;
  margin: 14mm 16mm;
}

@media print {
  .topbar,
  .site-header,
  .bk-navbar,
  #siteHeader,
  .skip-link,
  .breadcrumb,
  .hero,
  .doc-form-pane,
  .doc-actions,
  .doc-presets,
  .doc-guide-section,
  .doc-faq,
  .b2b-sponsor-slot,
  .feedback-strip,
  .footer,
  .no-print,
  .bk-feedback-dialog,
  .bk-feedback-trigger {
    display: none !important;
  }

  html,
  body {
    background: #FFFFFF !important;
    color: #0F172A !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  main,
  .wrap,
  .doc-workspace,
  .doc-preview-pane {
    display: block !important;
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
  }

  .doc-sheet {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    font-size: 11pt;
  }

  .doc-sheet table {
    width: 100%;
    border-collapse: collapse;
  }

  .doc-sheet thead {
    display: table-header-group;
  }

  .doc-sheet tr,
  .doc-signature-grid,
  .doc-signature-box,
  .doc-totals,
  .doc-terbilang-box,
  .doc-kuitansi-footer {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .doc-sheet p,
  .doc-sheet li {
    orphans: 3;
    widows: 3;
  }
}
