/* resVista booking widget. Colors are CSS variables (D15: resVista green on the posVista palette);
   a restaurant's own color is a later feature and only needs these variables to be overridden.
   Rules (checked by test/contrast.test.mjs): text on bg/surface/alt >= 4.5:1, control borders and icons >= 3:1,
   --rv-primary as link text only on bg and surface; a state is always an icon plus a label, never only a color. */

:root,
:root[data-theme="light"] {
  color-scheme: light;
  --rv-bg: #F4F0E6;
  --rv-surface: #FBF8F1;
  --rv-surface-alt: #EAE4D4;
  --rv-border: #B9B09A;
  --rv-control: #756E5C;
  --rv-text: #1E2227;
  --rv-text-2: #565F6B;
  --rv-primary: #047857;
  --rv-on-primary: #FFFFFF;
  --rv-success: #1B7F3B;
  --rv-error: #C0123C;
  --rv-error-text: #C0123C;
  --rv-warning: #9A5B00;
  --rv-focus: #047857;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --rv-bg: #0F1419;
  --rv-surface: #15202B;
  --rv-surface-alt: #1E2732;
  --rv-border: #38444D;
  --rv-control: #6F8090;
  --rv-text: #FFFFFF;
  --rv-text-2: #8899A6;
  --rv-primary: #34D399;
  --rv-on-primary: #0F1419;
  --rv-success: #00C853;
  --rv-error: #FF003F;
  --rv-error-text: #FF6B88;
  --rv-warning: #FFB300;
  --rv-focus: #34D399;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --rv-bg: #0F1419;
    --rv-surface: #15202B;
    --rv-surface-alt: #1E2732;
    --rv-border: #38444D;
    --rv-control: #6F8090;
    --rv-text: #FFFFFF;
    --rv-text-2: #8899A6;
    --rv-primary: #34D399;
    --rv-on-primary: #0F1419;
    --rv-success: #00C853;
    --rv-error: #FF003F;
    --rv-error-text: #FF6B88;
    --rv-warning: #FFB300;
    --rv-focus: #34D399;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--rv-bg);
  color: var(--rv-text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--rv-primary); }
h1, h2, h3, p { overflow-wrap: anywhere; }

.rv-root { display: flow-root; }
.rv-wrap { max-width: 560px; margin: 0 auto; padding: 16px; }
.rv-embedded .rv-wrap { padding: 8px 4px; }
.rv-boot, .rv-nojs { margin: 24px 16px; }

.rv-main, .rv-pick, .rv-form, .rv-results { display: block; }
.rv-group { margin: 0 0 4px; }
.rv-hint + .rv-form { margin-top: 16px; }
.rv-email { overflow-wrap: anywhere; }
.rv-date { min-width: 0; }

/* header (standalone page only) */
.rv-head { padding: 8px 0 16px; }
.rv-name { font-size: 1.625rem; line-height: 1.2; margin: 0 0 6px; }
.rv-desc, .rv-addr { margin: 4px 0; color: var(--rv-text-2); }

/* card and headings */
.rv-card { background: var(--rv-surface); border: 1px solid var(--rv-border); border-radius: 12px; padding: 16px; }
.rv-embedded .rv-card { padding: 14px; }
.rv-popup .rv-wrap { padding: 12px; }
.rv-title { font-size: 1.25rem; line-height: 1.3; margin: 0 0 12px; }
.rv-title:focus { outline: none; }
.rv-title:focus-visible { outline: 3px solid var(--rv-focus); outline-offset: 4px; border-radius: 4px; }
.rv-sub { font-size: 1rem; margin: 16px 0 8px; }
.rv-subtitle { font-size: 1.125rem; margin: 0 0 12px; }
.rv-hint { color: var(--rv-text-2); font-size: .9375rem; margin: 6px 0 0; }
.rv-note { margin: 12px 0 8px; font-weight: 600; }
.rv-count { text-align: right; color: var(--rv-text-2); font-size: .875rem; margin: -8px 0 12px; }
.rv-loading { display: flex; gap: 10px; align-items: center; color: var(--rv-text-2); margin: 12px 0; }

/* focus */
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid var(--rv-focus);
  outline-offset: 2px;
}

/* form controls (touch targets >= 44 px) */
.rv-field { margin: 0 0 16px; }
.rv-label { display: block; font-weight: 600; margin: 0 0 6px; }
.rv-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  font: inherit;
  color: var(--rv-text);
  background: var(--rv-surface);
  border: 2px solid var(--rv-control);
  border-radius: 10px;
}
.rv-input[aria-invalid="true"] { border-color: var(--rv-error); }
.rv-textarea { resize: vertical; min-height: 96px; }
.rv-err { color: var(--rv-error-text); font-size: .9375rem; font-weight: 600; margin: 6px 0 0; }
.rv-err[hidden] { display: none; }
.rv-datebar, .rv-stepper { display: flex; gap: 8px; align-items: stretch; }
.rv-datebar .rv-input { flex: 1; min-width: 0; }
.rv-stepper { align-items: center; }
.rv-num { width: 5rem; flex: none; text-align: center; -moz-appearance: textfield; appearance: textfield; }
.rv-num::-webkit-inner-spin-button, .rv-num::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.rv-unit { color: var(--rv-text-2); margin-left: 4px; }
.rv-iconbtn {
  flex: none;
  width: 48px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font: inherit;
  color: var(--rv-text);
  background: var(--rv-surface);
  border: 2px solid var(--rv-control);
  border-radius: 10px;
  cursor: pointer;
}
.rv-iconbtn:hover { background: var(--rv-surface-alt); }
.rv-iconbtn.is-disabled { opacity: .45; cursor: not-allowed; }
.rv-checkrow { display: flex; gap: 12px; align-items: flex-start; }
.rv-check { flex: none; width: 24px; height: 24px; margin: 10px 0 0; accent-color: var(--rv-primary); }
.rv-checkrow label { display: block; min-height: 44px; padding: 8px 0; }
.rv-linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--rv-primary); text-decoration: underline; cursor: pointer; }
.rv-hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.rv-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* buttons */
.rv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: pointer;
}
.rv-btn--primary { background: var(--rv-primary); color: var(--rv-on-primary); }
.rv-btn--primary:hover { box-shadow: inset 0 0 0 999px rgba(0, 0, 0, .12); }
.rv-btn--secondary { background: var(--rv-surface); color: var(--rv-text); border-color: var(--rv-control); }
.rv-btn--secondary:hover { background: var(--rv-surface-alt); }
.rv-btn--danger { background: var(--rv-surface); color: var(--rv-error-text); border-color: var(--rv-error); }
.rv-btn--danger:hover { background: var(--rv-surface-alt); }
.rv-btn--block { width: 100%; }
.rv-btn--small { min-height: 44px; padding: 6px 14px; }
.rv-btn.is-busy { cursor: progress; }
.rv-btn .rv-spin { border-color: currentColor; border-top-color: transparent; }
.rv-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.rv-actions:empty { display: none; }

