/* =============================================
   SMARTINTERN — Smarty Chatbot Widget
   Place in: static/css/chatbot.css
   ============================================= */

:root {
  --cb-blue:      #2563eb;
  --cb-blue-lt:   #3b82f6;
  --cb-blue-glow: #2563eb55;
  --cb-bg:        #0d1117;
  --cb-surface:   #161b22;
  --cb-border:    #21262d;
  --cb-text:      #e6edf3;
  --cb-muted:     #7d8590;
  --cb-green:     #3fb950;
  --cb-red:       #ef4444;
  --cb-font:      'Sora', -apple-system, sans-serif;
  --cb-mono:      'JetBrains Mono', monospace;
}

/* ── Floating Bubble ─────────────────────────── */
#smarty-bubble {
  position: fixed;
  bottom: 28px; right: 28px;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border: none; cursor: pointer;
  box-shadow: 0 4px 24px var(--cb-blue-glow);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1);
  animation: cbBubblePop 0.5s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes cbBubblePop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
#smarty-bubble:hover { transform: scale(1.1); }
#smarty-bubble:not(.is-open)::after {
  content: ''; position: absolute; inset: -4px;
  border-radius: 50%; border: 2px solid #2563eb66;
  animation: cbPulse 2.5s ease-out infinite;
}
@keyframes cbPulse {
  0%  { transform: scale(1);   opacity: 0.8; }
  70% { transform: scale(1.3); opacity: 0;   }
  100%{ transform: scale(1.3); opacity: 0;   }
}
.cb-icon { position: absolute; transition: opacity 0.2s, transform 0.2s; }
.cb-icon svg { width: 26px; height: 26px; fill: white; display: block; }
.cb-icon.cb-close { opacity: 0; transform: rotate(-90deg) scale(0.7); }
#smarty-bubble.is-open .cb-icon.cb-chat  { opacity: 0; transform: rotate(90deg) scale(0.7); }
#smarty-bubble.is-open .cb-icon.cb-close { opacity: 1; transform: rotate(0) scale(1); }

#smarty-badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 20px; height: 20px;
  background: var(--cb-red); border-radius: 10px; border: 2px solid white;
  font-size: 10px; font-weight: 700; color: white;
  display: none; align-items: center; justify-content: center;
  padding: 0 4px; font-family: var(--cb-mono);
}
#smarty-badge.show { display: flex; }

/* ── Chat Window ─────────────────────────────── */
#smarty-window {
  position: fixed;
  bottom: 98px; right: 28px;
  width: 370px; height: 540px;
  background: var(--cb-bg);
  border-radius: 16px;
  box-shadow: 0 16px 64px rgba(0,0,0,0.55), 0 0 0 1px #21262d;
  display: flex; flex-direction: column;
  z-index: 9998; overflow: hidden;
  transform: scale(0.88) translateY(16px);
  opacity: 0; pointer-events: none;
  transform-origin: bottom right;
  transition:
    transform 0.3s cubic-bezier(0.34,1.56,0.64,1),
    opacity   0.2s ease,
    width     0.35s cubic-bezier(0.4,0,0.2,1),
    height    0.35s cubic-bezier(0.4,0,0.2,1),
    bottom    0.35s cubic-bezier(0.4,0,0.2,1),
    right     0.35s cubic-bezier(0.4,0,0.2,1),
    border-radius 0.35s ease;
}
#smarty-window.is-open  { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; }
#smarty-window.is-fullscreen {
  bottom: 0 !important; right: 0 !important;
  width: 100vw !important; height: 100vh !important;
  border-radius: 0 !important;
}

/* ── Header ──────────────────────────────────── */
.cb-header {
  background: var(--cb-surface); border-bottom: 1px solid var(--cb-border);
  padding: 12px 14px; display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.cb-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; box-shadow: 0 2px 8px var(--cb-blue-glow);
}
.cb-avatar svg { width: 18px; height: 18px; fill: white; }
.cb-header-info { flex: 1; min-width: 0; }
.cb-name { font-size: 13px; font-weight: 700; color: var(--cb-text); font-family: var(--cb-font); }
.cb-status {
  font-size: 11px; color: var(--cb-muted);
  display: flex; align-items: center; gap: 5px; margin-top: 1px; font-family: var(--cb-font);
}
.cb-dot {
  width: 6px; height: 6px; background: var(--cb-green);
  border-radius: 50%; box-shadow: 0 0 5px var(--cb-green);
  animation: cbBlink 2s infinite; flex-shrink: 0;
}
@keyframes cbBlink { 0%,100%{opacity:1} 50%{opacity:0.4} }

