/* ─────────────────────────────────────────────────────────────
   forms.css — shared styles for AR Workspace forms
   Used by: form-contact, form-buyer, form-listing, form-offer,
   form-update-offer. Theme: data-theme on <html>, localStorage "ar-theme".
   ───────────────────────────────────────────────────────────── */

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

:root {
  --bg:        #0D1B2E;
  --surface:   #152338;
  --card:      #1A2E47;
  --border:    rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.16);
  --gold:      #C5A55A;
  --gold-dim:  rgba(197,165,90,0.15);
  --on-gold:   #0D1B2E;
  --text:      #EDF0F3;
  --muted:     #7A92A8;
  --input-bg:  rgba(0,0,0,0.22);
  --green:     #4BAF7A;
  --rose:      #C46A7A;
  --shadow:    0 12px 40px rgba(0,0,0,0.45);
  --backdrop:  rgba(5,12,22,0.66);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

[data-theme="light"] {
  --bg:        #F2F0EC;
  --surface:   #E8E5DF;
  --card:      #FFFFFF;
  --border:    rgba(0,0,0,0.08);
  --border-strong: rgba(0,0,0,0.20);
  --gold:      #86691C;
  --gold-dim:  rgba(134,105,28,0.12);
  --on-gold:   #FFFFFF;
  --text:      #1A2535;
  --muted:     #5A6E82;
  --input-bg:  #F7F5F1;
  --green:     #2C7E52;
  --rose:      #B0485B;
  --shadow:    0 12px 40px rgba(26,37,53,0.18);
  --backdrop:  rgba(26,37,53,0.45);
}

html { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
}
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  transition: color .18s, border-color .18s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--muted); }

/* ── Page ── */
.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 36px 24px 120px;
}
.page-title { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
.page-subtitle { color: var(--muted); margin-top: 6px; margin-bottom: 28px; max-width: 56ch; }

/* ── Panels ── */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 26px;
  margin-bottom: 16px;
}
.panel-title { font-size: 16px; font-weight: 600; margin-bottom: 18px; }
.section-divider { border: 0; border-top: 1px solid var(--border); margin: 22px 0; }

/* ── Fields ── */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.field label .opt { font-weight: 400; opacity: .8; }

.field input[type="text"],
.field input[type="tel"],
.field input[type="email"],
.field input[type="number"],
.field input[type="date"],
.field input[type="time"],
.field textarea,
.field select {
  width: 100%;
  font: inherit;
  font-size: 16px;               /* prevents iOS zoom on focus */
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px 12px;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.field select { appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%237A92A8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.field select option { background: var(--card); color: var(--text); }
.field input::placeholder, .field textarea::placeholder { color: var(--muted); opacity: .65; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}
.field.invalid input, .field.invalid select, .field.invalid textarea {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(196,106,122,0.18);
}
.field-error { color: var(--rose); font-size: 13px; margin-top: 6px; }
.help-text { font-size: 13px; color: var(--muted); margin-top: 6px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr 1.2fr; gap: 0 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 16px; }
@media (max-width: 620px) {
  .page { padding: 24px 16px 120px; }
  .panel { padding: 20px 18px; }
  .topbar { padding: 12px 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ── Disclosure (optional fields) ── */
.disclosure { margin-top: 4px; }
.disclosure > summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gold);
  padding: 4px 0;
  border-radius: 4px;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before {
  content: '';
  width: 7px; height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .15s;
}
.disclosure[open] > summary::before { transform: rotate(45deg); }
.disclosure-body { padding-top: 14px; }

/* ── Toggle switch ── */
.toggle-row { display: flex; align-items: center; gap: 12px; }
.toggle-row label:not(.toggle) { font-size: 15px; color: var(--text); cursor: pointer; }
.toggle { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.toggle .slider {
  position: absolute; inset: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  transition: background .18s, border-color .18s;
}
.toggle .slider::before {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: var(--muted);
  border-radius: 50%;
  transition: transform .18s, background .18s;
}
.toggle input:checked + .slider { background: var(--gold-dim); border-color: var(--gold); }
.toggle input:checked + .slider::before { transform: translateX(18px); background: var(--gold); }
.toggle input:focus-visible + .slider { box-shadow: 0 0 0 3px var(--gold-dim); }
.couple-row { padding: 6px 4px 22px; }

/* ── Collapsible (show/hide via .open) ── */
.collapsible { display: none; }
.collapsible.open { display: block; }
.panel.collapsible.open { display: block; }

/* ── Search / relation pickers ── */
.search-wrap { position: relative; }
.search-results {
  display: none;
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  max-height: 260px; overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 50;
}
.search-results .result-item { padding: 10px 12px; cursor: pointer; font-size: 14px; }
.search-results .result-item:hover { background: var(--gold-dim); }
.search-results .result-item .sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.search-results .result-new { padding: 10px 12px; cursor: pointer; font-size: 14px; color: var(--gold); border-top: 1px solid var(--border); }
.search-results .result-new:hover { background: var(--gold-dim); }
.selected-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--gold-dim);
  color: var(--text);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 3px 6px 3px 12px;
  font-size: 13px;
}
.selected-badge button {
  background: none; border: 0; cursor: pointer;
  color: var(--muted); font-size: 16px; line-height: 1;
  width: 22px; height: 22px; border-radius: 50%;
}
.selected-badge button:hover { color: var(--text); background: var(--border); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-size: 15px; font-weight: 600;
  padding: 11px 22px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: filter .15s, background .15s, border-color .15s;
}
.btn-primary, .btn-gold { background: var(--gold); color: var(--on-gold); }
.btn-primary:hover, .btn-gold:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .55; cursor: default; filter: none; }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.form-actions {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center; gap: 12px;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  z-index: 40;
}
.form-actions .btn-primary { min-width: 160px; }

/* ── Status pill ── */
.status-pill { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: 999px; background: var(--gold-dim); color: var(--gold); }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: var(--backdrop);
  z-index: 200;
  align-items: center; justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 28px;
  width: 100%; max-width: 420px;
}
.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.modal-msg { color: var(--muted); margin-bottom: 22px; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; }

