/* Back office styles. Mobile-first: base styles are for phones, wider screens are
   handled at the bottom-of-file breakpoints. Colours live in variables so light
   and dark mode only redefine them. */

:root {
  --bg: #f7f4f2;
  --surface: #ffffff;
  --text: #241f21;
  --muted: #6b6266;
  --border: #e6dfdc;
  --primary: #9b4d63;
  --primary-hover: #843f52;
  --on-primary: #ffffff;
  --primary-soft: #f5e6ea;
  --success-bg: #e2f3e8;
  --success-text: #17603a;
  --danger-bg: #fbe4e4;
  --danger-text: #9b1c1c;
  --warn-bg: #fdf0d5;
  --warn-text: #7a4b00;
  --seg-attending: #2f9e63;
  --seg-declined: #d05a5a;
  --seg-pending: #c9bfc3;
  --shadow: 0 1px 2px rgba(36, 31, 33, 0.06);
  /* Love-note card colours (pastel paper) */
  --note-0: #fde8ee;
  --note-1: #fdf1dc;
  --note-2: #e6f2ea;
  --note-3: #e8ecfa;
  --note-4: #f3e8f7;
  --note-ink: #3b2a30;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171415;
    --surface: #211d1f;
    --text: #f2eded;
    --muted: #a89fa3;
    --border: #372f33;
    --primary: #d97a94;
    --primary-hover: #e592a9;
    --on-primary: #1a0f13;
    --primary-soft: #3a2630;
    --success-bg: #163524;
    --success-text: #8fdcae;
    --danger-bg: #3f1c1c;
    --danger-text: #f5b5b5;
    --warn-bg: #3d2e10;
    --warn-text: #f0cd85;
    --seg-pending: #5a5054;
    --shadow: none;
    --note-0: #3a2329;
    --note-1: #3a3022;
    --note-2: #233226;
    --note-3: #262b3d;
    --note-4: #33263a;
    --note-ink: #f5ecee;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  padding-bottom: 76px; /* room for the bottom nav on phones */
}

a { color: var(--primary); }
h1 { font-size: 1.6rem; margin: 0; line-height: 1.2; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
p { margin: 0 0 12px; }

/* ---------- Header and navigation ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }

.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  justify-content: space-around;
  gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.nav a {
  flex: 1;
  text-align: center;
  padding: 10px 4px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}
.nav a.active { background: var(--primary-soft); color: var(--primary); }

.signout { margin: 0; }
.link-button {
  background: none;
  border: 0;
  padding: 8px;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
}
.link-button:hover { color: var(--text); }

/* ---------- Layout ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 20px 16px; }
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.stack > * + * { margin-top: 16px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.footer { text-align: center; padding: 24px 16px; color: var(--muted); font-size: 0.85rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-flush { padding: 0; overflow: hidden; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-danger { background: var(--danger-text); color: var(--surface); }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 0.9rem; }

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.stat { display: block; text-decoration: none; color: inherit; }
.stat:hover { border-color: var(--primary); }
.stat .num { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: 0.9rem; }

.bar {
  display: flex;
  height: 12px;
  border-radius: 99px;
  overflow: hidden;
  background: var(--border);
  margin: 12px 0;
}
.bar span { display: block; min-width: 0; }
.seg-attending { background: var(--seg-attending); }
.seg-declined { background: var(--seg-declined); }
.seg-pending { background: var(--seg-pending); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.875rem; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field input:not([type="checkbox"]),
.field select,
.field textarea,
.search input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit; /* 16px keeps iOS from zooming on focus */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.help { color: var(--muted); font-size: 0.875rem; margin-top: 4px; }
.errorlist { list-style: none; margin: 6px 0 0; padding: 0; color: var(--danger-text); font-size: 0.9rem; }

/* ---------- Messages and alerts ---------- */
.msg, .alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; }
.msg-success { background: var(--success-bg); color: var(--success-text); }
.msg-error, .alert-error { background: var(--danger-bg); color: var(--danger-text); }
.alert-error ul { margin: 8px 0 0; padding-left: 20px; }

