/* Salony booking assistant — chat widget.
   Colours come from the theme (Appearance settings) with the default gold fallbacks. */
.sbot {
  --sb-primary: var(--theme-primary, var(--gold, #B8962E));
  --sb-dark: var(--theme-secondary, #2A2010);
  --sb-accent: var(--theme-accent, #F0E4C0);
  --sb-text: var(--theme-text-body, #4A3820);
  --sb-muted: var(--theme-text-muted, #7A6A45);
  --sb-bg: color-mix(in srgb, var(--sb-accent) 22%, #FFFDF9);
  --sb-card: #fff;
  --sb-line: color-mix(in srgb, var(--sb-muted) 18%, transparent);
  --sb-radius: 18px;
  position: fixed;
  z-index: 9990;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  inset-inline-end: 20px;
  font-family: 'Tajawal', 'DM Sans', system-ui, sans-serif;
  color: var(--sb-text);
}
.sbot[data-pos="start"] { inset-inline-end: auto; inset-inline-start: 20px; }
.sbot *, .sbot *::before, .sbot *::after { box-sizing: border-box; }

/* ── Launcher ─────────────────────────────────────────── */
.sbot-launch {
  display: inline-flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 22px 0 8px;
  border: 0; border-radius: 999px; cursor: pointer;
  background: var(--sb-dark); color: #fff;
  box-shadow: 0 10px 30px -8px color-mix(in srgb, var(--sb-dark) 55%, transparent);
  font: inherit; font-size: 15px; font-weight: 600;
  transition: transform .2s ease, box-shadow .2s ease;
}
[dir="rtl"] .sbot-launch { padding: 0 8px 0 22px; }
.sbot-launch:hover { transform: translateY(-2px); }
.sbot-launch:focus-visible { outline: 3px solid color-mix(in srgb, var(--sb-primary) 60%, transparent); outline-offset: 3px; }
.sbot-launch-icon {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--sb-primary); color: #fff;
}
.sbot-launch-icon svg { width: 20px; height: 20px; }
.sbot.is-open .sbot-launch { display: none; }
.sbot-launch.nudge .sbot-launch-icon { animation: sbot-nudge 1.6s ease 1; }
@keyframes sbot-nudge { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--sb-primary) 55%, transparent); } 50% { box-shadow: 0 0 0 12px transparent; } }

/* ── Panel ────────────────────────────────────────────── */
.sbot-panel {
  display: none; flex-direction: column;
  width: 390px; height: min(640px, calc(100vh - 40px));
  background: var(--sb-bg);
  border-radius: 22px; overflow: hidden;
  box-shadow: 0 30px 80px -20px rgba(20, 14, 6, .45), 0 0 0 1px rgba(0,0,0,.04);
  transform-origin: bottom right;
}
[dir="rtl"] .sbot-panel { transform-origin: bottom left; }
.sbot.is-open .sbot-panel { display: flex; animation: sbot-open .22s cubic-bezier(.2,.8,.2,1); }
@keyframes sbot-open { from { opacity: 0; transform: translateY(12px) scale(.98); } }

.sbot-head { background: var(--sb-dark); color: #fff; padding: 16px 18px 0; }
.sbot-head-row { display: flex; align-items: center; gap: 12px; }
.sbot-avatar {
  width: 42px; height: 42px; border-radius: 14px; flex-shrink: 0;
  display: grid; place-items: center; overflow: hidden;
  background: color-mix(in srgb, var(--sb-primary) 85%, #000);
}
.sbot-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sbot-avatar svg { width: 22px; height: 22px; color: #fff; }
.sbot-title { flex: 1; min-width: 0; }
.sbot-name { font-family: 'El Messiri', 'Tajawal', serif; font-size: 17px; font-weight: 600; line-height: 1.2; }
.sbot-status { font-size: 12px; opacity: .75; display: flex; align-items: center; gap: 6px; }
.sbot-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #34D399; }
.sbot-icon-btn {
  width: 34px; height: 34px; border-radius: 10px; border: 0; cursor: pointer;
  background: rgba(255,255,255,.08); color: #fff; display: grid; place-items: center;
}
.sbot-icon-btn:hover { background: rgba(255,255,255,.16); }
.sbot-icon-btn svg { width: 16px; height: 16px; }

/* booking progress rail */
.sbot-rail { display: flex; gap: 4px; margin-top: 14px; padding-bottom: 14px; }
.sbot-rail span { flex: 1; height: 3px; border-radius: 3px; background: rgba(255,255,255,.14); transition: background .3s ease; }
.sbot-rail span.on { background: var(--sb-primary); }
.sbot-rail[hidden] { display: none; }

/* ── Messages ─────────────────────────────────────────── */
.sbot-body { position: relative; flex: 1; overflow-y: auto; padding: 18px 16px 8px; scroll-behavior: smooth; overscroll-behavior: contain; }
.sbot-row { display: flex; margin-bottom: 10px; }
.sbot-row.user { justify-content: flex-end; }
.sbot-bubble {
  max-width: 84%; padding: 10px 14px; border-radius: var(--sb-radius);
  font-size: 14.5px; line-height: 1.65; white-space: pre-line; overflow-wrap: anywhere;
}
.sbot-row.bot .sbot-bubble { background: var(--sb-card); border: 1px solid var(--sb-line); border-end-start-radius: 6px; }
.sbot-row.user .sbot-bubble { background: var(--sb-primary); color: #fff; border-end-end-radius: 6px; }

.sbot-typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.sbot-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--sb-muted); opacity: .4; animation: sbot-dot 1s infinite; }
.sbot-typing i:nth-child(2) { animation-delay: .15s; } .sbot-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes sbot-dot { 50% { opacity: 1; transform: translateY(-3px); } }

.sbot-block { margin: 2px 0 12px; }

/* choices */
.sbot-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.sbot-choices.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.sbot-choices.scroll::-webkit-scrollbar { display: none; }
.sbot-chip {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  background: var(--sb-card); color: var(--sb-dark);
  border: 1px solid color-mix(in srgb, var(--sb-primary) 45%, transparent);
  font: inherit; font-size: 13.5px; font-weight: 500; text-decoration: none;
  transition: background .15s, color .15s, border-color .15s;
}
.sbot-chip:hover { background: color-mix(in srgb, var(--sb-primary) 10%, #fff); }
.sbot-chip.primary { background: var(--sb-primary); color: #fff; border-color: transparent; font-weight: 600; }
.sbot-chip.primary:hover { background: color-mix(in srgb, var(--sb-primary) 88%, #000); }
.sbot-chip.secondary { border-color: var(--sb-line); color: var(--sb-muted); }
.sbot-chip svg { width: 15px; height: 15px; }
.sbot-used .sbot-chip, .sbot-used .sbot-svc, .sbot-used .sbot-day, .sbot-used .sbot-slot, .sbot-used .sbot-person { pointer-events: none; opacity: .5; }
.sbot-used .sbot-chip.picked, .sbot-used .picked { opacity: 1; }

/* services */
.sbot-services { display: grid; gap: 8px; }
.sbot-svc {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px; border-radius: 14px; cursor: pointer; text-align: start;
  background: var(--sb-card); border: 1.5px solid var(--sb-line); font: inherit; color: inherit;
  transition: border-color .15s, background .15s;
}
.sbot-svc img, .sbot-svc .ph { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: var(--sb-accent); }
.sbot-svc-info { flex: 1; min-width: 0; }
.sbot-svc-name { display: block; font-weight: 600; font-size: 14px; line-height: 1.35; }
.sbot-svc-meta { display: block; font-size: 12px; color: var(--sb-muted); margin-top: 2px; }
.sbot-svc-price { font-weight: 700; font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sbot-tick { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--sb-line); flex-shrink: 0; display: grid; place-items: center; }
.sbot-tick svg { width: 12px; height: 12px; color: #fff; opacity: 0; }
.sbot-svc.on { border-color: var(--sb-primary); background: color-mix(in srgb, var(--sb-primary) 6%, #fff); }
.sbot-svc.on .sbot-tick { background: var(--sb-primary); border-color: var(--sb-primary); }
.sbot-svc.on .sbot-tick svg { opacity: 1; }
.sbot-continue { margin-top: 10px; width: 100%; justify-content: center; }
.sbot-continue[disabled] { opacity: .45; cursor: not-allowed; }

/* staff */
.sbot-people { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.sbot-people::-webkit-scrollbar { display: none; }
.sbot-person {
  flex-shrink: 0; width: 84px; padding: 10px 6px; border-radius: 14px; cursor: pointer; text-align: center;
  background: var(--sb-card); border: 1.5px solid var(--sb-line); font: inherit; color: inherit; font-size: 12.5px; line-height: 1.3;
}
.sbot-person:hover { border-color: var(--sb-primary); }
.sbot-person .face { width: 46px; height: 46px; border-radius: 50%; margin: 0 auto 6px; object-fit: cover; background: var(--sb-accent); display: grid; place-items: center; color: var(--sb-primary); }
.sbot-person .face svg { width: 22px; height: 22px; }

/* dates */
.sbot-days { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.sbot-days::-webkit-scrollbar { display: none; }
.sbot-day {
  flex-shrink: 0; min-width: 92px; padding: 10px 12px; border-radius: 14px; cursor: pointer; text-align: center;
  background: var(--sb-card); border: 1.5px solid var(--sb-line); font: inherit; color: inherit;
}
.sbot-day:hover { border-color: var(--sb-primary); }
.sbot-day b { display: block; font-size: 13.5px; }
.sbot-day small { display: block; font-size: 11.5px; color: var(--sb-muted); margin-top: 3px; }
.sbot-day.other { display: flex; flex-direction: column; justify-content: center; border-style: dashed; color: var(--sb-muted); }
.sbot-day input[type="date"] { width: 100%; border: 0; font: inherit; font-size: 12px; background: transparent; color: var(--sb-text); }

/* slots */
.sbot-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sbot-slot {
  padding: 9px 4px; border-radius: 12px; cursor: pointer;
  background: var(--sb-card); border: 1.5px solid var(--sb-line);
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--sb-dark); font-variant-numeric: tabular-nums;
}
.sbot-slot:hover { border-color: var(--sb-primary); color: var(--sb-primary); }

/* summary (receipt) */
.sbot-summary { background: var(--sb-card); border: 1px solid var(--sb-line); border-radius: 16px; padding: 14px 16px; }
.sbot-summary dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 13.5px; }
.sbot-summary dt { color: var(--sb-muted); }
.sbot-summary dd { margin: 0; text-align: end; font-weight: 600; }
.sbot-total { margin-top: 12px; padding-top: 12px; border-top: 1.5px dashed var(--sb-line); display: flex; justify-content: space-between; align-items: baseline; }
.sbot-total b { font-size: 20px; color: var(--sb-primary); font-variant-numeric: tabular-nums; }

/* success */
.sbot-success {
  text-align: center; padding: 22px 16px; border-radius: 18px;
  background: var(--sb-card); border: 1px solid color-mix(in srgb, var(--sb-primary) 35%, transparent);
}
.sbot-success .ok { width: 54px; height: 54px; border-radius: 50%; margin: 0 auto 10px; display: grid; place-items: center; background: var(--sb-primary); color: #fff; animation: sbot-pop .35s cubic-bezier(.2,1.6,.4,1); }
.sbot-success .ok svg { width: 26px; height: 26px; }
@keyframes sbot-pop { from { transform: scale(.4); opacity: 0; } }
.sbot-success h4 { margin: 0 0 6px; font-family: 'El Messiri', 'Tajawal', serif; font-size: 19px; color: var(--sb-dark); }
.sbot-success p { margin: 0 0 12px; font-size: 13.5px; line-height: 1.7; }
.sbot-number { display: inline-block; padding: 6px 14px; border-radius: 999px; background: var(--sb-bg); font-family: 'DM Sans', monospace; font-weight: 700; letter-spacing: .5px; direction: ltr; }

/* ── Composer ─────────────────────────────────────────── */
.sbot-foot { padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--sb-line); background: var(--sb-card); }
.sbot-form { display: flex; gap: 8px; align-items: center; }
.sbot-form input {
  flex: 1; min-width: 0; height: 44px; padding: 0 14px; border-radius: 14px;
  border: 1.5px solid var(--sb-line); background: var(--sb-bg); font: inherit; font-size: 14.5px; color: var(--sb-text);
}
.sbot-form input:focus { outline: none; border-color: var(--sb-primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--sb-primary) 14%, transparent) !important; }
.sbot-form.highlight input { border-color: var(--sb-primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--sb-primary) 14%, transparent); }
.sbot-send { width: 44px; height: 44px; border-radius: 14px; border: 0; cursor: pointer; background: var(--sb-primary); color: #fff; display: grid; place-items: center; flex-shrink: 0; }
.sbot-send svg { width: 18px; height: 18px; }
[dir="rtl"] .sbot-send svg { transform: scaleX(-1); }
.sbot-send[disabled] { opacity: .5; }

/* ── Phones: full-screen sheet ────────────────────────── */
@media (max-width: 640px) {
  .sbot { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); inset-inline-end: 14px; }
  .sbot-launch { height: 52px; padding: 0 !important; width: 52px; justify-content: center; }
  .sbot-launch-text { display: none; }
  .sbot-launch-icon { width: 52px; height: 52px; }
  .sbot.is-open { inset: 0; bottom: 0; }
  .sbot-panel { width: 100vw; height: 100dvh; border-radius: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sbot *, .sbot *::before { animation: none !important; transition: none !important; }
}
