/* ==========================================================================
   CHECKLIST HARIAN — KOORDINASI ZOOM (SPPG MBG)
   Pixel-faithful styling to PDF with modern interactivity & print support
   ========================================================================== */

:root {
  --navy-primary: #0b2545;
  --navy-dark: #07192f;
  --navy-light: #133966;
  --accent-gold: #f59e0b;
  --border-color: #6b7280;
  --border-light: #9ca3af;
  --text-main: #111827;
  --text-muted: #4b5563;
  --bg-app: #f1f5f9;
  --bg-page: #ffffff;
  --page-width: 210mm;
  --page-min-height: 297mm;
  --page-padding: 16mm 18mm;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.35;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   TOP TOOLBAR / DATEPICKER NAVIGATION BAR (Screen Only)
   ========================================================================== */
.top-toolbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #ffffff;
  border-bottom: 2px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  padding: 10px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toolbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-badge-icon {
  background: var(--navy-primary);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}

.toolbar-title h1 {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy-primary);
  line-height: 1.2;
}

.toolbar-title p {
  font-size: 11px;
  color: var(--text-muted);
}

.toolbar-date-nav {
  display: flex;
  align-items: center;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 4px 8px;
  gap: 8px;
}

.btn-nav-date {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--navy-primary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.btn-nav-date:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.date-picker-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.date-picker-input {
  border: 1px solid #94a3b8;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy-primary);
  background: #fff;
  outline: none;
  cursor: pointer;
}

.date-picker-input:focus {
  border-color: var(--navy-primary);
  box-shadow: 0 0 0 2px rgba(11, 37, 69, 0.15);
}

.date-display-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--navy-light);
  padding: 4px 8px;
  background: #e2e8f0;
  border-radius: 4px;
  white-space: nowrap;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.status-indicator.dirty {
  background: #fffbeb;
  color: #d97706;
  border-color: #fde68a;
}

.status-indicator.saved {
  background: #ecfdf5;
  color: #059669;
  border-color: #a7f3d0;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-action {
  background: var(--navy-primary);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-action:hover {
  background: var(--navy-light);
}

.btn-action.btn-secondary {
  background: #ffffff;
  color: var(--navy-primary);
  border: 1px solid #cbd5e1;
}

.btn-action.btn-secondary:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.btn-action.btn-accent {
  background: #0284c7;
}

.btn-action.btn-accent:hover {
  background: #0369a1;
}

.btn-action.btn-cloud {
  background: #7c3aed;
}

.btn-action.btn-cloud:hover {
  background: #6d28d9;
}

.btn-action.btn-print {
  background: #16a34a;
}

.btn-action.btn-print:hover {
  background: #15803d;
}

.status-indicator.cloud-active {
  background: #f5f3ff;
  color: #7c3aed;
  border-color: #ddd6fe;
}

.status-indicator.cloud-syncing {
  background: #eff6ff;
  color: #2563eb;
  border-color: #bfdbfe;
}

/* Sub-toolbar Quick Date Chips & View Switcher */
.sub-toolbar {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 6px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-dates {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.quick-label {
  color: var(--text-muted);
  font-weight: 500;
}

.date-chip {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--navy-primary);
  cursor: pointer;
  transition: all 0.1s;
}

.date-chip:hover, .date-chip.active {
  background: var(--navy-primary);
  color: #fff;
  border-color: var(--navy-primary);
}

.view-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}

.view-toggle {
  display: flex;
  background: #e2e8f0;
  border-radius: 6px;
  padding: 2px;
}

.view-toggle button {
  background: transparent;
  border: none;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
}

.view-toggle button.active {
  background: #fff;
  color: var(--navy-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ==========================================================================
   DOCUMENT CONTAINER & PDF PAGES
   ========================================================================== */
.document-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 80px 16px;
  gap: 28px;
}

/* When in continuous view mode */
.document-container.continuous-mode .pdf-page {
  margin: 0;
  box-shadow: none;
  border-bottom: 2px dashed #cbd5e1;
  border-radius: 0;
}

.document-container.continuous-mode .page-badge {
  display: none;
}

.pdf-page-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.page-badge {
  align-self: flex-start;
  margin-bottom: 6px;
  background: #e2e8f0;
  color: #475569;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

.pdf-page {
  width: var(--page-width);
  min-height: var(--page-min-height);
  padding: var(--page-padding);
  background: var(--bg-page);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.05);
  border-radius: 2px;
  position: relative;
  overflow: visible;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

/* Header Banner - Exact match to PDF */
.doc-header-banner {
  background-color: var(--navy-primary);
  color: #ffffff;
  text-align: center;
  padding: 11px 16px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 14px;
}

/* ==========================================================================
   TABLES & COMMON FORM STYLES
   ========================================================================== */
table.pdf-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 14px;
  font-size: 11.5px;
}

table.pdf-table th,
table.pdf-table td {
  border: 1px solid var(--border-color);
  padding: 5px 8px;
  vertical-align: middle;
}

table.pdf-table th {
  background-color: var(--navy-primary);
  color: #ffffff;
  font-weight: 700;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.25;
}

/* Metadata Top Table (Page 1) */
.meta-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 11.5px;
}

.meta-table td {
  border: 1px solid var(--border-color);
  padding: 4px 8px;
  vertical-align: middle;
}

.meta-label {
  font-weight: 700;
  width: 130px;
  color: var(--text-main);
  background-color: #fafafa;
}

.meta-value {
  width: 35%;
}

/* Section Headings */
.section-title {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 6px;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.subsection-header-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 10px;
  margin-bottom: 6px;
}

.subsection-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-main);
  text-transform: uppercase;
}

