/* ============================================================
   chatbot.css  —  Premium Glassmorphic Chatbot Widget
   Fully responsive — works perfectly at any screen size / zoom
   ============================================================ */

/* Base Imports */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono&family=Space+Grotesk:wght@500;700&display=swap');

:root {
  --chat-bg-dark:       #060b16;
  --chat-panel-glass:   rgba(15, 24, 41, 0.94);
  --chat-accent-blue:   #3b82f6;
  --chat-accent-cyan:   #22d3ee;
  --chat-border-glass:  rgba(120, 160, 220, 0.18);
  --chat-text-light:    #f4f8ff;
  --chat-text-dark:     #04111f;
  --chat-font-display:  'Space Grotesk', sans-serif;
  --chat-font-body:     'Inter', sans-serif;
  --chat-font-mono:     'JetBrains Mono', monospace;
}

/* ── Root container ──────────────────────────────────────── */
/* This is just an anchor for the launcher; it does NOT clip  */
#intraai-chat-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999998;
  font-family: var(--chat-font-body);
  pointer-events: none;
  /* Must have no size so it doesn't clip children */
  width: 0;
  height: 0;
}

#intraai-chat-root * {
  box-sizing: border-box;
}

/* ── Launcher Button ─────────────────────────────────────── */
.intraai-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-accent-blue), var(--chat-accent-cyan));
  color: var(--chat-text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(34, 211, 238, 0.45),
              0 2px 8px rgba(0, 0, 0, 0.4);
  border: none;
  outline: none;
  pointer-events: auto;
  z-index: 999999;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              box-shadow 0.3s ease;
}

.intraai-launcher:hover,
.intraai-launcher:focus-visible {
  transform: scale(1.1);
  box-shadow: 0 6px 32px rgba(34, 211, 238, 0.6),
              0 2px 12px rgba(0, 0, 0, 0.4);
}

/* Notification dot */
.intraai-notification {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #fff;
  display: block;
  animation: notif-pulse 2s ease infinite;
}

@keyframes notif-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.2); }
}

/* ── Chat Panel ──────────────────────────────────────────── */
/* Fixed to viewport — NEVER clips at any zoom/screen size   */
.intraai-panel {
  position: fixed;
  bottom: 100px;       /* above the launcher */
  right: 24px;
  width: min(380px, calc(100vw - 32px));   /* responsive width  */
  height: min(560px, calc(100vh - 140px)); /* responsive height */
  background: var(--chat-panel-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--chat-border-glass);
  border-radius: 18px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55),
              0 0 0 1px rgba(120, 160, 220, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 999999;
  /* Hidden by default */
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.3s ease,
              transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}

.intraai-panel.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* ── Mobile: full-screen sheet ───────────────────────────── */
@media (max-width: 520px) {
  .intraai-panel {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    transform: translateY(100%);
  }
  .intraai-panel.active {
    transform: translateY(0);
  }
  .intraai-launcher {
    bottom: 20px;
    right: 20px;
  }
}

/* ── Small desktop / tablet breakpoint ──────────────────── */
@media (min-width: 521px) and (max-height: 680px) {
  .intraai-panel {
    bottom: 92px;
    height: calc(100vh - 108px);
  }
}

/* ── Reduced motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .intraai-panel,
  .intraai-launcher { transition: none; }
}

/* ── Header ──────────────────────────────────────────────── */
.intraai-header {
  flex-shrink: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--chat-border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
}

.intraai-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.intraai-avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--chat-accent-blue), var(--chat-accent-cyan));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--chat-text-light);
  font-size: 15px;
}

.intraai-title {
  font-family: var(--chat-font-display);
  color: var(--chat-text-light);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.intraai-subtitle {
  font-size: 11px;
  color: var(--chat-accent-cyan);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.intraai-dot {
  width: 7px;
  height: 7px;
  background: #22c55e;
  border-radius: 50%;
  animation: blink 2s ease infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.intraai-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  line-height: 1;
}
.intraai-close:hover,
.intraai-close:focus-visible {
  color: var(--chat-text-light);
  background: rgba(255, 255, 255, 0.08);
}

/* ── Messages Area ───────────────────────────────────────── */
.intraai-messages {
  flex: 1;
  min-height: 0;           /* crucial for flex scroll to work */
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.intraai-messages::-webkit-scrollbar { width: 4px; }
.intraai-messages::-webkit-scrollbar-track { background: transparent; }
.intraai-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

/* ── Message Bubbles ─────────────────────────────────────── */
.msg-bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: break-word;
  animation: fadeUp 0.28s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  color: var(--chat-text-light);
  border: 1px solid var(--chat-border-glass);
  border-bottom-left-radius: 4px;
}

.msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--chat-accent-blue), var(--chat-accent-cyan));
  color: var(--chat-text-dark);
  font-weight: 500;
  border-bottom-right-radius: 4px;
}

.msg-bot ul, .msg-bot ol { margin-left: 16px; margin-top: 6px; }
.msg-bot li  { margin-bottom: 4px; }
.msg-bot strong { color: var(--chat-accent-cyan); font-weight: 600; }
.msg-bot a { color: var(--chat-accent-cyan); }

