/* AIDEN — AcreetionOS AI Chat Widget */
/* OpenRouter (via site proxy) is the only backend. Pollinations references removed. */

#aiden-chat {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  font-family: var(--font-sans), 'Roboto', -apple-system, sans-serif;
}

#aiden-bubble {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--acreetion-green, #2ecc71);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(46, 204, 113, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  color: #000;
}

#aiden-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(46, 204, 113, 0.5);
}

#aiden-panel {
  display: none;
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: var(--acreetion-panel-bg, #1a1a1a);
  border: 1px solid var(--acreetion-box-border, #333);
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  animation: aidenSlideUp 0.25s ease;
}

#aiden-panel.open {
  display: flex;
}

@keyframes aidenSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

#aiden-header {
  background: var(--acreetion-box-bg, #222);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--acreetion-box-border, #333);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

#aiden-header-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--acreetion-text-bright, #e5e5e5);
  font-weight: 700;
  font-size: 0.95rem;
}

#aiden-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--acreetion-green, #2ecc71);
}

#aiden-header-actions {
  display: flex;
  gap: 0.5rem;
}

#aiden-clear-btn, #aiden-close-btn {
  background: none;
  border: none;
  color: var(--acreetion-text, #b2b2b2);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px 6px;
  border-radius: 6px;
  transition: color 0.15s;
}

#aiden-clear-btn:hover, #aiden-close-btn:hover {
  color: var(--acreetion-text-bright, #e5e5e5);
}

#aiden-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.aiden-msg {
  max-width: 85%;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.45;
  word-wrap: break-word;
}

.aiden-msg.ai {
  align-self: flex-start;
  background: var(--acreetion-box-bg, #222);
  color: var(--acreetion-text, #b2b2b2);
  border-bottom-left-radius: 4px;
}

.aiden-msg.user {
  align-self: flex-end;
  background: rgba(46, 204, 113, 0.15);
  color: var(--acreetion-text-bright, #e5e5e5);
  border-bottom-right-radius: 4px;
}

.aiden-msg.error {
  align-self: flex-start;
  background: rgba(224, 108, 117, 0.15);
  color: var(--gnome-color, #e06c75);
  font-size: 0.82rem;
}

.aiden-retry-btn {
  background: rgba(224,108,117,0.2);
  border: 1px solid rgba(224,108,117,0.4);
  color: var(--gnome-color,#e06c75);
  border-radius: 10px;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  cursor: pointer;
  margin-left: 0.4rem;
  transition: background 0.15s;
  vertical-align: middle;
}
.aiden-retry-btn:hover {
  background: rgba(224,108,117,0.35);
}

.aiden-msg.ai code {
  background: rgba(46, 204, 113, 0.15);
  padding: 0.1rem 0.4rem;
  border-radius: 8px;
  font-family: var(--font-mono), 'Fira Code', monospace;
  font-size: 0.82rem;
  color: var(--acreetion-green, #2ecc71);
}

#aiden-typing {
  align-self: flex-start;
  color: var(--acreetion-text, #b2b2b2);
  font-size: 0.82rem;
  padding: 0.4rem 0.75rem;
  display: none;
}

#aiden-typing span {
  animation: aidenBlink 1.4s infinite;
}

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

@keyframes aidenBlink {
  0%, 60%, 100% { opacity: 0.3; }
  30% { opacity: 1; }
}

#aiden-input-area {
  border-top: 1px solid var(--acreetion-box-border, #333);
  padding: 0.6rem 0.75rem;
  flex-shrink: 0;
}

#aiden-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.aiden-chip {
  background: rgba(46, 204, 113, 0.1);
  border: 1px solid rgba(46, 204, 113, 0.2);
  color: var(--acreetion-green, #2ecc71);
  border-radius: 14px;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.aiden-chip:hover {
  background: rgba(46, 204, 113, 0.2);
}

#aiden-input-row {
  display: flex;
  gap: 0.5rem;
}

#aiden-input {
  flex: 1;
  background: var(--acreetion-box-bg, #222);
  border: 1px solid var(--acreetion-box-border, #333);
  border-radius: 20px;
  padding: 0.5rem 0.9rem;
  color: var(--acreetion-text-bright, #e5e5e5);
  font-size: 0.88rem;
  font-family: var(--font-sans), 'Roboto', sans-serif;
  outline: none;
}

#aiden-input:focus {
  border-color: var(--acreetion-green, #2ecc71);
}

#aiden-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--acreetion-green, #2ecc71);
  border: none;
  cursor: pointer;
  color: #000;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

#aiden-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#aiden-send:hover:not(:disabled) {
  background: #27ae60;
}

#aiden-backend-info {
  text-align: center;
  padding: 0.3rem 0.75rem;
  font-size: 0.68rem;
  color: var(--acreetion-text, #777);
  flex-shrink: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

#aiden-backend-info a {
  color: var(--acreetion-text, #777);
  text-decoration: underline;
}

#aiden-fallback-link {
  display: none;
  cursor: pointer;
  color: var(--storm-color, #61afef) !important;
  text-decoration: underline !important;
}

#aiden-fallback-link:hover {
  color: var(--acreetion-green, #2ecc71) !important;
}

@media (max-width: 480px) {
  #aiden-panel {
    right: 8px;
    bottom: 80px;
    width: calc(100vw - 16px);
    height: 420px;
  }
  #aiden-bubble {
    right: 8px;
    bottom: 16px;
    width: 46px;
    height: 46px;
    font-size: 1.2rem;
  }
}

/* Trump AI overrides — gold & navy theme for TrumpOS page */
body.trumpos-theme #aiden-bubble {
  background: #D4AF37;
  box-shadow: 0 4px 20px rgba(212, 175, 55, 0.45);
  color: #002147;
  font-weight: 900;
}
body.trumpos-theme #aiden-bubble:hover {
  box-shadow: 0 6px 28px rgba(212, 175, 55, 0.65);
}
body.trumpos-theme #aiden-panel {
  background: #002147;
  border-color: #D4AF37;
}
body.trumpos-theme #aiden-header {
  background: #D4AF37;
  color: #002147;
}
body.trumpos-theme #aiden-header-title span {
  color: #002147;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
}
body.trumpos-theme #aiden-status-dot {
  background: #002147;
}
body.trumpos-theme #aiden-clear-btn,
body.trumpos-theme #aiden-close-btn {
  color: #002147;
}
body.trumpos-theme #aiden-messages {
  background: #0a1a2f;
}
body.trumpos-theme .aiden-msg.ai {
  background: rgba(212, 175, 55, 0.12);
  color: #f0d060;
  border-color: rgba(212, 175, 55, 0.3);
}
body.trumpos-theme .aiden-msg.user {
  background: #D4AF37;
  color: #002147;
}
body.trumpos-theme .aiden-msg.error {
  background: rgba(198, 12, 48, 0.15);
  color: #ff6b6b;
  border-color: rgba(198, 12, 48, 0.3);
}
body.trumpos-theme .aiden-chip {
  background: rgba(212, 175, 55, 0.15);
  color: #D4AF37;
  border-color: rgba(212, 175, 55, 0.3);
}
body.trumpos-theme .aiden-chip:hover {
  background: #D4AF37;
  color: #002147;
}
body.trumpos-theme #aiden-input {
  background: rgba(0, 33, 71, 0.6);
  color: #D4AF37;
  border-color: rgba(212, 175, 55, 0.4);
}
body.trumpos-theme #aiden-input::placeholder {
  color: rgba(212, 175, 55, 0.5);
}
body.trumpos-theme #aiden-send {
  background: #D4AF37;
  color: #002147;
}
body.trumpos-theme #aiden-backend-info {
  color: rgba(212, 175, 55, 0.6);
  border-color: rgba(212, 175, 55, 0.2);
}
body.trumpos-theme #aiden-backend-info a {
  color: #D4AF37;
}
body.trumpos-theme .aiden-retry-btn {
  background: #D4AF37;
  color: #002147;
}