/* ── Toast ── */
.toast {
  position: fixed; top: 18px; left: 50%;
  transform: translate(-50%, -16px);
  opacity: 0; pointer-events: none;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 12px 18px;
  font-size: 14px;
  max-width: min(92vw, 520px);
  z-index: 300;
  transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.toast-error { border-left-color: var(--rose); }

/* ── Focus + motion ── */
a:focus-visible, button:focus-visible, summary:focus-visible, .theme-toggle:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ═════════ Extras folded in from individual pages ═════════ */
/* ── Shared helpers ── */
.help-text a { color: var(--gold); text-underline-offset: 2px; }
.field input[readonly] { color: var(--muted); cursor: default; }
.panel-title .opt {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}
.flags-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px 20px;
}
.flags-grid .toggle-row { margin-bottom: 8px; }
.add-new-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  color: var(--gold);
  cursor: pointer;
  text-underline-offset: 2px;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 13px;
}
.add-new-link:hover { text-decoration: underline; }
.loading-msg {
  color: var(--muted);
  font-size: 14px;
  padding: 12px 0;
}
.field .note {
  font-size: 13px;
  color: var(--muted);
  margin: -8px 0 16px;
}

/* ── Callouts / nested groups ── */
.callout {
  margin: 4px 0 16px;
  padding: 12px 16px;
  background: var(--gold-dim);
  border-left: 3px solid var(--gold);
  border-radius: 8px;
}
.callout label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 500;
}
.callout input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--gold);
}
.nested { margin-top: 16px; }

/* ── Date-time input ── */
.field input[type="datetime-local"] {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px 12px;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input[type="datetime-local"]:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}

/* ── Direction toggle (offer) ── */
.direction-toggle {
  position: relative;
  display: flex;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  overflow: hidden;
  background: var(--input-bg);
}
.direction-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.direction-toggle label {
  flex: 1;
  text-align: center;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  margin: 0;
  transition: background .15s, color .15s;
}
.direction-toggle input:checked + label { background: var(--gold); color: var(--on-gold); }
.direction-toggle input:focus-visible + label { outline: 2px solid var(--text); outline-offset: -3px; }
.direction-section { display: none; }
.direction-section.active { display: block; }

/* ── Inline create panels ── */
.inline-create {
  display: none;
  margin-top: 12px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.inline-create.open { display: block; }
.inline-create .ic-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}
.inline-create .ic-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ── Collapsible panel (HOA) ── */
.panel-details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}
.panel-details > summary::-webkit-details-marker { display: none; }
.panel-details > summary::before {
  content: '';
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--gold);
  border-bottom: 2px solid var(--gold);
  transform: rotate(-45deg);
  transition: transform .15s;
  flex-shrink: 0;
}
.panel-details[open] > summary::before { transform: rotate(45deg); }
.panel-details[open] > summary { margin-bottom: 18px; }
.panel-details > summary:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
  border-radius: 4px;
}
.panel-details .hoa-hint {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  margin-left: auto;
}

/* ── Days + business-days row ── */
.inline-days {
  display: flex;
  align-items: center;
  gap: 14px;
}
.inline-days input[type="number"] { width: 96px; flex-shrink: 0; }
.inline-days .check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  margin: 0;
}
.inline-days .check input {
  width: 16px;
  height: 16px;
  accent-color: var(--gold);
}

/* ── Offer picker (update form) ── */
.offer-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.offer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.offer-row:hover { background: var(--gold-dim); }
.offer-row:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.offer-row.type-received { border-left-color: var(--gold); }
.offer-row-name { font-weight: 500; font-size: 15px; }
.offer-row-meta {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}
.offer-row-badge {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--border);
  color: var(--muted);
}
.badge-submitted { background: var(--gold-dim); color: var(--gold); }
.badge-received { background: var(--border-strong); color: var(--text); }
.badge-accepted { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
.badge-dead { background: color-mix(in srgb, var(--rose) 18%, transparent); color: var(--rose); }
.change-offer-link {
  display: inline-block;
  margin-bottom: 14px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  text-underline-offset: 2px;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 14px;
}
.change-offer-link:hover { color: var(--gold); }
.selected-offer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  margin-bottom: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: 12px;
}
.selected-offer-header.type-received { border-left-color: var(--gold); }
.selected-offer-header .offer-title { font-size: 16px; font-weight: 600; }
.selected-offer-header .offer-meta {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Auto-calculated dates ── */
.calc-dates-grid {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 16px;
  padding: 16px 18px;
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.calc-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--gold);
}
.calc-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gold-dim);
}
.calc-label { font-size: 12px; color: var(--muted); }
.calc-val { font-size: 15px; font-weight: 500; }
.calc-note {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--muted);
}

/* ── Accepted confirmation ── */
.warn-banner {
  display: none;
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--gold-dim);
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  font-size: 14px;
}
.warn-banner .warn-actions {
  margin-top: 10px;
  display: flex;
  gap: 10px;
}

/* ── Responsive (extras) ── */
@media (max-width: 620px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .direction-toggle { flex-direction: column; }
  .calc-dates-grid { grid-template-columns: 1fr 1fr; }
}
