/* ==========================================================================
   Casa Playa — site chat (js/chat.js). Uses the tokens from style.css.
   ========================================================================== */

.chat { --chat-w: 380px; font-family: var(--font-body); }

.chat-fab {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 260;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--sunset);
  color: var(--white);
  cursor: pointer;
  box-shadow: 0 16px 34px -12px rgba(0, 0, 0, .55);
  transition: background .2s, transform .3s var(--ease);
}
.chat-fab:hover { background: var(--sunset-dark); }
.chat-fab:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.chat-fab svg { width: 26px; height: 26px; grid-area: 1 / 1; transition: opacity .2s, transform .3s var(--ease); }
.chat-ico { fill: currentColor; }
.chat-x { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; opacity: 0; transform: rotate(-45deg); }
.chat.is-open .chat-ico { opacity: 0; transform: scale(.6); }
.chat.is-open .chat-x { opacity: 1; transform: none; }
html.no-scroll .chat-fab { transform: translateY(160%); }

.chat-panel {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  z-index: 350; /* above the site header, below the lightbox */
  display: flex;
  flex-direction: column;
  width: var(--chat-w);
  height: min(640px, calc(100vh - 120px));
  height: min(640px, calc(100dvh - 120px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-lift);
  animation: chatIn .35s var(--ease);
}
@keyframes chatIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

.chat-h {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  background: var(--ocean-deep);
  color: var(--white);
}
.chat-av {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--sunset);
  font: 600 .8rem/1 var(--font-body);
  letter-spacing: .04em;
}
.chat-ht { display: grid; flex: 1; min-width: 0; line-height: 1.2; }
.chat-tt { font: 500 1.08rem/1.2 var(--font-display); }
.chat-st { color: rgba(255, 253, 249, .72); font-size: .78rem; }
.chat-close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 253, 249, .1);
  color: inherit;
  cursor: pointer;
}
.chat-close:hover { background: rgba(255, 253, 249, .2); }
.chat-close + .chat-close { margin-left: -4px; }
.chat-new svg { width: 17px; height: 17px; }
.chat-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.chat-log {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 14px 8px;
  background: var(--sand);
}

.cm {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 18px;
  font-size: .92rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.cm p { margin: 0; }
.cm p + p, .cm p + dl, .cm dl + p, .cm p + .cm-cat, .cm .cm-cat + .cm-cat, .cm-cat + p { margin-top: 8px; }
.cm-bot { align-self: flex-start; border-bottom-left-radius: 6px; background: var(--white); box-shadow: 0 1px 2px rgba(30, 26, 21, .06); }
.cm-me { align-self: flex-end; border-bottom-right-radius: 6px; background: var(--ink); color: var(--white); white-space: pre-wrap; }
.cm-wide { max-width: 100%; width: 100%; }
.cm-card { max-width: 100%; width: 100%; }
.cm-ok { border-left: 3px solid var(--ocean); }
.cm-wait p::after { content: ""; display: inline-block; width: 1em; animation: chatDots 1.2s steps(4) infinite; overflow: hidden; vertical-align: bottom; }
@keyframes chatDots { from { width: 0; } to { width: 1em; } }
.cm-soft { color: var(--ink-soft); font-size: .82rem; }
.cm-warn { margin-top: 10px !important; color: var(--sunset-dark); font-size: .8rem; }
.cm-k { margin-top: 10px !important; font-weight: 700; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ocean); }

.cm-sum { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0 0; font-size: .88rem; }
.cm-sum dt { color: var(--muted); }
.cm-sum dd { margin: 0; font-weight: 600; }
.cm-sum dt:empty { display: none; }
.cm-sum dt:empty + dd { grid-column: 1 / -1; }

.cm-consent { display: flex; align-items: flex-start; gap: 9px; margin-top: 10px; font-size: .84rem; cursor: pointer; }
.cm-consent input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--sunset); }

.cm-code { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin-top: 8px !important; }
.cm-code span { color: var(--muted); font-size: .8rem; }
.cm-code strong { font-size: 1.1rem; letter-spacing: .08em; }

