/* =========================================================
   FOO ASSISTANT — Chatbot Widget Styles
   Brand tokens pulled from the Foo logo + site's moody,
   warm-lit restaurant aesthetic.
   ========================================================= */

:root {
  --foo-cream: #fdf9d6;
  --foo-cream-dim: #eee7b4;
  --foo-charcoal: #17140f;
  --foo-charcoal-2: #221d15;
  --foo-charcoal-3: #2c2519;
  --foo-red: #9e2b25;
  --foo-red-dark: #7a211c;
  --foo-red-light: #c14a3d;
  --foo-muted: #b8b29b;
  --foo-radius-lg: 22px;
  --foo-radius-md: 14px;
  --foo-radius-sm: 9px;
  --foo-shadow: 0 20px 60px -12px rgba(0, 0, 0, 0.55);
  --foo-font-display: "Space Grotesk", "Segoe UI", sans-serif;
  --foo-font-body: "Inter", "Segoe UI", sans-serif;
}

/* ---------- Launcher ---------- */
.foo-chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1.5px solid var(--foo-cream-dim);
  background: var(--foo-charcoal);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--foo-shadow);
  z-index: 1055;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  padding: 0;
}

.foo-chat-launcher:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 24px 70px -10px rgba(0, 0, 0, 0.65);
}

.foo-chat-launcher img {
  width: 30px;
  height: auto;
  filter: drop-shadow(0 0 6px rgba(253, 249, 214, 0.25));
}

.foo-chat-launcher .foo-steam {
  position: absolute;
  top: -6px;
  width: 2px;
  height: 14px;
  border-radius: 2px;
  background: var(--foo-cream-dim);
  opacity: 0;
  animation: foo-steam-rise 2.4s ease-in-out infinite;
}
.foo-chat-launcher .foo-steam:nth-child(2) { left: 24px; animation-delay: 0s; }
.foo-chat-launcher .foo-steam:nth-child(3) { left: 32px; animation-delay: 0.8s; }
.foo-chat-launcher .foo-steam:nth-child(4) { left: 40px; animation-delay: 1.6s; }

@keyframes foo-steam-rise {
  0%   { opacity: 0; transform: translateY(0) scaleY(0.6); }
  30%  { opacity: 0.55; }
  100% { opacity: 0; transform: translateY(-16px) scaleY(1.2); }
}

.foo-chat-launcher .foo-ping {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--foo-red);
  border: 2px solid var(--foo-charcoal);
}

/* ---------- Panel ---------- */
.foo-chat-panel {
  position: fixed;
  right: 24px;
  bottom: 100px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: var(--foo-charcoal);
  border-radius: var(--foo-radius-lg);
  box-shadow: var(--foo-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1056;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  font-family: var(--foo-font-body);
  border: 1px solid rgba(253, 249, 214, 0.08);
}

.foo-chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---------- Header ---------- */
.foo-chat-header {
  background: linear-gradient(160deg, var(--foo-charcoal-2), var(--foo-charcoal));
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(253, 249, 214, 0.08);
  flex-shrink: 0;
}

.foo-chat-header img {
  width: 40px;
  height: auto;
}

.foo-chat-header .foo-title {
  font-family: var(--foo-font-display);
  color: var(--foo-cream);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.15;
  margin: 0;
  letter-spacing: 0.2px;
}

.foo-chat-header .foo-subtitle {
  color: var(--foo-muted);
  font-size: 0.76rem;
  margin: 2px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.foo-chat-header .foo-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6fbf73;
  display: inline-block;
  box-shadow: 0 0 0 3px rgba(111, 191, 115, 0.15);
}

.foo-chat-close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--foo-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}
.foo-chat-close:hover {
  background: rgba(253, 249, 214, 0.08);
  color: var(--foo-cream);
}

/* ---------- Body ---------- */
.foo-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background:
    radial-gradient(circle at 15% 0%, rgba(158, 43, 37, 0.08), transparent 40%),
    var(--foo-charcoal);
}

.foo-chat-body::-webkit-scrollbar { width: 6px; }
.foo-chat-body::-webkit-scrollbar-thumb {
  background: var(--foo-charcoal-3);
  border-radius: 6px;
}

.foo-msg-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 96%;
}
.foo-msg-row.foo-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.foo-msg-row.foo-msg-bot { align-self: flex-start; }

