/* Salon AI Connect — widget styles v1.5 */
.saic-widget, .saic-widget * { box-sizing: border-box; }

/* ─── Theme tokens ─────────────────────────────────────────────── */
.saic-widget {
  --saic-bg:      #ffffff;
  --saic-surface: #f4f6f8;
  --saic-text:    #1a1f2e;
  --saic-muted:   #7a8694;
  --saic-radius:  18px;
  --saic-bot-bg:  #ffffff;
  --saic-bot-bd:  #e6eaee;
  --saic-shadow:  0 2px 12px rgba(0,0,0,.07);
  direction: ltr;
  display: flex;
  flex-direction: column;
  background: var(--saic-bg);
  border: 1px solid #dce3ea;
  border-radius: var(--saic-radius);
  overflow: hidden;
  font-family: inherit;
  box-shadow: 0 12px 40px rgba(0,0,0,.10);
  height: 100%;
  min-height: 320px;
}
.saic-inline { height: var(--saic-h, 520px); }
.saic-inline .saic-widget { height: 100%; }

/* ─── Header ───────────────────────────────────────────────────── */
.saic-header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 16px 13px 14px;
  background: linear-gradient(135deg, var(--saic-primary, #1a7f64) 0%, color-mix(in srgb, var(--saic-primary, #1a7f64) 80%, #000) 100%);
  color: #fff;
  flex: 0 0 auto;
  position: relative;
  overflow: hidden;
}
.saic-header::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 110% -20%, rgba(255,255,255,.12) 0%, transparent 60%);
  pointer-events: none;
}
.saic-header .saic-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  border: 2px solid rgba(255,255,255,.45);
  display: grid; place-items: center;
  font-size: 17px;
  flex-shrink: 0;
  overflow: hidden;
}
.saic-header .saic-avatar svg { width: 22px; height: 22px; }
.saic-header .saic-avatar img { width:100%; height:100%; object-fit:cover; border-radius:50%; display:block; }
.saic-header .saic-title { font-weight: 700; font-size: 15px; line-height: 1.2; letter-spacing: -.01em; }
.saic-header .saic-status {
  font-size: 11.5px; opacity: .88;
  display: flex; align-items: center; gap: 5px; margin-top: 1px;
}
.saic-header .saic-status::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: #7dffc3; box-shadow: 0 0 0 3px rgba(125,255,195,.28);
  animation: saic-pulse 2.4s infinite;
}
@keyframes saic-pulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(125,255,195,.28); }
  50% { box-shadow: 0 0 0 5px rgba(125,255,195,.10); }
}

/* header actions (close + new chat) */
.saic-header-actions {
  margin-inline-start: auto;
  display: flex; align-items: center; gap: 4px;
}
.saic-header-actions button {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  opacity: .78;
  transition: opacity .15s, background .15s;
}
.saic-header-actions button:hover { opacity: 1; background: rgba(255,255,255,.18); }
.saic-header-actions button svg { width: 16px; height: 16px; display: block; }

