/* Athena AI Agent Frontend Styles - SpaceX/NASA inspired */
:root {
    --aa-bg: #0b0f19;
    --aa-surface: #1a1f35;
    --aa-surface-light: #252b48;
    --aa-primary: #3b82f6;
    --aa-primary-hover: #2563eb;
    --aa-accent: #00d4ff;
    --aa-text: #f8fafc;
    --aa-text-secondary: #cbd5e1;
    --aa-border: #334155;
    --aa-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --aa-radius: 16px;
    --aa-radius-sm: 8px;
    --aa-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* Root container */
.aa-root {
    font-family: var(--aa-font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--aa-text);
}

/* Launcher button */
.aa-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--aa-primary), var(--aa-accent));
    border: none;
    cursor: pointer;
    box-shadow: var(--aa-shadow);
    z-index: 10000;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.aa-launcher:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(59, 130, 246, 0.4);
}

.aa-launcher-core {
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 2px;
    position: relative;
    transform: rotate(45deg);
    transition: transform 0.3s ease;
}

.aa-launcher:hover .aa-launcher-core {
    transform: rotate(90deg);
}

/* Floating chat window */
.aa-chat {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 400px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 140px);
    background: var(--aa-bg);
    border: 1px solid var(--aa-border);
    border-radius: var(--aa-radius);
    box-shadow: var(--aa-shadow);
    z-index: 9999;
    /* IMPORTANT: hidden by default to prevent flash */
    display: none;
    opacity: 0;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(20px);
    transition: opacity 0.3s ease;
}

/* Visible state controlled by JS */
.aa-chat.aa-open {
    display: flex;
    opacity: 1;
}

.aa-chat-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

/* Header */
.aa-chat-header {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--aa-surface);
    border-bottom: 1px solid var(--aa-border);
    cursor: move;
    user-select: none;
}

.aa-logo {
    width: 32px;
    height: 32px;
    margin-right: 12px;
    flex-shrink: 0;
}

.aa-logo img {
    width: 100%;
    height: 100%;
    border-radius: 6px;
}

.aa-titles {
    flex: 1;
}

.aa-titles strong {
    display: block;
    font-size: 16px;
    font-weight: 600;
}

.aa-titles span {
    font-size: 12px;
    color: var(--aa-text-secondary);
}

.aa-controls {
    display: flex;
    gap: 4px;
}

.aa-iconbtn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--aa-text-secondary);
    border-radius: var(--aa-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
}

.aa-iconbtn:hover {
    background: var(--aa-surface-light);
    color: var(--aa-text);
}

/* Chat log */
.aa-chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.aa-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--aa-radius-sm);
    line-height: 1.5;
    position: relative;
    animation: aa-message-appear 0.3s ease-out;
}

@keyframes aa-message-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.aa-message-user {
    align-self: flex-end;
    background: var(--aa-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.aa-message-assistant {
    align-self: flex-start;
    background: var(--aa-surface-light);
    border: 1px solid var(--aa-border);
    border-bottom-left-radius: 4px;
}

/* Copy button in assistant messages */
.aa-copy {
  position: absolute;
  top: 6px;
  right: 8px;
  padding: 2px 8px;
  font-size: 10px;
  border-radius: 999px;
  border: 1px solid var(--aa-border);
  background: rgba(15,23,42,0.98);
  color: var(--aa-text-secondary);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
}

.aa-message-assistant:hover .aa-copy {
  opacity: 1;
  pointer-events: auto;
}


/* Message labels */
.aa-message-label {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 6px;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.aa-message-user .aa-message-label {
    text-align: right;
    color: var(--aa-accent);
}

.aa-message-assistant .aa-message-label {
    color: var(--aa-accent);
}

.aa-message-assistant .aa-citations {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--aa-border);
    font-size: 12px;
    color: var(--aa-text-secondary);
}

.aa-message-assistant .aa-citations a {
    color: var(--aa-accent);
    text-decoration: none;
}

.aa-message-assistant .aa-citations a:hover {
    text-decoration: underline;
}

.aa-actions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--aa-border);
}

.aa-actions-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--aa-accent);
    margin-bottom: 8px;
}

.aa-actions-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.aa-action-item {
    font-size: 12px;
    color: var(--aa-text-secondary);
    padding-left: 12px;
    position: relative;
}

.aa-action-item:before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--aa-accent);
}

