/* =========================================================
   Acadia Homes · Payment Receipt Generator
   Stylesheet
   ---------------------------------------------------------
   - Brand tokens at :root — change these to rebrand.
   - Layout uses Tailwind utilities (loaded via CDN in HTML).
   - This file defines all custom components and the receipt.
   ========================================================= */

:root {
  /* Brand tokens — pulled from the Acadia Homes logo */
  --primary:        #2D4A3E;   /* forest green (logo) */
  --primary-dark:   #1F3429;
  --primary-light:  #4A6B5E;
  --accent:         #B89968;   /* warm gold */
  --accent-dark:    #8F7649;

  /* Feedback colors */
  --success:        #2D4A3E;
  --success-soft:   #DCEDE3;
  --warning:        #B45309;
  --warning-soft:   #FEF3C7;
  --danger:         #B91C1C;
  --danger-soft:    #FEE2E2;
  --info:           #1E4D6B;

  /* Neutrals */
  --paper:          #F4EFE5;   /* warm cream page bg */
  --cream-band:     #F2EDE3;   /* matches logo background */
  --surface:        #FFFFFF;
  --ink:            #14202B;
  --muted:          #6B7280;
  --border:         #E5DFD2;
  --border-strong:  #C9C0AB;
  --soft:           #FBF8F1;
  --table-header:   #F4F1EA;
}

* { box-sizing: border-box; }

body {
  font-family: 'Geist', system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  margin: 0;
}

.font-display { font-family: 'Fraunces', Georgia, serif; font-optical-sizing: auto; }

/* ============================================================
   App header
   ============================================================ */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.app-mark {
  width: 36px; height: 36px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--cream-band);
  border: 1px solid var(--border);
}
.brand-title {
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  color: var(--primary);
  margin: 0;
}
.brand-tagline {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1;
  margin: 6px 0 0;
}
.header-actions { display: flex; align-items: center; gap: 10px; }

@media (min-width: 768px) {
  .app-header-inner { padding: 16px 40px; }
}

/* ============================================================
   Buttons
   ============================================================ */
.btn-primary {
  background: var(--primary);
  color: white;
  padding: 9px 18px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s, transform 0.05s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border: none;
  font-family: inherit;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-ghost {
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border-strong);
  padding: 8px 14px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink); background: var(--soft); }

/* ============================================================
   Error summary banner
   ============================================================ */
.error-summary {
  max-width: 1400px;
  margin: 16px auto 0;
  padding: 12px 18px;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #FCA5A5;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 48px);
}
@media (min-width: 768px) {
  .error-summary { width: calc(100% - 80px); margin: 16px auto 0; }
}

/* ============================================================
   Page main layout
   ============================================================ */
.page-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  align-items: start;
}
@media (min-width: 1024px) {
  .page-main {
    padding: 32px 40px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  }
}

/* ============================================================
   Form
   ============================================================ */
.form-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.form-section {
  padding: 22px 24px;
  border-bottom: 1px solid var(--border);
}
.form-section:last-child { border-bottom: none; }

.section-head { margin-bottom: 16px; }
.section-title {
  font-family: 'Fraunces', serif;
  font-size: 19px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.1;
  margin: 0;
}
.section-meta { font-size: 11.5px; color: var(--muted); margin: 3px 0 0; }

/* Form fields */
.field-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
  display: block;
}
.req {
  color: var(--warning);
  margin-left: 2px;
  font-size: 11px;
}

.field-input {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
  color: var(--ink);
}
.field-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 74, 62, 0.16);
}
.field-input[readonly] {
  background: var(--soft);
  color: var(--muted);
  cursor: not-allowed;
}
.field-input--error {
  border-color: var(--danger);
}
.field-input--error:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14);
}
.field-error {
  color: var(--danger);
  font-size: 11.5px;
  margin: 5px 0 0;
  line-height: 1.35;
  font-weight: 500;
}
.field-error:empty { display: none; }

.field-info {
  color: var(--info);
  font-size: 11px;
  margin: 5px 0 0;
  line-height: 1.35;
  font-weight: 500;
}
.field-info:empty { display: none; }

.field-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

/* ============================================================
   Preview pane
   ============================================================ */
