/**
 * Anees chat widget — shadcn-inspired tokens, SVG-only icons, dark-mode
 * aware. Mobile: full-height bottom sheet (matches the pattern already
 * used for hotel-archive filters). Respects prefers-reduced-motion,
 * 44px min touch targets, visible focus rings — see implementation guide
 * section 4.9 / ui-ux-pro-max checklist.
 *
 * File: assets/ai-widget.css
 */

:root {
  --u2g-ai-radius: 16px;
  --u2g-ai-radius-sm: 10px;
  --u2g-ai-border: #e4e4e7;
  --u2g-ai-bg: #ffffff;
  --u2g-ai-bg-subtle: #fafafa;
  --u2g-ai-fg: #18181b;
  --u2g-ai-muted: #71717a;
  --u2g-ai-accent: #0f6e56;
  --u2g-ai-accent-fg: #ffffff;
  --u2g-ai-focus: #0f6e56;
  --u2g-ai-shadow: 0 8px 30px rgba(0, 0, 0, .12), 0 1px 3px rgba(0, 0, 0, .08);
  --u2g-ai-user-bg: #0f6e56;
  --u2g-ai-user-fg: #ffffff;
  --u2g-ai-assist-bg: #f4f4f5;
  --u2g-ai-assist-fg: #18181b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --u2g-ai-border: #27272a;
    --u2g-ai-bg: #18181b;
    --u2g-ai-bg-subtle: #1f1f22;
    --u2g-ai-fg: #f4f4f5;
    --u2g-ai-muted: #a1a1aa;
    --u2g-ai-assist-bg: #27272a;
    --u2g-ai-assist-fg: #f4f4f5;
  }
}

#u2g-ai-launcher,
#u2g-ai-panel,
#u2g-ai-panel * {
  box-sizing: border-box;
  font-family: inherit;
}

/* Defensive reset — the theme/core stylesheet may apply global icon or
   button-svg rules (e.g. an icon-font system that hides raw <svg> by
   default) that would otherwise blank out these icons. Scoped tightly to
   this widget's own elements only. */
#u2g-ai-launcher svg,
#u2g-ai-panel svg {
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1;
  flex-shrink: 0;
  vertical-align: middle;
}
#u2g-ai-close,
#u2g-ai-form button[type="submit"] {
  color: inherit;
}

/* ── Launcher ─────────────────────────────────────────────────────── */
#u2g-ai-launcher {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  right: 20px;
  z-index: 9999;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: var(--u2g-ai-accent);
  color: var(--u2g-ai-accent-fg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--u2g-ai-shadow);
  cursor: pointer;
  transition: transform .15s ease-out;
}
html[dir="rtl"] #u2g-ai-launcher { right: auto; left: 20px; }

#u2g-ai-launcher:hover { transform: scale(1.05); }
#u2g-ai-launcher:active { transform: scale(0.97); }
#u2g-ai-launcher:focus-visible {
  outline: 3px solid var(--u2g-ai-focus);
  outline-offset: 3px;
}

.u2g-ai-icon-close { display: none; }
#u2g-ai-launcher.is-open .u2g-ai-icon-chat { display: none; }
#u2g-ai-launcher.is-open .u2g-ai-icon-close { display: block; }

@media (prefers-reduced-motion: reduce) {
  #u2g-ai-launcher { transition: none; }
}

/* ── Panel (desktop: floating card) ──────────────────────────────── */
#u2g-ai-panel {
  position: fixed;
  z-index: 9999;
  bottom: 88px;
  right: 20px;
  width: 380px;
  max-height: min(600px, 80vh);
  background: var(--u2g-ai-bg);
  color: var(--u2g-ai-fg);
  border: 1px solid var(--u2g-ai-border);
  border-radius: var(--u2g-ai-radius);
  box-shadow: var(--u2g-ai-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
html[dir="rtl"] #u2g-ai-panel { right: auto; left: 20px; }
#u2g-ai-panel.u2g-ai-hidden { display: none; }

.u2g-ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--u2g-ai-border);
  background: var(--u2g-ai-bg-subtle);
  flex-shrink: 0;
}
.u2g-ai-header-text { display: flex; flex-direction: column; line-height: 1.25; }
.u2g-ai-header-title { font-weight: 600; font-size: 14px; }
.u2g-ai-header-sub { font-size: 12px; color: var(--u2g-ai-muted); }

#u2g-ai-close {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border: none;
  background: transparent;
  color: var(--u2g-ai-muted);
  border-radius: var(--u2g-ai-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
#u2g-ai-close:hover { background: var(--u2g-ai-border); }
#u2g-ai-close:focus-visible { outline: 2px solid var(--u2g-ai-focus); outline-offset: 2px; }

/* ── Messages ─────────────────────────────────────────────────────── */
#u2g-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  line-height: 1.5;
  min-height: 200px;
}