/* Suggestions */
.aa-chat-suggestions {
    padding: 12px 16px;
    border-top: 1px solid var(--aa-border);
    background: var(--aa-surface);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.aa-chip {
    padding: 6px 12px;
    background: var(--aa-surface-light);
    border: 1px solid var(--aa-border);
    border-radius: 20px;
    color: var(--aa-text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.aa-chip:hover {
    background: var(--aa-primary);
    color: white;
    transform: translateY(-1px);
}

/* Input area - full-width pill with sleek inline buttons */
.aa-chat-input {
    padding: 12px 16px 8px;
    border-top: 1px solid var(--aa-border);
    background: var(--aa-surface);
    position: relative;
}

/* Full-width rounded input */
.aa-chat-input textarea {
    width: 100%;
    box-sizing: border-box;
    background: var(--aa-bg);
    border: 1px solid var(--aa-border);
    border-radius: 999px;
    color: var(--aa-text);
    padding: 10px 120px 10px 14px; /* room for mic + send pills */
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    min-height: 42px;
    max-height: 140px;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background-color 0.2s ease;
}

.aa-chat-input textarea:focus {
    outline: none;
    border-color: var(--aa-primary);
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.25);
    background: #020817;
}

/* Shared pill style for mic + send */
.aa-voice-btn,
.aa-send {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 30px;
    padding: 0 14px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.5);
}

/* Voice pill (subtle/ghost) */
.aa-voice-btn {
    right: 78px;
    background: rgba(10, 16, 30, 0.98);
    color: var(--aa-text-secondary);
    border: 1px solid rgba(148, 163, 253, 0.35);
    backdrop-filter: blur(10px);
}

.aa-voice-btn:hover {
    color: #e5e7eb;
    border-color: var(--aa-primary);
    box-shadow: 0 4px 18px rgba(59, 130, 246, 0.45);
    transform: translateY(-50%) translateX(-1px);
}

/* Send pill (primary gradient) */
.aa-send {
    right: 24px;
    background: linear-gradient(135deg, var(--aa-primary), var(--aa-accent));
    color: #ffffff;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.aa-send:hover {
    background: linear-gradient(135deg, var(--aa-primary-hover), var(--aa-accent));
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
    transform: translateY(-50%) translateX(-1px);
}

/* Helper text */
.aa-mini {
    padding: 2px 16px 10px;
    font-size: 11px;
    color: var(--aa-text-secondary);
    text-align: center;
}

.aa-mini kbd {
    background: var(--aa-surface-light);
    border: 1px solid var(--aa-border);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
}




/* Contact Form Styles */
.aa-contact-form {
    background: var(--aa-surface-light);
    border: 1px solid var(--aa-border);
    border-radius: var(--aa-radius-sm);
    padding: 16px;
    margin-top: 12px;
    animation: aa-message-appear 0.3s ease-out;
}

.aa-contact-form h4 {
    margin: 0 0 12px 0;
    color: var(--aa-accent);
    font-size: 14px;
    font-weight: 600;
}

.aa-form-group {
    margin-bottom: 12px;
}

.aa-form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    color: var(--aa-text-secondary);
    font-weight: 500;
}

.aa-form-group input,
.aa-form-group textarea {
    width: 100%;
    background: var(--aa-bg);
    border: 1px solid var(--aa-border);
    border-radius: var(--aa-radius-sm);
    color: var(--aa-text);
    padding: 8px 12px;
    font-family: inherit;
    font-size: 13px;
    transition: border-color 0.2s ease;
}

.aa-form-group input:focus,
.aa-form-group textarea:focus {
    outline: none;
    border-color: var(--aa-primary);
}

.aa-form-group textarea {
    resize: vertical;
    min-height: 60px;
}

.aa-form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

.aa-form-submit {
    background: var(--aa-primary);
    border: none;
    border-radius: var(--aa-radius-sm);
    color: white;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.aa-form-submit:hover {
    background: var(--aa-primary-hover);
}

.aa-form-cancel {
    background: transparent;
    border: 1px solid var(--aa-border);
    border-radius: var(--aa-radius-sm);
    color: var(--aa-text-secondary);
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
}

.aa-form-cancel:hover {
    background: var(--aa-surface);
    color: var(--aa-text);
}

.aa-form-message {
    margin-top: 12px;
    padding: 8px 12px;
    border-radius: var(--aa-radius-sm);
    font-size: 12px;
    text-align: center;
}

.aa-form-message.success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #22c55e;
}