/* ── Typing Indicator ────────────────────────────────────── */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 10px 14px;
  align-items: center;
}
.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--chat-accent-cyan);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing {
  0%, 80%, 100% { transform: scale(0.4); opacity: 0.5; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* ── Quick Reply Chips ───────────────────────────────────── */
.intraai-quick-replies {
  flex-shrink: 0;
  padding: 4px 14px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.intraai-chip {
  background: rgba(34, 211, 238, 0.1);
  color: var(--chat-accent-cyan);
  border: 1px solid rgba(34, 211, 238, 0.25);
  padding: 5px 12px;
  border-radius: 100px;
  font-size: 11.5px;
  font-family: var(--chat-font-body);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.intraai-chip:hover {
  background: rgba(34, 211, 238, 0.2);
  border-color: rgba(34, 211, 238, 0.45);
}

/* ── Input Area ──────────────────────────────────────────── */
.intraai-input-area {
  flex-shrink: 0;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.25);
  border-top: 1px solid var(--chat-border-glass);
  display: flex;
  align-items: center;
  gap: 10px;
}

.intraai-input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--chat-border-glass);
  border-radius: 24px;
  color: var(--chat-text-light);
  font-family: var(--chat-font-body);
  font-size: 13.5px;
  padding: 9px 16px;
  outline: none;
  transition: border-color 0.2s;
}
.intraai-input:focus {
  border-color: rgba(34, 211, 238, 0.45);
}
.intraai-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.intraai-send {
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--chat-accent-blue), var(--chat-accent-cyan));
  color: var(--chat-text-dark);
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(34, 211, 238, 0.35);
}
.intraai-send:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 14px rgba(34, 211, 238, 0.5);
}



/* ── Light Theme Overrides ───────────────────────────────── */
html[data-theme="light"],
[data-theme="light"] {
  --chat-panel-glass:   rgba(255, 255, 255, 0.96);
  --chat-accent-blue:   #2563eb;
  --chat-accent-cyan:   #0891b2;
  --chat-border-glass:  rgba(15, 23, 42, 0.12);
  --chat-text-light:    #0f1c33;
  --chat-text-dark:     #ffffff;
}

/* Specific Light Theme Component Adjustments */
html[data-theme="light"] .intraai-panel,
[data-theme="light"] .intraai-panel {
  background: var(--chat-panel-glass);
  border-color: var(--chat-border-glass);
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.12),
              0 0 0 1px rgba(15, 23, 42, 0.04);
}

html[data-theme="light"] .intraai-header,
[data-theme="light"] .intraai-header {
  background: rgba(15, 23, 42, 0.02);
  border-bottom-color: var(--chat-border-glass);
}

html[data-theme="light"] .intraai-close,
[data-theme="light"] .intraai-close {
  color: rgba(15, 23, 42, 0.5);
}
html[data-theme="light"] .intraai-close:hover,
html[data-theme="light"] .intraai-close:focus-visible,
[data-theme="light"] .intraai-close:hover,
[data-theme="light"] .intraai-close:focus-visible {
  color: #0f1c33;
  background: rgba(15, 23, 42, 0.06);
}

html[data-theme="light"] .intraai-messages::-webkit-scrollbar-thumb,
[data-theme="light"] .intraai-messages::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.15);
}

/* Bot Message Bubbles */
html[data-theme="light"] .msg-bot,
[data-theme="light"] .msg-bot {
  background: #f1f5f9;
  color: #0f1c33;
  border-color: var(--chat-border-glass);
}
html[data-theme="light"] .msg-bot strong,
[data-theme="light"] .msg-bot strong {
  color: #2563eb;
}
html[data-theme="light"] .msg-bot a,
[data-theme="light"] .msg-bot a {
  color: #2563eb;
}

/* Quick Reply Chips */
html[data-theme="light"] .intraai-chip,
[data-theme="light"] .intraai-chip {
  background: rgba(37, 99, 235, 0.05);
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.2);
}
html[data-theme="light"] .intraai-chip:hover,
[data-theme="light"] .intraai-chip:hover {
  background: rgba(37, 99, 235, 0.1);
  border-color: rgba(37, 99, 235, 0.4);
}

/* Input Area & Box */
html[data-theme="light"] .intraai-input-area,
[data-theme="light"] .intraai-input-area {
  background: rgba(15, 23, 42, 0.02);
  border-top-color: var(--chat-border-glass);
}

html[data-theme="light"] .intraai-input,
[data-theme="light"] .intraai-input {
  background: #ffffff !important;
  color: #0f1c33 !important;
  border: 1px solid rgba(15, 23, 42, 0.15) !important;
}
html[data-theme="light"] .intraai-input:focus,
[data-theme="light"] .intraai-input:focus {
  border-color: #2563eb !important;
}
html[data-theme="light"] .intraai-input::placeholder,
[data-theme="light"] .intraai-input::placeholder {
  color: rgba(15, 23, 42, 0.45) !important;
}

/* Brand Colors Locking for Buttons, Avatar, User Messages & Send */
html[data-theme="light"] .intraai-launcher,
[data-theme="light"] .intraai-launcher {
  background: linear-gradient(135deg, #3b82f6, #22d3ee) !important;
  color: #f4f8ff !important;
  box-shadow: 0 4px 24px rgba(34, 211, 238, 0.45),
              0 2px 8px rgba(0, 0, 0, 0.2) !important;
}
html[data-theme="light"] .intraai-avatar,
[data-theme="light"] .intraai-avatar {
  background: linear-gradient(135deg, #3b82f6, #22d3ee) !important;
  color: #f4f8ff !important;
}
html[data-theme="light"] .msg-user,
[data-theme="light"] .msg-user {
  background: linear-gradient(135deg, #3b82f6, #22d3ee) !important;
  color: #04111f !important;
}
html[data-theme="light"] .intraai-send,
[data-theme="light"] .intraai-send {
  background: linear-gradient(135deg, #3b82f6, #22d3ee) !important;
  color: #04111f !important;
  box-shadow: 0 2px 8px rgba(34, 211, 238, 0.25) !important;
}
html[data-theme="light"] .intraai-send:hover,
[data-theme="light"] .intraai-send:hover {
  box-shadow: 0 4px 14px rgba(34, 211, 238, 0.4) !important;
}
