/* ═══════════════════════════════════════════════════════════════ */
/* DREAM AI PUBLIC ASSISTANT — Floating Chat Orb & Panel         */
/* Premium glassmorphism design with breathing animations        */
/* ═══════════════════════════════════════════════════════════════ */

:root {
  --ai-accent: #7c5cfc;
  --ai-accent-glow: rgba(124, 92, 252, 0.4);
  --ai-bg: rgba(15, 15, 25, 0.92);
  --ai-surface: rgba(255, 255, 255, 0.06);
  --ai-border: rgba(255, 255, 255, 0.08);
  --ai-text: #e8e6f0;
  --ai-text-muted: rgba(255, 255, 255, 0.5);
  --ai-radius: 24px;
}

.dream-ai-assistant {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  max-width: calc(100vw - 1.5rem);
}

/* ── Floating Orb ── */
.dream-ai-orb {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #7c5cfc, #5b3fd4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px var(--ai-accent-glow), 0 0 0 0 var(--ai-accent-glow);
  transition: box-shadow 0.28s ease, filter 0.28s ease, background 0.28s ease;
  z-index: 2;
  outline: none;
  touch-action: manipulation;
  will-change: box-shadow;
}
.dream-ai-orb:hover {
  box-shadow: 0 6px 32px var(--ai-accent-glow), 0 0 0 8px rgba(124, 92, 252, 0.12);
  filter: brightness(1.04);
}
.dream-ai-orb:active {
  filter: brightness(0.98);
}
.dream-ai-orb:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.orb-icon {
  font-size: 24px;
  color: #fff;
  z-index: 3;
  position: relative;
  transition: transform 0.3s ease;
}
.dream-ai-orb:hover .orb-icon {
  transform: rotate(15deg) scale(1.1);
}

.orb-core {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--ai-accent-glow), transparent 70%);
  animation: core-pulse 3s ease-in-out infinite;
}

.orb-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(124, 92, 252, 0.15);
  pointer-events: none;
}
.orb-ring-1 { inset: -8px; animation: ring-expand 4s ease-in-out infinite; }
.orb-ring-2 { inset: -16px; animation: ring-expand 4s ease-in-out infinite 1s; }
.orb-ring-3 { inset: -24px; animation: ring-expand 4s ease-in-out infinite 2s; }

.orb-particle {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ai-accent);
  pointer-events: none;
}
.p1 { animation: orbit 6s linear infinite; top: -12px; left: 50%; }
.p2 { animation: orbit 8s linear infinite reverse; bottom: -8px; right: 10%; }
.p3 { animation: orbit 10s linear infinite; top: 50%; left: -10px; }

/* ── Chat Panel ── */
.dream-ai-panel {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 400px;
  height: 520px;
  border-radius: var(--ai-radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--ai-bg);
  backdrop-filter: blur(32px) saturate(1.4);
  -webkit-backdrop-filter: blur(32px) saturate(1.4);
  border: 1px solid var(--ai-border);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(124, 92, 252, 0.1);
  animation: panel-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Header */
.dream-ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ai-border);
  flex-shrink: 0;
}
.dream-ai-header-left { display: flex; align-items: center; gap: 10px; }
.dream-ai-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--ai-accent), #5b3fd4);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff; flex-shrink: 0;
}
.dream-ai-name { font-size: 14px; font-weight: 600; color: #fff; }
.dream-ai-status {
  font-size: 11px; color: #4ade80;
  display: flex; align-items: center; gap: 4px;
}
.dream-ai-status::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: #4ade80;
}
.dream-ai-close {
  background: var(--ai-surface); border: none; color: var(--ai-text-muted);
  cursor: pointer; width: 32px; height: 32px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s ease;
}
.dream-ai-close:hover { background: rgba(255,255,255,0.1); color: #fff; }
.dream-ai-close:focus-visible { outline: 2px solid var(--ai-accent); outline-offset: 1px; }

/* Messages */
.dream-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}
.dream-ai-messages::-webkit-scrollbar { width: 4px; }
.dream-ai-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1); border-radius: 2px;
}

.dream-ai-msg { display: flex; flex-direction: column; max-width: 85%; animation: msg-in 0.3s ease; }
.msg-user { align-self: flex-end; }
.msg-ai { align-self: flex-start; }

.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ai-text);
  word-break: break-word;
}
.msg-user .msg-bubble {
  background: var(--ai-accent);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.msg-ai .msg-bubble {
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  border-bottom-left-radius: 6px;
}

/* Action chips */
.msg-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; padding-left: 4px; }
.msg-action-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 10px;
  background: rgba(124, 92, 252, 0.12); border: 1px solid rgba(124, 92, 252, 0.2);
  color: #c4b5fd; font-size: 12px; cursor: pointer;
  transition: all 0.2s ease; text-decoration: none; white-space: nowrap;
}
.msg-action-chip:hover {
  background: rgba(124, 92, 252, 0.2); color: #e0d4ff;
  transform: translateY(-1px);
}
.msg-action-chip i { font-size: 14px; }

/* Typing indicator */
.typing-indicator {
  display: flex; gap: 4px; align-items: center;
  padding: 12px 16px !important;
}
.typing-indicator span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ai-text-muted);
  animation: typing-bounce 1.4s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

/* Quick Actions */
.dream-ai-quick-actions {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 4px 16px 12px;
  flex-shrink: 0;
}
.quick-action-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 13px; border-radius: 12px;
  background: var(--ai-surface); border: 1px solid var(--ai-border);
  color: var(--ai-text-muted); font-size: 12.5px;
  cursor: pointer; transition: all 0.2s ease;
  white-space: nowrap;
}
.quick-action-chip:hover {
  background: rgba(124, 92, 252, 0.1); border-color: rgba(124, 92, 252, 0.3);
  color: var(--ai-text); transform: translateY(-1px);
}
.quick-action-chip i { font-size: 14px; color: var(--ai-accent); }

/* Input */
.dream-ai-input-wrap {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--ai-border);
  flex-shrink: 0;
}
.dream-ai-input {
  flex: 1;
  background: var(--ai-surface);
  border: 1px solid var(--ai-border);
  border-radius: 14px;
  padding: 10px 14px;
  color: #fff;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s ease;
  font-family: inherit;
}
.dream-ai-input::placeholder { color: var(--ai-text-muted); }
.dream-ai-input:focus { border-color: rgba(124, 92, 252, 0.4); }
.dream-ai-send {
  width: 40px; height: 40px; border-radius: 14px;
  background: linear-gradient(135deg, var(--ai-accent), #5b3fd4);
  border: none; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.dream-ai-send:hover { transform: scale(1.05); }

/* ═══ Animations ═══ */
@keyframes orb-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
@keyframes core-pulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.1); }
}
@keyframes ring-expand {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 0.1; transform: scale(1.15); }
}
@keyframes orbit {
  from { transform: rotate(0deg) translateX(20px) rotate(0deg); }
  to { transform: rotate(360deg) translateX(20px) rotate(-360deg); }
}
@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes panel-in {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ═══ Mobile ═══ */
@media (max-width: 640px) {
  .dream-ai-assistant {
    bottom: max(16px, env(safe-area-inset-bottom));
    right: 16px;
  }
  .dream-ai-orb { width: 52px; height: 52px; }
  .orb-icon { font-size: 20px; }
  .orb-ring,
  .orb-particle {
    display: none;
  }
  .dream-ai-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    bottom: 0;
    right: 0;
  }
}