.aa-form-message.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

/* Responsive */
@media (max-width: 768px) {
  .aa-launcher {
    bottom: 18px;
    right: 18px;
    width: 56px;
    height: 56px;
    box-shadow: 0 6px 22px rgba(15, 23, 42, 0.6);
  }

  .aa-chat {
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 18px 18px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.6);
  }

  /* Slightly shorter if the browser supports safe areas / nav bars */
  .aa-chat-shell {
    padding-top: env(safe-area-inset-top, 6px);
  }

  .aa-chat-header {
    padding: 12px 14px;
    cursor: default;            /* no drag handle feel on mobile */
  }

  .aa-logo {
    width: 28px;
    height: 28px;
    margin-right: 8px;
  }

  .aa-titles strong {
    font-size: 15px;
  }

  .aa-titles span {
    font-size: 11px;
  }

  /* Reduce chrome in header on mobile: hide less-used controls */
  .aa-chat-header .aa-iconbtn[data-act="export"],
  .aa-chat-header .aa-iconbtn[data-act="clear"] {
    display: none;
  }

  .aa-chat-log {
    padding: 12px;
    gap: 10px;
  }

  .aa-message {
    max-width: 92%;
    padding: 10px 12px;
    font-size: 13px;
  }

  .aa-copy {
    top: 4px;
    right: 6px;
    padding: 1px 6px;
    font-size: 9px;
  }

  .aa-chat-input {
    padding: 8px 10px 6px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  }

  .aa-chat-input textarea {
    border-radius: 14px;
    padding: 9px 96px 9px 11px;
    min-height: 38px;
    font-size: 13px;
  }

  .aa-voice-btn,
  .aa-send {
    height: 28px;
    padding: 0 10px;
    font-size: 11px;
    top: 50%;
  }

  .aa-voice-btn {
    right: 64px;
  }

  .aa-send {
    right: 16px;
  }

  .aa-mini {
    font-size: 10px;
    padding: 2px 10px 6px;
  }

  /* Tooltip: tuck closer to launcher on mobile */
  .aa-helper-tooltip {
    right: 16px;
    bottom: 90px;
    max-width: 70vw;
    font-size: 12px;
    padding: 8px 12px;
  }
}


/* Drag state */
.aa-chat-shell[data-aa-dragging] {
    cursor: grabbing;
    user-select: none;
}

/* Collapsed state */
.aa-chat[data-aa-collapsed] {
    height: auto;
    max-height: 44px;
    overflow: hidden;
}

.aa-chat[data-aa-collapsed] .aa-chat-log,
.aa-chat[data-aa-collapsed] .aa-chat-suggestions,
.aa-chat[data-aa-collapsed] .aa-chat-input,
.aa-chat[data-aa-collapsed] .aa-mini {
    display: none;
}

/* Loading animation */
.aa-typing {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.aa-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--aa-text-secondary);
    border-radius: 50%;
    animation: aa-typing 1.4s infinite ease-in-out;
}

.aa-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.aa-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes aa-typing {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Fix for citations and contact form */
.aa-content {
  margin-bottom: 12px;
}

/* Rich content bullet lists inside assistant messages */
.aa-message-assistant .aa-list {
  margin: 4px 0 0;
  padding-left: 18px;
  list-style: disc;
}

.aa-message-assistant .aa-list li {
  margin: 2px 0;
  color: var(--aa-text-secondary);
}

.aa-citations {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--aa-border);
  font-size: 12px;
}


.aa-citations-title {
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--aa-text-secondary);
}

.aa-citations ul {
  margin: 0;
  padding-left: 16px;
  list-style: none;
}

.aa-citations li {
  margin-bottom: 4px;
}

.aa-citations a {
  color: var(--aa-accent);
  text-decoration: none;
}

.aa-citations a:hover {
  text-decoration: underline;
}

/* Contact form styles */
.aa-contact-form {
  margin-top: 16px;
  padding: 16px;
  background: var(--aa-surface-light);
  border: 1px solid var(--aa-border);
  border-radius: var(--aa-radius-sm);
}

.aa-contact-form h4 {
  margin: 0 0 16px 0;
  color: var(--aa-accent);
  font-size: 16px;
  font-weight: 600;
}