.foo-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--foo-charcoal-3);
  border: 1px solid rgba(253, 249, 214, 0.15);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.foo-msg-avatar img { width: 16px; height: auto; }

.foo-msg-bubble {
  padding: 12px 15px;
  border-radius: var(--foo-radius-md);
  font-size: 0.92rem;
  line-height: 1.5;
}

.foo-msg-bot .foo-msg-bubble {
  background: var(--foo-charcoal-2);
  color: var(--foo-cream);
  border-bottom-left-radius: 4px;
}

.foo-msg-user .foo-msg-bubble {
  background: var(--foo-red);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.foo-msg-bubble a { color: var(--foo-cream); text-decoration: underline; }
.foo-msg-user .foo-msg-bubble a { color: #fff; }

/* Typing indicator */
.foo-typing .foo-msg-bubble {
  display: flex;
  gap: 4px;
  padding: 12px 14px;
}
.foo-typing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--foo-muted);
  animation: foo-bounce 1.1s infinite ease-in-out;
}
.foo-typing span:nth-child(2) { animation-delay: 0.15s; }
.foo-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes foo-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Quick replies */
.foo-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 2px 0 4px 34px;
  max-width: 90%;
}

.foo-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--foo-cream-dim);
  background: transparent;
  color: var(--foo-cream);
  font-family: var(--foo-font-body);
  font-size: 0.78rem;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
  white-space: normal;
  width: auto;
}
.foo-chip:hover {
  background: var(--foo-red);
  border-color: var(--foo-red);
  color: #fff;
  transform: translateY(-1px);
}
.foo-chip-icon {
  display: inline-flex;
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  color: var(--foo-red-light);
  transition: color 0.15s ease;
}
.foo-chip:hover .foo-chip-icon { color: #fff; }
.foo-chip-icon svg { width: 100%; height: 100%; }

/* Dish spotlight card ("tonight's pick") */
.foo-dish-spotlight {
  background: linear-gradient(155deg, var(--foo-charcoal-2), var(--foo-charcoal-3));
  border: 1px solid rgba(158, 43, 37, 0.4);
  border-radius: var(--foo-radius-md);
  border-bottom-left-radius: 4px;
  padding: 10px 13px;
  max-width: 78%;
}
.foo-dish-label {
  margin: 0 0 2px;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--foo-red-light);
  font-family: var(--foo-font-display);
}
.foo-dish-name {
  margin: 0 0 2px;
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--foo-cream);
  font-family: var(--foo-font-display);
}
.foo-dish-note {
  margin: 0 0 8px;
  font-size: 0.8rem;
  color: var(--foo-muted);
  line-height: 1.4;
}
.foo-dish-link {
  display: inline-block;
  font-size: 0.76rem;
  color: var(--foo-red-light);
  text-decoration: underline;
}
.foo-dish-link:hover { color: var(--foo-cream); }

/* Lead capture card (mandatory name + phone before continuing) */
.foo-lead-card {
  background: linear-gradient(155deg, var(--foo-charcoal-2), var(--foo-charcoal-3));
  border: 1px solid rgba(158, 43, 37, 0.4);
  border-radius: var(--foo-radius-md);
  border-bottom-left-radius: 4px;
  padding: 12px 13px;
  max-width: 82%;
  width: 100%;
}
.foo-lead-title {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: var(--foo-cream);
  line-height: 1.4;
}
.foo-lead-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.foo-lead-input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 11px;
  border-radius: var(--foo-radius-sm);
  border: 1px solid rgba(238, 231, 180, 0.25);
  background: var(--foo-charcoal);
  color: var(--foo-cream);
  font-family: var(--foo-font-body);
  font-size: 0.85rem;
}
.foo-lead-input::placeholder { color: var(--foo-muted); }
.foo-lead-input:focus {
  outline: none;
  border-color: var(--foo-red-light);
}
.foo-lead-submit {
  margin-top: 2px;
  padding: 9px 11px;
  border: none;
  border-radius: var(--foo-radius-sm);
  background: var(--foo-red);
  color: var(--foo-cream);
  font-family: var(--foo-font-display);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.foo-lead-submit:hover:not(:disabled) { background: var(--foo-red-light); }
.foo-lead-submit:disabled { opacity: 0.6; cursor: default; }
.foo-lead-error {
  margin: 0;
  font-size: 0.76rem;
  color: var(--foo-red-light);
}
.foo-lead-thanks {
  margin: 0;
  font-size: 0.88rem;
  color: var(--foo-cream);
  line-height: 1.4;
}

/* ---------- Footer / input ---------- */
.foo-chat-footer {
  padding: 12px;
  border-top: 1px solid rgba(253, 249, 214, 0.08);
  background: var(--foo-charcoal-2);
  flex-shrink: 0;
}

.foo-chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--foo-charcoal);
  border: 1px solid rgba(253, 249, 214, 0.12);
  border-radius: 999px;
  padding: 5px 5px 5px 16px;
}

