/* Sahm chat widget -- Wajez Travel. Everything is scoped under #sahm-root / .sahm-*. */
#sahm-root {
  --sahm-teal: #2486a3;
  --sahm-cyan: #2cb9d5;
  --sahm-gold: #d9942e;
  --sahm-gold-2: #db8632;
  --sahm-gold-ink: #21150a; /* text on gold: white on #d9942e is only ~2.5:1 */
  --sahm-wa: #25d366;
  --sahm-bg: #ffffff;
  --sahm-surface: #f6fafb;
  --sahm-bot: #eaf5f8;
  --sahm-text: #12313a;
  --sahm-muted: #5d7680;
  --sahm-border: #d6e6eb;
  --sahm-chip: #ffffff;
  --sahm-link: #1f7792;
  --sahm-shadow: 0 24px 60px -18px rgba(9, 45, 56, .45);
  --sahm-font: var(--f-ui, "Cairo", "Montserrat", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif);
}
/* Dark: the site's Auto mode (system dark, no explicit choice) ... */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #sahm-root:not([data-theme="light"]) {
    --sahm-bg: #0f1d22; --sahm-surface: #13252c; --sahm-bot: #1b3640; --sahm-text: #e5f0f3;
    --sahm-muted: #9ab2ba; --sahm-border: #29444f; --sahm-chip: #13252c; --sahm-link: #5fd0e6;
    --sahm-shadow: 0 24px 60px -18px rgba(0, 0, 0, .7);
  }
}
/* ... and an explicit Dark choice (site toggle, or set on #sahm-root on pages without the toggle) */
:root[data-theme="dark"] #sahm-root:not([data-theme="light"]), #sahm-root[data-theme="dark"] {
  --sahm-bg: #0f1d22; --sahm-surface: #13252c; --sahm-bot: #1b3640; --sahm-text: #e5f0f3;
  --sahm-muted: #9ab2ba; --sahm-border: #29444f; --sahm-chip: #13252c; --sahm-link: #5fd0e6;
  --sahm-shadow: 0 24px 60px -18px rgba(0, 0, 0, .7);
}

#sahm-root, #sahm-root * { box-sizing: border-box; }
#sahm-root { font-family: var(--sahm-font); font-size: 15px; line-height: 1.55; color: var(--sahm-text); }
/* zero specificity for the id, so the widget's own class rules win while host button{} rules still lose */
:where(#sahm-root) :is(button, input, select, textarea) { font: inherit; color: inherit; }
#sahm-root [hidden] { display: none !important; }

/* ---------- floating buttons (same corner as the site's WhatsApp button) ---------- */
.sahm-launcher {
  position: fixed; inset-block-end: 20px; inset-inline-end: 20px; z-index: 9991;
  width: 60px; height: 60px; padding: 0; border-radius: 50%; cursor: pointer;
  border: 3px solid #fff; background: #eaf7fb; overflow: visible;
  box-shadow: 0 12px 30px -8px rgba(36, 134, 163, .65);
  transition: transform .2s ease;
}
.sahm-launcher:hover { transform: scale(1.06); }
.sahm-launcher:focus-visible { outline: 3px solid var(--sahm-gold); outline-offset: 3px; }
.sahm-launcher img { width: 100%; height: 100%; border-radius: 50%; display: block; object-fit: cover; }
.sahm-launcher .sahm-ai {
  position: absolute; inset-block-start: -4px; inset-inline-end: -6px;
  background: linear-gradient(135deg, var(--sahm-gold), var(--sahm-gold-2)); color: var(--sahm-gold-ink);
  font-size: 10px; font-weight: 800; line-height: 1; padding: 4px 6px; border-radius: 10px;
  border: 2px solid #fff; letter-spacing: .5px; font-family: "Montserrat", var(--sahm-font);
}
.sahm-launcher .sahm-x {
  position: absolute; inset: 0; border-radius: 50%; display: none; place-items: center;
  background: linear-gradient(135deg, var(--sahm-teal), var(--sahm-cyan)); color: #fff; font-size: 26px; line-height: 1;
}
html.sahm-open .sahm-launcher .sahm-x { display: grid; }
html.sahm-open .sahm-launcher .sahm-ai { display: none; }
@keyframes sahm-pulse {
  0% { box-shadow: 0 0 0 0 rgba(44, 185, 213, .55), 0 12px 30px -8px rgba(36, 134, 163, .65); transform: scale(1); }
  40% { transform: scale(1.08); }
  100% { box-shadow: 0 0 0 18px rgba(44, 185, 213, 0), 0 12px 30px -8px rgba(36, 134, 163, .65); transform: scale(1); }
}
.sahm-launcher.sahm-pulse { animation: sahm-pulse 1.4s ease-out 1.2s 1; }

/* small WhatsApp button above Sahm (ours on pages without one; the homepage's #fab is moved instead).
   Literal colours: #fab lives outside #sahm-root, where the --sahm-* variables don't exist. */
.sahm-wa-mini, html.sahm-on #fab {
  position: fixed; inset-block-end: 92px; inset-inline-end: 26px; z-index: 9990;
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  background: #25d366; color: #05340f; box-shadow: 0 10px 24px -8px rgba(37, 211, 102, .6);
}
.sahm-wa-mini svg, html.sahm-on #fab svg { width: 24px; height: 24px; }
.sahm-wa-mini:hover { transform: scale(1.06); }
html.sahm-open #fab, html.sahm-open .sahm-wa-mini, html.sahm-open .sahm-bubble { display: none; }

