/*
  ============================================================
  SCAMANOT SUPPORT CHAT WIDGET  |  v1.1  |  June 2026
  styles extracted to external file — SPF §9.1 compliant
  ============================================================
*/

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sn-green:       #0F6E56;
  --sn-green-light: #E1F5EE;
  --sn-green-dark:  #085041;
  --sn-coral:       #D85A30;
  --sn-white:       #ffffff;
  --sn-radius-sm:   8px;
  --sn-radius-md:   12px;
  --sn-radius-full: 999px;
  --sn-shadow:      0 2px 12px rgba(0,0,0,0.10);
  --sn-trans:       0.26s cubic-bezier(.4,0,.2,1);
  --sn-cookie-offset: 0px;
}

body.cookie-bar-visible {
  --sn-cookie-offset: 56px;
}

/* ── Visually hidden (accessibility) ─────────────────────── */
.sn-sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════
   TRIGGER BUTTON
   ═══════════════════════════════════════════════════════════ */

#sn-trigger {
  position: fixed;
  z-index: 9000;
  border: none;
  cursor: pointer;
  background: var(--sn-green);
  transition:
    opacity .15s ease,
    bottom var(--sn-trans),
    right var(--sn-trans);
  display: flex;
  align-items: center;
  justify-content: center;
}

#sn-trigger:hover  { opacity: .88; }
#sn-trigger:focus-visible {
  outline: 2px solid var(--sn-green);
  outline-offset: 3px;
}

/* Desktop / tablet pill  ≥481px */
@media (min-width: 481px) {
  #sn-trigger {
    top: 50%;
    transform: translateY(-50%);
    right: 0;
    bottom: auto;
    border-radius: var(--sn-radius-md) 0 0 var(--sn-radius-md);
    flex-direction: column;
    gap: 8px;
    padding: 18px 0;
    width: 46px;
  }

  #sn-trigger .sn-icon { font-size: 20px; color: var(--sn-white); }

  #sn-trigger .sn-label {
    display: block;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 11px;
    font-weight: 500;
    color: var(--sn-white);
    letter-spacing: .05em;
    white-space: nowrap;
  }
}

/* Mobile FAB  ≤480px */
@media (max-width: 480px) {
  #sn-trigger {
    bottom: calc(100px + var(--sn-cookie-offset));
    right: 16px;
    top: auto;
    transform: none;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    box-shadow: var(--sn-shadow);
  }

  #sn-trigger .sn-icon  { font-size: 24px; color: var(--sn-white); }
  #sn-trigger .sn-label { display: none; }
}

/* Notification dot */
#sn-notif-dot {
  position: absolute;
  top: -3px; right: -3px;
  width: 10px; height: 10px;
  background: var(--sn-coral);
  border-radius: 50%;
  border: 2px solid var(--sn-green);
  display: none;
  pointer-events: none;
}

#sn-notif-dot.visible { display: block; }

/* ═══════════════════════════════════════════════════════════
   BACK-TO-TOP BUTTON
   ═══════════════════════════════════════════════════════════ */

#sn-back-top {
  position: fixed;
  z-index: 8999;
  right: 16px;
  bottom: calc(52px + var(--sn-cookie-offset));
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid #d0d0cc;
  background: var(--sn-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, bottom var(--sn-trans);
  box-shadow: var(--sn-shadow);
}

#sn-back-top.visible {
  opacity: 1;
  pointer-events: auto;
}

#sn-back-top:hover { opacity: .8; }
#sn-back-top:focus-visible {
  outline: 2px solid var(--sn-green);
  outline-offset: 2px;
}

#sn-back-top svg {
  width: 16px; height: 16px;
  stroke: #5f5e5a;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* On desktop, back-top sits at fixed bottom-right corner */
@media (min-width: 481px) {
  #sn-back-top {
    right: 16px;
    bottom: calc(20px + var(--sn-cookie-offset));
  }
}

/* ═══════════════════════════════════════════════════════════
   CHAT PANEL
   ═══════════════════════════════════════════════════════════ */

#sn-panel {
  position: fixed;
  z-index: 9001;
  top: 0;
  right: 0;
  height: 100%;
  width: 360px;
  max-width: 100vw;
  background: #fff;
  border-left: 0.5px solid #e4e4df;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--sn-trans);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  box-shadow: -4px 0 24px rgba(0,0,0,0.07);
}

#sn-panel.open { transform: translateX(0); }

/* Full-width on small mobile */
@media (max-width: 480px) {
  #sn-panel { width: 100%; border-left: none; }
}

/* Panel header */
#sn-panel-hdr {
  background: var(--sn-green);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
}

.sn-hdr-av {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sn-hdr-av svg {
  width: 18px; height: 18px;
  stroke: #fff; fill: none;
  stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}

.sn-hdr-name {
  font-size: 14px; font-weight: 500; color: #fff;
}

.sn-hdr-status {
  font-size: 11px; color: rgba(255,255,255,.72); margin-top: 1px;
}

.sn-hdr-ai {
  font-size: 10px; font-weight: 500;
  padding: 2px 9px; border-radius: var(--sn-radius-full);
  background: rgba(255,255,255,.15); color: #fff;
  letter-spacing: .03em; white-space: nowrap;
}

#sn-close {
  margin-left: auto;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,.14);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}

#sn-close:hover { background: rgba(255,255,255,.24); }
#sn-close:focus-visible { outline: 2px solid rgba(255,255,255,.6); }

#sn-close svg {
  width: 15px; height: 15px;
  stroke: #fff; fill: none;
  stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* Category tabs */
#sn-cats {
  display: flex;
  gap: 5px;
  padding: 9px 14px 7px;
  border-bottom: 0.5px solid #ececea;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}

#sn-cats::-webkit-scrollbar { display: none; }