/* ---------- Search and filters ---------- */
.search { display: flex; gap: 8px; margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* A checkbox styled to look like a .chip, so several can be active at once
   (used for the venue status filter - real checkboxes, submitted with a form,
   rather than the single-select links .chip is normally used for). */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-checkbox { display: inline-flex; cursor: pointer; }
.chip-checkbox input {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0);
  overflow: hidden;
}
.chip-checkbox span {
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
}
.chip-checkbox input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.chip-checkbox input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.filter-panel { margin-bottom: 16px; }
.filter-panel .field { margin-bottom: 12px; }
.filter-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 12px; }
@media (min-width: 700px) {
  .filter-grid { grid-template-columns: repeat(5, 1fr); }
}

/* ---------- Venue comparison cards ---------- */
.venue-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 560px) {
  .venue-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1000px) {
  .venue-grid { grid-template-columns: repeat(3, 1fr); }
}
.venue-card { display: flex; flex-direction: column; gap: 12px; }
.venue-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.venue-card-head h3 { margin: 0 0 6px; font-size: 1.05rem; }
.icon-link {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--text);
}
.icon-link:hover { background: var(--primary-soft); color: var(--primary); }

.venue-card-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 16px;
  margin: 0;
}
.venue-card-stats dt { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.venue-card-stats dd { margin: 2px 0 0; font-weight: 600; }
.venue-card-flags { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 0.8rem; font-weight: 600; }
.badge-attending { background: var(--success-bg); color: var(--success-text); }
.badge-declined { background: var(--danger-bg); color: var(--danger-text); }
.badge-pending { background: var(--warn-bg); color: var(--warn-text); }
.badge-booked { background: var(--success-bg); color: var(--success-text); }
.badge-rejected { background: var(--danger-bg); color: var(--danger-text); }
.badge-considering, .badge-contacted, .badge-visit_scheduled, .badge-visited {
  background: var(--primary-soft); color: var(--primary);
}

/* ---------- Table (becomes a list of cards on phones) ---------- */
.table { width: 100%; border-collapse: collapse; }
.table thead { display: none; }
.table, .table tbody, .table tr, .table td { display: block; }
.table tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.table tr:last-child { border-bottom: 0; }
.table td {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0;
  text-align: right;
}
.table td::before {
  content: attr(data-label);
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: left;
}
.table td.actions { justify-content: flex-end; padding-top: 10px; }
.table td.actions::before { content: none; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-plain li:last-child { border-bottom: 0; }

/* ---------- Maps (Leaflet) ---------- */
.venue-map {
  height: 300px;
  margin-bottom: 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--border); /* shows while tiles are still loading */
}
#maps-paste.is-invalid { border-color: var(--danger-text); }
/* ---------- Toggle switches (canapes / seated meal) ---------- */
.toggle-field { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.toggle-field label { margin-bottom: 0; }
input.toggle-input {
  appearance: none;
  -webkit-appearance: none;
  width: 46px;
  height: 26px;
  min-height: 0;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--border);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
}
input.toggle-input::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}
input.toggle-input:checked { background: var(--primary); border-color: var(--primary); }
input.toggle-input:checked::before { transform: translateX(20px); }

/* ---------- Venue documents ---------- */
.doc-list { list-style: none; margin: 0 0 16px; padding: 0; }
.doc-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.doc-list li:last-child { border-bottom: 0; }
.doc-list a { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.doc-delete { margin: 0; }

.venue-map-notice {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}
.venue-map-overview {
  height: 60vh;
  min-height: 320px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--border);
}

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }

/* ---------- Love notes ---------- */
.alert-warn { background: var(--warn-bg); color: var(--warn-text); }
.note-heart { color: var(--primary); flex-shrink: 0; }

.note-teaser {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  border-color: var(--primary);
  background: var(--primary-soft);
}

.note-text {
  font-family: 'Caveat', 'Segoe Script', cursive;
  font-size: 1.45rem;
  line-height: 1.35;
  color: var(--note-ink);
  margin: 0;
  overflow-wrap: anywhere;
}
.note-text-large { font-size: 2.1rem; }

