/* ================================================================
   SWD Smart Chat — Premium Frosted Glass Edition
   Brand: #fc1d55 | Light frosted glass | Modern & clean
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ── Root reset ─────────────────────────────────────────────── */
#swdc-root, #swdc-root * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  line-height: normal;
}

#swdc-root {
  /* Brand */
  --pink:        #fc1d55;
  --pink-dark:   #d4153f;
  --pink-light:  #ff5c8a;
  --pink-glow:   rgba(252, 29, 85, 0.30);
  --pink-soft:   rgba(252, 29, 85, 0.09);
  --pink-border: rgba(252, 29, 85, 0.22);

  /* Glass surfaces */
  --glass-bg:    rgba(255, 255, 255, 0.82);
  --glass-blur:  blur(24px) saturate(1.8);
  --msg-bg:      rgba(248, 248, 252, 0.70);
  --input-bg:    rgba(255, 255, 255, 0.90);

  /* Borders */
  --border:      rgba(0, 0, 0, 0.07);
  --border-md:   rgba(0, 0, 0, 0.11);

  /* Text */
  --text:        #1c1c2e;
  --text-sub:    #6b6b80;
  --text-muted:  #9090a8;

  /* Bubble */
  --bot-bub:     rgba(255, 255, 255, 0.95);
  --user-bub:    linear-gradient(135deg, #fc1d55 0%, #e8104a 100%);

  /* Radius & easing */
  --r-panel:   22px;
  --r-bub:     18px;
  --spring:    cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease:      cubic-bezier(0.25, 0.46, 0.45, 0.94);

  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  position: fixed;
  bottom: 24px;
  right: 24px;        /* right-anchored */
  left: auto;
  z-index: 2147483640;
}

/* ================================================================
   FAB
   ================================================================ */
#swdc-fab {
  position: relative;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fc1d55 0%, #ff5c8a 100%);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow:
    0 4px 24px rgba(252,29,85,0.50),
    0 1px 4px rgba(0,0,0,0.15);
  transition: transform .28s var(--spring), box-shadow .3s ease;
  animation: swdcPulse 3s ease-in-out infinite;
}
@keyframes swdcPulse {
  0%,100% { box-shadow: 0 4px 24px rgba(252,29,85,0.5), 0 1px 4px rgba(0,0,0,0.15); }
  50%      { box-shadow: 0 4px 24px rgba(252,29,85,0.5), 0 0 0 14px rgba(252,29,85,0), 0 1px 4px rgba(0,0,0,0.15); }
}
#swdc-fab:hover  { transform: scale(1.08) translateY(-2px); }
#swdc-fab:active { transform: scale(0.93); }
#swdc-fab.is-open {
  animation: none;
  background: linear-gradient(135deg, #fc1d55, #d4153f);
  box-shadow: 0 4px 16px rgba(0,0,0,0.20);
}

.swdc-fab-ring {
  position: absolute; inset: -7px; border-radius: 50%;
  border: 1.5px solid rgba(252,29,85,0.35);
  animation: swdcRing 2.5s ease-out infinite;
  pointer-events: none;
}
.swdc-fab-ring2 { animation-delay: .9s; }
@keyframes swdcRing {
  0%   { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.75); opacity: 0; }
}
#swdc-fab.is-open .swdc-fab-ring { display: none; }

#swdc-fab svg { position: absolute; transition: transform .30s var(--spring), opacity .22s; }
.swdc-ico-chat  { width: 26px; height: 26px; opacity: 1;  transform: scale(1) rotate(0deg); }
.swdc-ico-close { width: 22px; height: 22px; opacity: 0;  transform: scale(0.3) rotate(-90deg); }
#swdc-fab.is-open .swdc-ico-chat  { opacity: 0;  transform: scale(0.3) rotate(90deg); }
#swdc-fab.is-open .swdc-ico-close { opacity: 1;  transform: scale(1) rotate(0deg); }

.swdc-badge {
  position: absolute; top: -2px; right: -2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; color: var(--pink);
  font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--pink);
  transition: transform .3s var(--spring), opacity .2s;
  animation: swdcBadgePop 1.8s ease-in-out infinite;
}
@keyframes swdcBadgePop { 0%,100%{transform:scale(1)} 50%{transform:scale(1.18)} }
#swdc-fab.is-open .swdc-badge { transform: scale(0); opacity: 0; }

