/* SIMADDA chatbot widget — fixed bottom-right */

#simadda-chatbot-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 99990;
  font-family: 'Montserrat', system-ui, sans-serif;
  --scb-gold: var(--gold, #D4AF37);
  --scb-bg: #0c0c0c;
  --scb-panel: #141414;
  --scb-border: rgba(255, 255, 255, 0.08);
}

#simadda-chatbot-root * {
  box-sizing: border-box;
}

.scb-launcher {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 1px solid rgba(212, 175, 55, 0.45);
  background: linear-gradient(145deg, #1a1a1a, #0a0a0a);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(212, 175, 55, 0.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: visible;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  z-index: 1;
}

.scb-launcher:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.65), 0 0 24px rgba(212, 175, 55, 0.15);
}

#simadda-chatbot-root.scb-anim-on .scb-launcher:hover,
#simadda-chatbot-root.scb-anim-on .scb-launcher:hover .scb-launcher-halo {
  animation-play-state: paused;
}

.scb-launcher-face {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #1a1a1a, #0a0a0a);
}

.scb-launcher img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scb-launcher .scb-default-icon {
  font-size: 30px;
  color: var(--scb-gold);
  font-variation-settings: 'FILL' 1;
}

/* Soft expanding halo behind the launcher (animation 1) */
.scb-launcher-halo {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
  opacity: 0;
  border: 1px solid rgba(212, 175, 55, 0.35);
  box-shadow: 0 0 0 0 rgba(212, 175, 55, 0);
}

.scb-panel {
  display: none;
  position: absolute;
  right: 0;
  bottom: 76px;
  width: min(380px, calc(100vw - 28px));
  height: min(560px, calc(100vh - 120px));
  background: var(--scb-panel);
  border: 1px solid var(--scb-border);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.75);
  overflow: hidden;
  flex-direction: column;
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  transform-origin: bottom right;
  will-change: transform, opacity;
}

.scb-panel.open {
  display: flex;
}

.scb-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--scb-border);
  background: linear-gradient(180deg, rgba(212, 175, 55, 0.08), transparent);
}

.scb-header-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(212, 175, 55, 0.35);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a0a;
  flex-shrink: 0;
}

.scb-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scb-online-dot {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #4ade80;
  border: 1.5px solid #141414;
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.4);
}

.scb-header-meta {
  flex: 1;
  min-width: 0;
}

.scb-header-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  margin: 0;
}

.scb-header-sub {
  font-size: 11px;
  color: #9a9a9a;
  margin: 2px 0 0;
}

.scb-close {
  background: transparent;
  border: none;
  color: #888;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background 0.2s ease;
}

.scb-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.scb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scb-bubble {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.scb-bubble.bot {
  align-self: flex-start;
  background: #1a1a1a;
  border: 1px solid var(--scb-border);
  color: #e8e8e8;
  border-bottom-left-radius: 4px;
}

.scb-bubble.user {
  align-self: flex-end;
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid rgba(212, 175, 55, 0.35);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.scb-bubble a {
  color: var(--scb-gold);
}

.scb-sources {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.scb-sources a {
  font-size: 11px;
  color: var(--scb-gold);
  text-decoration: none;
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 999px;
  padding: 3px 8px;
}

.scb-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 10px;
}

.scb-chip {
  border: 1px solid rgba(212, 175, 55, 0.28);
  background: transparent;
  color: #ccc;
  font-size: 11px;
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.scb-chip:hover {
  border-color: var(--scb-gold);
  color: #fff;
  background: rgba(212, 175, 55, 0.06);
}

.scb-hint {
  width: 100%;
  font-size: 11px;
  color: #888;
  padding: 2px 2px 0;
}

.scb-sources-label {
  width: 100%;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 2px;
}

.scb-footer-actions {
  padding: 0 16px 8px;
}

.scb-ticket-btn {
  width: 100%;
  border: 1px dashed rgba(212, 175, 55, 0.35);
  background: transparent;
  color: var(--scb-gold);
  font-size: 12px;
  font-weight: 600;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.scb-ticket-btn:hover {
  background: rgba(212, 175, 55, 0.06);
  border-color: rgba(212, 175, 55, 0.55);
}

.scb-composer {
  display: flex;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--scb-border);
  background: #0f0f0f;
}

.scb-composer input {
  flex: 1;
  background: #1a1a1a;
  border: 1px solid var(--scb-border);
  border-radius: 10px;
  color: #fff;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease;
}

.scb-composer input:focus {
  border-color: rgba(212, 175, 55, 0.5);
}

.scb-composer button {
  border: none;
  background: var(--scb-gold);
  color: #111;
  font-weight: 700;
  border-radius: 10px;
  padding: 0 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.scb-composer button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.scb-composer button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.scb-ticket-form {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--scb-border);
  background: #101010;
}

.scb-ticket-form.open {
  display: flex;
}

.scb-ticket-form input,
.scb-ticket-form textarea {
  width: 100%;
  background: #1a1a1a;
  border: 1px solid var(--scb-border);
  border-radius: 8px;
  color: #fff;
  padding: 8px 10px;
  font-size: 12px;
  font-family: inherit;
}

.scb-ticket-form .scb-ticket-actions {
  display: flex;
  gap: 8px;
}

.scb-ticket-form .scb-ticket-actions button {
  flex: 1;
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.scb-ticket-submit {
  background: var(--scb-gold);
  border: none;
  color: #111;
}

.scb-ticket-cancel {
  background: transparent;
  border: 1px solid var(--scb-border);
  color: #ccc;
}

/* Typing indicator (animation 5) */
.scb-typing {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 12px 14px;
  background: #1a1a1a;
  border: 1px solid var(--scb-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.scb-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(212, 175, 55, 0.55);
  opacity: 0.45;
}

/* ========== Animated mode (primary-admin toggle) ========== */

/* 1) Soft idle breathe on launcher */
#simadda-chatbot-root.scb-anim-on .scb-launcher:not(.scb-launcher-open) {
  animation: scb-breathe 3.6s ease-in-out infinite;
}

/* 2) Expanding gold halo */
#simadda-chatbot-root.scb-anim-on .scb-launcher:not(.scb-launcher-open) .scb-launcher-halo {
  animation: scb-halo 3.6s ease-out infinite;
}

/* Pause breathe/halo while panel is open so it feels calm */
#simadda-chatbot-root.scb-anim-on .scb-launcher.scb-launcher-open {
  animation: none;
}

#simadda-chatbot-root.scb-anim-on .scb-launcher.scb-launcher-open .scb-launcher-halo {
  animation: none;
  opacity: 0;
}

/* 3) Panel open / close */
#simadda-chatbot-root.scb-anim-on .scb-panel.open {
  animation: scb-panel-in 0.32s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

#simadda-chatbot-root.scb-anim-on .scb-panel.scb-panel-closing {
  display: flex;
  animation: scb-panel-out 0.22s ease forwards;
}

