/* ============================================
   AriaStar Chat — Full Stage Experience
   Desktop: takes over entire main area (sidebar stays)
   Mobile: full-screen takeover
   ============================================ */

/* --- Floating Button --- */
.ariastar-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.ariastar-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(99, 102, 241, 0.55);
}

/* Hide FAB when panel is open */
.ariastar-fab.open {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

.ariastar-fab-icon {
  font-size: 1.5rem;
  line-height: 1;
  color: white;
}

/* Pulse animation on first load */
@keyframes ariastarPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4); }
  50% { box-shadow: 0 4px 30px rgba(99, 102, 241, 0.7); }
}

.ariastar-fab.pulse {
  animation: ariastarPulse 2s ease-in-out 3;
}

/* --- Full-Stage Panel — fills everything right of sidebar --- */
.ariastar-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 220px; /* Align to sidebar edge */
  background: var(--bg, #0f172a);
  z-index: 899;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.ariastar-panel.open {
  transform: translateX(0);
}

/* Desktop: hide main content when AriaStar is active */
@media (min-width: 769px) {
  body.ariastar-active .main {
    visibility: hidden;
    pointer-events: none;
  }
}

/* Backdrop — not needed on desktop (panel covers everything) */
.ariastar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 898;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  display: none;
}

.ariastar-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Panel Header */
.ariastar-panel-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 2rem;
  background: var(--bg-card, #1e293b);
  border-bottom: 1px solid var(--border, #334155);
  flex-shrink: 0;
}

.ariastar-panel-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.ariastar-panel-title {
  flex: 1;
  min-width: 0;
}

.ariastar-panel-name {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text, #f8fafc);
}

.ariastar-panel-status {
  font-size: 0.85rem;
  color: var(--secondary, #10b981);
}

.ariastar-panel-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ariastar-panel-btn {
  padding: 0.5rem;
  background: none;
  border: none;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ariastar-panel-btn:hover {
  background: var(--bg-hover, #334155);
  color: var(--text, #f8fafc);
}

.ariastar-delete-current:hover {
  color: #ef4444;
}

/* End chat — green hover to distinguish from Delete (red). End is a
   constructive action: it saves the conversation summary and triggers
   decision-memory + Bridge Map milestone extraction in the background. */
.ariastar-end-current:hover {
  color: #22c55e;
}

/* Labeled panel buttons (New chat, History) — show inline text on
   wider viewports so the affordance is unmistakable. Stays icon-only
   on narrow viewports to avoid header overflow. */
.ariastar-panel-btn-labeled {
  gap: 0.4rem;
  padding: 0.4rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: inherit;
}

.ariastar-panel-btn-label {
  display: none;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

@media (min-width: 720px) {
  .ariastar-panel-btn-label {
    display: inline;
  }
}

/* Messages — centered column with max-width for readability */
.ariastar-panel-messages {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}

.ariastar-msg {
  max-width: 80%;
  padding: 1rem 1.25rem;
  border-radius: 18px;
  font-size: 1rem;
  line-height: 1.7;
}

.ariastar-msg.assistant {
  background: var(--bg-card, #1e293b);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  color: var(--text, #f8fafc);
  position: relative;
}

/* Blueprint 32 Phase 3B — per-message actions (copy + thumbs) */
.ariastar-msg-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  opacity: 0.9;
  transition: opacity 0.15s;
}
.ariastar-msg.assistant:hover .ariastar-msg-actions { opacity: 1; }

.ariastar-msg-action-btn {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: var(--text-muted, #94a3b8);
  border-radius: 8px;
  padding: 0.3rem 0.65rem;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
}
.ariastar-msg-action-btn:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--text, #f8fafc);
  border-color: var(--primary, #6366f1);
}
.ariastar-msg-action-btn.active {
  background: var(--primary, #6366f1);
  color: white;
  border-color: var(--primary, #6366f1);
}
.ariastar-msg-action-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.ariastar-msg.assistant p { margin: 0 0 0.6rem 0; }
.ariastar-msg.assistant p:last-child { margin-bottom: 0; }
.ariastar-msg.assistant strong { color: var(--primary, #6366f1); font-weight: 600; }
.ariastar-msg.assistant em { color: var(--text, #f8fafc); font-style: italic; }
.ariastar-msg.assistant ul, .ariastar-msg.assistant ol { margin: 0.3rem 0 0.6rem 0; padding-left: 1.4rem; }
.ariastar-msg.assistant li { margin-bottom: 0.25rem; line-height: 1.6; }

.ariastar-msg.user {
  background: var(--primary, #6366f1);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.ariastar-msg.loading {
  background: var(--bg-card, #1e293b);
  align-self: flex-start;
  color: var(--text-muted, #94a3b8);
  border-bottom-left-radius: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.6rem 1rem;
}

.ariastar-msg.loading .thinking-text {
  font-size: 0.85rem;
  font-style: italic;
}

.ariastar-msg.loading .thinking-dots {
  display: flex;
  align-items: center;
  gap: 3px;
}

.ariastar-msg.loading .thinking-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary, #6366f1);
  opacity: 0.5;
  animation: ariaThinkPulse 1.4s ease-in-out infinite;
}

.ariastar-msg.loading .thinking-dot:nth-child(2) {
  animation-delay: 150ms;
}

.ariastar-msg.loading .thinking-dot:nth-child(3) {
  animation-delay: 300ms;
}

@keyframes ariaThinkPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* Action result badges */
.ariastar-action-result {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  align-self: flex-start;
  padding: 0.5rem 0.85rem;
  border-radius: 10px;
  font-size: 0.8rem;
  line-height: 1.4;
  margin-top: -0.25rem;
}
.ariastar-action-result.success {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.25);
  color: #4ade80;
}
.ariastar-action-result.failure {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #f87171;
}
.ariastar-action-icon {
  font-size: 0.9rem;
  font-weight: 700;
  flex-shrink: 0;
}
.ariastar-action-label {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.ariastar-action-detail {
  display: block;
  font-size: 0.75rem;
  opacity: 0.75;
}

/* Quick actions in messages */
.ariastar-quick-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.ariastar-quick-action {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.7rem;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 8px;
  color: var(--primary, #6366f1);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}

.ariastar-quick-action:hover {
  background: rgba(99, 102, 241, 0.25);
}

/* Suggestions — centered with messages */
.ariastar-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0 2rem 1rem;
  flex-shrink: 0;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  justify-content: center;
}

.ariastar-suggestion {
  padding: 0.55rem 1rem;
  background: var(--bg, #0f172a);
  border: 1px solid var(--border, #334155);
  border-radius: 20px;
  color: var(--text-muted, #94a3b8);
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s;
}

.ariastar-suggestion:hover {
  border-color: var(--primary, #6366f1);
  color: var(--primary, #6366f1);
}

/* Input Area — centered with messages */
.ariastar-panel-input {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 2rem 1.25rem;
  border-top: 1px solid var(--border, #334155);
  background: var(--bg-card, #1e293b);
  flex-shrink: 0;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}

/* Full-width input wrapper so it stretches edge-to-edge */
.ariastar-panel > .ariastar-panel-input {
  max-width: none;
  background: var(--bg-card, #1e293b);
}

.ariastar-panel-input-inner {
  display: flex;
  gap: 0.75rem;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}

.ariastar-input {
  flex: 1;
  padding: 0.75rem 1rem;
  background: var(--bg, #0f172a);
  border: 1px solid var(--border, #334155);
  border-radius: 12px;
  color: var(--text, #f8fafc);
  font-size: 1rem;
  font-family: inherit;
  min-height: 48px;
  /* textarea-specific (no-op for non-textarea elements) */
  resize: none;
  line-height: 1.4;
  max-height: 400px;
  overflow-y: auto;
}

.ariastar-input:focus {
  border-color: var(--primary, #6366f1);
  outline: none;
}

.ariastar-send-btn {
  padding: 0.75rem 1.15rem;
  background: var(--primary, #6366f1);
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  min-width: 48px;
  min-height: 48px;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ariastar-send-btn:hover {
  background: var(--primary-dark, #4f46e5);
}

.ariastar-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Image Upload Button + Preview --- */
.ariastar-image-btn {
  padding: 0.65rem;
  background: var(--bg, #0f172a);
  border: 1px solid var(--border, #334155);
  border-radius: 12px;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
  color: var(--text-muted, #94a3b8);
  flex-shrink: 0;
}
.ariastar-image-btn:hover {
  border-color: var(--primary, #6366f1);
  color: var(--primary, #6366f1);
}
.ariastar-image-btn:focus-visible {
  outline: 2px solid var(--primary, #6366f1);
  outline-offset: 2px;
}

/* File input hidden visually, but reachable for label clicks on Safari/iOS.
   Pure display:none can break label-triggered file pickers in some Safari
   versions; this position-off-screen pattern is the established Safari-safe
   alternative. */
.ariastar-file-input-hidden {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.ariastar-image-preview {
  display: none;
  padding: 0.5rem 2rem;
}
.ariastar-image-preview.has-images {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.ariastar-image-preview img {
  max-height: 64px;
  border-radius: 6px;
  object-fit: cover;
}
.ariastar-image-thumb {
  position: relative;
  display: inline-block;
}
.ariastar-image-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.65);
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.ariastar-image-remove:hover {
  background: rgba(239, 68, 68, 0.85);
}

/* --- History Panel — overlays messages area only (below header) --- */
.ariastar-history-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--bg, #0f172a);
}

.ariastar-history-panel.open {
  display: flex;
}

/* History visibility is controlled via JS — see shared-ariastar.js toggleHistoryView() */

.ariastar-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border, #334155);
  flex-shrink: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text, #f8fafc);
}

.ariastar-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.ariastar-history-item {
  padding: 1rem 1.25rem;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
  margin-bottom: 0.5rem;
}

.ariastar-history-item:hover {
  background: var(--bg-card, #1e293b);
  border-color: var(--border, #334155);
}

.ariastar-history-item.active {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.3);
}

.ariastar-history-item-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.ariastar-history-item-summary {
  font-size: 0.95rem;
  color: var(--text, #f8fafc);
  line-height: 1.5;
  margin-bottom: 0.4rem;
  flex: 1;
  min-width: 0;
}

.ariastar-history-item-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.ariastar-history-item:hover .ariastar-history-item-actions {
  opacity: 1;
}

.ariastar-history-action {
  padding: 0.3rem;
  background: none;
  border: none;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.ariastar-history-action:hover {
  background: var(--bg-hover, #334155);
  color: var(--text, #f8fafc);
}

.ariastar-history-action-delete:hover {
  color: #ef4444;
}

.ariastar-history-item-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.78rem;
  color: var(--text-muted, #94a3b8);
}

.ariastar-history-status-active {
  color: var(--secondary, #10b981);
}

.ariastar-history-status-completed {
  color: var(--text-muted, #94a3b8);
}

.ariastar-history-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted, #94a3b8);
  font-size: 0.95rem;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
  .ariastar-panel {
    left: 0; /* No sidebar on mobile */
    width: 100vw;
  }

  /* Show backdrop on mobile */
  .ariastar-backdrop {
    display: block;
  }

  .ariastar-fab {
    bottom: 1rem;
    right: 1rem;
    width: 54px;
    height: 54px;
  }

  .ariastar-panel-header {
    padding: 1rem 1.25rem;
  }

  .ariastar-panel-messages {
    padding: 1.25rem;
  }

  .ariastar-msg {
    max-width: 90%;
  }

  .ariastar-suggestions {
    padding: 0 1.25rem 0.75rem;
  }

  .ariastar-panel-input {
    padding: 0.85rem 1.25rem;
  }

  .ariastar-history-header {
    padding: 1rem 1.25rem;
  }

  .ariastar-history-list {
    padding: 0.75rem;
  }
}

/* ============================================
   LGAAS Modal — replaces native confirm()/alert()
   Dark theme matching the application design
   ============================================ */
.lgaas-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.lgaas-modal-overlay.visible {
  opacity: 1;
}

.lgaas-modal {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 1.75rem;
  min-width: 320px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transform: scale(0.95) translateY(8px);
  transition: transform 0.15s ease;
}

.lgaas-modal-overlay.visible .lgaas-modal {
  transform: scale(1) translateY(0);
}

.lgaas-modal-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.lgaas-modal-icon.danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.lgaas-modal-icon.info {
  background: rgba(99, 102, 241, 0.15);
  color: #6366f1;
}

.lgaas-modal-icon.warning {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.lgaas-modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #f8fafc;
  margin-bottom: 0.5rem;
}

.lgaas-modal-message {
  font-size: 0.92rem;
  color: #94a3b8;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.lgaas-modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.lgaas-modal-btn {
  padding: 0.55rem 1.15rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  font-family: inherit;
}

.lgaas-modal-btn-cancel {
  background: #334155;
  color: #cbd5e1;
}

.lgaas-modal-btn-cancel:hover {
  background: #475569;
  color: #f8fafc;
}

.lgaas-modal-btn-confirm {
  background: #6366f1;
  color: white;
}

.lgaas-modal-btn-confirm:hover {
  background: #4f46e5;
}

.lgaas-modal-btn-danger {
  background: #dc2626;
  color: white;
}

.lgaas-modal-btn-danger:hover {
  background: #b91c1c;
}

/* ============================================================================
   Blueprint 32 Phase 4 — Coaching Layer specialist mode chip strip
   ============================================================================ */
.ariastar-mode-bar {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.55);
  scrollbar-width: none;
}

.ariastar-mode-bar::-webkit-scrollbar {
  display: none;
}

.ariastar-mode-chip {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.10);
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.ariastar-mode-chip:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
}

.ariastar-mode-chip.active {
  background: #6366f1;
  color: #ffffff;
  border-color: #6366f1;
}

.ariastar-mode-chip.active:hover {
  background: #4f46e5;
  border-color: #4f46e5;
}

/* ============================================================================
   Blueprint 52 Gap B / Blueprint 61 — Ephemeral metric-capture banner
   ============================================================================
   Hidden by default; setEphemeralState(true) flips display to flex.
   The "Save to thread" button uses the brand accent so it reads as the
   primary action affordance, not background informational copy. */
.ariastar-ephemeral-banner {
  display: none;
  padding: 10px 14px;
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.12), rgba(139, 92, 246, 0.12));
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  font-size: 0.82rem;
  color: var(--text, #e6e8ed);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.ariastar-ephemeral-banner-text {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.ariastar-ephemeral-banner-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.ariastar-ephemeral-promote-btn {
  background: #6366f1;
  color: #ffffff;
  border: 1px solid #6366f1;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.ariastar-ephemeral-promote-btn:hover:not(:disabled) {
  background: #4f46e5;
  border-color: #4f46e5;
}

.ariastar-ephemeral-promote-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.ariastar-ephemeral-promote-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
