/* Smartsup chatbot — self-contained, template-agnostic. Brand color is injected via --ss-brand. */
#smartsup-root,
#smartsup-root * { box-sizing: border-box; }

#smartsup-root {
  --ss-brand: #4f46e5;
  --ss-brand-dark: #3730a3;
  --ss-bg: #ffffff;
  --ss-surface: #f4f5fa;
  --ss-text: #1b1f2e;
  --ss-muted: #6b7289;
  --ss-border: #e4e6f0;
  --ss-bot: #eef0f8;
  --ss-radius: 20px;
  --ss-shadow: 0 18px 50px rgba(20, 24, 50, .28), 0 2px 8px rgba(20, 24, 50, .12);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ss-text);
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 2147483000;
}

#smartsup-root.ss-dark {
  --ss-bg: #151826;
  --ss-surface: #1d2133;
  --ss-text: #eceefa;
  --ss-muted: #9aa1bd;
  --ss-border: #2b3050;
  --ss-bot: #232844;
}

/* ---------- Launcher ---------- */
.ss-launcher {
  position: relative;
  width: 62px; height: 62px;
  border: 0; border-radius: 50%;
  background: linear-gradient(135deg, var(--ss-brand), var(--ss-brand-dark));
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .35);
  transition: transform .2s ease, box-shadow .2s ease;
  margin-left: auto;
}
.ss-launcher:hover { transform: translateY(-2px) scale(1.04); }
.ss-launcher:focus-visible { outline: 3px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 5px var(--ss-brand); }
.ss-ic-chat, .ss-ic-close { position: absolute; display: flex; transition: transform .25s ease, opacity .2s ease; }
.ss-launcher svg { width: 28px; height: 28px; }
.ss-ic-close { opacity: 0; transform: rotate(-90deg) scale(.6); }
.ss-open .ss-ic-chat { opacity: 0; transform: rotate(90deg) scale(.6); }
.ss-open .ss-ic-close { opacity: 1; transform: none; }
html.ss-lock { overflow: hidden; }
.ss-launcher::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: var(--ss-brand); opacity: .5; z-index: -1;
  animation: ss-pulse 2.4s ease-out infinite;
}
.ss-open .ss-launcher::before { animation: none; opacity: 0; }
@keyframes ss-pulse { 0% { transform: scale(1); opacity: .5; } 100% { transform: scale(1.7); opacity: 0; } }

.ss-badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 20px; height: 20px; padding: 0 5px;
  background: #ef4444; color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 10px; display: none; align-items: center; justify-content: center;
  border: 2px solid #fff;
}
.ss-badge.ss-show { display: flex; }

/* Greeting teaser */
.ss-teaser {
  position: absolute; right: 74px; bottom: 8px;
  max-width: 250px; padding: 12px 34px 12px 16px;
  background: var(--ss-bg); color: var(--ss-text);
  border-radius: 16px 16px 4px 16px;
  box-shadow: var(--ss-shadow); cursor: pointer;
  opacity: 0; transform: translateY(8px) scale(.96); pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
}
.ss-teaser.ss-show { opacity: 1; transform: none; pointer-events: auto; }
.ss-teaser b { display: block; font-size: 13px; margin-bottom: 2px; }
.ss-teaser span { color: var(--ss-muted); font-size: 13px; }
.ss-teaser-x {
  position: absolute; top: 6px; right: 8px; border: 0; background: none;
  color: var(--ss-muted); font-size: 18px; line-height: 1; cursor: pointer; padding: 2px 4px;
}

/* ---------- Panel ---------- */
.ss-panel {
  position: absolute; right: 0; bottom: 78px;
  width: 392px; max-width: calc(100vw - 28px);
  height: 640px; max-height: calc(100vh - 110px);
  display: flex; flex-direction: column;
  background: var(--ss-bg); border-radius: var(--ss-radius);
  box-shadow: var(--ss-shadow); overflow: hidden;
  opacity: 0; visibility: hidden; transform: translateY(16px) scale(.97);
  transform-origin: bottom right;
  transition: opacity .25s ease, transform .25s ease, visibility 0s .25s;
}
.ss-open .ss-panel { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }

