/* Skylina AI Support Widget — dark theme, 215 features */
@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:wght@400;600;700&family=DM+Sans:wght@400;500&family=JetBrains+Mono:wght@400&display=swap');

:root {
  --sw-bg: #0A0E1A;
  --sw-surface: #111827;
  --sw-surface-2: #1a2332;
  --sw-border: #1f2937;
  --sw-text: #e5e7eb;
  --sw-text-dim: #9ca3af;
  --sw-lime: #B8FF47;
  --sw-violet: #8B5CF6;
  --sw-cyan: #06B6D4;
  --sw-danger: #ef4444;
  --sw-warning: #f59e0b;
  --sw-success: #22c55e;
  --sw-radius: 12px;
  --sw-shadow: 0 8px 32px rgba(0,0,0,0.4);
  --sw-accent: #B8FF47;
  --sw-color: #B8FF47;
}

/* ── Container & floating button ────────────────────────────────────────── */
.skylina-support {
  position: fixed;
  z-index: 99999;
  font-family: 'DM Sans', sans-serif;
}

.sw-right { right: 20px; bottom: 20px; }
.sw-left { left: 20px; bottom: 20px; }

.sw-chat-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  background: var(--sw-accent, #B8FF47);
  color: #000;
}

.sw-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0,0,0,0.4);
}

.sw-chat-btn--open { display: none; }

.sw-chat-btn--pulse {
  animation: sw-pulse 1.5s ease-in-out;
}

@keyframes sw-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 4px 20px rgba(0,0,0,0.3); }
  50% { transform: scale(1.12); box-shadow: 0 6px 28px rgba(184,255,71,0.4); }
}

.sw-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--sw-danger, #ef4444);
  color: white;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.sw-unread-badge--visible { opacity: 1; }