.cb-header-btns { display: flex; gap: 4px; }
.cb-hbtn {
  width: 30px; height: 30px; background: transparent;
  border: 1px solid var(--cb-border); border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: var(--cb-muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.cb-hbtn:hover { background: #21262d; color: var(--cb-text); border-color: #30363d; }
.cb-hbtn svg { width: 14px; height: 14px; }

/* ── Fullscreen Sidebar ──────────────────────── */
.cb-fs-wrap { display: contents; }
#smarty-window.is-fullscreen .cb-fs-wrap {
  display: flex; flex-direction: row; flex: 1; overflow: hidden; min-height: 0;
}
.cb-sidebar {
  display: none; width: 230px; flex-shrink: 0;
  background: #0a0e14; border-right: 1px solid var(--cb-border);
  padding: 20px 14px; flex-direction: column; gap: 10px; overflow-y: auto;
}
#smarty-window.is-fullscreen .cb-sidebar { display: flex; }
.cb-sidebar-title {
  font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.8px; color: #30363d; font-weight: 600; font-family: var(--cb-font);
}
.cb-sidebar-prompt {
  background: transparent; border: 1px solid var(--cb-border); border-radius: 8px;
  padding: 9px 11px; font-size: 12px; color: var(--cb-muted);
  cursor: pointer; text-align: left; font-family: var(--cb-font); line-height: 1.4;
  transition: all 0.15s;
}
.cb-sidebar-prompt:hover { background: #1d4ed811; border-color: #2563eb44; color: var(--cb-text); }
.cb-sidebar-clear {
  margin-top: auto; background: transparent; border: 1px solid var(--cb-border);
  border-radius: 8px; padding: 9px 11px; font-size: 12px; color: var(--cb-muted);
  cursor: pointer; font-family: var(--cb-font); display: flex; align-items: center; gap: 7px;
  transition: all 0.15s;
}
.cb-sidebar-clear:hover { border-color: #ef444444; color: var(--cb-red); background: #ef444411; }
.cb-sidebar-clear svg { width: 13px; height: 13px; }
.cb-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ── Messages ────────────────────────────────── */
#smarty-messages {
  flex: 1; overflow-y: auto; padding: 16px 14px;
  display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth;
}
#smarty-messages::-webkit-scrollbar { width: 3px; }
#smarty-messages::-webkit-scrollbar-thumb { background: var(--cb-border); border-radius: 3px; }

.cb-welcome {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 20px 16px 8px; gap: 8px;
  animation: cbFadeUp 0.4s ease;
}
@keyframes cbFadeUp { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }
.cb-welcome-icon {
  width: 48px; height: 48px; background: #1d4ed811;
  border: 1px solid #2563eb44; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 4px;
}
.cb-welcome-icon svg { width: 24px; height: 24px; fill: var(--cb-blue-lt); }
.cb-welcome h4 { font-size: 14px; font-weight: 700; color: var(--cb-text); font-family: var(--cb-font); }
.cb-welcome p  { font-size: 12px; color: var(--cb-muted); line-height: 1.5; max-width: 240px; font-family: var(--cb-font); }
.cb-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; padding-top: 4px; }
.cb-chip {
  font-size: 11.5px; padding: 5px 11px; background: var(--cb-surface);
  border: 1px solid var(--cb-border); border-radius: 20px; color: var(--cb-blue-lt);
  cursor: pointer; font-family: var(--cb-font); font-weight: 500; transition: all 0.15s;
}
.cb-chip:hover { background: #1d4ed822; border-color: var(--cb-blue); }

.cb-msg { display: flex; gap: 8px; animation: cbMsgIn 0.2s ease; }
@keyframes cbMsgIn { from{opacity:0;transform:translateY(5px)} to{opacity:1;transform:translateY(0)} }
.cb-msg.user { flex-direction: row-reverse; }
.cb-msg-av {
  width: 26px; height: 26px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 2px;
}
.cb-msg.user .cb-msg-av { background: #1d4ed8; border: 1px solid var(--cb-blue); }
.cb-msg.bot  .cb-msg-av { background: var(--cb-surface); border: 1px solid var(--cb-border); }
.cb-msg-av svg { width: 13px; height: 13px; fill: var(--cb-muted); }
.cb-msg.user .cb-msg-av svg { fill: #93c5fd; }
.cb-msg-body { max-width: calc(100% - 34px); display: flex; flex-direction: column; gap: 3px; }
.cb-msg.user .cb-msg-body { align-items: flex-end; }
.cb-bubble {
  padding: 9px 12px; border-radius: 11px;
  font-size: 13px; line-height: 1.6; word-break: break-word; font-family: var(--cb-font);
}
.cb-msg.user .cb-bubble {
  background: #1d4ed8; border: 1px solid var(--cb-blue);
  color: #dbeafe; border-top-right-radius: 3px;
}
.cb-msg.bot .cb-bubble {
  background: var(--cb-surface); border: 1px solid var(--cb-border);
  color: var(--cb-text); border-top-left-radius: 3px;
}
.cb-msg-time { font-size: 10px; color: var(--cb-muted); font-family: var(--cb-mono); padding: 0 2px; }

/* Formatted content */
.cb-msg.bot .cb-bubble ol,
.cb-msg.bot .cb-bubble ul { padding-left: 18px; margin: 4px 0; display: flex; flex-direction: column; gap: 3px; }
.cb-msg.bot .cb-bubble li { line-height: 1.55; }
.cb-msg.bot .cb-bubble strong { color: #e6edf3; font-weight: 600; }
.cb-msg.bot .cb-bubble em { font-style: italic; opacity: 0.85; }
.cb-msg.bot .cb-bubble code {
  font-family: var(--cb-mono); font-size: 11.5px;
  background: #0d1117; border: 1px solid var(--cb-border); border-radius: 4px; padding: 1px 5px;
}

/* Typing */
#smarty-typing { display: none; gap: 8px; align-items: flex-start; }
#smarty-typing.show { display: flex; }
.cb-typing-bubble {
  background: var(--cb-surface); border: 1px solid var(--cb-border);
  border-radius: 11px; border-top-left-radius: 3px;
  padding: 11px 14px; display: flex; gap: 4px; align-items: center;
}
.cb-typing-bubble span {
  width: 5px; height: 5px; background: var(--cb-muted); border-radius: 50%;
  animation: cbDot 1.2s infinite;
}
.cb-typing-bubble span:nth-child(2){animation-delay:.2s}
.cb-typing-bubble span:nth-child(3){animation-delay:.4s}
@keyframes cbDot { 0%,60%,100%{transform:translateY(0);opacity:.4} 30%{transform:translateY(-4px);opacity:1} }

/* ── Input ───────────────────────────────────── */
.cb-input-area {
  border-top: 1px solid var(--cb-border); padding: 10px 12px;
  background: var(--cb-surface); flex-shrink: 0;
}
.cb-input-row {
  display: flex; gap: 8px; align-items: flex-end;
  background: var(--cb-bg); border: 1px solid var(--cb-border);
  border-radius: 11px; padding: 8px 10px; transition: border-color 0.2s;
}
.cb-input-row:focus-within { border-color: var(--cb-blue); }
#smarty-input {
  flex: 1; background: transparent; border: none; outline: none;
  resize: none; font-family: var(--cb-font); font-size: 13px;
  color: var(--cb-text); line-height: 1.5; max-height: 90px;
}
#smarty-input::placeholder { color: var(--cb-muted); }
.cb-send {
  width: 32px; height: 32px; background: var(--cb-blue); border: none; border-radius: 8px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; box-shadow: 0 2px 8px var(--cb-blue-glow);
  transition: background 0.15s, transform 0.1s;
}
.cb-send:hover  { background: var(--cb-blue-lt); }
.cb-send:active { transform: scale(0.9); }
.cb-send:disabled { background: #21262d; box-shadow: none; cursor: not-allowed; }
.cb-send svg { width: 15px; height: 15px; fill: white; }
.cb-hint { font-size: 10px; color: #30363d; text-align: center; margin-top: 6px; font-family: var(--cb-mono); }

/* ── Mobile ──────────────────────────────────── */
@media (max-width: 480px) {
  #smarty-window { width: calc(100vw - 20px); right: 10px; bottom: 84px; height: 72vh; }
  #smarty-bubble { bottom: 16px; right: 16px; }
}