.ss-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px 16px 18px; color: #fff;
  background: linear-gradient(135deg, var(--ss-brand), var(--ss-brand-dark));
  position: relative;
}
.ss-head::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 90% -20%, rgba(255,255,255,.28), transparent 55%);
}
.ss-avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 1;
}
.ss-avatar svg { width: 24px; height: 24px; }
.ss-avatar i {
  position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px;
  background: #22c55e; border: 2px solid var(--ss-brand-dark); border-radius: 50%;
}
.ss-title { flex: 1; min-width: 0; position: relative; z-index: 1; }
.ss-title strong { display: block; font-size: 16px; font-weight: 700; letter-spacing: .2px; }
.ss-title small { opacity: .85; font-size: 12px; }
.ss-actions { display: flex; gap: 2px; position: relative; z-index: 1; }
.ss-iconbtn {
  width: 34px; height: 34px; border: 0; border-radius: 10px; cursor: pointer;
  background: transparent; color: #fff; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.ss-iconbtn:hover, .ss-iconbtn:focus-visible { background: rgba(255,255,255,.2); outline: none; }
.ss-iconbtn svg { width: 18px; height: 18px; }

/* Messages */
.ss-body {
  flex: 1; overflow-y: auto; padding: 18px 16px 8px;
  background: var(--ss-surface); scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.ss-body::-webkit-scrollbar { width: 6px; }
.ss-body::-webkit-scrollbar-thumb { background: var(--ss-border); border-radius: 3px; }

.ss-row { display: flex; gap: 8px; margin-bottom: 12px; animation: ss-in .28s ease both; }
.ss-row.ss-user { justify-content: flex-end; }
@keyframes ss-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.ss-mini {
  width: 28px; height: 28px; border-radius: 50%; flex: none; margin-top: 2px;
  background: linear-gradient(135deg, var(--ss-brand), var(--ss-brand-dark));
  color: #fff; display: flex; align-items: center; justify-content: center;
}
.ss-mini svg { width: 15px; height: 15px; }
.ss-bubble {
  max-width: 82%; padding: 10px 14px; border-radius: 16px;
  word-wrap: break-word; overflow-wrap: anywhere;
}
.ss-bot .ss-bubble { background: var(--ss-bg); border: 1px solid var(--ss-border); border-top-left-radius: 4px; color: var(--ss-text); }
.ss-user .ss-bubble { background: var(--ss-brand); color: #fff; border-bottom-right-radius: 4px; }
.ss-bubble p { margin: 0 0 6px; }
.ss-bubble p:last-child { margin-bottom: 0; }
.ss-bubble ul { margin: 4px 0 0; padding-left: 18px; }
.ss-bubble a { color: var(--ss-brand); font-weight: 600; text-decoration: underline; }
.ss-user .ss-bubble a { color: #fff; }
.ss-time { font-size: 10.5px; color: var(--ss-muted); margin: -6px 0 10px 36px; }
.ss-user + .ss-time { text-align: right; margin-left: 0; }

/* Typing */
.ss-typing .ss-bubble { display: flex; gap: 4px; padding: 14px 16px; }
.ss-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ss-muted); animation: ss-dot 1.2s infinite ease-in-out; }
.ss-typing i:nth-child(2) { animation-delay: .15s; }
.ss-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ss-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }

/* Cards (plans) */
.ss-cards { display: flex; flex-direction: column; gap: 8px; margin: 2px 0 12px 36px; animation: ss-in .3s ease both; }
.ss-card {
  background: var(--ss-bg); border: 1px solid var(--ss-border); border-radius: 14px;
  padding: 12px 14px; text-align: left; cursor: pointer; color: var(--ss-text);
  font: inherit; transition: border-color .15s, transform .15s, box-shadow .15s;
}
.ss-card:hover, .ss-card:focus-visible { border-color: var(--ss-brand); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,0,0,.08); outline: none; }
.ss-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.ss-card-top b { font-size: 14.5px; }
.ss-pill {
  background: color-mix(in srgb, var(--ss-brand) 14%, transparent);
  color: var(--ss-brand); font-weight: 700; font-size: 12px; padding: 2px 9px; border-radius: 20px; white-space: nowrap;
}
.ss-card small { display: block; color: var(--ss-muted); font-size: 12.5px; }

