/* ============================================================================
   Movie Zetu AI Support Assistant — Unified Dark Crimson Cinema Theme
   Ported in architecture & polish from rahapre-main's AiAgent + AiChat,
   adapted cleanly to Movie Zetu's crimson & obsidian color palette.
   ========================================================================== */

:root {
  --mz-ai-bg: #0e0e13;
  --mz-ai-surface: #07070a;
  --mz-ai-surface-elevated: #16161e;
  --mz-ai-border: #232330;
  --mz-ai-border-strong: #343446;
  --mz-ai-text: #f3f4f6;
  --mz-ai-text-strong: #ffffff;
  --mz-ai-text-muted: #9ca3af;
  --mz-ai-text-dim: #6b7280;
  --mz-ai-primary: #e50914;
  --mz-ai-primary-hover: #f6121d;
  --mz-ai-primary-deep: #b20710;
  --mz-ai-primary-soft: #ff5c66;
  --mz-ai-primary-glow: rgba(229, 9, 20, 0.42);
  --mz-ai-emerald: #10b981;
  --mz-ai-emerald-soft: #34d399;
  --mz-ai-danger: #f87171;
}

/* ── Animations ───────────────────────────────────────────────────────────── */
@keyframes mz-ai-fade-up {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes mz-ai-ping {
  75%,
  100% {
    transform: scale(1.65);
    opacity: 0;
  }
}

@keyframes mz-ai-pulse {
  0%,
  100% {
    opacity: 0.7;
  }
  50% {
    opacity: 0.25;
  }
}

@keyframes mz-ai-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* ── Floating Speech Greeting Bubble ──────────────────────────────────────── */
.mz-ai-bubble {
  position: fixed;
  right: 1rem;
  bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px));
  z-index: 9990;
  width: 310px;
  max-width: calc(100vw - 2rem);
  padding: 14px;
  border-radius: 20px;
  border: 1px solid rgba(229, 9, 20, 0.4);
  background: rgba(14, 14, 19, 0.96);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow:
    0 12px 35px -5px rgba(0, 0, 0, 0.75),
    0 0 26px -2px rgba(229, 9, 20, 0.28);
  color: var(--mz-ai-text);
  cursor: pointer;
  animation: mz-ai-fade-up 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
  transition:
    transform 0.2s ease,
    border-color 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.mz-ai-bubble:hover {
  transform: scale(1.02);
  border-color: rgba(229, 9, 20, 0.68);
}

.mz-ai-bubble:active {
  transform: scale(0.98);
}