/* ================================================================
   PANEL — frosted glass, right-anchored
   ================================================================ */
#swdc-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  left: auto;
  width: 368px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100dvh - 108px);

  /* Frosted glass */
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);

  border-radius: var(--r-panel);
  border: 1px solid rgba(255, 255, 255, 0.60);

  /* Layered shadow for depth */
  box-shadow:
    0 0 0 1px rgba(252, 29, 85, 0.08),
    0 2px 4px rgba(0,0,0,0.04),
    0 8px 16px rgba(0,0,0,0.06),
    0 24px 48px rgba(0,0,0,0.12),
    inset 0 1px 0 rgba(255,255,255,0.80);

  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Entry animation */
  opacity: 0;
  transform: scale(0.90) translateY(20px);
  transform-origin: bottom right;
  pointer-events: none;
  transition:
    opacity .35s var(--ease),
    transform .42s var(--spring);
}
#swdc-panel.is-open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: all;
}

/* Glass inner shimmer */
#swdc-panel::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: var(--r-panel);
  background: linear-gradient(
    145deg,
    rgba(255,255,255,0.55) 0%,
    rgba(255,255,255,0.05) 60%
  );
  pointer-events: none; z-index: 0;
}
#swdc-panel > * { position: relative; z-index: 1; }

/* ================================================================
   HEADER
   ================================================================ */
.swdc-header {
  flex-shrink: 0;
  padding: 14px 18px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #fc1d55 0%, #c8123e 100%);
  border-bottom: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--r-panel) var(--r-panel) 0 0;
  position: relative;
  overflow: hidden;
}

/* Shimmer on header */
.swdc-header::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(
    105deg,
    transparent 40%,
    rgba(255,255,255,0.12) 50%,
    transparent 60%
  );
  background-size: 200% 100%;
  animation: swdcShimmer 4s linear infinite;
}
@keyframes swdcShimmer {
  0%   { background-position: -100% 0; }
  100% { background-position: 200% 0; }
}

.swdc-hdr-left  { display: flex; align-items: center; gap: 11px; position: relative; }
.swdc-hdr-right { position: relative; }

.swdc-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255,255,255,0.18);
  border: 2px solid rgba(255,255,255,0.40);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.swdc-avatar svg { width: 36px; height: 36px; }
.swdc-status-ring {
  position: absolute; bottom: -1px; right: -1px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #22c55e;
  border: 2px solid #c8123e;
  box-shadow: 0 0 0 0 rgba(34,197,94,0.6);
  animation: swdcStatusPulse 2s ease-in-out infinite;
}
@keyframes swdcStatusPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
  50%     { box-shadow: 0 0 0 5px rgba(34,197,94,0); }
}

.swdc-hdr-name {
  color: #fff; font-size: 15px; font-weight: 800;
  letter-spacing: -.4px; line-height: 1.2;
}
.swdc-hdr-sub {
  color: rgba(255,255,255,0.72);
  font-size: 10.5px; font-weight: 500;
  display: flex; align-items: center; gap: 5px; margin-top: 3px;
}
.swdc-online-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #4ade80; display: inline-block;
  animation: swdcBlink 2s ease-in-out infinite;
}
@keyframes swdcBlink { 0%,100%{opacity:1} 50%{opacity:.4} }

.swdc-hdr-btn {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.22);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .2s, transform .2s;
}
.swdc-hdr-btn:hover  { background: rgba(255,255,255,0.26); transform: scale(1.05); }
.swdc-hdr-btn:active { transform: scale(0.92); }
.swdc-hdr-btn svg    { width: 14px; height: 14px; display: block; }

/* ================================================================
   INTRO CHIPS BAR
   ================================================================ */
.swdc-intro-bar {
  flex-shrink: 0;
  display: flex; gap: 6px;
  padding: 9px 16px;
  background: rgba(252,29,85,0.04);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -ms-overflow-style: none; scrollbar-width: none;
}
.swdc-intro-bar::-webkit-scrollbar { display: none; }

.swdc-intro-chip {
  flex-shrink: 0;
  padding: 4px 11px;
  border-radius: 20px;
  background: var(--pink-soft);
  border: 1px solid var(--pink-border);
  color: var(--pink);
  font-size: 10.5px; font-weight: 700;
  letter-spacing: .1px;
  white-space: nowrap;
}

/* ================================================================
   MESSAGES
   ================================================================ */
