/* Jomera guided chat (js/chat.js) — uses the tokens from styles.css */
.has-chat .wa-float { display: none; } /* the chat replaces the WhatsApp button; it stays as the no-JavaScript fallback */

.chat { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: var(--z-float); font-family: var(--font-body); }

/* Launcher */
.chat-launcher {
  position: relative; display: inline-flex; align-items: center; gap: 12px; height: 56px; padding: 0 24px 0 20px; border-radius: 999px;
  background: var(--navy); color: var(--on-night); font-weight: 600; font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase;
  box-shadow: 0 12px 34px rgba(0, 22, 37, 0.28), 0 0 0 1px rgba(252, 250, 246, 0.08) inset;
  transition: transform var(--t-med) var(--ease-out), opacity var(--t-med), background-color var(--t-med), color var(--t-med);
}
.chat-launcher svg { width: 22px; height: 22px; color: var(--amber); transition: color var(--t-med); }
.chat-launcher:hover { transform: translateY(-3px); background: var(--amber); color: var(--ink-black); }
.chat-launcher:hover svg { color: var(--ink-black); }
.chat-launcher.is-hidden { opacity: 0; pointer-events: none; transform: scale(0.8); }
.chat-launcher__dot { position: absolute; top: 6px; right: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--amber); border: 2px solid var(--navy); }
@media (max-width: 639px) { .chat-launcher { width: 56px; padding: 0; justify-content: center; } .chat-launcher__label { display: none; } }
.menu-open .chat { opacity: 0; pointer-events: none; }
[data-page="book"] .chat { display: none; } /* visitors here are already filling in an enquiry; keep the form buttons clear */

/* Greeting bubble (phones: shown instead of auto-opening the full panel) */
.chat-teaser {
  position: absolute; right: 0; bottom: 68px; width: min(300px, calc(100vw - 32px));
  display: flex; align-items: flex-start; background: var(--paper); border-radius: 16px 16px 6px 16px;
  box-shadow: 0 16px 44px rgba(0, 22, 37, 0.24), 0 0 0 1px rgba(0, 49, 83, 0.08);
  opacity: 0; transform: translateY(10px) scale(0.97); transform-origin: bottom right;
  transition: opacity 240ms var(--ease-out), transform 320ms var(--ease-out);
}
.chat-teaser.is-open { opacity: 1; transform: none; }
.chat-teaser__body { flex: 1; display: flex; gap: 10px; align-items: flex-start; padding: 14px 4px 14px 14px; text-align: left; font-size: 0.88rem; line-height: 1.45; color: var(--ink); }
.chat-teaser__body strong { display: block; font-family: var(--font-display); font-weight: 400; font-size: 1.02rem; color: var(--navy); margin-bottom: 2px; }
.chat-teaser .chat-head__mark { width: 30px; height: 30px; background-image: url("../assets/jomera-mark-sm.png"); margin-top: 2px; }
.chat-teaser__x { width: 40px; height: 40px; flex: none; font-size: 1.4rem; line-height: 1; color: var(--ink-2); border-radius: 10px; }

/* Panel */
.chat-panel {
  position: absolute; right: 0; bottom: 0; width: min(390px, calc(100vw - 32px)); height: min(600px, calc(100svh - 110px));
  display: flex; flex-direction: column; background: var(--paper); border-radius: 18px; overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 22, 37, 0.28), 0 0 0 1px rgba(0, 49, 83, 0.08);
  opacity: 0; transform: translateY(16px) scale(0.98); transform-origin: bottom right;
  transition: opacity 260ms var(--ease-out), transform 360ms var(--ease-out);
}
.chat-panel.is-open { opacity: 1; transform: none; }
@media (max-width: 639px) {
  .chat-panel { position: fixed; left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); width: auto; height: min(78svh, 640px); }
}