/* ─── Quick-reply chips ─────────────────────────────────────────── */
.saic-chips {
  display: flex; flex-wrap: wrap; gap: 7px;
  padding: 10px 14px 4px;
  background: var(--saic-surface);
  flex: 0 0 auto;
}
.saic-chip {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  border: 1.5px solid var(--saic-primary, #1a7f64);
  color: var(--saic-primary, #1a7f64);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.4;
  background: #fff;
  transition: background .15s, color .15s, transform .1s;
  white-space: nowrap;
}
.saic-chip:hover { background: var(--saic-primary, #1a7f64); color: #fff; transform: translateY(-1px); }

/* ─── Messages ──────────────────────────────────────────────────── */
.saic-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--saic-surface);
  scroll-behavior: smooth;
}
.saic-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  animation: saic-in .2s ease-out;
}
.saic-msg-row.saic-row-bot { align-self: flex-start; max-width: 84%; }
.saic-msg-row.saic-row-user { align-self: flex-end; max-width: 84%; flex-direction: row-reverse; }
.saic-msg-row-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--saic-primary, #1a7f64);
  flex-shrink: 0;
  display: grid; place-items: center;
  overflow: hidden;
  margin-bottom: 2px;
}
.saic-msg-row-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.saic-msg-row-avatar svg { width: 14px; height: 14px; color: #fff; }
.saic-msg-col { display: flex; flex-direction: column; gap: 2px; }
.saic-msg {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--saic-text);
  word-break: break-word;
  white-space: pre-wrap;
}
.saic-msg.saic-bot {
  background: var(--saic-bot-bg);
  border: 1px solid var(--saic-bot-bd);
  border-start-start-radius: 4px;
  box-shadow: var(--saic-shadow);
}
.saic-msg.saic-user {
  background: var(--saic-primary, #1a7f64);
  color: #fff;
  border-start-end-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.saic-msg.saic-error {
  background: #fff4f3;
  border: 1px solid #f2c9c4;
  color: #8a3229;
  border-start-start-radius: 4px;
}
.saic-msg-time {
  font-size: 10.5px;
  color: var(--saic-muted);
  padding: 0 4px;
  opacity: 0;
  transition: opacity .2s;
}
.saic-msg-row:hover .saic-msg-time { opacity: 1; }
.saic-row-user .saic-msg-time { text-align: right; }
.saic-msg a { color: var(--saic-primary, #1a7f64); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.saic-msg a:hover { opacity: .8; }
.saic-msg.saic-user a { color: rgba(255,255,255,.9); }
@keyframes saic-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .saic-msg-row { animation: none; }
  .saic-messages { scroll-behavior: auto; }
}

/* ─── Typing indicator ──────────────────────────────────────────── */
.saic-typing {
  display: inline-flex; gap: 5px; align-items: center;
  padding: 12px 16px;
}
.saic-typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--saic-muted); display: block;
  animation: saic-blink 1.3s infinite;
}
.saic-typing i:nth-child(2) { animation-delay: .18s; }
.saic-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes saic-blink { 0%,80%,100% { opacity: .22; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ─── Input row ─────────────────────────────────────────────────── */
.saic-inputrow {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: var(--saic-bg);
  border-top: 1px solid #e2e8ec;
  align-items: flex-end;
}
.saic-input {
  all: unset;
  box-sizing: border-box;
  flex: 1;
  border: 1.5px solid #d4dce3;
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 16px;
  font-family: inherit;
  resize: none;
  max-height: 110px;
  line-height: 1.5;
  background: #fff;
  color: var(--saic-text);
  transition: border-color .18s, box-shadow .18s;
  width: 100%;
  overflow-y: auto;
}
.saic-input:focus {
  border-color: var(--saic-primary, #1a7f64);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--saic-primary, #1a7f64) 18%, transparent);
  outline: none;
}
.saic-send {
  all: unset;
  box-sizing: border-box;
  background: var(--saic-primary, #1a7f64);
  color: #fff;
  border-radius: 14px;
  width: 44px; height: 44px;
  min-width: 44px;
  cursor: pointer;
  display: grid; place-items: center;
  transition: filter .15s, transform .12s;
  flex-shrink: 0;
}
.saic-send:hover:not(:disabled) { filter: brightness(1.08); transform: scale(1.04); }
.saic-send:disabled { opacity: .4; cursor: default; }
.saic-send svg { width: 20px; height: 20px; display: block; }

/* ─── Floating bubble ───────────────────────────────────────────── */
#saic-bubble-root {
  position: fixed; bottom: 22px; z-index: 99999;
  display: flex; flex-direction: column; align-items: flex-end;
}
#saic-bubble-root.saic-left { left: 22px; align-items: flex-start; }
#saic-bubble-root.saic-right { right: 22px; }

/* teaser bubble */
.saic-teaser {
  background: #fff;
  border: 1px solid #dce3ea;
  border-radius: 18px 18px 4px 18px;
  padding: 9px 14px;
  font-size: 13.5px;
  color: var(--saic-text, #1a1f2e);
  box-shadow: 0 4px 18px rgba(0,0,0,.10);
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 8px;
  animation: saic-teaser-in .3s ease-out;
  max-width: 200px;
  line-height: 1.4;
  cursor: pointer;
}
.saic-teaser .saic-teaser-close {
  all: unset; cursor: pointer; font-size: 16px; color: var(--saic-muted); line-height: 1; flex-shrink: 0;
}
@keyframes saic-teaser-in { from { opacity: 0; transform: translateY(8px) scale(.95); } to { opacity: 1; transform: none; } }
.saic-left .saic-teaser { border-radius: 18px 18px 18px 4px; }

/* fab */
.saic-fab {
  width: 58px; height: 58px;
  border-radius: 50%; border: 0;
  background: var(--saic-primary, #1a7f64);
  color: #fff; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
  transition: transform .18s, box-shadow .18s, opacity .25s;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  padding: 0;
}
.saic-fab:hover { transform: scale(1.07); box-shadow: 0 12px 30px rgba(0,0,0,.28); }
.saic-fab svg { width: 27px; height: 27px; }
.saic-fab img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }

/* notification badge */
.saic-badge {
  position: absolute; top: 3px; right: 3px;
  background: #e63e3e; color: #fff;
  border: 2px solid #fff;
  border-radius: 50%;
  width: 18px; height: 18px;
  font-size: 10px; font-weight: 700; font-family: inherit;
  display: grid; place-items: center;
  pointer-events: none;
  animation: saic-badge-in .25s ease-out;
  line-height: 1;
}
@keyframes saic-badge-in { from { transform: scale(0); } to { transform: scale(1); } }

/* hide fab when panel is open */
.saic-fab.saic-fab-hidden { opacity: 0; pointer-events: none; visibility: hidden; }

/* scroll-aware fab visibility */
.saic-fab.saic-fab-scroll-hidden { opacity: 0 !important; pointer-events: none !important; visibility: hidden !important; transform: scale(.85) !important; }

/* panel */
.saic-panel {
  position: absolute; bottom: 72px;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 120px));
  display: none;
  filter: drop-shadow(0 16px 48px rgba(0,0,0,.14));
}
#saic-bubble-root.saic-left .saic-panel { left: 0; }
#saic-bubble-root.saic-right .saic-panel { right: 0; }
.saic-panel.saic-open { display: block; animation: saic-panel-in .22s ease-out; }
.saic-panel .saic-widget { height: 100%; }
@keyframes saic-panel-in { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }

/* ─── Mobile fullscreen ─────────────────────────────────────────── */
@media (max-width: 480px) {
  .saic-panel { position: fixed; inset: 0; width: 100%; height: 100%; bottom: 0; filter: none; }
  .saic-panel .saic-widget { border-radius: 0; }
}

/* ─── Theme-safe overrides (beats most WP themes) ──────────────── */
#saic-bubble-root button,
.saic-panel button, .saic-panel textarea,
.saic-inline button, .saic-inline textarea {
  font-family: inherit;
  letter-spacing: inherit;
}