.cm-date { display: grid; gap: 6px; font-size: .86rem; }
.cm-date input { min-height: 42px; padding: 0 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); font: inherit; color: inherit; }

.cm-head { font-weight: 700; font-size: .98rem; line-height: 1.35; }
.cm-cat { margin-top: 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); overflow: hidden; }
.cm-cat summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 44px; padding: 0 12px; cursor: pointer; list-style: none;
  font-weight: 600; font-size: .9rem;
}
.cm-cat summary::-webkit-details-marker { display: none; }
.cm-cat summary::after { content: ""; flex: none; width: 8px; height: 8px; margin-left: 2px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translateY(-2px); transition: transform .2s; }
.cm-cat[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
.cm-cat summary span { flex: 1; min-width: 0; }
.cm-cat summary b { display: grid; place-items: center; min-width: 24px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--ocean); color: var(--white); font-size: .74rem; }
.cm-cat ul, .cm-board { margin: 0; padding: 0; list-style: none; }
.cm-cat ul { padding: 0 12px 6px; }
.cm-cat li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.cm-cat li small { grid-column: 1 / -1; color: var(--ink-soft); font-size: .78rem; line-height: 1.4; }
.cm-alg { grid-column: 1 / -1; color: var(--muted); font-size: .74rem; line-height: 1.4; }
.cm-tag { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: rgba(31, 122, 77, .12); color: #1f6b45; font: 600 .68rem/1.5 var(--font-body); font-style: normal; vertical-align: 1px; }
.cm-verdict { margin-top: 8px !important; padding: 8px 10px; border-radius: 12px; font-weight: 600; font-size: .88rem; }
.cm-verdict.is-yes { background: rgba(31, 122, 77, .1); color: #1f6b45; }
.cm-verdict.is-no { background: rgba(196, 84, 44, .1); color: var(--sunset-dark); }

/* allergy and diet picker */
.cm-tg { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 6px; }
.cc.cc-sm { min-height: 34px; padding: 0 12px; font-size: .8rem; }
.cc.cc-n { min-width: 42px; padding: 0 10px; justify-content: center; text-align: center; }
.cc.cc-sm.on::before { content: "✓ "; }
.cc:disabled { opacity: .55; cursor: default; }
.cc:disabled, .cc:disabled:hover { border-color: var(--sand-dark); }
.cc.on:disabled { border-color: var(--ocean); }
.cm-more-alg { margin-top: 10px; }
.cm-more-alg summary { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; color: var(--ocean); font-weight: 600; font-size: .82rem; cursor: pointer; list-style: none; }
.cm-more-alg summary::-webkit-details-marker { display: none; }
.cm-more-alg summary::before { content: "+"; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid currentColor; font-size: .8rem; line-height: 1; }
.cm-more-alg[open] summary::before { content: "−"; }

/* privacy, folded under the consent box */
.cm-priv { margin-top: 8px; font-size: .78rem; color: var(--ink-soft); }
.cm-priv summary { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; color: var(--ocean); font-weight: 600; cursor: pointer; list-style: none; }
.cm-priv summary::-webkit-details-marker { display: none; }
.cm-priv summary::before { content: ""; width: 12px; height: 12px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2 4 5v6c0 5 3.4 9.6 8 11 4.6-1.4 8-6 8-11V5l-8-3z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2 4 5v6c0 5 3.4 9.6 8 11 4.6-1.4 8-6 8-11V5l-8-3z'/%3E%3C/svg%3E") center / contain no-repeat; }
.cm-priv summary::after { content: "▾"; font-size: .8rem; transition: transform .2s; }
.cm-priv[open] summary::after { transform: rotate(180deg); }
.cm-priv p { margin: 4px 0 0 !important; padding: 8px 10px; border-radius: 10px; background: var(--sand); line-height: 1.45; }

/* typing dots */
.cm-typing { display: inline-flex; gap: 4px; align-items: center; padding: 13px 14px; }
.cm-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: chatType 1s infinite ease-in-out; }
.cm-typing i:nth-child(2) { animation-delay: .15s; }
.cm-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes chatType { 0%, 60%, 100% { opacity: .35; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
.cm-bot:not(.cm-typing) { animation: chatMsg .28s var(--ease); }
@keyframes chatMsg { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* labels between groups of times */
.cc-lab { flex-basis: 100%; margin: 4px 2px -2px; color: var(--muted); font: 700 .7rem/1.2 var(--font-body); letter-spacing: .08em; text-transform: uppercase; }
.cc-lab:first-child, .cc-ghost + .cc-lab { margin-top: 0; }

/* greeting bubble next to the chat button */
.chat-teaser {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  z-index: 259;
  display: flex; align-items: flex-start; gap: 4px;
  max-width: min(270px, calc(100vw - 32px));
  padding: 4px 4px 4px 0;
  border-radius: 18px 18px 6px 18px;
  background: var(--white);
  color: var(--ink);
  box-shadow: var(--shadow-lift);
  animation: chatIn .4s var(--ease);
  transition: opacity .35s, transform .35s;
}
.chat-teaser.is-out { opacity: 0; transform: translateY(8px); }
.chat-teaser-t { flex: 1; padding: 10px 4px 10px 14px; border: 0; background: none; color: inherit; font: 500 .88rem/1.4 var(--font-body); text-align: left; cursor: pointer; }
.chat-teaser-x { flex: none; width: 28px; height: 28px; border: 0; border-radius: 50%; background: var(--sand); color: var(--ink-soft); font-size: 1.1rem; line-height: 1; cursor: pointer; }
html.chat-open .chat-teaser { display: none; }
@media (max-width: 640px) { .chat-teaser { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); } }
.cm-dn { font-weight: 600; }
.cm-dp { color: var(--ink-soft); font-size: .84rem; white-space: nowrap; }
.cm-more { color: var(--muted); font-size: .8rem; }

.cm-dishes { display: grid; gap: 10px; margin-top: 10px; }
.cm-dish { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; }
.cm-dish:not(:has(img)) { grid-template-columns: 1fr; }
.cm-dish img { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; }
.cm-dish div { display: grid; gap: 2px; }
.cm-dish small { color: var(--ink-soft); font-size: .78rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.cm-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.cbtn {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--white);
  font-weight: 600;
  font-size: .84rem;
  text-decoration: none;
}
.cbtn:hover { background: var(--ocean-deep); }
.cbtn-wa { background: #1f7a4d; }
.cbtn-wa:hover { background: #17603c; }

.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-height: 34%;
  overflow-y: auto;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--sand);
}
.cc {
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--sand-dark);
  border-radius: 999px;
  background: var(--white);
  color: var(--ink);
  font: 600 .84rem/1.2 var(--font-body);
  text-align: left;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
@media (hover: hover) { .cc:hover { border-color: var(--sunset); } .cc-main:hover { background: var(--sunset-dark); } }
.cc:focus-visible { outline: 2px solid var(--sunset); outline-offset: 2px; }
.cc.on { border-color: var(--ocean); background: var(--ocean); color: var(--white); }
.cc-main { border-color: var(--sunset); background: var(--sunset); color: var(--white); }
.cc-ghost { border-style: dashed; background: transparent; color: var(--ink-soft); }

.chat-in { display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--paper); }
.chat-in input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--ink);
  font: 16px/1.2 var(--font-body);
}
.chat-in input:focus { outline: none; border-color: var(--ocean); }
.chat-in button {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--white);
  cursor: pointer;
}
.chat-in button svg { width: 18px; height: 18px; fill: currentColor; }

/* The "Reservar mesa" pill and the chat bubble share the bottom edge on tablets and phones. */
html.chat-open .fab { translate: -50% 140%; }

@media (max-width: 640px) {
  .chat-panel {
    inset: 0;
    width: auto;
    height: auto;
    border: 0;
    border-radius: 0;
    animation-name: chatUp;
  }
  @keyframes chatUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
  .chat.is-open .chat-fab { display: none; }
  html.chat-open { overflow: hidden; }
  .chat-h { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  .cm { max-width: 90%; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-panel, .chat-fab, .chat-fab svg, .cm-bot, .chat-teaser { animation: none; transition: none; }
}