#aiden-mic-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--acreetion-green, #2ecc71);
  border: none;
  cursor: pointer;
  color: #000;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, box-shadow 0.2s;
}

#aiden-mic-btn:hover {
  background: #27ae60;
}

#aiden-mic-btn.aiden-active-mic {
  background: #e74c3c;
  box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.3);
  animation: micPulse 1s ease-in-out infinite;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(231, 76, 60, 0.15); }
}

#aiden-voice-btn.aiden-active-tts {
  color: #fff;
  background: var(--acreetion-green, #2ecc71);
}

.aiden-streaming::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 14px;
  background: var(--acreetion-text-bright, #e5e5e5);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: streamBlink 0.6s infinite;
}

@keyframes streamBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

/* ── Voice hint ── */
.aiden-voice-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--acreetion-text, #777);
  padding: 0.3rem 0.75rem;
  transition: opacity 0.5s ease;
  opacity: 0;
  pointer-events: none;
}

.aiden-voice-hint em {
  color: var(--acreetion-green, #2ecc71);
  font-style: normal;
  font-weight: 600;
}

/* ── Interim (live transcription) ── */
.aiden-interim-text {
  display: none;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  color: var(--acreetion-green, #2ecc71);
  font-style: italic;
  border-top: 1px dashed var(--acreetion-box-border, #333);
  background: rgba(46, 204, 113, 0.05);
  min-height: 1.4em;
}

/* ── Accessibility Controls ── */
#aiden-voice-btn,
#aiden-caption-btn,
#aiden-mic-btn,
#aiden-zoom-out-btn,
#aiden-zoom-reset-btn,
#aiden-zoom-in-btn {
  background: none;
  border: none;
  color: var(--acreetion-text, #b2b2b2);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 2px 6px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

#aiden-voice-btn:hover,
#aiden-caption-btn:hover,
#aiden-mic-btn:hover,
#aiden-zoom-out-btn:hover,
#aiden-zoom-reset-btn:hover,
#aiden-zoom-in-btn:hover {
  color: var(--acreetion-text-bright, #e5e5e5);
  background: rgba(255, 255, 255, 0.06);
}

#aiden-clear-btn, #aiden-close-btn {
  background: none;
  border: none;
  color: var(--acreetion-text, #b2b2b2);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px 6px;
  border-radius: 6px;
  transition: color 0.15s;
}

#aiden-clear-btn:hover, #aiden-close-btn:hover {
  color: var(--acreetion-text-bright, #e5e5e5);
}

/* ── TTS active / speaking states ── */
#aiden-voice-btn.aiden-active {
  color: var(--acreetion-green, #2ecc71);
  background: rgba(46, 204, 113, 0.15);
}

#aiden-voice-btn.aiden-speaking {
  color: #fff;
  background: var(--acreetion-green, #2ecc71);
  animation: aidenVoicePulse 1.2s ease-in-out infinite;
}

@keyframes aidenVoicePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ── Input row with mic ── */
#aiden-input-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

#aiden-zoom-out-btn,
#aiden-zoom-reset-btn,
#aiden-zoom-in-btn {
  font-size: 0.85rem;
  font-weight: 700;
  min-width: 28px;
  text-align: center;
}

/* ── Captions ── */
#aiden-captions {
  display: none;
  background: rgba(46, 204, 113, 0.1);
  border: 1px solid rgba(46, 204, 113, 0.25);
  border-radius: 10px;
  padding: 0.6rem 0.85rem;
  margin: 0.4rem 0;
  font-size: 0.82rem;
  color: var(--acreetion-text-bright, #e5e5e5);
  line-height: 1.4;
  word-wrap: break-word;
  max-width: 100%;
}

/* ── Trump theme overrides for accessibility controls ── */
body.trumpos-theme #aiden-voice-btn,
body.trumpos-theme #aiden-caption-btn,
body.trumpos-theme #aiden-zoom-out-btn,
body.trumpos-theme #aiden-zoom-reset-btn,
body.trumpos-theme #aiden-zoom-in-btn {
  color: #002147;
}

body.trumpos-theme #aiden-voice-btn:hover,
body.trumpos-theme #aiden-caption-btn:hover,
body.trumpos-theme #aiden-zoom-out-btn:hover,
body.trumpos-theme #aiden-zoom-reset-btn:hover,
body.trumpos-theme #aiden-zoom-in-btn:hover {
  color: #D4AF37;
  background: rgba(212, 175, 55, 0.12);
}

body.trumpos-theme #aiden-voice-btn.aiden-active,
body.trumpos-theme #aiden-caption-btn.aiden-active {
  color: #D4AF37;
  background: rgba(212, 175, 55, 0.2);
}