.foo-chat-form input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--foo-cream);
  font-family: var(--foo-font-body);
  font-size: 0.85rem;
}
.foo-chat-form input::placeholder { color: var(--foo-muted); }
.foo-chat-form input:disabled { opacity: 0.5; cursor: not-allowed; }

.foo-chat-send {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--foo-red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.15s ease;
}
.foo-chat-send:hover { background: var(--foo-red-light); transform: scale(1.05); }
.foo-chat-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.foo-chat-footer .foo-fineprint {
  text-align: center;
  color: var(--foo-muted);
  font-size: 0.66rem;
  margin: 8px 0 0;
  letter-spacing: 0.2px;
}

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
  .foo-chat-launcher {
    right: 16px;
    bottom: 16px;
    width: 52px;
    height: 52px;
  }

  .foo-chat-panel {
    right: 10px;
    left: 10px;
    bottom: 84px;
    width: auto;
    max-width: none;
    /* 100vh breaks on mobile browsers once the address bar collapses;
       dvh tracks the real visible viewport. Falls back to vh below for
       older browsers that don't support dvh. */
    height: calc(100vh - 104px);
    height: calc(100dvh - 104px);
    max-height: none;
    border-radius: 18px;
  }

  .foo-chat-header {
    padding: 14px 14px 12px;
  }
  .foo-chat-header img { width: 34px; }
  .foo-chat-header .foo-title { font-size: 0.95rem; }
  .foo-chat-header .foo-subtitle { font-size: 0.72rem; }

  .foo-chat-body {
    padding: 14px 12px;
    gap: 10px;
  }

  .foo-msg-bubble {
    font-size: 0.9rem;
    max-width: 88%;
  }

  .foo-dish-spotlight,
  .foo-lead-card {
    max-width: 88%;
  }

  .foo-quick-replies {
    gap: 6px;
  }
  .foo-chip {
    font-size: 0.76rem;
    padding: 7px 10px;
    white-space: normal;
    line-height: 1.15;
    text-align: center;
  }

  .foo-chat-footer {
    padding: 10px;
    /* Keeps the input clear of the iOS home-indicator / gesture bar */
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
  .foo-chat-form {
    padding: 4px 4px 4px 14px;
  }
  .foo-chat-form input {
    /* 16px minimum stops iOS Safari from auto-zooming in on focus */
    font-size: 16px;
  }
  .foo-lead-input {
    font-size: 16px;
  }
  .foo-chat-send {
    width: 38px;
    height: 38px;
  }
}

/* Very small phones (older/small-screen devices) */
@media (max-width: 340px) {
  .foo-chat-panel {
    right: 6px;
    left: 6px;
    bottom: 78px;
    height: calc(100vh - 92px);
    height: calc(100dvh - 92px);
  }
  .foo-msg-bubble { font-size: 0.84rem; }
}

/* Short/landscape phone screens: prioritize vertical space */
@media (max-height: 480px) and (orientation: landscape) {
  .foo-chat-panel {
    bottom: 8px;
    top: 8px;
    height: auto;
    max-height: none;
  }
  .foo-chat-launcher { bottom: 8px; }
}

/* Larger touch targets whenever the device has no fine pointer (touch,
   not mouse) — independent of screen width, so it also covers tablets. */
@media (pointer: coarse) {
  .foo-chat-launcher { width: 56px; height: 56px; }
  .foo-chat-close { padding: 8px 10px; }
  .foo-chip { padding: 8px 12px; }
  .foo-chat-send { width: 38px; height: 38px; }
}