.aa-form-group {
  margin-bottom: 16px;
}

.aa-form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--aa-text-secondary);
  font-weight: 500;
}

.aa-form-group input,
.aa-form-group textarea {
  width: 100%;
  background: var(--aa-bg);
  border: 1px solid var(--aa-border);
  border-radius: var(--aa-radius-sm);
  color: var(--aa-text);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.2s ease;
}

.aa-form-group input:focus,
.aa-form-group textarea:focus {
  outline: none;
  border-color: var(--aa-primary);
}

.aa-form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.aa-form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.aa-form-submit {
  background: var(--aa-primary);
  border: none;
  border-radius: var(--aa-radius-sm);
  color: white;
  padding: 10px 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.2s ease;
}

.aa-form-submit:hover {
  background: var(--aa-primary-hover);
}

.aa-form-cancel {
  background: transparent;
  border: 1px solid var(--aa-border);
  border-radius: var(--aa-radius-sm);
  color: var(--aa-text-secondary);
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.aa-form-cancel:hover {
  background: var(--aa-surface);
  color: var(--aa-text);
}

.aa-form-message {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--aa-radius-sm);
  font-size: 14px;
  text-align: center;
}

.aa-form-message.success {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #22c55e;
}

.aa-form-message.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

/* Typing animation */
.aa-typing-dots {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.aa-typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--aa-text-secondary);
  border-radius: 50%;
  animation: aa-typing 1.4s infinite ease-in-out;
}

.aa-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.aa-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes aa-typing {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* Ensure chat maintains its visual state */
.aa-chat {
    transition: opacity 0.3s ease;
}

.aa-chat.aa-open {
    opacity: 1;
}

/* Smooth transitions for all interactive elements */
.aa-launcher,
.aa-message,
.aa-chip {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Floating "How can I help?" tooltip */
.aa-helper-tooltip {
  position: fixed;
  bottom: 100px;
  right: 100px;
  background: rgba(26, 31, 53, 0.9);
  color: #f8fafc;
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-family: var(--aa-font);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(59, 130, 246, 0.3);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.5s ease;
  z-index: 9999;
  pointer-events: none;
}

/* Show state */
.aa-helper-tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

/* Tooltip glow pulse */
@keyframes aa-tooltip-glow {
  0%, 100% { box-shadow: 0 0 10px rgba(0,212,255,0.2); }
  50% { box-shadow: 0 0 20px rgba(0,212,255,0.4); }
}
.aa-helper-tooltip.show {
  animation: aa-tooltip-glow 3s infinite ease-in-out;
}

/* Pulse effect when listening */
.aa-voice-btn.aa-voice-listening {
  background: radial-gradient(circle at center, rgba(59,130,246,0.8) 0%, rgba(15,23,42,0.95) 60%);
  box-shadow: 0 0 0 0 rgba(59,130,246,0.6);
  animation: aaPulse 1.5s infinite;
  color: #fff;
}

@keyframes aaPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(59,130,246,0.6);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(59,130,246,0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(59,130,246,0);
  }
}

/* === Athena Status Indicator (Hybrid Version) === */
.aa-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.aa-status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #00ff8c; /* Calm green (idle/online) */
  box-shadow: 0 0 8px rgba(0, 255, 140, 0.6);
  transition: all 0.4s ease;
}

/* Pulse animation for "thinking" */
@keyframes aaPulseBlue {
  0%, 100% {
    transform: scale(1);
    opacity: 0.9;
    box-shadow: 0 0 8px rgba(0, 186, 255, 0.8);
  }
  50% {
    transform: scale(1.3);
    opacity: 1;
    box-shadow: 0 0 14px rgba(0, 186, 255, 1);
  }
}

/* Active (AI typing) state */
.aa-status-indicator[data-state="thinking"] {
  background-color: #00baff;
  animation: aaPulseBlue 2s ease-in-out infinite;
}

/* Error (offline or server issue) */
.aa-status-indicator[data-state="error"] {
  background-color: #ff4444;
  box-shadow: 0 0 8px rgba(255, 68, 68, 0.8);
  animation: none;
}

/* Mute button visual states */
.aa-iconbtn[data-act="mute"] {
  font-size: 16px;
  transition: color 0.2s ease;
}

.aa-iconbtn[data-act="mute"].muted {
  color: #ff4444;
}
