/* ─── AI Chat Widget ─────────────────────────────────────
   Matches the SySSA design system (dark theme by default)
───────────────────────────────────────────────────────── */

#aic-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  font-family: var(--font-primary, 'Inter', sans-serif);
}

/* ── Toggle button ─────────────────────────────────────── */
.aic-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--grad-primary, linear-gradient(135deg, #3b82f6, #8b5cf6));
  color: #fff;
  box-shadow: 0 8px 28px rgba(59, 130, 246, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.aic-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 36px rgba(59, 130, 246, 0.55);
}
.aic-toggle:focus-visible {
  outline: 2px solid var(--color-primary, #3b82f6);
  outline-offset: 3px;
}
.aic-icon { display: flex; }

/* ── Panel ─────────────────────────────────────────────── */
.aic-panel {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  width: 360px;
  max-height: 520px;
  background: var(--bg-secondary, #0d1b2a);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.07));
  border-radius: var(--radius-md, 12px);
  box-shadow: var(--shadow-lg, 0 16px 48px rgba(0, 0, 0, 0.5));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.aic-panel--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Header ────────────────────────────────────────────── */
.aic-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  background: var(--bg-card, #111c2e);
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.07));
  flex-shrink: 0;
}
.aic-header-info { display: flex; align-items: center; gap: 0.6rem; }
.aic-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--grad-primary, linear-gradient(135deg, #3b82f6, #8b5cf6));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.aic-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary, #f1f5f9);
}
.aic-status {
  font-size: 0.72rem;
  color: var(--text-muted, #64748b);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 1px;
}
.aic-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-success, #10b981);
  animation: aic-pulse 2s ease infinite;
}
@keyframes aic-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}
.aic-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted, #64748b);
  padding: 0.25rem;
  border-radius: 6px;
  display: flex;
  transition: color 0.15s, background 0.15s;
}
.aic-close:hover {
  color: var(--text-primary, #f1f5f9);
  background: var(--border-color, rgba(255, 255, 255, 0.07));
}

/* ── Messages ──────────────────────────────────────────── */
.aic-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color, rgba(255, 255, 255, 0.1)) transparent;
}
.aic-messages::-webkit-scrollbar       { width: 4px; }
.aic-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.aic-msg         { display: flex; }
.aic-msg--user   { justify-content: flex-end; }
.aic-msg--bot    { justify-content: flex-start; }

.aic-bubble {
  max-width: 82%;
  padding: 0.55rem 0.85rem;
  border-radius: 14px;
  font-size: 0.855rem;
  line-height: 1.55;
  word-break: break-word;
}
.aic-msg--user .aic-bubble {
  background: var(--color-primary, #3b82f6);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.aic-msg--bot .aic-bubble {
  background: var(--bg-card, #111c2e);
  color: var(--text-primary, #f1f5f9);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.07));
  border-bottom-left-radius: 4px;
}

/* ── Typing indicator ──────────────────────────────────── */
.aic-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.65rem 0.85rem;
}
.aic-typing span {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted, #64748b);
  animation: aic-bounce 1.2s ease infinite;
}
.aic-typing span:nth-child(2) { animation-delay: 0.15s; }
.aic-typing span:nth-child(3) { animation-delay: 0.30s; }
@keyframes aic-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%            { transform: translateY(-5px); }
}

/* ── Footer / input ────────────────────────────────────── */
.aic-footer {
  padding: 0.75rem 1rem 0.65rem;
  border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.07));
  background: var(--bg-card, #111c2e);
  flex-shrink: 0;
}
.aic-input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}
.aic-input {
  flex: 1;
  resize: none;
  background: var(--bg-primary, #050b1a);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.07));
  border-radius: 10px;
  color: var(--text-primary, #f1f5f9);
  font-family: inherit;
  font-size: 0.855rem;
  line-height: 1.5;
  padding: 0.55rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
  max-height: 120px;
  overflow-y: auto;
}
.aic-input::placeholder { color: var(--text-muted, #64748b); }
.aic-input:focus        { border-color: var(--border-focus, rgba(59, 130, 246, 0.6)); }

.aic-send {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background: var(--color-primary, #3b82f6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, opacity 0.15s, transform 0.15s;
}
.aic-send:hover:not(:disabled) {
  background: var(--color-primary-hover, #2563eb);
  transform: scale(1.05);
}
.aic-send:disabled { opacity: 0.4; cursor: not-allowed; }

.aic-note {
  font-size: 0.7rem;
  color: var(--text-muted, #64748b);
  margin: 0.45rem 0 0;
  text-align: center;
}
.aic-note a            { color: inherit; text-decoration: underline; }
.aic-note a:hover      { color: var(--color-primary, #3b82f6); }

/* ── Light mode overrides ──────────────────────────────── */
[data-theme="light"] .aic-panel           { background: #f8fafc; border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .aic-header          { background: #fff;    border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .aic-footer          { background: #fff;    border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .aic-msg--bot .aic-bubble {
  background: #fff;
  color: #0f172a;
  border-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .aic-input {
  background: #f1f5f9;
  border-color: rgba(0,0,0,0.1);
  color: #0f172a;
}
[data-theme="light"] .aic-input:focus     { border-color: #3b82f6; }
[data-theme="light"] .aic-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 420px) {
  #aic-widget { bottom: 1rem; right: 1rem; }
  .aic-panel  { width: calc(100vw - 2rem); right: -1rem; }
}
