/* Florida AI Partners — Client Portal. Self-contained, on-brand (teal/navy/ivory),
   mobile-first. No framework. Reuses the flagship's tokens + Sora/Inter/Lora feel. */

:root {
  --teal: #009ca8;
  --teal-deep: #007a83;
  --navy: #002454;
  --navy-soft: #14365e;
  --accent: #fc6000;
  --accent-hover: #c24a00;
  --bg: #f7f4ef;
  --surface: #ffffff;
  --line: #e4ddd2;
  --ink: #1d2a3a;
  --muted: #5d6b7b;
  --ok: #1c7a4a;
  --ok-wash: #e8f6ee;
  --warn-wash: #fff6e6;
  --warn-line: #f0c869;
  --danger: #b3261e;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(0, 36, 84, 0.06), 0 8px 24px rgba(0, 36, 84, 0.07);
  --font-display: "Sora", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Lora", Georgia, serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  font-size: 16px;
}
h1, h2, h3 { font-family: var(--font-display); color: var(--navy); line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 1em; }
a { color: var(--teal-deep); }
small, .muted { color: var(--muted); }
.muted { font-size: .9rem; }

/* ── Layout shells ── */
.shell { max-width: 760px; margin: 0 auto; padding: 18px 16px 96px; }
.center-shell {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
}
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card + .card { margin-top: 16px; }

/* ── Top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 30; background: var(--navy); color: #fff;
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
}
.topbar .brand { font-family: var(--font-display); font-weight: 700; letter-spacing: .2px; }
.topbar .brand span { color: #7fe3ea; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: .85rem; opacity: .85; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar button { background: transparent; color: #cfe6ff; border: 1px solid #335; }

/* ── Buttons ── */
button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--navy);
  padding: 11px 16px; min-height: 44px; transition: background .15s, border-color .15s, transform .02s;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--teal-deep); border-color: var(--teal-deep); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-sm { padding: 7px 11px; min-height: 36px; font-size: .9rem; }
.btn-danger { color: var(--danger); border-color: #ecc; }

/* ── Forms ── */
label { display: block; font-weight: 600; font-size: .92rem; margin: 0 0 6px; color: var(--navy-soft); }
input, textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 12px; min-height: 44px;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--teal); outline-offset: 1px; border-color: var(--teal); }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }

