/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: #f1f5f9;
  color: #0f172a;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

/* === SHELL === */
.portal-shell {
  width: min(1120px, calc(100% - 24px));
  margin: 0 auto;
  padding-top: 18px;
  padding-bottom: max(32px, env(safe-area-inset-bottom, 32px));
}

/* === HEADER === */
.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px 16px;
}

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

.brand-icon {
  display: grid;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  place-items: center;
  border-radius: 10px;
  background: #0f172a;
  overflow: hidden;
  padding: 2px;
}

.portal-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}

.portal-subtitle {
  margin: 2px 0 0;
  color: #64748b;
  font-size: 12px;
  line-height: 1.4;
}

.portal-link {
  color: #0e7490;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  padding: 8px 12px;
  border: 1.5px solid #a5f3fc;
  border-radius: 8px;
  background: #ecfeff;
  white-space: nowrap;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

/* === MAIN GRID === */
.portal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.7fr);
  gap: 14px;
  align-items: start;
}

/* === PANEL === */
.panel {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.panel-header {
  border-bottom: 1px solid #e2e8f0;
  padding: 16px 18px;
}

.panel-header h2 {
  margin: 0;
  font-size: 16px;
}

.panel-header p {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 13px;
  line-height: 1.5;
}

/* === FORM GRID === */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.field-full {
  grid-column: 1 / -1;
}

/* === LABELS === */
label {
  display: block;
  margin-bottom: 6px;
  color: #475569;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* === INPUTS / SELECTS / TEXTAREA === */
input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  font: inherit;
  font-size: 16px; /* ≥16px: cegah iOS auto-zoom saat fokus */
  outline: none;
  padding: 10px 13px;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}

textarea {
  min-height: 130px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #0891b2;
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.14);
}

/* Panah custom untuk select (karena appearance:none menghilangkan panah default) */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 36px;
  cursor: pointer;
}

/* === CHECKBOX ROW === */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  color: #334155;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.checkbox-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  min-height: 22px;
  flex-shrink: 0;
  border-radius: 6px;
  accent-color: #0e7490;
  cursor: pointer;
  -webkit-appearance: checkbox;
  appearance: checkbox;
}

/* === FORM ACTIONS === */
.form-actions {
  padding: 4px 18px 18px;
}

/* === BUTTONS === */
button {
  display: block;
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 12px;
  background: #0e7490;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.01em;
  padding: 12px 20px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s, opacity 0.12s;
}

button:active {
  opacity: 0.82;
}

@media (hover: hover) {
  button:hover { background: #155e75; }
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* === PORTAL MESSAGE === */
.portal-message {
  margin-bottom: 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}

/* === RECEIPT CARD === */
.portal-message-success {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #16a34a;
  padding: 0;
  overflow: hidden;
}

.receipt-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: #f0fdf4;
  border-bottom: 1px solid #dcfce7;
}
.receipt-top-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #16a34a;
  flex-shrink: 0;
}
.receipt-top-text strong {
  display: block;
  font-size: 14px;
  font-weight: 800;
  color: #14532d;
}
.receipt-top-text span {
  font-size: 12px;
  color: #4ade80;
  font-weight: 500;
}

.receipt-body {
  padding: 16px 20px;
}

/* Highlight row: Nomor Tiket + Kode Akses */
.receipt-highlight {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
@media (max-width: 480px) {
  .receipt-highlight { grid-template-columns: 1fr; }
}
.receipt-highlight-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.receipt-highlight-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
}
.receipt-ticket {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #0f172a;
  font-family: monospace;
}
.receipt-token {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #0f172a;
  font-family: monospace;
  background: #e0f2fe;
  border-radius: 5px;
  padding: 1px 7px;
  display: inline-block;
}

/* Info grid: Pokok Keluhan + Kategori */
.receipt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 20px;
  margin-bottom: 0;
}
@media (max-width: 480px) {
  .receipt-grid { grid-template-columns: 1fr; }
}
.receipt-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.receipt-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #94a3b8;
}
.receipt-value {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

/* Footer row */
.receipt-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 20px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  flex-wrap: wrap;
}
.receipt-note {
  font-size: 11.5px;
  color: #64748b;
  font-weight: 500;
  margin: 0;
}
.receipt-print-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #0f172a;
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 7px 16px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}
.receipt-print-btn:hover { background: #1e293b; }

.portal-message-error {
  padding: 14px 16px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #b91c1c;
  border-radius: 12px;
}

/* === STATUS PANEL === */
.status-panel form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.status-card {
  margin: 0 18px 18px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  padding: 16px;
}

.status-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.ticket-code {
  color: #0e7490;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 800;
  word-break: break-all;
}

.status-pill {
  border-radius: 999px;
  background: #cffafe;
  color: #0e7490;
  font-size: 11px;
  font-weight: 900;
  padding: 5px 10px;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-card h3 {
  margin: 10px 0;
  font-size: 15px;
  line-height: 1.4;
}

dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 12px;
}

dt {
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 3px 0 0;
  font-size: 13px;
  font-weight: 600;
  word-break: break-word;
}

.public-response {
  border-top: 1px solid #e2e8f0;
  padding-top: 12px;
}

.public-response p {
  margin: 6px 0 0;
  color: #475569;
  font-size: 13px;
  line-height: 1.6;
}

/* === LOCATION GRID (Kota / Kecamatan / Kelurahan) === */
.location-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 6px;
}

.location-grid > div > label {
  font-size: 10px;
  color: #64748b;
  margin-bottom: 4px;
  letter-spacing: 0.03em;
}

/* ========================================
   RESPONSIVE BREAKPOINTS
======================================== */

/* Tablet (≤ 740px): stack panels, form masih 2-col */
@media (max-width: 740px) {
  .portal-grid {
    grid-template-columns: 1fr;
  }

  .panel-header { padding: 14px 16px; }

  .form-grid { padding: 16px; gap: 12px; }
  .form-actions { padding: 4px 16px 16px; }

  .status-panel form { padding: 16px; }
  .status-card { margin: 0 16px 16px; }
}

/* Mobile (≤ 520px): form 1-kolom, location 1-kolom */
@media (max-width: 520px) {
  .portal-shell {
    width: calc(100% - 16px);
    padding-top: 12px;
  }

  .portal-header {
    padding: 12px 14px;
    gap: 10px;
  }

  .portal-title { font-size: 15px; }
  .portal-subtitle { font-size: 11px; }

  .form-grid {
    grid-template-columns: 1fr;
    padding: 14px;
    gap: 12px;
  }

  .field-full { grid-column: 1; }

  .form-actions { padding: 4px 14px 14px; }

  .panel-header { padding: 12px 14px; }

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

  dl { grid-template-columns: 1fr; }

  .status-panel form { padding: 14px; }
  .status-card { margin: 0 14px 14px; padding: 14px; }

  .checkbox-row { min-height: 44px; padding: 4px 0; }
}

/* Sangat kecil (≤ 360px) */
@media (max-width: 360px) {
  .portal-title { font-size: 14px; }
  .panel-header h2 { font-size: 15px; }
  input, select, textarea { font-size: 15px; }
}

/* === REDUCED MOTION (aksesibilitas & low-end) === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}
