/* =============================================================
   INTARIAN CHATBOT WIDGET — Component Stylesheet
   Usage: <link rel="stylesheet" href="intarian-chatbot.css" />
   Version: 2.0 | Reusable Web Component
   ============================================================= */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600;700&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ── CSS Custom Properties (scoped to widget root) ── */
.intarian-chatbot-root {
  /* Brand */
  --icb-primary:        #E31B6D;
  --icb-primary-dark:   #C2155D;
  --icb-primary-light:  #FF4D8D;
  --icb-primary-glow:   rgba(227, 27, 109, 0.25);
  --icb-primary-ultra:  rgba(227, 27, 109, 0.08);

  /* Dark theme surfaces */
  --icb-bg-glass:   rgba(17, 17, 24, 0.90);
  --icb-bg-card:    #111118;
  --icb-bg-user:    rgba(227, 27, 109, 0.15);
  --icb-bg-bot:     rgba(255,255,255,0.04);
  --icb-bg-input:   rgba(255,255,255,0.06);

  /* Dark theme text */
  --icb-text-primary:   #F0EDE8;
  --icb-text-secondary: rgba(240, 237, 232, 0.55);
  --icb-text-muted:     rgba(240, 237, 232, 0.30);

  /* Dark theme borders & shadows */
  --icb-border:         rgba(255,255,255,0.07);
  --icb-border-active:  rgba(227, 27, 109, 0.40);
  --icb-shadow:         0 20px 60px rgba(0,0,0,0.6), 0 0 40px rgba(227,27,109,0.12);
  --icb-shadow-btn:     0 8px 32px rgba(227, 27, 109, 0.45);

  /* Radii */
  --icb-r-lg: 24px;
  --icb-r-md: 16px;
  --icb-r-sm: 10px;
  --icb-r-xs:  6px;

  /* Typography */
  --icb-font-display: 'Cormorant Garamond', Georgia, serif;
  --icb-font-body:    'DM Sans', system-ui, sans-serif;

  /* Motion */
  --icb-ease:   0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --icb-spring: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Dimensions */
  --icb-w: 400px;
  --icb-h: 620px;
}

/* ── Light mode override (toggled via JS on .intarian-chatbot-root) ── */
.intarian-chatbot-root.icb-light {
  --icb-bg-glass:       rgba(255, 252, 248, 0.95);
  --icb-bg-card:        #FFFFFF;
  --icb-bg-user:        rgba(227, 27, 109, 0.10);
  --icb-bg-bot:         rgba(0,0,0,0.04);
  --icb-bg-input:       rgba(0,0,0,0.04);
  --icb-text-primary:   #1A1A2E;
  --icb-text-secondary: rgba(26, 26, 46, 0.55);
  --icb-text-muted:     rgba(26, 26, 46, 0.35);
  --icb-border:         rgba(0,0,0,0.08);
  --icb-shadow:         0 20px 60px rgba(0,0,0,0.15), 0 0 40px rgba(227,27,109,0.08);
}

/* ── All widget elements – fully prefixed to avoid global pollution ── */
.intarian-chatbot-root * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ================================================
   FLOATING TRIGGER BUTTON
================================================ */
.icb-trigger {
  position: fixed;
  bottom: 290px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--icb-primary-light), var(--icb-primary-dark));
  border: none;
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--icb-shadow-btn);
  transition: transform var(--icb-spring), box-shadow var(--icb-ease);
  overflow: visible;
  outline: none;
  font-family: var(--icb-font-body);
}
.icb-trigger::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--icb-primary), transparent, var(--icb-primary-light), transparent, var(--icb-primary));
  animation: icb-spin 4s linear infinite;
  opacity: 0.5;
  z-index: -1;
}
.icb-trigger::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--icb-primary-glow), transparent 70%);
  animation: icb-pulse 2.5s ease-out infinite;
}
.icb-trigger:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 48px rgba(227,27,109,0.6);
}
.icb-trigger.icb-open {
  transform: scale(0.9) rotate(180deg);
}

/* Trigger icon states */
.icb-trigger-icon {
  position: relative;
  z-index: 1;
  width: 28px;
  height: 28px;
}
.icb-trigger-icon svg {
  width: 28px;
  height: 28px;
  fill: white;
  transition: opacity var(--icb-ease);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.icb-icon-chat  { opacity: 1; }
.icb-icon-close { opacity: 0; }
.icb-trigger.icb-open .icb-icon-chat  { opacity: 0; }
.icb-trigger.icb-open .icb-icon-close { opacity: 1; }

/* Notification badge */
.icb-badge {
  position: absolute;
  top: 0;
  right: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  color: var(--icb-primary);
  font-size: 10px;
  font-weight: 700;
  font-family: var(--icb-font-body);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--icb-primary-dark);
  animation: icb-badge-pop 1s var(--icb-spring) 1.5s both;
}

