/* Sparkle Live Chat — sticky, mobile-app style */
.slv-chat {
  --slv-ink: #0B2545;
  --slv-gold: #D0122A;
  --slv-cream: #F5F7FA;
  --slv-panel: #fff;
  --slv-shadow: 0 18px 50px rgba(11, 37, 69, 0.22);
  position: fixed;
  z-index: 1080;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  font-family: 'Poppins', system-ui, sans-serif;
}

.slv-chat-panel .slv-chat-status {
  letter-spacing: 0.02em;
}

.slv-chat-fab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px 6px 6px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #0B2545 0%, #0B2545 100%);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(11, 37, 69, 0.28);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.slv-chat-fab:hover,
.slv-chat-fab:focus-visible {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 14px 34px rgba(11, 37, 69, 0.34);
  outline: none;
}

.slv-chat-fab-ring {
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid rgba(208, 18, 42, 0.45);
  animation: slv-fab-pulse 2.2s ease-out infinite;
  pointer-events: none;
}

.slv-chat-fab-face {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: block;
  background: #fff;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.slv-chat-fab-label {
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding-right: 4px;
}

.slv-chat.is-open .slv-chat-fab {
  display: none;
}

.slv-chat-panel {
  width: min(380px, calc(100vw - 24px));
  height: min(560px, calc(100dvh - 96px));
  display: flex;
  flex-direction: column;
  background: var(--slv-panel);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--slv-shadow);
  border: 1px solid rgba(208, 18, 42, 0.22);
  transform-origin: bottom right;
  animation: slv-panel-in 0.28s ease;
  position: relative;
  z-index: 2;
}

.slv-chat-panel[hidden] {
  display: none !important;
}

.slv-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 12px;
  background: linear-gradient(135deg, #0B2545 0%, #061628 55%, #163A5F 100%);
  color: #ffffff;
}

.slv-chat-head-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.slv-chat-head-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  flex-shrink: 0;
  object-fit: contain;
  padding: 4px;
}

.slv-chat-head-copy {
  min-width: 0;
}

.slv-chat-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slv-chat-fab-face {
  object-fit: contain;
  padding: 4px;
}

.slv-chat-bubble-face {
  object-fit: contain;
  background: #fff;
  padding: 2px;
}

.slv-chat-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 18, 34, 0.35);
  z-index: 1;
}

.slv-chat-backdrop[hidden] {
  display: none !important;
}

.slv-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 2px 4px;
}

.slv-chat-chips button {
  border: 1px solid rgba(11, 37, 69, 0.14);
  background: #fff;
  color: #0B2545;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.slv-chat-chips button:hover {
  border-color: #D0122A;
  color: #D0122A;
}

.slv-chat-status {
  margin: 2px 0 0;
  font-size: 0.72rem;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 6px;
}

.slv-chat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.25);
}

.slv-chat-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.slv-chat-wa,
.slv-chat-close {
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.slv-chat-close {
  font-size: 1.35rem;
  line-height: 1;
}

.slv-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background:
    radial-gradient(circle at 10% 0%, rgba(208, 18, 42, 0.12), transparent 40%),
    linear-gradient(180deg, #ffffff 0%, #f7f3ea 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.slv-chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 92%;
}

.slv-chat-msg--bot {
  align-self: flex-start;
}

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

.slv-chat-bubble-face {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}

.slv-chat-bubble {
  padding: 10px 12px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--slv-ink);
  background: #fff;
  box-shadow: 0 4px 14px rgba(11, 37, 69, 0.06);
  border: 1px solid rgba(11, 37, 69, 0.06);
  white-space: pre-wrap;
  word-break: break-word;
}

.slv-chat-msg--user .slv-chat-bubble {
  background: linear-gradient(135deg, #0B2545, #0B2545);
  color: #ffffff;
  border-color: transparent;
}

.slv-chat-typing .slv-chat-bubble {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  min-width: 52px;
}

.slv-chat-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a09060;
  display: block;
  animation: slv-dot 1s infinite ease-in-out;
}

.slv-chat-typing i:nth-child(2) { animation-delay: 0.15s; }
.slv-chat-typing i:nth-child(3) { animation-delay: 0.3s; }

.slv-chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: #fff;
  border-top: 1px solid rgba(11, 37, 69, 0.08);
}

.slv-chat-form input[type="text"] {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(11, 37, 69, 0.12);
  border-radius: 999px;
  padding: 12px 14px;
  font-size: 0.92rem;
  background: var(--slv-cream);
  color: var(--slv-ink);
  outline: none;
}

.slv-chat-form input[type="text"]:focus {
  border-color: rgba(208, 18, 42, 0.55);
  box-shadow: 0 0 0 3px rgba(208, 18, 42, 0.15);
}

.slv-chat-send {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #D0122A, #A50E21);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.slv-chat-send:disabled {
  opacity: 0.55;
  cursor: wait;
}

.slv-chat .visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@keyframes slv-fab-pulse {
  0% { opacity: 0.9; transform: scale(1); }
  70% { opacity: 0; transform: scale(1.12); }
  100% { opacity: 0; transform: scale(1.12); }
}

@keyframes slv-panel-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes slv-dot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* Mobile: full-height app sheet */
@media (max-width: 575.98px) {
  .slv-chat {
    right: 0;
    left: 0;
    bottom: 0;
  }

  .slv-chat:not(.is-open) {
    right: max(12px, env(safe-area-inset-right));
    left: auto;
    bottom: calc(76px + env(safe-area-inset-bottom));
  }

  .slv-chat:not(.is-open) .slv-chat-fab {
    padding: 5px;
    gap: 0;
  }

  .slv-chat:not(.is-open) .slv-chat-fab-label {
    display: none;
  }

  .slv-chat:not(.is-open) .slv-chat-fab-face {
    width: 46px;
    height: 46px;
  }

  .slv-chat.is-open .slv-chat-panel {
    width: 100vw;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border: 0;
    animation: slv-sheet-up 0.3s ease;
  }

  .slv-chat-form {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

@keyframes slv-sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

body.slv-chat-open {
  overflow: hidden;
}
