/* ==========================================================================
   NEBULA AI — Conference Intelligence assistant
   Premium glass-panel chat with cosmic purple/midnight identity.
   ========================================================================== */
.ai-chat {
  position: fixed;
  inset: 0;
  z-index: 520;
  pointer-events: none;
}
.ai-chat[hidden] { display: none; }

/* Floating toggle button */
.ai-chat__toggle {
  position: fixed;
  right: clamp(1rem, 3vw, 2.4rem);
  bottom: clamp(1rem, 3vw, 2rem);
  z-index: 530;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid rgba(183, 169, 255, 0.35);
  background: rgba(8, 6, 14, 0.82);
  backdrop-filter: blur(12px);
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.ai-chat__toggle:hover {
  transform: translateY(-2px);
  border-color: var(--violet-bright);
  box-shadow: 0 24px 70px rgba(143, 123, 255, 0.35);
}
.ai-chat__toggle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}
.ai-chat__orb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--violet-bright);
  box-shadow: 0 0 20px rgba(183, 169, 255, 0.8);
  position: relative;
}
.ai-chat__orb::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid rgba(183, 169, 255, 0.5);
  animation: ai-orb-pulse 2.2s ease-in-out infinite;
}
.ai-chat__label {
  margin-left: 0.35rem;
  white-space: nowrap;
}
@keyframes ai-orb-pulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.12); opacity: 1; }
}
.ai-chat__toggle.is-thinking .ai-chat__orb {
  background: var(--blue);
  box-shadow: 0 0 24px rgba(92, 157, 255, 0.9);
}
.ai-chat__toggle.is-thinking .ai-chat__orb::after {
  border-color: rgba(92, 157, 255, 0.7);
  animation: ai-orb-pulse 1.1s ease-in-out infinite;
}

/* Chat panel */
.ai-chat__panel {
  position: fixed;
  right: clamp(0.75rem, 3vw, 2rem);
  bottom: clamp(3rem, 6vh, 4rem);
  z-index: 530;
  width: auto;
  max-width: min(420px, 94vw);
  height: auto;
  max-height: min(560px, 82vh);
  background: linear-gradient(165deg, rgba(14, 10, 24, 0.88), rgba(6, 5, 14, 0.92));
  border: 1px solid rgba(183, 169, 255, 0.3);
  border-radius: 20px;
  backdrop-filter: blur(20px) saturate(1.2);
  box-shadow:
    0 30px 100px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  opacity: 0;
  transform: translatey(20px) scale(0.96);
  transition: opacity 0.35s cubic-bezier(0.22, 1, 0.36, 1), transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}
.ai-chat__panel.is-open {
  opacity: 1;
  transform: translatey(0) scale(1);
}
.ai-chat__panel.hidden { display: none !important; }

.ai-chat__close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid rgba(183, 169, 255, 0.25);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  pointer-events: auto;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.ai-chat__close:hover { color: #fff; border-color: var(--violet-bright); }

.ai-chat__header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1.1rem 1.2rem 0.7rem;
  border-bottom: 1px solid rgba(183, 169, 255, 0.15);
  flex-shrink: 0;
}
.ai-chat__orb-small {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.4), transparent 60%),
    radial-gradient(circle at 50% 50%, rgba(183, 169, 255, 0.55), rgba(69, 90, 255, 0.45));
  box-shadow: 0 0 24px rgba(183, 169, 255, 0.5);
  position: relative;
}
.ai-chat__title h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #fff;
  margin: 0 0 0.15rem;
}
.ai-chat__title p {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.55);
  margin: 0;
  font-style: italic;
}
.ai-chat__reset {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(183, 169, 255, 0.25);
  color: rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  pointer-events: auto;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.ai-chat__reset:hover {
  color: #fff;
  border-color: var(--violet-bright);
  background: rgba(183, 169, 255, 0.08);
}

/* Messages area */
.ai-chat__messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  -webkit-overflow-scrolling: touch;
}
.ai-chat__msg {
  display: flex;
  gap: 0.7rem;
  max-width: 90%;
  animation: ai-msg-in 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.ai-chat__msg.ai-user { flex-direction: row-reverse; align-self: flex-end; }
.ai-chat__msg.ai-assistant { align-self: flex-start; }
@keyframes ai-msg-in {
  from { opacity: 0; transform: translatey(10px); }
  to   { opacity: 1; transform: none; }
}
.ai-chat__avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.ai-chat__msg.ai-assistant .ai-chat__avatar {
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.3), transparent 60%),
    linear-gradient(135deg, rgba(183, 169, 255, 0.35), rgba(92, 157, 255, 0.25));
  border: 1px solid rgba(183, 169, 255, 0.35);
  color: #fff;
  font-weight: 700;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.ai-chat__msg.ai-user .ai-chat__avatar {
  background: linear-gradient(135deg, var(--violet), var(--blue));
  color: #fff;
  font-weight: 700;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.ai-chat__bubble {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: #eef1f7;
}
.ai-chat__msg.ai-assistant .ai-chat__bubble {
  background: rgba(183, 169, 255, 0.12);
  border: 1px solid rgba(183, 169, 255, 0.2);
  border-bottom-left-radius: 3px;
}
.ai-chat__msg.ai-user .ai-chat__bubble {
  background: linear-gradient(135deg, var(--violet), var(--blue));
  border-bottom-right-radius: 3px;
}
.ai-chat__meta {
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 0.3rem;
  font-family: var(--font-body);
}

/* Typing indicator */
.ai-chat__typing {
  display: flex;
  gap: 0.7rem;
  align-self: flex-start;
  padding: 0 1.2rem 0.3rem;
  animation: ai-msg-in 0.3s ease;
}
.ai-chat__typing .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--violet-bright);
  animation: ai-typing 1.4s ease-in-out infinite both;
}
.ai-chat__typing .dot:nth-child(2) { animation-delay: 0.2s; }
.ai-chat__typing .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-typing {
  0%, 100% { transform: scale(0.6); opacity: 0.5; }
  50% { transform: scale(1); opacity: 1; }
}