.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 10px 14px 16px; background: var(--navy); color: var(--on-night); }
.chat-head__mark { width: 38px; height: 38px; flex: none; background: url("../assets/jomera-mark-sm-light.png") center / contain no-repeat; }
.chat-head__text { flex: 1; min-width: 0; }
.chat-head h2 { font-family: var(--font-display); font-size: 1.15rem; font-weight: 400; line-height: 1.2; letter-spacing: 0; }
.chat-head p { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--on-night-2); margin-top: 2px; }
.chat-online { width: 8px; height: 8px; border-radius: 50%; background: #4cc38a; box-shadow: 0 0 0 3px rgba(76, 195, 138, 0.25); }
.chat-icon-btn { width: 44px; height: 44px; flex: none; border-radius: 10px; display: grid; place-items: center; color: var(--on-night); }
.chat-icon-btn:hover { background: rgba(255, 255, 255, 0.1); }
.chat-icon-btn svg { width: 20px; height: 20px; }
.chat :focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* Messages */
.chat-log { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 18px 14px 8px; display: flex; flex-direction: column; gap: 8px; scroll-behavior: smooth; }
.chat-msg { max-width: 86%; padding: 10px 14px; border-radius: 16px; font-size: 0.95rem; line-height: 1.5; overflow-wrap: anywhere; }
.chat-msg--bot { align-self: flex-start; background: #fff; color: var(--ink); border-bottom-left-radius: 6px; box-shadow: 0 1px 2px rgba(0, 32, 54, 0.06); }
.chat-msg--user { align-self: flex-end; background: var(--navy); color: #fff; border-bottom-right-radius: 6px; }
.chat-msg--user em { opacity: 0.75; }
.chat-msg.is-new { animation: chatIn 320ms var(--ease-out); }
@keyframes chatIn { from { opacity: 0; transform: translateY(8px); } }
.chat-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.chat-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--navy-400); animation: chatDot 1s infinite ease-in-out; }
.chat-typing i:nth-child(2) { animation-delay: 0.15s; }
.chat-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatDot { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.chat-summary { display: grid; gap: 6px; margin: 0; }
.chat-summary div { display: grid; grid-template-columns: 88px 1fr; gap: 8px; }
.chat-summary dt { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); padding-top: 3px; }
.chat-summary dd { margin: 0; }
.chat-wa { display: inline-flex; align-items: center; gap: 8px; margin-top: 4px; min-height: 44px; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line-strong); font-weight: 600; color: var(--navy); }
.chat-wa svg { width: 18px; height: 18px; }
.chat-wa--primary { background: #1f7a4d; border-color: #1f7a4d; color: #fff; }

/* Quick replies + input */
.chat-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 14px 10px; max-height: 40%; overflow-y: auto; }
.chat-chip {
  min-height: 40px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--navy); background: #fff; color: var(--navy);
  font-size: 0.88rem; font-weight: 600; text-align: left; transition: background var(--t-fast), color var(--t-fast);
}
.chat-chip:hover { background: var(--navy); color: #fff; }
.chat-chip--primary { background: var(--amber); border-color: var(--amber); color: var(--ink-black); }
.chat-chip--primary:hover { background: var(--navy); border-color: var(--navy); color: #fff; }
.chat-chip:disabled { opacity: 0.7; cursor: progress; }
.chat-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: #fff; }
.chat-input { flex: 1; min-height: 44px; max-height: 120px; resize: none; padding: 11px 14px; border: 1px solid var(--line-strong); border-radius: 22px; background: var(--paper); font-size: 1rem; line-height: 1.4; color: var(--ink); }
.chat-input:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(0, 49, 83, 0.14); background: #fff; }
.chat-send { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--amber); color: var(--ink-black); }
.chat-send svg { width: 20px; height: 20px; }
.chat-send:hover { background: var(--navy); color: #fff; }
.chat-privacy { padding: 0 14px 10px; background: #fff; font-size: 0.72rem; color: var(--ink-2); }
.chat-spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(26, 27, 30, 0.3); border-top-color: var(--ink-black); display: inline-block; vertical-align: -2px; animation: spin 700ms linear infinite; }

@media (prefers-reduced-motion: reduce) {
  .chat-panel, .chat-launcher, .chat-teaser { transition: none; }
  .chat-msg.is-new, .chat-typing i { animation: none; }
}
@media print { .chat { display: none !important; } }
