/* ==========================================================================
   Secura Web Chatbot Widget — plain CSS, scoped under #secura-chatbot
   ========================================================================== */

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

#secura-chatbot, #secura-chatbot * , #secura-chatbot *::before, #secura-chatbot *::after {
  box-sizing: border-box;
}

#secura-chatbot {
  --sc-primary: #ff6500;
  --sc-primary-dark: #e05500;
  --sc-bg: #ffffff;
  --sc-bg-soft: #fffaf7;
  --sc-text: #16181d;
  --sc-text-muted: #6b7280;
  --sc-border: #fce8db;
  --sc-bubble-user: #ff6500;
  --sc-bubble-bot: #f7f1ec;

  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 999999;
  font-family: 'Inter', sans-serif;
}

/* ---------------- Launcher bubble ---------------- */

#sc-launcher {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--sc-primary), var(--sc-primary-dark));
  box-shadow: 0 8px 24px rgba(255, 101, 0, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#sc-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(255, 101, 0, 0.45);
}

#sc-launcher svg {
  width: 26px;
  height: 26px;
}

#sc-launcher .sc-icon-close {
  display: none;
}

#secura-chatbot.sc-open #sc-launcher .sc-icon-chat { display: none; }
#secura-chatbot.sc-open #sc-launcher .sc-icon-close { display: block; }

#sc-launcher-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

/* ---------------- Chat window ---------------- */

#sc-window {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 140px);
  background: var(--sc-bg);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(16, 24, 40, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#secura-chatbot.sc-open #sc-window {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---------------- Header ---------------- */

#sc-header {
  background: linear-gradient(135deg, var(--sc-primary), var(--sc-primary-dark));
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

#sc-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

#sc-header-text {
  flex: 1;
  min-width: 0;
}

#sc-header-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
}

#sc-header-status {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

#sc-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
}

#sc-close-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  padding: 4px;
  line-height: 0;
}

/* ---------------- Message list ---------------- */

#sc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--sc-bg-soft);
}

.sc-row {
  display: flex;
  max-width: 100%;
}

.sc-row.sc-bot { justify-content: flex-start; }
.sc-row.sc-user { justify-content: flex-end; }

.sc-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.87rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.sc-bot .sc-bubble {
  background: var(--sc-bubble-bot);
  color: var(--sc-text);
  border-bottom-left-radius: 4px;
}

.sc-user .sc-bubble {
  background: var(--sc-bubble-user);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */

.sc-typing .sc-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
}

.sc-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sc-text-muted);
  opacity: 0.6;
  animation: sc-blink 1.2s infinite ease-in-out;
}
.sc-typing span:nth-child(2) { animation-delay: 0.15s; }
.sc-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes sc-blink {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-3px); opacity: 1; }
}

/* Quick reply chips */

.sc-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.sc-chip {
  background: #fff;
  border: 1px solid var(--sc-border);
  color: var(--sc-primary);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.sc-chip:hover {
  background: #fff2e8;
  border-color: var(--sc-primary);
}

/* ---------------- Lead capture form ---------------- */

.sc-lead-form {
  background: #fff;
  border: 1px solid var(--sc-border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 90%;
}

.sc-lead-form input,
.sc-lead-form textarea {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 9px 11px;
  border: 1px solid var(--sc-border);
  border-radius: 8px;
  outline: none;
  color: var(--sc-text);
}

.sc-lead-form input:focus,
.sc-lead-form textarea:focus {
  border-color: var(--sc-primary);
}

.sc-lead-form textarea {
  resize: none;
  min-height: 60px;
}

.sc-lead-submit {
  background: var(--sc-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.sc-lead-submit:hover {
  background: var(--sc-primary-dark);
}

.sc-lead-note {
  font-size: 0.72rem;
  color: var(--sc-text-muted);
}

/* ---------------- Input bar ---------------- */

#sc-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--sc-border);
  background: #fff;
  flex-shrink: 0;
}

#sc-input {
  flex: 1;
  border: 1px solid var(--sc-border);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  color: var(--sc-text);
}

#sc-input:focus {
  border-color: var(--sc-primary);
}

#sc-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--sc-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

#sc-send-btn:hover {
  background: var(--sc-primary-dark);
}

#sc-send-btn svg {
  width: 16px;
  height: 16px;
}

/* ---------------- Scrollbar ---------------- */

#sc-messages::-webkit-scrollbar {
  width: 6px;
}
#sc-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 999px;
}

/* ---------------- Mobile ---------------- */

@media (max-width: 480px) {
  #secura-chatbot {
    right: 12px;
    bottom: 12px;
  }
  #sc-window {
    width: calc(100vw - 24px);
    height: calc(100vh - 120px);
    bottom: 74px;
    right: -8px;
  }
}