/* time slots and next days */
.rv-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin: 0 0 12px; }
.rv-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 8px;
  font: inherit;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  color: var(--rv-text);
  background: var(--rv-surface);
  border: 2px solid var(--rv-primary);
  border-radius: 10px;
  cursor: pointer;
}
.rv-slot:hover { background: var(--rv-primary); color: var(--rv-on-primary); }
.rv-days { display: grid; gap: 8px; margin-bottom: 12px; }
.rv-day {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 48px;
  padding: 8px 14px;
  font: inherit;
  text-align: left;
  color: var(--rv-text);
  background: var(--rv-surface);
  border: 2px solid var(--rv-control);
  border-radius: 10px;
  cursor: pointer;
}
.rv-day:hover { background: var(--rv-surface-alt); }
.rv-day span { color: var(--rv-text-2); font-size: .9375rem; }
.rv-waitcta { margin-top: 16px; padding: 12px; border: 1px dashed var(--rv-control); border-radius: 10px; }
.rv-waitcta p { margin: 0 0 10px; }

/* messages and status: the state is always icon plus text */
.rv-alert { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 12px; padding: 12px; background: var(--rv-surface-alt); border-left: 4px solid var(--rv-border); border-radius: 10px; }
.rv-alert .rv-icon { flex: none; margin-top: 2px; }
.rv-alert-body { flex: 1; min-width: 0; }
.rv-alert-body p { margin: 0 0 6px; }
.rv-alert-body p:last-child { margin-bottom: 0; }
.rv-alert[data-tone="warn"], .rv-badge[data-tone="warn"] { --rv-tone: var(--rv-warning); }
.rv-alert[data-tone="error"], .rv-badge[data-tone="error"] { --rv-tone: var(--rv-error); }
.rv-alert[data-tone="success"], .rv-badge[data-tone="success"] { --rv-tone: var(--rv-success); }
.rv-alert[data-tone="info"], .rv-badge[data-tone="info"] { --rv-tone: var(--rv-primary); }
.rv-alert[data-tone="muted"], .rv-badge[data-tone="muted"] { --rv-tone: var(--rv-text-2); }
.rv-alert { border-left-color: var(--rv-tone, var(--rv-border)); }
.rv-alert .rv-icon, .rv-badge .rv-icon { color: var(--rv-tone, var(--rv-text-2)); }
.rv-badge { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 12px; padding: 6px 14px 6px 10px; font-weight: 700; background: var(--rv-surface-alt); border-radius: 999px; }
.rv-reason { font-style: italic; }
.rv-formalert:empty { display: none; }
.rv-formalert { margin: 0 0 12px; }
.rv-ask { width: 100%; padding: 12px; background: var(--rv-surface-alt); border: 1px solid var(--rv-border); border-radius: 10px; }
.rv-ask p { margin: 0 0 6px; }

/* summary, contacts */
.rv-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin: 0 0 16px; padding: 10px 12px; background: var(--rv-surface-alt); border-radius: 10px; }
.rv-summary p { margin: 0; }
.rv-dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 12px 0; }
.rv-dl dt { color: var(--rv-text-2); }
.rv-dl dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.rv-contactblock { margin-top: 16px; }
.rv-contacts, .rv-contacts-inline { display: flex; flex-wrap: wrap; gap: 0 16px; margin: 4px 0; }
.rv-contacts-inline { display: inline-flex; vertical-align: middle; }
.rv-contact { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 600; color: var(--rv-primary); }

/* privacy dialog */
.rv-dlg { width: min(520px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow: auto; padding: 20px; color: var(--rv-text); background: var(--rv-surface); border: 1px solid var(--rv-border); border-radius: 12px; }
.rv-dlg::backdrop { background: rgba(0, 0, 0, .6); }

/* footer and spinner */
.rv-foot { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 16px 0 4px; color: var(--rv-text-2); font-size: .875rem; }
.rv-mark { width: 16px; height: 16px; border-radius: 5px; background: linear-gradient(to top right, #43E97B, #38F9D7); }
.rv-spin { display: inline-block; flex: none; width: 18px; height: 18px; border: 3px solid var(--rv-border); border-top-color: var(--rv-primary); border-radius: 50%; animation: rv-spin .8s linear infinite; }
@keyframes rv-spin { to { transform: rotate(360deg); } }

@media (max-width: 380px) {
  .rv-dl { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .rv-dl dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .rv-spin { animation-duration: 3s; }
  * { scroll-behavior: auto !important; transition: none !important; }
}