#swdc-msgs {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 16px 10px;
  display: flex; flex-direction: column; gap: 8px;
  scroll-behavior: smooth;
  background: var(--msg-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  -ms-overflow-style: none; scrollbar-width: none;
}
#swdc-msgs::-webkit-scrollbar { display: none; }

/* Timestamp divider */
.swdc-ts {
  text-align: center;
  font-size: 10px; color: var(--text-muted); font-weight: 600;
  margin: 2px 0 6px; letter-spacing: .3px;
  display: flex; align-items: center; gap: 8px;
}
.swdc-ts::before, .swdc-ts::after {
  content: ''; flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,0.08), transparent);
}

/* Message rows */
.swdc-row { display: flex; align-items: flex-end; gap: 7px; animation: swdcIn .34s var(--spring) both; }
.swdc-row.rx { justify-content: flex-start; }
.swdc-row.tx { justify-content: flex-end; }

@keyframes swdcIn {
  from { transform: translateY(16px) scale(.90); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* Bot avatar */
.swdc-mini-av {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #fc1d55, #ff5c8a);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 2px;
  box-shadow: 0 2px 8px rgba(252,29,85,0.28);
}
.swdc-mini-av svg { fill: white; width: 14px; height: 14px; display: block; }

/* Bubbles */
.swdc-bub {
  max-width: 78%;
  padding: 10px 14px;
  font-size: 13.5px; line-height: 1.58;
  word-break: break-word; letter-spacing: -.1px;
}
.swdc-bub.rx {
  background: var(--bot-bub);
  color: var(--text);
  border-radius: var(--r-bub) var(--r-bub) var(--r-bub) 5px;
  border: 1px solid var(--border-md);
  box-shadow:
    0 1px 3px rgba(0,0,0,0.05),
    0 4px 12px rgba(0,0,0,0.06),
    inset 0 1px 0 rgba(255,255,255,0.9);
}
.swdc-bub.tx {
  background: var(--user-bub);
  color: #fff;
  border-radius: var(--r-bub) var(--r-bub) 5px var(--r-bub);
  box-shadow: 0 4px 16px rgba(252,29,85,0.32);
}
.swdc-bub a { color: inherit; text-decoration: underline; }

/* Typing indicator */
.swdc-typing-row { display: flex; align-items: flex-end; gap: 7px; animation: swdcIn .28s var(--spring) both; }
.swdc-dots {
  display: flex; gap: 5px; padding: 12px 16px;
  background: var(--bot-bub);
  border-radius: var(--r-bub) var(--r-bub) var(--r-bub) 5px;
  border: 1px solid var(--border-md);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.swdc-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--pink); display: block;
  animation: swdcDot 1.3s ease-in-out infinite both;
}
.swdc-dots span:nth-child(1) { animation-delay: 0s; }
.swdc-dots span:nth-child(2) { animation-delay: .17s; }
.swdc-dots span:nth-child(3) { animation-delay: .34s; }
@keyframes swdcDot {
  0%,60%,100% { transform: translateY(0); opacity: .35; }
  30%          { transform: translateY(-7px); opacity: 1; }
}

/* ================================================================
   CHIPS
   ================================================================ */
#swdc-chips-area {
  flex-shrink: 0;
  padding: 0 16px 10px;
  display: flex; flex-wrap: wrap; gap: 6px;
  animation: swdcFade .3s ease both;
  background: var(--msg-bg);
}
#swdc-chips-area:empty { padding: 0; }
@keyframes swdcFade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.swdc-chip {
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 12.5px; font-weight: 600;
  font-family: inherit; cursor: pointer;
  border: none; outline: none;
  letter-spacing: -.1px;
  transition: transform .2s var(--spring), box-shadow .2s, filter .15s;
  -webkit-tap-highlight-color: transparent;
}
.swdc-chip.default {
  background: rgba(255,255,255,0.90);
  color: var(--text);
  border: 1px solid var(--border-md);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  backdrop-filter: blur(8px);
}
.swdc-chip.default:hover {
  border-color: var(--pink); color: var(--pink);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(252,29,85,0.15);
}
.swdc-chip.primary {
  background: linear-gradient(135deg, #fc1d55, #e8104a);
  color: #fff;
  box-shadow: 0 3px 12px rgba(252,29,85,.28);
}
.swdc-chip.primary:hover { filter: brightness(1.1); transform: translateY(-2px); }
.swdc-chip.green  { background: #16a34a; color: #fff; box-shadow: 0 3px 12px rgba(22,163,74,.25); }
.swdc-chip.green:hover { filter: brightness(1.08); }
.swdc-chip:active { transform: scale(.94) !important; }

/* ================================================================
   INPUT BAR
   ================================================================ */
.swdc-inputbar {
  flex-shrink: 0;
  padding: 12px 16px 14px;
  background: var(--input-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
}

.swdc-input-wrap {
  display: flex; align-items: flex-end; gap: 8px;
  background: rgba(245, 245, 250, 0.90);
  border: 1.5px solid var(--border-md);
  border-radius: 16px;
  padding: 5px 5px 5px 14px;
  transition: border-color .2s, box-shadow .2s;
}
.swdc-input-wrap:focus-within {
  border-color: var(--pink);
  box-shadow: 0 0 0 3.5px rgba(252,29,85,0.10);
  background: rgba(255,255,255,0.95);
}

#swdc-input {
  flex: 1;
  background: transparent; border: none; outline: none;
  color: var(--text);
  font-size: 13.5px; font-family: inherit;
  line-height: 1.5; resize: none;
  max-height: 96px;
  padding: 7px 4px;
}
#swdc-input::placeholder { color: var(--text-muted); }
#swdc-input:disabled { opacity: .4; cursor: not-allowed; }

#swdc-send {
  width: 36px; height: 36px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, #fc1d55, #e8104a);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(252,29,85,.38);
  transition: transform .2s var(--spring), filter .15s, box-shadow .2s;
}
#swdc-send:hover  { filter: brightness(1.1); transform: scale(1.05); box-shadow: 0 4px 16px rgba(252,29,85,.45); }
#swdc-send:active { transform: scale(.88); }
#swdc-send:disabled { opacity: .4; cursor: not-allowed; filter: none; transform: none; }
#swdc-send svg { width: 15px; height: 15px; display: block; }

.swdc-hint {
  font-size: 10.5px; color: var(--text-muted);
  margin-top: 7px; padding: 0 2px; min-height: 15px;
  transition: color .2s;
}
.swdc-hint.err { color: #e8104a; }
.swdc-hint.ok  { color: #16a34a; }

/* ================================================================
   SYSTEM MESSAGES
   ================================================================ */
.swdc-sys {
  text-align: center; font-size: 11px; color: var(--text-muted);
  background: rgba(252,29,85,0.05);
  border: 1px solid rgba(252,29,85,0.10);
  border-radius: 10px; padding: 6px 14px;
  align-self: center; margin: 2px 0;
  animation: swdcIn .3s var(--spring) both;
}

/* Action buttons (WhatsApp / Email) */
.swdc-action-row {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 4px 0 2px;
  animation: swdcFade .35s ease .1s both;
}
.swdc-action-btn {
  flex: 1; min-width: 110px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 14px; border-radius: 14px; border: none;
  font-size: 13px; font-weight: 700; font-family: inherit;
  cursor: pointer; letter-spacing: -.1px;
  transition: transform .2s var(--spring), filter .15s, box-shadow .2s;
  -webkit-tap-highlight-color: transparent;
}
.swdc-action-btn:hover  { filter: brightness(1.08); transform: translateY(-2px); }
.swdc-action-btn:active { transform: scale(.95); }
.swdc-action-btn.wa {
  background: #25D366; color: #fff;
  box-shadow: 0 4px 14px rgba(37,211,102,.28);
}
.swdc-action-btn.em {
  background: linear-gradient(135deg, #fc1d55, #e8104a); color: #fff;
  box-shadow: 0 4px 14px rgba(252,29,85,.28);
}

/* ================================================================
   RESPONSIVE — safe on all phones
   ================================================================ */
@media (max-width: 480px) {
  #swdc-root {
    right: 14px;
    bottom: 16px;
    left: auto;
  }
  #swdc-panel {
    position: fixed !important;
    right: 8px !important;
    left: 8px !important;
    bottom: 80px !important;
    width: auto !important;
    max-width: none !important;
    max-height: calc(100dvh - 100px);
    border-radius: 18px;
    transform-origin: bottom right;
  }
  #swdc-fab {
    width: 52px; height: 52px;
  }
}

@media (max-height: 620px) {
  #swdc-panel {
    max-height: calc(100dvh - 88px);
  }
}