.role-badge {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.instruction-text {
  font-size: 10.5px;
  color: var(--text-main);
  margin-bottom: 6px;
}

.notes-bottom-box {
  margin-top: 4px;
  margin-bottom: 14px;
  font-size: 10.5px;
  color: var(--text-main);
  line-height: 1.35;
}

.notes-bottom-box .note-petunjuk {
  font-style: italic;
}

.notes-bottom-box .note-sumber {
  font-style: italic;
  color: var(--text-muted);
}

/* ==========================================================================
   INTERACTIVE CHECKBOXES & FORM INPUTS
   Exact reproduction of PDF's [x] / [ ] boxes and underlined input fields
   ========================================================================== */
.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
  margin-right: 12px;
  font-size: 11.5px;
  color: var(--text-main);
  vertical-align: middle;
}

.checkbox-inline:last-child {
  margin-right: 0;
}

.checkbox-box {
  width: 13px;
  height: 13px;
  border: 1.2px solid #222;
  border-radius: 1px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  font-size: 11px;
  font-weight: 700;
  color: #111;
  line-height: 1;
  transition: all 0.1s ease;
  flex-shrink: 0;
}

.checkbox-inline:hover .checkbox-box {
  border-color: var(--navy-primary);
}

.checkbox-inline.checked .checkbox-box {
  background: #ffffff;
  color: #0b2545;
}

.checkbox-inline.checked .checkbox-box::after {
  content: "✓";
  font-weight: 900;
  font-size: 11px;
  line-height: 1;
}

/* Underline inputs and text inputs */
.pdf-input {
  border: none;
  border-bottom: 1px solid #333;
  background: transparent;
  padding: 1px 4px;
  font-family: inherit;
  font-size: 11.5px;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease;
}

.pdf-input:focus {
  border-bottom: 1.5px solid var(--navy-primary);
  background: #f0f7ff;
}

.pdf-input-inline {
  width: auto;
  display: inline-block;
}

.pdf-input-full {
  width: 100%;
}

.pdf-input-table {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 11.5px;
  color: var(--text-main);
  padding: 2px 4px;
  outline: none;
}

.pdf-input-table:focus {
  background: #eff6ff;
  outline: 1px solid #3b82f6;
}

/* ==========================================================================
   SPECIFIC SECTION STYLING (MATCHING PDF EXACTLY)
   ========================================================================== */

/* Status Sertifikasi Box (Page 1) */
.cert-box-container {
  display: flex;
  justify-content: center;
  margin: 12px 0 16px 0;
}

.cert-box {
  border: 1px solid var(--border-color);
  width: 250px;
}

.cert-box-header {
  background-color: var(--navy-primary);
  color: #ffffff;
  font-weight: 700;
  font-size: 11.5px;
  text-align: center;
  padding: 5px 8px;
}

.cert-box-body {
  padding: 6px 12px;
  font-size: 11px;
  background: #fff;
}

.cert-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid #f1f5f9;
}

.cert-row:last-child {
  border-bottom: none;
}

/* Water Section Table/Block (Page 1) */
.air-bersih-block {
  border: 1px solid var(--border-color);
  margin-bottom: 14px;
}

.air-row {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  padding: 5px 8px;
  font-size: 11px;
  align-items: center;
}

.air-row:last-child {
  border-bottom: none;
}