/* Quick replies */
.ss-chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 2px 0 12px 36px; animation: ss-in .3s ease both; }
.ss-chip {
  border: 1.5px solid var(--ss-brand); color: var(--ss-brand); background: var(--ss-bg);
  border-radius: 20px; padding: 6px 13px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s, color .15s, transform .1s;
}
.ss-chip:hover, .ss-chip:focus-visible { background: var(--ss-brand); color: #fff; outline: none; }
.ss-chip:active { transform: scale(.96); }

/* Feedback */
.ss-fb { display: flex; gap: 6px; margin: -4px 0 12px 36px; font-size: 12px; color: var(--ss-muted); align-items: center; }
.ss-fb button { border: 1px solid var(--ss-border); background: var(--ss-bg); border-radius: 14px; cursor: pointer; padding: 1px 9px; font-size: 13px; }
.ss-fb button:hover { border-color: var(--ss-brand); }

/* Lead form */
.ss-lead {
  margin: 2px 0 14px 36px; padding: 14px; background: var(--ss-bg); border: 1px solid var(--ss-border);
  border-radius: 16px; box-shadow: 0 4px 14px rgba(0,0,0,.06); animation: ss-in .3s ease both;
}
.ss-lead-t { font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.ss-lead label { display: block; font-size: 12px; font-weight: 600; color: var(--ss-muted); margin-bottom: 9px; }
.ss-lead label em { font-style: normal; font-weight: 400; }
.ss-lead input {
  display: block; width: 100%; margin-top: 4px; height: 40px; padding: 0 12px; font: inherit; font-size: 14px;
  color: var(--ss-text); background: var(--ss-surface); border: 1.5px solid var(--ss-border); border-radius: 10px; outline: none;
}
.ss-lead input:focus { border-color: var(--ss-brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ss-brand) 18%, transparent); }
.ss-lead-err { color: #dc2626; font-size: 12.5px; min-height: 0; margin-bottom: 6px; }
.ss-lead-go {
  width: 100%; height: 42px; border: 0; border-radius: 10px; background: var(--ss-brand); color: #fff;
  font: inherit; font-weight: 700; cursor: pointer; transition: filter .15s;
}
.ss-lead-go:hover:not(:disabled) { filter: brightness(1.08); }
.ss-lead-go:disabled { opacity: .6; cursor: default; }
.ss-lead-skip { display: block; margin: 8px auto 0; border: 0; background: none; color: var(--ss-muted); font: inherit; font-size: 12.5px; cursor: pointer; text-decoration: underline; }
.ss-lead-fine { text-align: center; font-size: 10.5px; color: var(--ss-muted); margin-top: 8px; }
.ss-input:disabled { opacity: .6; cursor: not-allowed; }

/* Live mode */
.ss-mode { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ss-muted); padding: 0 4px 8px; }
.ss-mode[hidden] { display: none; }
.ss-mode-back { border: 0; background: none; color: var(--ss-brand); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; text-decoration: underline; }
.ss-agent-l { font-size: 11px; font-weight: 700; color: var(--ss-brand); margin-bottom: 2px; text-transform: uppercase; letter-spacing: .4px; }

/* Composer */
.ss-foot { background: var(--ss-bg); border-top: 1px solid var(--ss-border); padding: 10px 12px 8px; }
.ss-form { display: flex; align-items: center; gap: 8px; }
.ss-input {
  flex: 1; min-width: 0; border: 1.5px solid var(--ss-border); background: var(--ss-surface); color: var(--ss-text);
  border-radius: 24px; padding: 11px 16px; font: inherit; font-size: 14px; outline: none; height: 44px;
  transition: border-color .15s, box-shadow .15s;
}
.ss-input:focus { border-color: var(--ss-brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ss-brand) 18%, transparent); }
.ss-input::placeholder { color: var(--ss-muted); }
.ss-send {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--ss-brand); color: #fff; display: flex; align-items: center; justify-content: center;
  transition: transform .15s, opacity .15s;
}
.ss-send:hover:not(:disabled) { transform: scale(1.07); }
.ss-send:disabled { opacity: .45; cursor: default; }
.ss-send svg { width: 20px; height: 20px; }
.ss-note { text-align: center; font-size: 10.5px; color: var(--ss-muted); margin-top: 6px; }

/* ---------- Mobile ---------- */
@media (max-width: 520px) {
  #smartsup-root { right: 14px; bottom: 14px; }
  .ss-open.ss-mobile-full { right: 0; bottom: 0; left: 0; top: 0; }
  .ss-open .ss-panel {
    position: fixed; inset: 0; width: 100vw; max-width: none; height: 100dvh; max-height: none; border-radius: 0;
  }
  .ss-open .ss-launcher { display: none; }
  .ss-teaser { max-width: 210px; }
}

@media (prefers-reduced-motion: reduce) {
  #smartsup-root *, #smartsup-root *::before { animation: none !important; transition: none !important; }
}
@media print { #smartsup-root { display: none; } }

/* Safety net: keep any leftover third-party live-chat widget (JivoChat) out of Smartsup's way */
jdiv, #jivo-iframe-container, #jcont, [id^="jivo"], [class*="jivo-"] { display: none !important; }
