/* ============================================================================
   ARAYA Music Intelligence Panel
   Part of the Consciousness Revolution platform
   Pattern: 3 -> 7 -> 13 -> Infinity | LFSME
   ============================================================================ */

/* ---------------------------------------------------------------------------
   CSS Custom Properties -- single source of truth
   --------------------------------------------------------------------------- */
:root {
  --araya-panel-width: 340px;
  --araya-bg: rgba(12, 12, 20, 0.92);
  --araya-border: rgba(255, 215, 0, 0.15);
  --araya-gold: #FFD700;
  --araya-gold-dim: rgba(255, 215, 0, 0.6);
  --araya-gold-glow: rgba(255, 215, 0, 0.12);
  --araya-user-bg: rgba(255, 255, 255, 0.08);
  --araya-user-text: #e0e0e0;
  --araya-ai-bg: rgba(255, 215, 0, 0.06);
  --araya-ai-text: #f5f0e0;
  --araya-input-bg: rgba(255, 255, 255, 0.06);
  --araya-scrollbar: rgba(255, 215, 0, 0.2);
  --araya-radius: 12px;
  --araya-transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------------------------------------------------------------------------
   Panel Container -- slides in from the right
   --------------------------------------------------------------------------- */
.araya-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--araya-panel-width);
  height: 100vh;
  height: 100dvh;
  background: var(--araya-bg);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border-left: 1px solid var(--araya-border);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.5);
  z-index: 9000;
  display: flex;
  flex-direction: column;

  /* Slide transition */
  transform: translateX(100%);
  opacity: 0;
  visibility: hidden;
  transition:
    transform var(--araya-transition),
    opacity var(--araya-transition),
    visibility 0s linear 0.35s;
}

.araya-panel.open {
  transform: translateX(0);
  opacity: 1;
  visibility: visible;
  transition:
    transform var(--araya-transition),
    opacity var(--araya-transition),
    visibility 0s linear 0s;
}

/* ---------------------------------------------------------------------------
   Header
   --------------------------------------------------------------------------- */
.araya-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--araya-border);
  flex-shrink: 0;
}

.araya-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.araya-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--araya-gold), #b8860b);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #0c0c14;
  flex-shrink: 0;
  box-shadow: 0 0 12px var(--araya-gold-glow);
}

.araya-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--araya-gold);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.araya-status {
  font-size: 10px;
  color: var(--araya-gold-dim);
  letter-spacing: 0.5px;
}

.araya-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
  line-height: 1;
}

.araya-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

/* ---------------------------------------------------------------------------
   Now Playing Context Bar
   --------------------------------------------------------------------------- */
.araya-now-playing {
  padding: 10px 20px;
  border-bottom: 1px solid var(--araya-border);
  background: var(--araya-gold-glow);
  flex-shrink: 0;
  display: none; /* shown via JS when a track is playing */
}

.araya-now-playing.active {
  display: block;
}

.araya-now-playing-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--araya-gold-dim);
  margin-bottom: 4px;
}

.araya-now-playing-title {
  font-size: 13px;
  color: var(--araya-gold);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.araya-now-playing-meta {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 2px;
}

/* ---------------------------------------------------------------------------
   Messages Area
   --------------------------------------------------------------------------- */
.araya-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Scrollbar styling */
.araya-messages::-webkit-scrollbar {
  width: 4px;
}

.araya-messages::-webkit-scrollbar-track {
  background: transparent;
}

.araya-messages::-webkit-scrollbar-thumb {
  background: var(--araya-scrollbar);
  border-radius: 2px;
}

.araya-messages {
  scrollbar-width: thin;
  scrollbar-color: var(--araya-scrollbar) transparent;
}

/* ---------------------------------------------------------------------------
   Message Bubbles
   --------------------------------------------------------------------------- */
.araya-message {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: var(--araya-radius);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: arayaFadeIn 0.25s ease-out;
}

.araya-message.araya {
  align-self: flex-start;
  background: var(--araya-ai-bg);
  color: var(--araya-ai-text);
  border: 1px solid rgba(255, 215, 0, 0.1);
  border-bottom-left-radius: 4px;
}

.araya-message.user {
  align-self: flex-end;
  background: var(--araya-user-bg);
  color: var(--araya-user-text);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom-right-radius: 4px;
}

/* Gold accent line on ARAYA messages */
.araya-message.araya::before {
  content: '';
  display: block;
  width: 20px;
  height: 2px;
  background: var(--araya-gold);
  margin-bottom: 6px;
  border-radius: 1px;
  opacity: 0.5;
}

/* Proactive insight style (unsolicited ARAYA messages) */
.araya-message.insight {
  align-self: flex-start;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.05), rgba(255, 215, 0, 0.02));
  color: var(--araya-gold-dim);
  border: 1px solid rgba(255, 215, 0, 0.08);
  font-style: italic;
  font-size: 12px;
  border-bottom-left-radius: 4px;
}