/* ================================================
   CHAT WINDOW
================================================ */
.icb-window {
  position: fixed;
  bottom: 108px;
  right: 28px;
  width: var(--icb-w);
  height: var(--icb-h);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  border-radius: var(--icb-r-lg);
  overflow: hidden;
  background: var(--icb-bg-glass);
  backdrop-filter: blur(24px) saturate(1.8);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  border: 1px solid var(--icb-border);
  box-shadow: var(--icb-shadow);
  transform: scale(0.85) translateY(20px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: transform var(--icb-spring), opacity var(--icb-ease);
}
.icb-window.icb-active {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}
/* Gradient border overlay */
.icb-window::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--icb-r-lg);
  padding: 1px;
  background: linear-gradient(135deg, rgba(227,27,109,0.5), transparent 40%, transparent 60%, rgba(227,27,109,0.2));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: 1;
}

/* ── Header ── */
.icb-header {
  padding: 18px 20px 14px;
  background: linear-gradient(135deg, rgba(227,27,109,0.12) 0%, transparent 60%);
  border-bottom: 1px solid var(--icb-border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.icb-header-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--icb-primary-light), var(--icb-primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 20px var(--icb-primary-glow);
  position: relative;
}
.icb-header-avatar svg { width: 22px; height: 22px; fill: white; }
.icb-online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22C55E;
  border: 2px solid var(--icb-bg-card);
  animation: icb-blink 2s infinite;
}
.icb-header-info { flex: 1; }
.icb-header-name {
  font-family: var(--icb-font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--icb-text-primary);
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.icb-header-status {
  font-size: 0.72rem;
  color: #22C55E;
  font-weight: 500;
  letter-spacing: 0.05em;
  font-family: var(--icb-font-body);
  margin-top: 2px;
}
.icb-header-actions { display: flex; gap: 6px; }
.icb-hbtn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--icb-bg-input);
  border: 1px solid var(--icb-border);
  color: var(--icb-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--icb-ease);
  outline: none;
}
.icb-hbtn:hover {
  background: var(--icb-primary-ultra);
  border-color: var(--icb-primary-glow);
  color: var(--icb-primary-light);
}
.icb-hbtn svg { width: 14px; height: 14px; fill: currentColor; }

/* ── Messages ── */
.icb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
.icb-messages::-webkit-scrollbar { width: 4px; }
.icb-messages::-webkit-scrollbar-track { background: transparent; }
.icb-messages::-webkit-scrollbar-thumb { background: var(--icb-border); border-radius: 2px; }

.icb-msg-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: icb-msg-in 0.4s var(--icb-spring) both;
}
.icb-msg-row.icb-user { flex-direction: row-reverse; }

.icb-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--icb-primary-light), var(--icb-primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 2px;
}
.icb-msg-avatar svg { width: 14px; height: 14px; fill: white; }
.icb-msg-row.icb-user .icb-msg-avatar { background: rgba(255,255,255,0.12); }

.icb-bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: 78%;
}
.icb-bubble {
  padding: 11px 14px;
  border-radius: var(--icb-r-md);
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--icb-text-primary);
  font-family: var(--icb-font-body);
}
.icb-msg-row.icb-bot .icb-bubble {
  background: var(--icb-bg-bot);
  border: 1px solid var(--icb-border);
  border-bottom-left-radius: var(--icb-r-xs);
}
.icb-msg-row.icb-user .icb-bubble {
  background: var(--icb-bg-user);
  border: 1px solid var(--icb-border-active);
  border-bottom-right-radius: var(--icb-r-xs);
}
.icb-msg-time {
  font-size: 0.65rem;
  color: var(--icb-text-muted);
  margin-top: 4px;
  display: block;
  text-align: right;
  font-family: var(--icb-font-body);
}
.icb-msg-row.icb-bot .icb-msg-time { text-align: left; }

/* Welcome card */
.icb-welcome-card {
  background: linear-gradient(135deg, rgba(227,27,109,0.1), rgba(100,40,180,0.06));
  border: 1px solid rgba(227,27,109,0.2);
  border-radius: var(--icb-r-md);
  padding: 18px 16px;
  text-align: center;
}
.icb-welcome-logo {
  font-family: var(--icb-font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--icb-primary-light);
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.icb-welcome-text {
  font-size: 0.82rem;
  color: var(--icb-text-secondary);
  line-height: 1.5;
  font-family: var(--icb-font-body);
}
.icb-welcome-text strong { color: var(--icb-text-primary); }

/* Quick chips */
.icb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  justify-content: center;
}
.icb-chip {
  padding: 5px 11px;
  border-radius: 20px;
  background: var(--icb-bg-input);
  border: 1px solid var(--icb-border);
  color: var(--icb-text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  font-family: var(--icb-font-body);
  cursor: pointer;
  transition: all var(--icb-ease);
  white-space: nowrap;
  outline: none;
}
.icb-chip:hover {
  background: var(--icb-primary-ultra);
  border-color: var(--icb-border-active);
  color: var(--icb-primary-light);
  transform: translateY(-1px);
}

/* Typing indicator */
.icb-typing {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: var(--icb-bg-bot);
  border: 1px solid var(--icb-border);
  border-radius: var(--icb-r-md);
  border-bottom-left-radius: var(--icb-r-xs);
  width: fit-content;
}
.icb-typing-dots { display: flex; gap: 4px; }
.icb-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--icb-primary);
  animation: icb-bounce 1.2s infinite;
}
.icb-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.icb-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ── FAQ strip ── */
.icb-faq-section {
  padding: 10px 14px 0;
  border-top: 1px solid var(--icb-border);
  flex-shrink: 0;
}
.icb-faq-label {
  font-size: 0.65rem;
  color: var(--icb-text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
  font-weight: 600;
  font-family: var(--icb-font-body);
}
.icb-faq-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 10px;
}
.icb-faq-chips::-webkit-scrollbar { height: 0; }