/* ── Dashboard section tiles ── */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile {
  display: flex; flex-direction: column; gap: 4px; text-align: left; align-items: flex-start;
  padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.tile:hover { border-color: var(--teal); }
.tile .ico { font-size: 1.4rem; }
.tile .t { font-family: var(--font-display); font-weight: 700; color: var(--navy); }
.tile .d { font-size: .82rem; color: var(--muted); }

/* ── AI box ── */
.ai-box { background: #f2fbfc; border: 1px solid #bfe7eb; border-radius: var(--radius); padding: 14px; margin-bottom: 16px; }
.ai-box h3 { color: var(--teal-deep); display: flex; align-items: center; gap: 7px; }
.ai-box .hint { font-size: .85rem; color: var(--muted); margin: -2px 0 10px; }

/* ── Banners / pills ── */
.banner { border-radius: var(--radius-sm); padding: 11px 13px; font-size: .92rem; margin-bottom: 14px; border: 1px solid; }
.banner-info { background: #eef6ff; border-color: #bcd9f5; color: #14365e; }
.banner-ok { background: var(--ok-wash); border-color: #bfe3cd; color: var(--ok); }
.banner-warn { background: var(--warn-wash); border-color: var(--warn-line); color: #7a5800; }
.banner-error { background: #fdeceb; border-color: #f1c2bf; color: var(--danger); }
.pill { display: inline-block; font-size: .74rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--warn-wash); color: #7a5800; border: 1px solid var(--warn-line); }
.pill-ok { background: var(--ok-wash); color: var(--ok); border-color: #bfe3cd; }

/* ── Diff / preview ── */
.diff-title { font-weight: 700; color: var(--navy); font-size: .9rem; margin: 12px 0 6px; }
.diff { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.diff-row { padding: 10px 12px; border-top: 1px solid var(--line); font-size: .9rem; }
.diff-row:first-child { border-top: 0; }
.diff-row .k { font-weight: 700; color: var(--navy); display: block; }
.diff-vals { margin-top: 2px; word-break: break-word; }
.diff .was { color: var(--muted); text-decoration: line-through; }
.diff .arrow { color: var(--muted); }
.diff .now { color: var(--ok); }
.diff-actions { margin-top: 12px; }

/* First-run hint + contact path */
.banner.onboard { border-left: 3px solid var(--teal); }
.contact-foot { font-size: .85rem; color: var(--muted); margin-top: 22px; }
.contact-foot a { color: var(--teal-deep); font-weight: 600; }

/* "Your services" settings group on the dashboard */
.group-title { font-family: var(--font-display); font-size: 1.15rem; color: var(--navy); margin: 28px 0 6px; }
.field select { width: 100%; font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }

/* Settings views: the website preview belongs only in the web editor — hide it
   and let the editor pane fill the width. */
.editor-layout.hide-preview .preview-pane { display: none; }
.editor-layout.hide-preview .editor-pane { flex: 1 1 auto; max-width: none; }

/* ── Repeatable rows (hours, menu, photos) ── */
.row-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 10px; background: #fcfbf8; }
.row-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.row-head .grip { color: var(--muted); cursor: grab; user-select: none; }
.row-head strong { flex: 1; }
.photo-row { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; }
.photo-row img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #eee; }

/* ── Sticky publish bar ── */
.publishbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--surface);
  border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(0,36,84,.08);
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
}
.publishbar .grow { flex: 1; font-size: .88rem; color: var(--muted); }
.hidden { display: none !important; }

/* ── Modal ── */
.modal-back { position: fixed; inset: 0; background: rgba(8,20,40,.45); display: grid; place-items: center; padding: 18px; z-index: 60; }
.modal { background: var(--surface); border-radius: var(--radius); max-width: 480px; width: 100%; padding: 22px; box-shadow: var(--shadow); }
/* Wider, scrollable variant — the pre-publish change review. */
.modal-wide { max-width: 580px; }
.modal-wide .diff { max-height: 52vh; overflow-y: auto; margin-top: 8px; }

/* ── Misc ── */
.brandmark { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; color: var(--navy); }
.brandmark span { color: var(--teal); }
.eyebrow { font-family: var(--font-display); text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; color: var(--teal-deep); font-weight: 700; }
.serif-lead { font-family: var(--font-serif); font-size: 1.05rem; color: var(--navy-soft); }
.stack > * + * { margin-top: 12px; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid #cfe6ea; border-top-color: var(--teal); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ── Two-column editor + live preview layout ── */

/*
  Wide: editor left (scrollable) + preview right (fixed height, fills window).
  Small: full-width editor; toggle reveals the preview pane instead.
*/
.editor-layout {
  display: flex;
  min-height: calc(100dvh - 48px); /* below the topbar */
}

/* Editor pane: scrollable column with the existing .shell inside */
.editor-pane {
  flex: 0 0 420px;
  max-width: 420px;
  min-width: 0;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--bg);
}

/* The .shell inside the editor pane keeps its own padding but loses auto-margin */
.editor-pane .shell {
  margin: 0;
  max-width: none;
  padding-bottom: 120px; /* room for the publish bar */
}

/* Preview pane: fills remaining width, sticky */
.preview-pane {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #e8e4dc;
  position: sticky;
  top: 48px; /* below topbar */
  height: calc(100dvh - 48px);
}

/* Label bar above the iframe */
.preview-pane__label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  background: var(--navy);
  color: #fff;
  font-size: .8rem;
  font-weight: 600;
  flex-shrink: 0;
}
.preview-pane__hint {
  flex: 1;
  opacity: .7;
  font-weight: 400;
  font-size: .75rem;
}
.preview-pane__refresh {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.25);
  color: #fff;
  min-height: 30px;
  padding: 4px 10px;
  font-size: .78rem;
}
.preview-pane__refresh:hover { background: rgba(255,255,255,.22); }

/* iframe + fallback overlay share a positioned wrapper that fills the pane */
.preview-body { position: relative; flex: 1 1 0; min-height: 0; }
.preview-pane__frame {
  position: absolute;
  inset: 0;
  border: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #fff;
}
/* Fallback overlay for no-domain / loading / couldn't-load states */
.preview-status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 28px;
  background: #f4f1ea;
  color: var(--navy-soft);
  font-size: .94rem;
  line-height: 1.5;
}
.preview-status[hidden] { display: none; }
.preview-status a { color: var(--teal-deep); font-weight: 600; }

/* Small-screen: stack the panes; toggle switches which is visible */
@media (max-width: 900px) {
  .editor-layout { display: block; }
  .editor-pane { max-width: none; border-right: 0; }
  .preview-pane {
    position: fixed;
    inset: 48px 0 0 0;
    height: calc(100dvh - 48px);
    display: none;
    z-index: 20;
  }
  /* When preview mode is active (class toggled by JS) */
  .editor-layout.show-preview .editor-pane { display: none; }
  .editor-layout.show-preview .preview-pane { display: flex; }
  /* Show the toggle button on small screens */
  .preview-toggle { display: inline-flex !important; }
}

/* On wide screens always show both panes; hide the toggle */
@media (min-width: 901px) {
  .preview-toggle { display: none !important; }
  /* Publish bar sits at bottom of editor pane only */
  .publishbar { left: 0; right: calc(100% - 420px); }
  /* …but spans full width in the Settings views, where the editor is full-width. */
  .editor-layout.hide-preview ~ .publishbar { right: 0; }
}