.air-label {
  font-weight: 700;
  width: 140px;
  flex-shrink: 0;
}

.air-content {
  flex-grow: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

/* Ruang Penyimpanan Block (Page 2 & 3) */
.suhu-penyimpanan-block {
  border: 1px solid var(--border-color);
  margin-bottom: 14px;
  font-size: 11px;
}

.suhu-row {
  border-bottom: 1px solid var(--border-color);
  padding: 6px 8px;
}

.suhu-row:last-child {
  border-bottom: none;
}

/* Distribution Block (Page 6) */
.distribusi-block {
  border: 1px solid var(--border-color);
  margin-bottom: 14px;
  font-size: 11px;
}

.dist-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding: 4px 8px;
}

.dist-row:last-child {
  border-bottom: none;
}

.dist-label {
  font-weight: 700;
  width: 320px;
}

.dist-val {
  flex-grow: 1;
}

/* Temuan & Keputusan (Page 7) */
.temuan-box {
  border: 1px solid var(--border-color);
  min-height: 220px;
  padding: 8px;
  margin-bottom: 14px;
  background: #fff;
}

.temuan-textarea {
  width: 100%;
  height: 180px;
  border: none;
  font-family: inherit;
  font-size: 12px;
  color: var(--text-main);
  resize: vertical;
  outline: none;
}

.keputusan-box {
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  margin-bottom: 24px;
  background: #fff;
}

.keputusan-header {
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 8px;
}

.keputusan-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
}

/* Emergency Footer Banner (Page 7) - Exact match to PDF */
.emergency-footer {
  background-color: var(--navy-primary);
  color: #ffffff;
  text-align: center;
  padding: 10px 16px;
  margin-top: auto;
}

.emergency-title {
  color: var(--accent-gold);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.8px;
  margin-bottom: 3px;
  text-transform: uppercase;
}

.emergency-contact {
  font-size: 11.5px;
  letter-spacing: 0.5px;
  color: #ffffff;
}

/* ==========================================================================
   MODAL DIALOGS (Screen Only)
   ========================================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: #fff;
  border-radius: 8px;
  width: 90%;
  max-width: 520px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  overflow: hidden;
}

.modal-header {
  background: var(--navy-primary);
  color: #fff;
  padding: 12px 18px;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header button {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.modal-body {
  padding: 16px 18px;
  font-size: 13px;
}

.modal-footer {
  padding: 12px 18px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Toast Notification */
.toast-notice {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--navy-primary);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  z-index: 3000;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast-notice.show {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   PRINT STYLING (@media print)
   Matches original PDF 100% across 7 pages
   ========================================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 10mm 12mm;
  }

  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 10.5pt !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }

  .top-toolbar,
  .sub-toolbar,
  .page-badge,
  .modal-overlay,
  .toast-notice {
    display: none !important;
  }

  .document-container {
    padding: 0 !important;
    margin: 0 !important;
    gap: 0 !important;
    width: 100% !important;
    display: block !important;
  }

  .pdf-page-wrapper {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    page-break-after: always !important;
    break-after: page !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .pdf-page-wrapper:last-child {
    page-break-after: auto !important;
    break-after: auto !important;
  }

  .pdf-page {
    width: 100% !important;
    min-height: auto !important;
    height: auto !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
    display: block !important;
  }

  /* Make sure background colors print properly */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .doc-header-banner,
  table.pdf-table th,
  .cert-box-header,
  .emergency-footer {
    background-color: #0b2545 !important;
    color: #ffffff !important;
  }

  .emergency-title {
    color: #f59e0b !important;
  }

  .pdf-input {
    border-bottom: 1px solid #000 !important;
  }

  .checkbox-box {
    border-color: #000 !important;
  }
}

/* ==========================================================================
   RESPONSIVE DESIGN (FOR TABLETS / PHONES)
   ========================================================================== */
@media screen and (max-width: 900px) {
  :root {
    --page-width: 100%;
    --page-padding: 12px 14px;
  }

  .top-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-brand {
    justify-content: space-between;
  }

  .toolbar-date-nav {
    flex-wrap: wrap;
    justify-content: center;
  }

  .toolbar-actions {
    flex-wrap: wrap;
    justify-content: center;
  }

  .document-container {
    padding: 12px 8px;
  }

  .pdf-page {
    width: 100%;
    min-height: auto;
  }

  .meta-table, .pdf-table {
    font-size: 10.5px;
  }

  .cert-box {
    width: 100%;
  }
}