body.trumpos-theme #aiden-voice-btn.aiden-speaking {
  color: #002147;
  background: #D4AF37;
}

body.trumpos-theme #aiden-mic-btn {
  color: #002147;
}

body.trumpos-theme #aiden-mic-btn:hover {
  color: #D4AF37;
  background: rgba(212, 175, 55, 0.12);
}

body.trumpos-theme #aiden-mic-btn.aiden-active-mic {
  background: #c0392b;
  box-shadow: 0 0 0 4px rgba(192, 57, 43, 0.3);
}

body.trumpos-theme #aiden-voice-btn.aiden-active-tts {
  color: #D4AF37;
  background: rgba(212, 175, 55, 0.2);
}

body.trumpos-theme #aiden-captions {
  background: rgba(212, 175, 55, 0.1);
  border-color: rgba(212, 175, 55, 0.3);
  color: #f0d060;
}

/* ── Go Live button ── */
#aiden-live-row {
  text-align: center;
  padding: 0.4rem 0.75rem 0.1rem;
  flex-shrink: 0;
}
#aiden-live-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--acreetion-green, #2ecc71);
  color: #000;
  border: none;
  border-radius: 20px;
  padding: 0.25rem 0.9rem;
  font-weight: 700;
  font-size: 0.78rem;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.2s, transform 0.1s;
}
#aiden-live-btn:hover {
  filter: brightness(1.1);
  transform: scale(1.04);
}
.aiden-live-dot {
  width: 6px;
  height: 6px;
  background: #000;
  border-radius: 50%;
  animation: aidenLivePulse 1.2s ease-in-out infinite;
}
@keyframes aidenLivePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}
body.trumpos-theme #aiden-live-btn {
  background: #D4AF37;
  color: #002147;
}
body.trumpos-theme .aiden-live-dot {
  background: #002147;
}

/* ── Panel width adjustment for extra buttons ── */
@media (max-width: 480px) {
  #aiden-panel {
    right: 8px;
    bottom: 80px;
  }
}