.araya-message.insight::before {
  display: none;
}

/* ---------------------------------------------------------------------------
   Typing Indicator
   --------------------------------------------------------------------------- */
.araya-typing {
  align-self: flex-start;
  padding: 10px 16px;
  display: none;
  gap: 5px;
  align-items: center;
}

.araya-typing.active {
  display: flex;
}

.araya-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--araya-gold-dim);
  animation: arayaTypingPulse 1.4s ease-in-out infinite;
}

.araya-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.araya-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

/* ---------------------------------------------------------------------------
   Quick Actions (suggested prompts)
   --------------------------------------------------------------------------- */
.araya-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 20px;
  border-top: 1px solid var(--araya-border);
  flex-shrink: 0;
}

.araya-quick-action {
  background: rgba(255, 215, 0, 0.06);
  border: 1px solid rgba(255, 215, 0, 0.12);
  color: var(--araya-gold-dim);
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.araya-quick-action:hover {
  background: rgba(255, 215, 0, 0.12);
  color: var(--araya-gold);
  border-color: rgba(255, 215, 0, 0.3);
}

/* ---------------------------------------------------------------------------
   Input Bar
   --------------------------------------------------------------------------- */
.araya-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--araya-border);
  flex-shrink: 0;
}

.araya-input {
  flex: 1;
  background: var(--araya-input-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e0e0e0;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 20px;
  outline: none;
  transition: border-color 0.2s ease;
  font-family: inherit;
}

.araya-input::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

.araya-input:focus {
  border-color: rgba(255, 215, 0, 0.3);
}

.araya-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--araya-gold), #b8860b);
  border: none;
  color: #0c0c14;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.araya-send:hover {
  transform: scale(1.08);
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.3);
}

.araya-send:active {
  transform: scale(0.95);
}

/* Arrow icon via CSS (no external dependency) */
.araya-send::after {
  content: '';
  display: block;
  width: 8px;
  height: 8px;
  border-top: 2px solid #0c0c14;
  border-right: 2px solid #0c0c14;
  transform: rotate(45deg) translate(-1px, 1px);
}

/* ---------------------------------------------------------------------------
   Toggle Button (floating, placed by the player)
   --------------------------------------------------------------------------- */
.araya-toggle {
  position: fixed;
  bottom: 100px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--araya-gold), #b8860b);
  border: none;
  color: #0c0c14;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  z-index: 8999;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.4),
    0 0 24px rgba(255, 215, 0, 0.15);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.araya-toggle:hover {
  transform: scale(1.1);
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.5),
    0 0 32px rgba(255, 215, 0, 0.25);
}

.araya-toggle.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

/* Notification dot */
.araya-toggle-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e74c3c;
  border: 2px solid #0c0c14;
  display: none;
}

.araya-toggle-dot.active {
  display: block;
  animation: arayaPulse 2s ease-in-out infinite;
}

/* ---------------------------------------------------------------------------
   Animations
   --------------------------------------------------------------------------- */
@keyframes arayaFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes arayaPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(231, 76, 60, 0);
  }
}

/* ---------------------------------------------------------------------------
   Mobile: Full-width overlay
   --------------------------------------------------------------------------- */
@media (max-width: 768px) {
  :root {
    --araya-panel-width: 100vw;
  }

  .araya-panel {
    width: 100vw;
    border-left: none;
    border-radius: 0;
  }

  .araya-toggle {
    bottom: 120px;
    right: 12px;
    width: 44px;
    height: 44px;
  }

  .araya-message {
    max-width: 85%;
    font-size: 14px;
  }

  .araya-input {
    font-size: 16px; /* prevent iOS zoom on focus */
  }
}

/* ---------------------------------------------------------------------------
   Reduced Motion
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .araya-panel {
    transition: none;
  }

  .araya-message {
    animation: none;
  }

  .araya-typing-dot {
    animation: none;
    opacity: 0.6;
  }

  .araya-toggle-dot.active {
    animation: none;
  }
}