.sn-cat {
  font-size: 11px; font-weight: 500;
  padding: 4px 11px;
  border-radius: var(--sn-radius-full);
  border: 0.5px solid #d8d8d4;
  background: #fff;
  color: #5f5e5a;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
  flex-shrink: 0;
}

.sn-cat:hover { background: #f2f2ef; }
.sn-cat.active { background: var(--sn-green); color: #fff; border-color: var(--sn-green); }

/* Messages */
#sn-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  scroll-behavior: smooth;
}

.sn-msg {
  display: flex;
  gap: 8px;
  max-width: 90%;
}

.sn-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.sn-av {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--sn-green-light);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 2px;
}

.sn-av svg {
  width: 13px; height: 13px;
  stroke: var(--sn-green); fill: none;
  stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}

.sn-msg.user .sn-av { display: none; }

.sn-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.65;
  color: #1a1a1a;
}

.sn-msg.bot  .sn-bubble { background: #f4f4f0; border-radius: 14px 14px 14px 3px; }
.sn-msg.user .sn-bubble { background: var(--sn-green); color: #fff; border-radius: 14px 14px 3px 14px; }

/* Links inside bot bubbles */
.sn-bubble a { color: var(--sn-green); text-decoration: none; font-weight: 500; }
.sn-bubble a:hover { text-decoration: underline; }

/* Crisis card */
.sn-crisis {
  background: #fff5f5;
  border: 0.5px solid #f7c1c1;
  border-radius: var(--sn-radius-sm);
  padding: 11px 13px;
  margin-top: 8px;
}

.sn-crisis-title {
  font-size: 12px; font-weight: 500; color: #a32d2d;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 5px;
}

.sn-crisis-title svg {
  width: 14px; height: 14px;
  stroke: #a32d2d; fill: none;
  stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}

.sn-resource {
  display: flex; gap: 7px; align-items: flex-start;
  margin-bottom: 6px; font-size: 12px; color: #1a1a1a;
  line-height: 1.5;
}

.sn-resource:last-child { margin-bottom: 0; }

.sn-resource svg {
  width: 13px; height: 13px;
  stroke: #a32d2d; fill: none;
  stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0; margin-top: 2px;
}

.sn-resource a { color: var(--sn-green); font-weight: 500; text-decoration: none; }
.sn-resource a:hover { text-decoration: underline; }

/* Escalate card */
.sn-escalate {
  background: #fef9ec;
  border: 0.5px solid #f5d98a;
  border-radius: var(--sn-radius-sm);
  padding: 10px 13px;
  margin-top: 8px;
  font-size: 12px; color: #1a1a1a; line-height: 1.55;
}

.sn-escalate-title {
  font-size: 12px; font-weight: 500; color: #854f0b;
  margin-bottom: 4px;
  display: flex; align-items: center; gap: 5px;
}

.sn-escalate-title svg {
  width: 13px; height: 13px;
  stroke: #854f0b; fill: none;
  stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}

.sn-escalate a { color: var(--sn-green); font-weight: 500; text-decoration: none; }
.sn-escalate a:hover { text-decoration: underline; }

/* Typing indicator */
.sn-typing span {
  display: inline-block;
  width: 5px; height: 5px;
  background: #b4b2a9;
  border-radius: 50%;
  animation: sn-blink 1s infinite;
}

.sn-typing span:nth-child(2) { animation-delay: .2s; }
.sn-typing span:nth-child(3) { animation-delay: .4s; }

@keyframes sn-blink {
  0%, 80%, 100% { opacity: .2; }
  40%            { opacity: 1; }
}

/* Quick replies */
#sn-quick {
  padding: 9px 14px 7px;
  border-top: 0.5px solid #ececea;
  display: flex; flex-wrap: wrap; gap: 5px;
  flex-shrink: 0;
}

.sn-qbtn {
  font-size: 11px;
  padding: 5px 11px;
  border-radius: var(--sn-radius-full);
  border: 0.5px solid #d8d8d4;
  background: #fff;
  color: #1a1a1a;
  cursor: pointer;
  transition: background .1s;
  white-space: nowrap;
}

.sn-qbtn:hover { background: #f2f2ef; }

/* Input row */
#sn-input-row {
  display: flex;
  gap: 8px;
  padding: 9px 14px 14px;
  flex-shrink: 0;
}

#sn-inp {
  flex: 1;
  font-size: 13px;
  padding: 9px 12px;
  border-radius: var(--sn-radius-sm);
  border: 0.5px solid #d8d8d4;
  background: #fff;
  color: #1a1a1a;
  outline: none;
  resize: none;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color .15s;
}

#sn-inp:focus { border-color: var(--sn-green); }

#sn-send {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--sn-green);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; align-self: flex-end;
  transition: opacity .15s;
}

#sn-send:hover { opacity: .85; }
#sn-send:focus-visible { outline: 2px solid var(--sn-green); outline-offset: 2px; }

#sn-send svg {
  width: 16px; height: 16px;
  stroke: #fff; fill: none;
  stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* Disclaimer */
#sn-disc {
  font-size: 11px;
  color: #888780;
  text-align: center;
  padding: 0 14px 11px;
  line-height: 1.5;
}

#sn-disc a { color: var(--sn-green); text-decoration: none; }
#sn-disc a:hover { text-decoration: underline; }

/* Overlay (mobile — dims page behind open panel) */
#sn-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.32);
  z-index: 9000;
  opacity: 0;
  transition: opacity .26s;
}

@media (max-width: 480px) {
  #sn-overlay.visible { display: block; opacity: 1; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  #sn-panel, #sn-trigger, #sn-back-top, #sn-overlay { transition: none; }
  .sn-typing span { animation: none; opacity: 1; }
}
