/* CallMyTable — Phase 1. Dark, cinematic, generous spacing. No build step.
   Deliberately not gold-plated: Phase 2 is the polished UI. */

:root {
  --bg: #07080c;
  --panel: #101319;
  --panel-2: #161a22;
  --line: #232936;
  --text: #e8ecf4;
  --muted: #8d97a9;
  --accent: #6ea8ff;
  --agent: #7dd3fc;
  --restaurant: #fbbf24;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 14px;
  --space: 20px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  padding: 28px clamp(16px, 4vw, 56px) 40px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "top    side"
    "stage  side"
    "footer side";
  gap: var(--space) clamp(20px, 3vw, 40px);
  max-width: 1240px;
  margin: 0 auto;
}

/* A soft radial wash so the dark page does not look flat. */
.glow {
  position: fixed;
  inset: -30% -10% auto -10%;
  height: 70vh;
  background: radial-gradient(60% 60% at 30% 0%, rgba(110, 168, 255, 0.14), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.topbar { grid-area: top; position: relative; z-index: 1; }
#stage { grid-area: stage; position: relative; z-index: 1; min-height: 0; display: flex; }
.footer { grid-area: footer; }
.reservation { grid-area: side; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 21px; margin: 0; font-weight: 600; letter-spacing: -0.01em; }

.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 4px rgba(141, 151, 169, 0.14);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
.dot[data-state="open"] { background: var(--ok); box-shadow: 0 0 0 4px rgba(74, 222, 128, 0.16); }
.dot[data-state="closed"] { background: var(--bad); box-shadow: 0 0 0 4px rgba(248, 113, 113, 0.16); }
.dot[data-state="connecting"] { background: var(--warn); box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.16); }

.tagline { color: var(--muted); margin: 8px 0 0; max-width: 62ch; }

/* ── views ──────────────────────────────────────────────────────────────── */

.view { display: none; flex-direction: column; flex: 1; min-height: 0; }
.view.is-active { display: flex; }

/* ── chat ───────────────────────────────────────────────────────────────── */

.chat-log {
  flex: 1;
  min-height: 240px;
  max-height: 56vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 6px;
  scrollbar-width: thin;
}

.msg {
  max-width: 74%;
  padding: 12px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: rise 0.22s ease-out;
}
.msg.user { align-self: flex-end; background: #1b2434; border-color: #2b3a52; }
.msg.agent { align-self: flex-start; }
.msg .who {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 5px;
}
.msg.error { border-color: rgba(248, 113, 113, 0.5); color: #ffd9d9; background: #241417; }
.msg.system { align-self: center; font-size: 13px; color: var(--muted); background: transparent; border-style: dashed; }

@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.composer { display: flex; gap: 10px; margin-top: var(--space); }

input[type="text"] {
  flex: 1;
  padding: 13px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
}
input[type="text"]:focus { outline: none; border-color: var(--accent); }

button {
  font: inherit;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 13px 20px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
button:hover:not(:disabled) { background: #1f2531; border-color: #313a4c; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.call-button {
  width: 100%;
  margin-top: 14px;
  background: var(--accent);
  border-color: var(--accent);
  color: #07101f;
  font-weight: 600;
}
.call-button:hover:not(:disabled) { background: #8bbaff; border-color: #8bbaff; }

/* ── call view ──────────────────────────────────────────────────────────── */

.call-head {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--space);
}

.call-state { display: flex; align-items: center; gap: 11px; font-size: 17px; font-weight: 600; }

.pulse {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--warn);
  animation: pulse 1.4s ease-in-out infinite;
}
.pulse[data-state="connected"] { background: var(--ok); }
.pulse[data-state="ended"] { background: var(--muted); animation: none; }
.pulse[data-state="aborted"] { background: var(--bad); animation: none; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.5); }
  50% { box-shadow: 0 0 0 11px rgba(251, 191, 36, 0); }
}

.call-who { color: var(--muted); font-size: 14px; }

.abort {
  margin-left: auto;
  background: #3a1620;
  border-color: #6b2233;
  color: #ffdada;
  font-weight: 600;
}
.abort:hover:not(:disabled) { background: #4d1b28; border-color: #8a2c42; }
.abort[hidden] { display: none; }

.sides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(14px, 2vw, 30px);
  min-height: 0;
  flex: 1;
}
@media (max-width: 760px) { .sides { grid-template-columns: 1fr; } }

.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}
.side[data-side="agent"] { border-top: 2px solid var(--agent); }
.side[data-side="restaurant"] { border-top: 2px solid var(--restaurant); }

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.side-name { font-size: 12px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); }
.side[data-side="agent"] .side-name { color: var(--agent); }
.side[data-side="restaurant"] .side-name { color: var(--restaurant); }

.viz { width: 110px; height: 22px; display: block; opacity: 0.35; transition: opacity 0.25s ease; }
.viz[data-speaking="true"] { opacity: 1; }

.turns {
  flex: 1;
  min-height: 120px;
  max-height: 42vh;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  scrollbar-width: thin;
}

.turn {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel-2);
  border-left: 2px solid var(--line);
  animation: rise 0.28s ease-out;
}
.side[data-side="agent"] .turn { border-left-color: var(--agent); }
.side[data-side="restaurant"] .turn { border-left-color: var(--restaurant); }
.turn time { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; font-variant-numeric: tabular-nums; }

/* ── reservation card ───────────────────────────────────────────────────── */

.reservation {
  align-self: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 18px;
}
.reservation header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.reservation h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); margin: 0; }

.badge {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge[data-confirmed="true"] { color: var(--ok); border-color: rgba(74, 222, 128, 0.45); }

.reservation dl { margin: 16px 0 0; display: grid; gap: 11px; }
.reservation .field { display: grid; gap: 2px; }
.reservation dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.reservation dd { margin: 0; word-break: break-word; }
.reservation dd[data-empty="true"] { color: #4a5364; }

.hint { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; text-align: center; }

/* ── result card ────────────────────────────────────────────────────────── */

.result {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 5;
  margin: 0 auto;
  max-width: 640px;
  padding: 24px 26px;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 18px 18px 0 0;
  background: #12161e;
  box-shadow: 0 -18px 60px rgba(0, 0, 0, 0.6);
  animation: rise 0.3s ease-out;
}
.result[hidden] { display: none; }
.result h2 { margin: 10px 0 6px; font-size: 19px; }
.result p { margin: 0 0 16px; color: var(--muted); }
.result-outcome {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.result-outcome[data-outcome="booked"] { color: var(--ok); border-color: rgba(74, 222, 128, 0.45); }
.result-outcome[data-outcome="no_availability"] { color: var(--warn); border-color: rgba(251, 191, 36, 0.45); }
.result-outcome[data-outcome="held"] { color: var(--accent); border-color: rgba(110, 168, 255, 0.45); }
.result-outcome[data-outcome="aborted"],
.result-outcome[data-outcome="error"] { color: var(--bad); border-color: rgba(248, 113, 113, 0.45); }

.footer {
  color: var(--muted);
  font-size: 12.5px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.footer strong { color: var(--warn); font-weight: 600; }