/* Input area */
.ai-chat__input-area {
  padding: 0.7rem 1.2rem;
  border-top: 1px solid rgba(183, 169, 255, 0.15);
  background: rgba(4, 3, 8, 0.4);
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
  flex-shrink: 0;
}
.ai-chat__form {
  display: flex;
  gap: 0.5rem;
}
.ai-chat__input {
  flex: 1;
  background: rgba(4, 3, 8, 0.6);
  border: 1px solid rgba(183, 169, 255, 0.25);
  border-radius: 999px;
  padding: 0.7rem 1rem;
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.ai-chat__input::placeholder { color: rgba(255, 255, 255, 0.35); }
.ai-chat__input:focus {
  border-color: var(--violet-bright);
  box-shadow: 0 0 0 3px rgba(183, 169, 255, 0.15);
}
.ai-chat__send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--violet), var(--blue));
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 24px rgba(106, 92, 224, 0.35);
  transition: transform 0.2s ease, filter 0.2s ease;
}
.ai-chat__send:hover { transform: translateY(-1px); filter: brightness(1.1); }
.ai-chat__send:active { transform: translateY(0); }
.ai-chat__send:disabled { opacity: 0.5; cursor: not-allowed; }

/* Suggested chips */
.ai-chat__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0 1.2rem 0.8rem;
}
.ai-chat__chip {
  background: rgba(183, 169, 255, 0.08);
  border: 1px solid rgba(183, 169, 255, 0.2);
  color: rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.ai-chat__chip:hover {
  background: rgba(183, 169, 255, 0.2);
  border-color: var(--violet-bright);
  color: #fff;
}

/* Empty state */
.ai-chat__empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  padding: 2rem 1rem;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
}
.ai-chat__empty .orb {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(183, 169, 255, 0.1);
  border: 1px solid rgba(183, 169, 255, 0.2);
  box-shadow: 0 0 30px rgba(183, 169, 255, 0.15);
  animation: ai-orb-pulse 3s ease-in-out infinite;
}

/* System / error messages */
.ai-chat__system {
  align-self: center;
  max-width: 90%;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 107, 129, 0.1);
  border: 1px solid rgba(255, 107, 129, 0.2);
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.72rem;
  text-align: center;
  animation: ai-msg-in 0.4s ease;
}

/* Responsive */
@media (max-width: 640px) {
  .ai-chat__panel {
    right: clamp(0.75rem, 3vw, 1.5rem);
    bottom: clamp(3.5rem, 7vw, 4rem);
    width: min(340px, 94vw);
    height: min(520px, 82vh);
  }
}
@media (prefers-reduced-motion: reduce) {
  .ai-chat__toggle,
  .ai-chat__panel,
  .ai-chat__msg,
  .ai-chat__chip,
  .ai-chat__send,
  .ai-chat__reset,
  .ai-chat__system,
  .ai-chat__typing .dot,
  .ai-chat__empty .orb {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  .ai-chat__panel.is-open { transform: none; opacity: 1; }
}

/* Floating toggle button */
.ai-chat__toggle {
  position: fixed;
  right: clamp(1rem, 3vw, 2.4rem);
  bottom: clamp(1rem, 3vw, 2rem);
  z-index: 530;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid rgba(183, 169, 255, 0.35);
  background: rgba(8, 6, 14, 0.82);
  backdrop-filter: blur(12px);
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.ai-chat__toggle:hover {
  transform: translateY(-2px);
  border-color: var(--violet-bright);
  box-shadow: 0 24px 70px rgba(143, 123, 255, 0.35);
}
.ai-chat__toggle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}
.ai-chat__orb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--violet-bright);
  box-shadow: 0 0 20px rgba(183, 169, 255, 0.8);
  position: relative;
}
.ai-chat__orb::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid rgba(183, 169, 255, 0.5);
  animation: ai-orb-pulse 2.2s ease-in-out infinite;
}
.ai-chat__label {
  margin-left: 0.35rem;
  white-space: nowrap;
}
@keyframes ai-orb-pulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.12); opacity: 1; }
}
.ai-chat__toggle.is-thinking .ai-chat__orb {
  background: var(--blue);
  box-shadow: 0 0 24px rgba(92, 157, 255, 0.9);
}
.ai-chat__toggle.is-thinking .ai-chat__orb::after {
  border-color: rgba(92, 157, 255, 0.7);
  animation: ai-orb-pulse 1.1s ease-in-out infinite;
}