/* ── Chat window ─────────────────────────────────────────────────────────── */
.sw-window {
  position: absolute;
  bottom: 70px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 100px);
  background: var(--sw-bg, #0A0E1A);
  border: 1px solid var(--sw-border, #1f2937);
  border-radius: var(--sw-radius, 12px);
  box-shadow: var(--sw-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: sw-slide-up 0.25s ease-out;
}

.sw-window--open { display: flex; }
.sw-right.sw-window--open { transform-origin: bottom right; }
.sw-left.sw-window--open { transform-origin: bottom left; }

@keyframes sw-slide-up {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.sw-window.sw-minimized { height: auto; }
.sw-window.sw-minimized .sw-body,
.sw-window.sw-minimized .sw-kb-suggestions,
.sw-window.sw-minimized .sw-footer { display: none; }

/* ── Header ──────────────────────────────────────────────────────────────── */
.sw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--sw-surface, #111827);
  border-bottom: 1px solid var(--sw-border, #1f2937);
  gap: 8px;
}

.sw-header-left { display: flex; align-items: center; gap: 10px; }

.sw-avatar {
  position: relative;
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--sw-lime, #B8FF47), var(--sw-cyan, #06B6D4));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sw-ai-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 9px;
  height: 9px;
  background: var(--sw-success, #22c55e);
  border-radius: 50%;
  border: 2px solid var(--sw-surface, #111827);
}

.sw-header-info { display: flex; flex-direction: column; gap: 1px; }

.sw-header-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--sw-text, #e5e7eb);
}

.sw-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--sw-text-dim, #9ca3af);
}

.sw-online-dot {
  width: 7px;
  height: 7px;
  background: var(--sw-success, #22c55e);
  border-radius: 50%;
  animation: sw-blink 2s ease-in-out infinite;
}

@keyframes sw-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.sw-header-actions { display: flex; gap: 4px; }

.sw-icon-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--sw-text-dim, #9ca3af);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.sw-icon-btn:hover {
  background: var(--sw-surface-2, #1a2332);
  color: var(--sw-text, #e5e7eb);
}

/* ── Status banner ────────────────────────────────────────────────────────── */
.sw-banner {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
}

.sw-banner--active {
  background: var(--sw-warning, #f59e0b);
  color: #000;
}

.sw-banner--hidden { display: none; }

/* ── Body / messages ─────────────────────────────────────────────────────── */
.sw-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#sw-body { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

.sw-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 24px 16px;
  gap: 8px;
  text-align: center;
}

.sw-welcome-avatar {
  font-size: 36px;
  margin-bottom: 4px;
}

.sw-welcome-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--sw-text, #e5e7eb);
}

.sw-welcome-sub {
  font-size: 13px;
  color: var(--sw-text-dim, #9ca3af);
  line-height: 1.5;
  max-width: 300px;
}

.sw-quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
  width: 100%;
}

.sw-quick-btn {
  background: var(--sw-surface-2, #1a2332);
  border: 1px solid var(--sw-border, #1f2937);
  color: var(--sw-text, #e5e7eb);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
  font-family: 'DM Sans', sans-serif;
}

.sw-quick-btn:hover {
  background: var(--sw-surface, #111827);
  border-color: var(--sw-color, #B8FF47);
}

.sw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--sw-border, #1f2937) transparent;
}

.sw-messages::-webkit-scrollbar { width: 4px; }
.sw-messages::-webkit-scrollbar-track { background: transparent; }
.sw-messages::-webkit-scrollbar-thumb { background: var(--sw-border, #1f2937); border-radius: 2px; }

/* ── Typing indicator ─────────────────────────────────────────────────────── */
.sw-typing-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--sw-text-dim, #9ca3af);
}

.sw-typing-dots { display: flex; gap: 4px; }

.sw-typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--sw-text-dim, #9ca3af);
  border-radius: 50%;
  animation: sw-typing-bounce 1.2s ease-in-out infinite;
}

.sw-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.sw-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes sw-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* ── Message bubbles ──────────────────────────────────────────────────────── */
.sw-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.5;
  animation: sw-bubble-in 0.2s ease-out;
}

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

.sw-bubble--user {
  align-self: flex-end;
  background: var(--sw-color, #B8FF47);
  color: #000;
  border-bottom-right-radius: 4px;
}

.sw-bubble--ai {
  align-self: flex-start;
  background: var(--sw-surface-2, #1a2332);
  color: var(--sw-text, #e5e7eb);
  border: 1px solid var(--sw-border, #1f2937);
  border-bottom-left-radius: 4px;
}

.sw-bubble--system {
  align-self: center;
  background: transparent;
  color: var(--sw-text-dim, #9ca3af);
  font-size: 12px;
  text-align: center;
  border: 1px dashed var(--sw-border, #1f2937);
  border-radius: 8px;
}

.sw-bubble-meta {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
  min-height: 18px;
}

.sentiment-badge, .confidence-badge {
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--sw-surface, #111827);
  border: 1px solid var(--sw-border, #1f2937);
}

.confidence-badge.low { color: var(--sw-warning, #f59e0b); }

.sw-bubble-content { word-break: break-word; }
.sw-bubble-content code {
  background: rgba(0,0,0,0.2);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

.sw-bubble-content .code-block {
  margin: 8px 0;
  background: #0d1117;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--sw-border, #1f2937);
}

.sw-bubble-content .code-lang {
  background: var(--sw-surface, #111827);
  padding: 4px 10px;
  font-size: 11px;
  color: var(--sw-violet, #8B5CF6);
  font-family: 'JetBrains Mono', monospace;
}

.sw-bubble-content .code-block pre {
  margin: 0;
  padding: 10px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
}

.sw-bubble-content .code-block .copy-btn {
  background: var(--sw-surface, #111827);
  border: 1px solid var(--sw-border, #1f2937);
  color: var(--sw-text-dim, #9ca3af);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  margin: 0 8px 8px;
  font-family: 'DM Sans', sans-serif;
}

.sw-bubble-content .code-block .copy-btn:hover { color: var(--sw-lime, #B8FF47); }

.sw-bubble-content a {
  color: var(--sw-cyan, #06B6D4);
  text-decoration: none;
}

.sw-bubble-content a:hover { text-decoration: underline; }

.sw-bubble-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  gap: 8px;
}

.sw-bubble-time {
  font-size: 10px;
  color: var(--sw-text-dim, #9ca3af);
}

.sw-bubble--user .sw-bubble-time { color: rgba(0,0,0,0.5); }

.sw-bubble-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.sw-bubble:hover .sw-bubble-actions { opacity: 1; }

.sw-reaction {
  background: none;
  border: none;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 3px;
  border-radius: 4px;
  opacity: 0.6;
  transition: opacity 0.15s, transform 0.1s;
}

.sw-reaction:hover { opacity: 1; transform: scale(1.2); }
.sw-reaction--active { opacity: 1; }

/* ── KB suggestions ───────────────────────────────────────────────────────── */
.sw-kb-suggestions {
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-top: 1px solid var(--sw-border, #1f2937);
  background: var(--sw-surface, #111827);
}

.sw-kb-article {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--sw-surface-2, #1a2332);
  border: 1px solid var(--sw-border, #1f2937);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--sw-text, #e5e7eb);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-family: 'DM Sans', sans-serif;
}

.sw-kb-article:hover {
  border-color: var(--sw-cyan, #06B6D4);
  background: var(--sw-bg, #0A0E1A);
}

.sw-kb-article-icon { font-size: 11px; }
.sw-kb-article-title { font-weight: 500; }

/* ── Footer / input area ─────────────────────────────────────────────────── */
.sw-footer {
  border-top: 1px solid var(--sw-border, #1f2937);
  background: var(--sw-surface, #111827);
  padding: 8px 12px;
}

.sw-input-area { display: flex; flex-direction: column; gap: 4px; }

.sw-toolbar {
  display: flex;
  gap: 2px;
  margin-bottom: 2px;
}

.sw-toolbar-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--sw-text-dim, #9ca3af);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.sw-toolbar-btn:hover {
  background: var(--sw-surface-2, #1a2332);
  color: var(--sw-color, #B8FF47);
}

.sw-toolbar-btn.sw-mic--active {
  background: var(--sw-color, #B8FF47);
  color: #000;
  animation: sw-pulse 0.8s ease-in-out;
}

.sw-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sw-input {
  flex: 1;
  background: var(--sw-bg, #0A0E1A);
  border: 1px solid var(--sw-border, #1f2937);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  color: var(--sw-text, #e5e7eb);
  font-family: 'DM Sans', sans-serif;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}

.sw-input:focus { border-color: var(--sw-color, #B8FF47); }
.sw-input::placeholder { color: var(--sw-text-dim, #9ca3af); }

.sw-send-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--sw-color, #B8FF47);
  color: #000;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.1s, opacity 0.1s;
}

.sw-send-btn:hover { transform: scale(1.05); }
.sw-send-btn:active { transform: scale(0.95); }

.sw-attachments-preview {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 0;
}

.sw-attachment-item {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--sw-surface-2, #1a2332);
  border: 1px solid var(--sw-border, #1f2937);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--sw-text-dim, #9ca3af);
}

.sw-attachment-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sw-footer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--sw-border, #1f2937);
  font-size: 10px;
  color: var(--sw-text-dim, #9ca3af);
}

.sw-meta-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  padding: 2px;
}

.sw-powered-by { font-size: 10px; }
.sw-lang-indicator {
  background: var(--sw-surface-2, #1a2332);
  border: 1px solid var(--sw-border, #1f2937);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* ── Modal (history) ─────────────────────────────────────────────────────── */
.sw-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  animation: sw-fade-in 0.15s ease-out;
}

@keyframes sw-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sw-modal {
  background: var(--sw-surface, #111827);
  border: 1px solid var(--sw-border, #1f2937);
  border-radius: var(--sw-radius, 12px);
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--sw-shadow);
}

.sw-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--sw-border, #1f2937);
}

.sw-modal-header h3 {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--sw-text, #e5e7eb);
  margin: 0;
}

.sw-modal-close {
  background: none;
  border: none;
  color: var(--sw-text-dim, #9ca3af);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
}

.sw-modal-body {
  overflow-y: auto;
  padding: 12px;
}

.sw-history-item {
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 4px;
}

.sw-history-item:hover { background: var(--sw-surface-2, #1a2332); }

.sw-history-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.sw-history-subject {
  font-size: 13px;
  font-weight: 500;
  color: var(--sw-text, #e5e7eb);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sw-history-status {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sw-status--open { background: rgba(34,197,94,0.15); color: var(--sw-success, #22c55e); }
.sw-status--resolved { background: rgba(139,92,246,0.15); color: var(--sw-violet, #8B5CF6); }
.sw-status--closed { background: var(--sw-surface-2, #1a2332); color: var(--sw-text-dim, #9ca3af); }
.sw-status--pending { background: rgba(245,158,11,0.15); color: var(--sw-warning, #f59e0b); }

.sw-history-item-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--sw-text-dim, #9ca3af);
}

.sw-loading, .sw-empty-state {
  text-align: center;
  padding: 32px;
  color: var(--sw-text-dim, #9ca3af);
  font-size: 13px;
}

/* ── Admin live takeover indicator ────────────────────────────────────────── */
.sw-live-takeover-banner {
  background: var(--sw-danger, #ef4444);
  color: white;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.sw-live-dot {
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
  animation: sw-blink 0.8s ease-in-out infinite;
}

/* ── Accessibility ─────────────────────────────────────────────────────────── */
.skylina-support *:focus-visible {
  outline: 2px solid var(--sw-color, #B8FF47);
  outline-offset: 2px;
}

/* ── High contrast mode support ──────────────────────────────────────────── */
@media (prefers-contrast: high) {
  .sw-input { border-width: 2px; }
  .sw-bubble { border: 1px solid currentColor; }
}

/* ── Mobile adjustments ────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .sw-window {
    width: calc(100vw - 16px);
    bottom: 64px;
    height: calc(100vh - 80px);
    max-height: none;
  }

  .sw-quick-actions { grid-template-columns: 1fr; }

  .sw-bubble { max-width: 93%; }
}

/* ── Pre-chat form (for non-authenticated) ───────────────────────────────── */
.sw-prechat {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--sw-border, #1f2937);
}

.sw-prechat input {
  background: var(--sw-bg, #0A0E1A);
  border: 1px solid var(--sw-border, #1f2937);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--sw-text, #e5e7eb);
  font-family: 'DM Sans', sans-serif;
  outline: none;
}

.sw-prechat input:focus { border-color: var(--sw-color, #B8FF47); }
.sw-prechat label { font-size: 12px; color: var(--sw-text-dim, #9ca3af); font-weight: 500; }