.preview-pane { position: sticky; top: 32px; }
@media (max-width: 1023px) { .preview-pane { position: static; } }

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.preview-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--muted);
  margin: 0;
}
.preview-meta {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   RECEIPT (preview + PDF source)
   ============================================================ */
.receipt {
  background: white;
  width: 100%;
  max-width: 595px;
  aspect-ratio: 595 / 842;
  box-shadow: 0 24px 60px -24px rgba(20, 32, 43, 0.22), 0 4px 12px -4px rgba(20, 32, 43, 0.08);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-size: 11px;
  color: var(--ink);
  position: relative;
}
.receipt::before {
  /* Thin brand strip at the very top */
  content: '';
  display: block;
  height: 6px;
  background: var(--primary);
  width: 100%;
}

/* Receipt header: cream band with logo + title */
.receipt-header {
  background: var(--cream-band);
  padding: 22px 36px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--border);
}
.receipt-brand { display: flex; align-items: center; gap: 14px; }
.receipt-logo {
  width: 64px;
  height: 64px;
  border-radius: 4px;
  object-fit: contain;
  background: var(--cream-band);
  flex-shrink: 0;
}
.receipt-brand-text h1 {
  font-family: 'Fraunces', serif;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--primary);
  margin: 0;
  line-height: 1.05;
}
.receipt-brand-text p {
  font-size: 10px;
  color: var(--primary-light);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 4px 0 0;
  font-weight: 500;
}
.receipt-title-block { text-align: right; }
.receipt-title-block .eyebrow {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.receipt-title-block h2 {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  margin: 2px 0 0;
  letter-spacing: -0.01em;
}
.receipt-title-block .rcpt-num {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* Receipt body */
.receipt-body {
  padding: 22px 36px 28px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Status pill */
.status-row { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.status-pill.paid { background: var(--success-soft); color: var(--success); }
.status-pill.partial { background: var(--warning-soft); color: var(--warning); }
.status-pill.pending { background: #F1F5F9; color: var(--muted); }
.status-dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.status-context { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Labels & values */
.r-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}
.r-value { font-size: 11px; line-height: 1.45; }
.r-value-strong { font-size: 12.5px; font-weight: 600; line-height: 1.4; }

/* Two-column meta */
.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  padding: 14px 0 16px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.meta-grid > div > div + div { margin-top: 9px; }

/* Section heading */
.section-heading {
  font-family: 'Fraunces', serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Stay details */
.stay-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 22px;
  font-size: 11px;
  margin: 0 0 22px;
}
.stay-grid dt {
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.stay-grid dd { color: var(--ink); margin: 0; font-weight: 500; }
.stay-grid dd.strong { font-weight: 600; }
.stay-grid .nights {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  color: var(--primary);
}

/* Payment breakdown */
.pay-block {
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 18px;
  margin-bottom: 18px;
}
.pay-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.pay-row.muted { color: var(--muted); }
.pay-divider { height: 1px; background: var(--border-strong); margin: 8px 0 6px; }
.pay-final {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 8px;
  margin-top: 4px;
  border-top: 2px solid var(--accent);
  font-variant-numeric: tabular-nums;
}
.pay-final .label {
  font-family: 'Fraunces', serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pay-final .amount {
  font-family: 'Fraunces', serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--accent-dark);
}
.pay-final.is-paid .amount { color: var(--primary); }
.due-by {
  font-size: 10px;
  color: var(--warning);
  margin-top: 6px;
  letter-spacing: 0.04em;
}
.due-by.paid { color: var(--muted); }

/* Remark */
.remark-box {
  background: var(--cream-band);
  border-left: 3px solid var(--primary);
  padding: 10px 14px;
  border-radius: 0 4px 4px 0;
  margin-bottom: 22px;
  font-size: 10.5px;
  line-height: 1.55;
}
.remark-box .r-label { margin-bottom: 3px; }

/* Signatures */
.signatures {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  padding-top: 28px;
}
.sig-line {
  border-top: 1px solid var(--ink);
  padding-top: 6px;
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}
.sig-line .name {
  font-family: 'Fraunces', serif;
  font-size: 11px;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  margin-bottom: 2px;
}

/* Receipt footer */
.receipt-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 10.5px;
  color: var(--muted);
}
.receipt-footer .brand-tag {
  color: var(--primary);
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0.04em;
}

@media (max-width: 1024px) {
  .receipt-header { padding: 18px 22px; }
  .receipt-body { padding: 18px 22px 22px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D4CFC2; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #B8B2A2; }