.u2g-ai-msg {
  max-width: 85%;
  padding: 10px 13px;
  border-radius: var(--u2g-ai-radius-sm);
  word-wrap: break-word;
  white-space: pre-wrap;
}
.u2g-ai-user {
  align-self: flex-end;
  background: var(--u2g-ai-user-bg);
  color: var(--u2g-ai-user-fg);
  border-bottom-right-radius: 4px;
}
html[dir="rtl"] .u2g-ai-user { border-bottom-right-radius: var(--u2g-ai-radius-sm); border-bottom-left-radius: 4px; }

.u2g-ai-assistant {
  align-self: flex-start;
  background: var(--u2g-ai-assist-bg);
  color: var(--u2g-ai-assist-fg);
  border-bottom-left-radius: 4px;
}
html[dir="rtl"] .u2g-ai-assistant { border-bottom-left-radius: var(--u2g-ai-radius-sm); border-bottom-right-radius: 4px; }

.u2g-ai-typing { opacity: .6; }
.u2g-ai-typing span {
  display: inline-block;
  width: 5px; height: 5px;
  margin-right: 2px;
  border-radius: 50%;
  background: currentColor;
  animation: u2g-ai-bounce 1s infinite ease-in-out;
}
.u2g-ai-typing span:nth-child(2) { animation-delay: .15s; }
.u2g-ai-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes u2g-ai-bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) {
  .u2g-ai-typing span { animation: none; }
}

/* ── Quick prompts ────────────────────────────────────────────────── */
#u2g-ai-quickrow {
  padding: 0 16px 10px;
  flex-shrink: 0;
}
.u2g-ai-quick {
  min-height: 36px;
  padding: 8px 14px;
  font-size: 13px;
  border: 1px solid var(--u2g-ai-border);
  background: var(--u2g-ai-bg-subtle);
  color: var(--u2g-ai-fg);
  border-radius: 999px;
  cursor: pointer;
}
.u2g-ai-quick:hover { background: var(--u2g-ai-border); }
.u2g-ai-quick:focus-visible { outline: 2px solid var(--u2g-ai-focus); outline-offset: 2px; }

/* ── Input ────────────────────────────────────────────────────────── */
#u2g-ai-form {
  display: flex;
  align-items: center;
  gap: 6px;
  border-top: 1px solid var(--u2g-ai-border);
  padding: 8px;
  flex-shrink: 0;
}
#u2g-ai-input {
  flex: 1;
  min-height: 40px;
  border: none;
  padding: 8px 10px;
  background: transparent;
  color: inherit;
  font-size: 16px; /* avoids iOS auto-zoom on focus */
}
#u2g-ai-input:focus { outline: none; }
#u2g-ai-input::placeholder { color: var(--u2g-ai-muted); }

#u2g-ai-form button[type="submit"] {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border: none;
  background: var(--u2g-ai-accent);
  color: var(--u2g-ai-accent-fg);
  border-radius: var(--u2g-ai-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
#u2g-ai-form button[type="submit"]:disabled { opacity: .5; cursor: not-allowed; }
#u2g-ai-form button[type="submit"]:focus-visible { outline: 2px solid var(--u2g-ai-focus); outline-offset: 2px; }
html[dir="rtl"] #u2g-ai-form button[type="submit"] svg { transform: scaleX(-1); }

/* ── WhatsApp handoff CTA ─────────────────────────────────────────── */
#u2g-ai-whatsapp-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px;
  margin: 0 8px 8px;
  font-size: 12px;
  color: var(--u2g-ai-muted);
  text-decoration: none;
  border: 1px solid var(--u2g-ai-border);
  border-radius: var(--u2g-ai-radius-sm);
  flex-shrink: 0;
}
#u2g-ai-whatsapp-cta:hover { background: var(--u2g-ai-bg-subtle); }
#u2g-ai-whatsapp-cta:focus-visible { outline: 2px solid var(--u2g-ai-focus); outline-offset: 2px; }
#u2g-ai-whatsapp-cta.u2g-ai-hidden { display: none; }

/* ── Mobile: full-height bottom sheet ────────────────────────────── */
@media (max-width: 640px) {
  #u2g-ai-panel {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 88vh;
    max-height: 88dvh;
    border-radius: var(--u2g-ai-radius) var(--u2g-ai-radius) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  html[dir="rtl"] #u2g-ai-panel { left: 0; right: 0; }

  #u2g-ai-launcher {
    bottom: max(16px, env(safe-area-inset-bottom));
    right: 16px;
  }
  html[dir="rtl"] #u2g-ai-launcher { right: auto; left: 16px; }
}