.note-today {
  position: relative;
  text-align: center;
  padding: 36px 24px 40px;
  margin-bottom: 32px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--note-0), var(--note-4));
  box-shadow: 0 10px 30px rgba(155, 77, 99, 0.15);
  animation: note-reveal 0.7s ease-out both;
}
.note-today .note-heart { margin-bottom: 4px; }
.note-today-label {
  margin: 0 0 12px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
}
@keyframes note-reveal {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .note-today { animation: none; }
}

.notes-earlier-heading { margin: 0 0 16px; }
.preview-banner { margin-bottom: 20px; }
/* A single card on the preview page, at the width it has on her board. */
.note-board.note-board-preview { columns: 1; max-width: 340px; }

/* Masonry: CSS columns let each card keep its natural height, Pinterest-style. */
.note-board { columns: 1; column-gap: 16px; }
.note-card {
  break-inside: avoid;
  margin: 0 0 16px;
  padding: 20px;
  border-radius: 16px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.note-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08); }
.note-tone-0 { background: var(--note-0); }
.note-tone-1 { background: var(--note-1); }
.note-tone-2 { background: var(--note-2); }
.note-tone-3 { background: var(--note-3); }
.note-tone-4 { background: var(--note-4); }
.note-date { margin: 12px 0 0; font-size: 0.8rem; color: var(--note-ink); opacity: 0.6; }

@media (min-width: 560px) { .note-board { columns: 2; } }
@media (min-width: 900px) { .note-board { columns: 3; } }

/* Pictures on notes */
.note-picture {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
}
.note-picture[hidden], .note-thumb[hidden], .note-thumb-large[hidden] { display: none; }
.note-card.has-picture { padding: 10px 10px 16px; }
.note-card.has-picture .note-text, .note-card.has-picture .note-date { padding: 0 10px; }
.note-card.has-picture .note-picture + .note-text { margin-top: 12px; }
.note-picture-today {
  max-width: 520px;
  max-height: 60vh;
  width: auto;
  margin: 0 auto 20px;
  object-fit: contain;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* Author's queue */
.note-preview { white-space: normal; }
.note-queue { list-style: none; margin: 0; padding: 8px 20px 12px; }
.note-queue li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.note-queue li:last-child { border-bottom: 0; }
.note-queue-pos {
  flex-shrink: 0;
  width: 24px;
  text-align: center;
  font-weight: 700;
  color: var(--muted);
}
.note-queue-text { flex: 1; min-width: 140px; overflow-wrap: anywhere; }
.note-queue-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.note-queue-actions form { margin: 0; }
.note-thumb {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
}
.note-thumb-large {
  display: block;
  max-width: 100%;
  max-height: 260px;
  margin-bottom: 12px;
  border-radius: 12px;
}
.btn-icon { min-height: 36px; min-width: 36px; padding: 0; font-size: 1.05rem; }
.btn:disabled { opacity: 0.35; cursor: default; }

/* ---------- Tablet and desktop ---------- */
@media (min-width: 700px) {
  body { padding-bottom: 0; }
  .nav {
    position: static;
    flex: 1;
    justify-content: flex-start;
    padding: 0;
    background: none;
    border: 0;
  }
  .nav a { flex: none; padding: 8px 14px; font-size: 1rem; }
  .brand { white-space: nowrap; }
  .topbar-inner { gap: 16px; }
}

/* Five nav links get tight on small tablets: trim padding until there's room. */
@media (min-width: 700px) and (max-width: 959px) {
  .nav a { padding: 8px 8px; font-size: 0.95rem; }
}

@media (min-width: 700px) {
  .nav a:hover { background: var(--primary-soft); color: var(--text); }
  .container { padding: 28px 24px; }
  .stats { grid-template-columns: repeat(5, 1fr); }

  .table thead { display: table-header-group; }
  .table { display: table; }
  .table tbody { display: table-row-group; }
  .table tr { display: table-row; padding: 0; }
  .table td { display: table-cell; padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
  .table tr:last-child td { border-bottom: 0; }
  .table td::before { content: none; }
  .table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
  }
  .table td.actions { text-align: right; white-space: nowrap; padding-top: 12px; }

  .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  .two-col.stack > * + * { margin-top: 0; }
  .narrow { max-width: 640px; }
}