.mz-ai-bubble-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.mz-ai-bubble-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 9999px;
  border: 1px solid rgba(229, 9, 20, 0.45);
  background: linear-gradient(45deg, #450408 0%, #14141b 55%, #7a0910 100%);
  color: var(--mz-ai-primary-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

.mz-ai-bubble-avatar svg {
  width: 24px;
  height: 24px;
}

.mz-ai-bubble-online {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 12px;
  height: 12px;
  border-radius: 9999px;
  background: var(--mz-ai-emerald);
  border: 2px solid var(--mz-ai-bg);
}

.mz-ai-bubble-body {
  min-width: 0;
  flex: 1;
}

.mz-ai-bubble-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.mz-ai-bubble-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--mz-ai-primary-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mz-ai-bubble-close {
  background: transparent;
  border: none;
  color: var(--mz-ai-text-muted);
  padding: 4px;
  margin: -4px -4px 0 0;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.mz-ai-bubble-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--mz-ai-text-strong);
}

.mz-ai-bubble-close svg {
  width: 16px;
  height: 16px;
}

.mz-ai-bubble-text {
  margin-top: 4px;
  font-size: 12.5px;
  line-height: 1.42;
  color: #e2e4ea;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mz-ai-bubble-tail {
  position: absolute;
  right: 24px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  transform: rotate(45deg);
  border-right: 1px solid rgba(229, 9, 20, 0.4);
  border-bottom: 1px solid rgba(229, 9, 20, 0.4);
  background: rgba(14, 14, 19, 0.96);
}

/* ── Floating Circular Launcher Button (FAB) ──────────────────────────────── */
.mz-ai-fab-wrap {
  position: fixed;
  right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  z-index: 9991;
  display: flex;
}

.mz-ai-fab-wrap.mz-ai-open-hide-mobile {
  display: none;
}

.mz-ai-fab {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 9999px;
  border: 2px solid rgba(255, 110, 118, 0.45);
  background: linear-gradient(45deg, var(--mz-ai-primary-deep) 0%, var(--mz-ai-primary) 60%, #ff2a36 100%);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 8px 28px rgba(229, 9, 20, 0.48),
    0 0 16px rgba(229, 9, 20, 0.32);
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  padding: 0;
}

.mz-ai-fab:hover {
  transform: scale(1.06);
  border-color: rgba(255, 150, 156, 0.75);
  box-shadow:
    0 10px 34px rgba(229, 9, 20, 0.62),
    0 0 22px rgba(229, 9, 20, 0.4);
}

.mz-ai-fab:active {
  transform: scale(0.95);
}

.mz-ai-fab-ring-ping {
  position: absolute;
  inset: -6px;
  border-radius: 9999px;
  background: rgba(229, 9, 20, 0.28);
  pointer-events: none;
  animation: mz-ai-ping 2.2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.mz-ai-fab-ring-pulse {
  position: absolute;
  inset: -10px;
  border-radius: 9999px;
  border: 2px solid rgba(255, 92, 102, 0.32);
  pointer-events: none;
  animation: mz-ai-pulse 2.2s ease-in-out infinite;
}

.mz-ai-fab-online {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.mz-ai-fab-online-ping {
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  background: var(--mz-ai-emerald-soft);
  opacity: 0.75;
  animation: mz-ai-ping 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.mz-ai-fab-online-dot {
  position: relative;
  width: 14px;
  height: 14px;
  border-radius: 9999px;
  background: var(--mz-ai-emerald);
  border: 2px solid #07070a;
}

.mz-ai-fab svg {
  width: 27px;
  height: 27px;
  position: relative;
  z-index: 1;
}

/* ── Floating Chat Modal Container ────────────────────────────────────────── */
.mz-ai-modal {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9995;
  margin: 0 auto;
  width: 100%;
  height: 85dvh;
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 18px 18px 0 0;
  border: 1px solid var(--mz-ai-border);
  border-bottom: none;
  background: var(--mz-ai-bg);
  box-shadow: 0 -10px 45px rgba(0, 0, 0, 0.8);
  animation: mz-ai-fade-up 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.mz-ai-hidden {
  display: none !important;
}

@media (min-width: 640px) {
  .mz-ai-bubble {
    right: 1.5rem;
    bottom: calc(6rem + env(safe-area-inset-bottom, 0px));
    width: 332px;
    border-radius: 22px;
  }

  .mz-ai-bubble-text {
    font-size: 13px;
  }

  .mz-ai-fab-wrap {
    right: 1.5rem;
  }

  .mz-ai-fab-wrap.mz-ai-open-hide-mobile {
    display: flex;
  }

  .mz-ai-fab {
    width: 60px;
    height: 60px;
  }

  .mz-ai-modal {
    left: auto;
    right: 1.5rem;
    bottom: calc(6rem + env(safe-area-inset-bottom, 0px));
    width: 400px;
    max-width: calc(100vw - 2rem);
    height: 560px;
    max-height: 80dvh;
    border-radius: 18px;
    border-bottom: 1px solid var(--mz-ai-border);
    box-shadow:
      0 20px 55px rgba(0, 0, 0, 0.8),
      0 0 0 1px rgba(255, 255, 255, 0.04);
  }
}

/* ── Shared Chat Shell (used in both floating modal & /ai full page) ─────── */
.mz-ai-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  width: 100%;
  background: var(--mz-ai-bg);
  color: var(--mz-ai-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.5;
  box-sizing: border-box;
}

.mz-ai-shell *,
.mz-ai-shell *::before,
.mz-ai-shell *::after {
  box-sizing: border-box;
}

.mz-ai-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--mz-ai-surface);
  border-bottom: 1px solid var(--mz-ai-border);
  flex-shrink: 0;
}

.mz-ai-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 9999px;
  background: linear-gradient(135deg, var(--mz-ai-primary) 0%, var(--mz-ai-primary-deep) 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(229, 9, 20, 0.35);
}

.mz-ai-header-avatar svg {
  width: 20px;
  height: 20px;
}

.mz-ai-header-meta {
  min-width: 0;
  flex: 1;
}

.mz-ai-header-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--mz-ai-text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mz-ai-header-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--mz-ai-text-muted);
}

.mz-ai-header-dot {
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: var(--mz-ai-emerald);
  display: inline-block;
}

.mz-ai-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mz-ai-icon-btn {
  background: transparent;
  border: none;
  color: var(--mz-ai-text-muted);
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.mz-ai-icon-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--mz-ai-text-strong);
}

.mz-ai-icon-btn svg {
  width: 19px;
  height: 19px;
}

/* ── Messages Stream ──────────────────────────────────────────────────────── */
.mz-ai-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--mz-ai-border-strong) transparent;
}

.mz-ai-messages::-webkit-scrollbar {
  width: 6px;
}

.mz-ai-messages::-webkit-scrollbar-thumb {
  background: var(--mz-ai-border-strong);
  border-radius: 999px;
}

.mz-ai-row {
  display: flex;
  width: 100%;
  animation: mz-ai-fade-up 0.18s ease both;
}

.mz-ai-row-user {
  justify-content: flex-end;
}

.mz-ai-row-assistant {
  justify-content: flex-start;
}