/* greeting bubble */
.sahm-bubble {
  position: fixed; inset-block-end: 30px; inset-inline-end: 92px; z-index: 9989; max-width: 250px;
  background: var(--sahm-bg); color: var(--sahm-text); border: 1px solid var(--sahm-border);
  border-radius: 16px; padding: 10px 34px 10px 14px; box-shadow: var(--sahm-shadow); cursor: pointer;
  font-size: 14px; font-weight: 600; animation: sahm-in .35s ease-out;
}
[dir="rtl"] .sahm-bubble { padding: 10px 14px 10px 34px; }
.sahm-bubble .sahm-bubble-x {
  position: absolute; inset-block-start: 4px; inset-inline-end: 6px; border: 0; background: none;
  font-size: 18px; line-height: 1; color: var(--sahm-muted); cursor: pointer; padding: 4px;
}
@keyframes sahm-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- panel ---------- */
.sahm-panel {
  position: fixed; inset-block-end: 92px; inset-inline-end: 20px; z-index: 9992;
  width: 380px; height: 620px; max-height: calc(100vh - 112px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--sahm-bg); border: 1px solid var(--sahm-border); border-radius: 20px;
  box-shadow: var(--sahm-shadow); animation: sahm-in .25s ease-out;
}
.sahm-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; color: #fff;
  background: linear-gradient(120deg, var(--sahm-teal), var(--sahm-cyan));
}
.sahm-head img { width: 42px; height: 42px; border-radius: 50%; border: 2px solid #fff; background: #eaf7fb; flex: none; }
.sahm-head-txt { flex: 1; min-width: 0; }
.sahm-head-name { font-weight: 800; font-size: 15px; line-height: 1.3; }
.sahm-head-status { font-size: 12px; opacity: .95; line-height: 1.3; }
.sahm-icon-btn {
  flex: none; width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; background: rgba(255, 255, 255, .18); color: #fff; text-decoration: none;
}
.sahm-icon-btn:hover { background: rgba(255, 255, 255, .3); }
.sahm-icon-btn svg { width: 20px; height: 20px; }
.sahm-icon-btn.sahm-close { font-size: 22px; line-height: 1; }

.sahm-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; background: var(--sahm-surface); overscroll-behavior: contain; padding: 14px 12px 10px; }
.sahm-msgs { display: flex; flex-direction: column; gap: 8px; }
.sahm-tailbox { margin-block-start: 8px; padding-inline-start: 36px; }
.sahm-row { display: flex; gap: 8px; align-items: flex-end; max-width: 100%; }
.sahm-row.sahm-user { justify-content: flex-end; }
.sahm-row .sahm-av { width: 28px; height: 28px; border-radius: 50%; flex: none; background: #eaf7fb; }
.sahm-msg {
  max-width: 82%; padding: 9px 12px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word;
  overflow-wrap: anywhere; unicode-bidi: plaintext;
}
.sahm-bot .sahm-msg { background: var(--sahm-bot); border-end-start-radius: 4px; }
.sahm-user .sahm-msg { background: linear-gradient(135deg, var(--sahm-teal), #2a9cbc); color: #fff; border-end-end-radius: 4px; }
.sahm-sys { align-self: center; font-size: 12.5px; color: var(--sahm-muted); text-align: center; padding: 2px 10px; }
.sahm-meta { font-size: 11px; color: var(--sahm-muted); margin-block-start: 3px; direction: ltr; text-align: start; }
.sahm-links { display: flex; flex-wrap: wrap; gap: 6px; margin-block-start: 6px; padding-inline-start: 36px; }
.sahm-link {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 11px; border-radius: 999px;
  background: var(--sahm-chip); border: 1px solid var(--sahm-border); color: var(--sahm-link);
  font-size: 13px; font-weight: 700; text-decoration: none;
}
.sahm-link:hover { border-color: var(--sahm-cyan); }

/* typing */
.sahm-typing { display: flex; align-items: center; gap: 8px; color: var(--sahm-muted); font-size: 13px; }
.sahm-typing img { width: 64px; height: auto; }
.sahm-dots span { display: inline-block; width: 6px; height: 6px; margin: 0 2px; border-radius: 50%; background: var(--sahm-cyan); animation: sahm-dot 1s infinite; }
.sahm-dots span:nth-child(2) { animation-delay: .15s; }
.sahm-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes sahm-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* chips + controls */
.sahm-ctl { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.sahm-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sahm-chip {
  padding: 7px 12px; border-radius: 999px; cursor: pointer; font-size: 13.5px; font-weight: 600;
  background: var(--sahm-chip); color: var(--sahm-text); border: 1.5px solid var(--sahm-cyan);
}
.sahm-chip:hover, .sahm-chip[aria-pressed="true"] { background: var(--sahm-cyan); color: #06303b; }
.sahm-chip.sahm-chip-quiet { border-color: var(--sahm-border); color: var(--sahm-muted); }
.sahm-chip.sahm-chip-wa { border-color: var(--sahm-wa); }
.sahm-chip.sahm-chip-wa:hover { background: var(--sahm-wa); color: #05340f; }
.sahm-box {
  background: var(--sahm-bg); border: 1px solid var(--sahm-border); border-radius: 14px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.sahm-field { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--sahm-muted); font-weight: 600; min-width: 0; }
.sahm-field input, .sahm-field select, .sahm-field textarea {
  width: 100%; min-width: 0; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--sahm-border);
  background: var(--sahm-surface); color: var(--sahm-text); font-size: 14px; font-weight: 500;
}
.sahm-field input:focus, .sahm-field select:focus, .sahm-input textarea:focus { outline: 2px solid var(--sahm-cyan); outline-offset: 0; border-color: transparent; }
.sahm-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sahm-counter { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--sahm-text); font-weight: 600; }
.sahm-counter .sahm-step { display: flex; align-items: center; gap: 8px; }
.sahm-counter button {
  width: 32px; height: 32px; border-radius: 50%; border: 1.5px solid var(--sahm-cyan); background: var(--sahm-chip);
  cursor: pointer; font-size: 18px; line-height: 1; color: var(--sahm-link);
}
.sahm-counter output { min-width: 22px; text-align: center; font-weight: 800; }
.sahm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 10px 14px; border-radius: 12px; border: 0; cursor: pointer; font-weight: 800; font-size: 14.5px;
  background: linear-gradient(135deg, var(--sahm-gold), var(--sahm-gold-2)); color: var(--sahm-gold-ink);
}
.sahm-btn svg { width: 20px; height: 20px; flex: none; }
.sahm-ico { display: contents; }
.sahm-btn.sahm-btn-wa { background: var(--sahm-wa); color: #05340f; }
.sahm-btn.sahm-btn-ghost { background: transparent; color: var(--sahm-link); border: 1.5px solid var(--sahm-border); font-weight: 700; }
.sahm-btn[disabled] { opacity: .6; cursor: progress; }
.sahm-formwrap { display: flex; flex-direction: column; gap: 8px; }
.sahm-card-head { display: flex; align-items: center; gap: 10px; }
.sahm-card-head img { width: 54px; height: auto; flex: none; }
.sahm-card-title { font-weight: 800; font-size: 15px; color: var(--sahm-text); }
.sahm-card-hint { font-size: 12.5px; color: var(--sahm-muted); }
.sahm-err { color: #c0392b; font-size: 12.5px; font-weight: 700; }
.sahm-rate { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--sahm-muted); }
.sahm-rate button { border: 1px solid var(--sahm-border); background: var(--sahm-chip); border-radius: 10px; padding: 4px 10px; cursor: pointer; font-size: 17px; }

/* input */
.sahm-input { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 6px; background: var(--sahm-bg); border-top: 1px solid var(--sahm-border); }
.sahm-input textarea {
  flex: 1; resize: none; max-height: 110px; min-height: 42px; padding: 10px 12px; border-radius: 14px;
  border: 1px solid var(--sahm-border); background: var(--sahm-surface); color: var(--sahm-text); font-size: 15px; line-height: 1.4;
}
.sahm-send {
  flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--sahm-gold), var(--sahm-gold-2)); color: var(--sahm-gold-ink);
}
.sahm-send svg { width: 20px; height: 20px; }
[dir="rtl"] .sahm-send svg { transform: scaleX(-1); }
.sahm-send[disabled] { opacity: .5; cursor: default; }
.sahm-foot { padding: 0 12px 8px; background: var(--sahm-bg); font-size: 11px; color: var(--sahm-muted); line-height: 1.45; }
.sahm-foot a { color: inherit; }
.sahm-foot-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-block-start: 4px; }
.sahm-foot button, .sahm-foot select { border: 0; background: none; color: var(--sahm-muted); font-size: 11px; cursor: pointer; padding: 0; text-decoration: underline; }
.sahm-foot select { text-decoration: none; border: 1px solid var(--sahm-border); border-radius: 6px; padding: 1px 4px; }

/* ---------- phones (and phones held sideways): full-screen chat, smaller buttons ---------- */
@media (max-width: 620px), (max-height: 500px) {
  .sahm-panel {
    inset: 0; width: 100%; height: 100vh; height: 100dvh; max-height: none; border-radius: 0; border: 0;
  }
  html.sahm-open .sahm-launcher { display: none; }
  html.sahm-open, html.sahm-open body { overflow: hidden; }
  .sahm-field input, .sahm-field select, .sahm-input textarea { font-size: 16px; } /* 16px: no iOS auto-zoom */
}
@media (max-width: 620px) {
  .sahm-launcher { width: 56px; height: 56px; inset-block-end: 16px; inset-inline-end: 16px; }
  .sahm-wa-mini, html.sahm-on #fab { inset-block-end: 84px; inset-inline-end: 22px; width: 44px; height: 44px; }
  .sahm-bubble { inset-block-end: 24px; inset-inline-end: 82px; max-width: calc(100vw - 110px); }
}
@media (max-width: 400px) {
  .sahm-two { grid-template-columns: minmax(0, 1fr); }
  .sahm-tailbox, .sahm-links { padding-inline-start: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sahm-launcher.sahm-pulse, .sahm-panel, .sahm-bubble, .sahm-dots span { animation: none; }
}
@media print { #sahm-root { display: none; } }