/* ── Suggestions dropdown ── */
.icb-suggestions {
  background: var(--icb-bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--icb-border);
  border-bottom: none;
  border-radius: var(--icb-r-md) var(--icb-r-md) 0 0;
  max-height: 160px;
  overflow-y: auto;
  display: none;
  flex-shrink: 0;
}
.icb-suggestions.icb-visible { display: block; }
.icb-suggestion-item {
  padding: 9px 14px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--icb-text-secondary);
  font-family: var(--icb-font-body);
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--icb-border);
  transition: all var(--icb-ease);
}
.icb-suggestion-item:last-child { border-bottom: none; }
.icb-suggestion-item:hover { background: var(--icb-primary-ultra); color: var(--icb-text-primary); }
.icb-suggestion-item svg { width: 12px; height: 12px; fill: var(--icb-primary); flex-shrink: 0; }
.icb-sug-hl { color: var(--icb-primary-light); font-weight: 600; }

/* ── Input area ── */
.icb-input-area {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--icb-border);
  background: rgba(0,0,0,0.1);
  flex-shrink: 0;
}
.icb-input-row { display: flex; gap: 8px; align-items: flex-end; }
.icb-input {
  flex: 1;
  background: var(--icb-bg-input);
  border: 1px solid var(--icb-border);
  border-radius: var(--icb-r-sm);
  padding: 10px 14px;
  color: var(--icb-text-primary);
  font-family: var(--icb-font-body);
  font-size: 0.875rem;
  resize: none;
  outline: none;
  transition: border-color var(--icb-ease);
  max-height: 100px;
  min-height: 42px;
  line-height: 1.5;
}
.icb-input::placeholder { color: var(--icb-text-muted); }
.icb-input:focus { border-color: var(--icb-border-active); }
.icb-send-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--icb-r-sm);
  background: linear-gradient(135deg, var(--icb-primary-light), var(--icb-primary-dark));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--icb-spring), box-shadow var(--icb-ease);
  box-shadow: 0 4px 16px var(--icb-primary-glow);
  outline: none;
}
.icb-send-btn:hover { transform: scale(1.08); box-shadow: var(--icb-shadow-btn); }
.icb-send-btn:active { transform: scale(0.95); }
.icb-send-btn svg { width: 18px; height: 18px; fill: white; }
.icb-footer {
  margin-top: 8px;
  text-align: center;
  font-size: 0.65rem;
  color: var(--icb-text-muted);
  letter-spacing: 0.04em;
  font-family: var(--icb-font-body);
}
.icb-footer span { color: var(--icb-primary); }

/* ── Chip section label ── */
.icb-chips-label {
  font-size: 0.7rem;
  color: var(--icb-text-muted);
  margin: 12px 0 6px;
  text-align: center;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  font-family: var(--icb-font-body);
}

/* ================================================
   KEYFRAME ANIMATIONS
================================================ */
@keyframes icb-spin    { to { transform: rotate(360deg); } }
@keyframes icb-pulse   { 0%{transform:scale(0.9);opacity:0.8} 100%{transform:scale(1.5);opacity:0} }
@keyframes icb-blink   { 0%,100%{opacity:1} 50%{opacity:0.4} }
@keyframes icb-bounce  { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-6px)} }
@keyframes icb-msg-in  { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }
@keyframes icb-badge-pop { from{transform:scale(0)} to{transform:scale(1)} }

/* ================================================
   RESPONSIVE
================================================ */
@media (max-width: 480px) {
  .intarian-chatbot-root {
    --icb-w: calc(100vw - 16px);
    --icb-h: calc(100dvh - 110px);
  }
  .icb-window {
    right: 8px;
    bottom: 96px;
    border-radius: var(--icb-r-md);
  }
  .icb-trigger {
    bottom: 20px;
    right: 16px;
    width: 58px;
    height: 58px;
  }
}
