/* Orbital Streams Chat Widget — uses dashboard CSS variables */

#os-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
}

/* ── Toggle button ─────────────────────────────────────────────────────── */

#os-chat-toggle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1.5px solid var(--border-light, rgba(255,255,255,0.20));
  background: var(--bg-card, rgba(0,0,0,0.25));
  color: var(--accent-light, #128962);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color 0.2s, background 0.2s;
}

#os-chat-toggle:hover {
  border-color: var(--accent, #0d6e4e);
  background: var(--accent-20, rgba(13,110,78,0.20));
}

#os-chat-toggle.active {
  border-color: var(--accent, #0d6e4e);
  background: var(--accent-20, rgba(13,110,78,0.20));
}

/* ── Panel ─────────────────────────────────────────────────────────────── */

#os-chat-panel {
  display: none;
  flex-direction: column;
  position: absolute;
  bottom: 64px;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 48px);
  height: 480px;
  max-height: calc(100vh - 120px);
  background: var(--bg, #0e0e0e);
  border: 1.5px solid var(--border-light, rgba(255,255,255,0.20));
  border-radius: 12px;
  overflow: hidden;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

#os-chat-panel.open {
  display: flex;
}

/* ── Header ────────────────────────────────────────────────────────────── */

#os-chat-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.12));
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

#os-chat-header span:first-child {
  font-weight: 600;
  font-size: 13px;
  color: var(--accent-light, #128962);
  letter-spacing: 0.3px;
}

#os-chat-status {
  font-size: 11px;
  color: var(--text-dim, #8e8e8e);
}

/* ── Messages ──────────────────────────────────────────────────────────── */

#os-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.os-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.os-msg-user {
  align-self: flex-end;
  background: var(--accent-20, rgba(13,110,78,0.20));
  color: var(--text, #f0f0f0);
  border: 1px solid var(--accent-dim, #0a5a3f);
  border-bottom-right-radius: 2px;
}

.os-msg-assistant {
  align-self: flex-start;
  background: var(--bg-card, rgba(0,0,0,0.25));
  color: var(--text, #f0f0f0);
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-bottom-left-radius: 2px;
}

/* ── Typing indicator ──────────────────────────────────────────────────── */

.os-typing {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
}

.os-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim, #8e8e8e);
  animation: os-bounce 1.4s infinite;
}

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

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

/* ── Input form ────────────────────────────────────────────────────────── */

#os-chat-form {
  display: flex;
  padding: 10px 12px;
  gap: 8px;
  border-top: 1px solid var(--border, rgba(255,255,255,0.12));
  flex-shrink: 0;
}

#os-chat-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: 6px;
  background: var(--bg-card, rgba(0,0,0,0.25));
  color: var(--text, #f0f0f0);
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

#os-chat-input:focus {
  border-color: var(--accent, #0d6e4e);
}

#os-chat-input::placeholder {
  color: var(--text-dim, #8e8e8e);
}

#os-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  background: var(--accent-20, rgba(13,110,78,0.20));
  color: var(--accent-light, #128962);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

#os-chat-send:hover {
  background: var(--accent-dim, #0a5a3f);
  border-color: var(--accent, #0d6e4e);
  color: var(--text, #f0f0f0);
}

#os-chat-send:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ── Mobile ────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  #os-chat-panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 100px);
    bottom: 60px;
    right: -12px;
    border-radius: 10px;
  }

  #os-chat-widget {
    bottom: 16px;
    right: 16px;
  }
}