#simadda-chatbot-root:not(.scb-anim-on) .scb-panel.open {
  opacity: 1;
  transform: none;
  animation: none;
}

/* 4) Message bubble entrance */
#simadda-chatbot-root.scb-anim-on .scb-bubble.scb-bubble-enter {
  animation: scb-bubble-in 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
}

#simadda-chatbot-root.scb-anim-on .scb-bubble.user.scb-bubble-enter {
  animation-name: scb-bubble-in-user;
}

/* Online status pulse */
#simadda-chatbot-root.scb-anim-on .scb-online-dot {
  animation: scb-online-pulse 2.4s ease-in-out infinite;
}

/* Typing dots bounce */
#simadda-chatbot-root.scb-anim-on .scb-typing span {
  animation: scb-typing-dot 1.2s ease-in-out infinite;
}

#simadda-chatbot-root.scb-anim-on .scb-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

#simadda-chatbot-root.scb-anim-on .scb-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

/* Suggestion chips stagger when panel opens */
#simadda-chatbot-root.scb-anim-on .scb-panel.open .scb-chip {
  animation: scb-chip-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

#simadda-chatbot-root.scb-anim-on .scb-panel.open .scb-chip:nth-child(1) { animation-delay: 0.08s; }
#simadda-chatbot-root.scb-anim-on .scb-panel.open .scb-chip:nth-child(2) { animation-delay: 0.14s; }
#simadda-chatbot-root.scb-anim-on .scb-panel.open .scb-chip:nth-child(3) { animation-delay: 0.2s; }
#simadda-chatbot-root.scb-anim-on .scb-panel.open .scb-chip:nth-child(4) { animation-delay: 0.26s; }

@keyframes scb-breathe {
  0%, 100% {
    transform: translateY(0) scale(1);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(212, 175, 55, 0.12), 0 0 12px rgba(212, 175, 55, 0.06);
  }
  50% {
    transform: translateY(-3px) scale(1.035);
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(212, 175, 55, 0.22), 0 0 22px rgba(212, 175, 55, 0.14);
  }
}

@keyframes scb-halo {
  0% {
    opacity: 0.55;
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.22);
  }
  70% {
    opacity: 0;
    transform: scale(1.45);
    box-shadow: 0 0 0 10px rgba(212, 175, 55, 0);
  }
  100% {
    opacity: 0;
    transform: scale(1.45);
  }
}

@keyframes scb-panel-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes scb-panel-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
}

@keyframes scb-bubble-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes scb-bubble-in-user {
  from {
    opacity: 0;
    transform: translateY(8px) translateX(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1);
  }
}

@keyframes scb-online-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.45);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(74, 222, 128, 0);
  }
}

@keyframes scb-typing-dot {
  0%, 80%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
    background: rgba(212, 175, 55, 0.9);
  }
}

@keyframes scb-chip-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  #simadda-chatbot-root.scb-anim-on .scb-launcher,
  #simadda-chatbot-root.scb-anim-on .scb-launcher-halo,
  #simadda-chatbot-root.scb-anim-on .scb-online-dot,
  #simadda-chatbot-root.scb-anim-on .scb-typing span,
  #simadda-chatbot-root.scb-anim-on .scb-bubble.scb-bubble-enter,
  #simadda-chatbot-root.scb-anim-on .scb-panel.open .scb-chip {
    animation: none !important;
  }

  #simadda-chatbot-root.scb-anim-on .scb-panel.open,
  #simadda-chatbot-root.scb-anim-on .scb-panel.scb-panel-closing {
    animation: none !important;
    opacity: 1;
    transform: none;
  }

  #simadda-chatbot-root.scb-anim-on .scb-launcher-halo {
    opacity: 0;
  }
}

@media (max-width: 480px) {
  #simadda-chatbot-root {
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
  }
  .scb-panel {
    width: calc(100vw - 24px);
    height: min(70vh, 520px);
  }
}