.mz-ai-msg {
  max-width: 84%;
  padding: 9px 14px;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.mz-ai-msg-user {
  border-radius: 16px 16px 4px 16px;
  background: linear-gradient(135deg, var(--mz-ai-primary) 0%, var(--mz-ai-primary-deep) 100%);
  color: #ffffff;
  box-shadow: 0 3px 12px rgba(229, 9, 20, 0.25);
}

.mz-ai-msg-assistant {
  border-radius: 16px 16px 16px 4px;
  background: var(--mz-ai-surface);
  border: 1px solid var(--mz-ai-border);
  color: var(--mz-ai-text);
}

.mz-ai-msg strong {
  font-weight: 600;
  color: var(--mz-ai-text-strong);
}

.mz-ai-msg-user strong {
  color: #ffffff;
}

.mz-ai-link {
  color: var(--mz-ai-primary-soft);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.mz-ai-link:hover {
  color: #ff8a92;
}

.mz-ai-msg-user .mz-ai-link {
  color: #ffffff;
}

.mz-ai-msg-img {
  display: block;
  margin-bottom: 6px;
  max-height: 176px;
  max-width: 100%;
  width: auto;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

/* ── Quick-Reply Suggestion Chips ─────────────────────────────────────────── */
.mz-ai-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}

.mz-ai-suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--mz-ai-border);
  background: var(--mz-ai-surface);
  color: var(--mz-ai-text);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.15s ease;
}

.mz-ai-suggestion:hover {
  border-color: rgba(229, 9, 20, 0.6);
  background: var(--mz-ai-surface-elevated);
}

.mz-ai-suggestion:active {
  transform: scale(0.985);
}

.mz-ai-suggestion svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--mz-ai-primary-soft);
  transition: transform 0.18s ease;
}

.mz-ai-suggestion:hover svg {
  transform: translateX(3px);
}

/* ── Typing Indicator Bubble ──────────────────────────────────────────────── */
.mz-ai-typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 12px 15px;
  border-radius: 16px 16px 16px 4px;
  background: var(--mz-ai-surface);
  border: 1px solid var(--mz-ai-border);
}

.mz-ai-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: var(--mz-ai-text-muted);
  animation: mz-ai-bounce 1.2s infinite ease-in-out;
}

.mz-ai-typing-dot:nth-child(2) {
  animation-delay: 120ms;
}

.mz-ai-typing-dot:nth-child(3) {
  animation-delay: 240ms;
}

/* ── Composer Footer ──────────────────────────────────────────────────────── */
.mz-ai-composer {
  border-top: 1px solid var(--mz-ai-border);
  background: var(--mz-ai-surface);
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  flex-shrink: 0;
}

.mz-ai-attach-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--mz-ai-border-strong);
  background: var(--mz-ai-bg);
}

.mz-ai-attach-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.mz-ai-attach-label {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--mz-ai-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mz-ai-attach-remove {
  background: transparent;
  border: none;
  color: var(--mz-ai-text-muted);
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mz-ai-attach-remove:hover {
  color: var(--mz-ai-danger);
}

.mz-ai-attach-remove svg {
  width: 16px;
  height: 16px;
}

.mz-ai-composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.mz-ai-attach-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  border: 1px solid var(--mz-ai-border-strong);
  background: transparent;
  color: var(--mz-ai-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.16s ease, border-color 0.16s ease, transform 0.14s ease;
}

.mz-ai-attach-btn:hover:not(:disabled) {
  color: var(--mz-ai-primary-soft);
  border-color: rgba(229, 9, 20, 0.55);
}

.mz-ai-attach-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.mz-ai-attach-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mz-ai-attach-btn svg {
  width: 19px;
  height: 19px;
}

.mz-ai-textarea {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  max-height: 112px;
  resize: none;
  border-radius: 12px;
  border: 1px solid var(--mz-ai-border-strong);
  background: var(--mz-ai-bg);
  color: var(--mz-ai-text);
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.18s ease;
}

.mz-ai-textarea::placeholder {
  color: var(--mz-ai-text-dim);
}

.mz-ai-textarea:focus {
  border-color: var(--mz-ai-primary);
}

.mz-ai-send-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--mz-ai-primary) 0%, var(--mz-ai-primary-deep) 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: filter 0.16s ease, transform 0.14s ease, opacity 0.16s ease;
  box-shadow: 0 2px 10px rgba(229, 9, 20, 0.35);
}

.mz-ai-send-btn:hover:not(:disabled) {
  filter: brightness(1.1);
}

.mz-ai-send-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.mz-ai-send-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  box-shadow: none;
}

.mz-ai-send-btn svg {
  width: 19px;
  height: 19px;
}

/* ── Toast Viewport ───────────────────────────────────────────────────────── */
.mz-ai-toasts {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10010;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(380px, calc(100vw - 2rem));
  pointer-events: none;
}

.mz-ai-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #121218;
  border: 1px solid var(--mz-ai-border-strong);
  color: var(--mz-ai-text);
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.65);
  animation: mz-ai-fade-up 0.2s ease both;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.mz-ai-toast-success {
  border-color: rgba(16, 185, 129, 0.5);
  color: #6ee7b7;
}

.mz-ai-toast-error {
  border-color: rgba(248, 113, 113, 0.5);
  color: #fca5a5;
}

.mz-ai-toast-info {
  border-color: rgba(229, 9, 20, 0.45);
  color: #f3f4f6;
}

.mz-ai-toast-msg {
  flex: 1;
  min-width: 0;
}

.mz-ai-toast-close {
  background: transparent;
  border: none;
  color: inherit;
  opacity: 0.65;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
}

.mz-ai-toast-close:hover {
  opacity: 1;
}
