/* ============================================================
   EmaarX — LiveAvatar Chat & HLS Video Player Styles
   Obsidian & Gold Luxury Aesthetic
   ============================================================ */

:root {
  --ax-obsidian: #0A0A0A;
  --ax-charcoal: #141412;
  --ax-surface: #1A1916;
  --ax-gold: #C9AB4C;
  --ax-gold-light: #EBD48A;
  --ax-gold-dim: rgba(201, 171, 76, 0.16);
  --ax-gold-line: rgba(201, 171, 76, 0.28);
  --ax-limestone: #E8E3D9;
  --ax-lime-60: rgba(232, 227, 217, 0.65);
  --ax-lime-40: rgba(232, 227, 217, 0.40);
  --ax-danger: #D9704F;
  --ax-success: #6FAE7F;
  --ax-radius: 14px;
}

/* ──────────────────────────────────────────────────────────
   1. HLS Video Player Component (Replaces static photostrip)
   ────────────────────────────────────────────────────────── */

.emaarx-video-wrapper {
  position: relative;
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 52px;
  border: 1px solid var(--ax-gold-dim);
  background: #000;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 40px rgba(201, 171, 76, 0.08);
  aspect-ratio: 16/9;
  z-index: 1;
}

.emaarx-video-element {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  background: #000;
}

.emaarx-video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, 0.35);
  cursor: pointer;
  transition: all 0.35s ease;
  z-index: 2;
}

.emaarx-video-wrapper.playing .emaarx-video-overlay {
  opacity: 0;
  pointer-events: none;
}

.emaarx-video-overlay:hover {
  background: rgba(10, 10, 10, 0.2);
}

.emaarx-play-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ax-gold) 0%, var(--ax-gold-light) 50%, var(--ax-gold) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ax-obsidian);
  box-shadow: 0 12px 35px rgba(201, 171, 76, 0.45);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.emaarx-play-btn svg {
  width: 32px;
  height: 32px;
  margin-left: 4px;
  fill: currentColor;
}

.emaarx-video-overlay:hover .emaarx-play-btn {
  transform: scale(1.1);
}

.emaarx-video-badge {
  position: absolute;
  top: 18px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(10, 10, 10, 0.82);
  border: 1px solid var(--ax-gold-line);
  border-radius: 30px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ax-gold);
  backdrop-filter: blur(12px);
  z-index: 3;
}

.emaarx-video-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ax-gold);
  box-shadow: 0 0 8px var(--ax-gold);
}

.emaarx-video-controls {
  position: absolute;
  bottom: 16px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 3;
}

.emaarx-ctrl-btn {
  background: rgba(15, 15, 13, 0.85);
  border: 1px solid var(--ax-gold-dim);
  color: var(--ax-limestone);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s ease;
  backdrop-filter: blur(10px);
}

.emaarx-ctrl-btn:hover {
  background: var(--ax-gold);
  color: var(--ax-obsidian);
  border-color: var(--ax-gold);
}


/* ──────────────────────────────────────────────────────────
   2. Floating AI Avatar Trigger Button
   ────────────────────────────────────────────────────────── */

#emaarx-chat-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

#emaarx-chat-bubble .ax-bubble-label {
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ax-limestone);
  background: rgba(10, 10, 10, 0.78);
  border: 1px solid var(--ax-gold-line);
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(201, 171, 76, 0.25), 0 0 18px rgba(201, 171, 76, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.3s ease;
}

#emaarx-chat-bubble .ax-bubble-circle {
  position: relative;
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #C9AB4C 0%, #EBD48A 50%, #C9AB4C 100%);
  animation: ax-glow-pulse 2.4s infinite ease-in-out;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#emaarx-chat-bubble:hover .ax-bubble-circle {
  transform: scale(1.08);
}

#emaarx-chat-bubble:hover .ax-bubble-label {
  transform: translateX(-2px);
}

@keyframes ax-glow-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(201, 171, 76, 0.18), 0 12px 36px rgba(201, 171, 76, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(201, 171, 76, 0.28), 0 16px 44px rgba(201, 171, 76, 0.6); }
}

@keyframes ax-pulse {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50% { transform: scale(1.15); opacity: 0.8; }
}

#emaarx-chat-bubble .ax-bubble-avatar {
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  object-fit: cover;
  object-position: 50% 15%;
  border-radius: 50%;
  display: block;
  position: relative;
  z-index: 1;
  margin: auto;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  box-shadow: inset 0 0 0 1px rgba(10, 10, 10, 0.25);
}


/* ──────────────────────────────────────────────────────────
   3. Chat Drawer & LiveAvatar Container
   ────────────────────────────────────────────────────────── */

#emaarx-chat-drawer {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 10000;
  width: calc(100vw - 40px);
  max-width: 440px;
  max-height: 88vh;
  background: var(--ax-obsidian);
  border: 1px solid var(--ax-gold-line);
  border-radius: 20px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.8), 0 0 30px rgba(201, 171, 76, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-body), 'Manrope', -apple-system, sans-serif;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

#emaarx-chat-drawer.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.ax-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(201, 171, 76, 0.15);
  background: rgba(18, 18, 16, 0.85);
  backdrop-filter: blur(14px);
}

.ax-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ax-header-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ax-limestone);
  margin: 0;
}

.ax-header-sub {
  font-size: 0.72rem;
  color: var(--ax-lime-40);
  margin: 0;
}

.ax-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ax-avatar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(201, 171, 76, 0.12);
  border: 1px solid rgba(201, 171, 76, 0.28);
  color: var(--ax-gold);
  cursor: pointer;
  transition: all 0.25s ease;
}

.ax-avatar-btn:hover {
  background: var(--ax-gold);
  color: var(--ax-obsidian);
}

.ax-close-btn {
  background: transparent;
  border: none;
  color: var(--ax-lime-60);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.ax-close-btn:hover {
  color: var(--ax-limestone);
}

/* Avatar Panel */
.ax-avatar-panel {
  display: none;
  position: relative;
  width: 100%;
  height: 270px;
  background: #0B0B0B;
  border-bottom: 1px solid rgba(201, 171, 76, 0.15);
  overflow: hidden;
}

.ax-avatar-panel.active {
  display: block;
}

.ax-avatar-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center top;
  display: block;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.ax-avatar-video.visible {
  opacity: 1;
}

/* Status Pill */
.ax-status-pill {
  position: absolute;
  top: 12px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(10, 10, 10, 0.85);
  border: 1px solid var(--ax-gold-dim);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ax-limestone);
  backdrop-filter: blur(8px);
  z-index: 5;
}

.ax-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ax-lime-40);
}

.ax-status-dot.connecting,
.ax-status-dot.listening,
.ax-status-dot.transcribing,
.ax-status-dot.thinking {
  background: var(--ax-gold);
  animation: ax-pulse 1.2s infinite;
}

.ax-status-dot.connected {
  background: var(--ax-success);
}

.ax-status-dot.speaking {
  background: var(--ax-success);
  animation: ax-pulse 0.8s infinite;
}

.ax-status-dot.error {
  background: var(--ax-danger);
}

/* Disconnect Button */
.ax-disconnect-btn {
  position: absolute;
  bottom: 12px;
  right: 12px;
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(10, 10, 10, 0.85);
  border: 1px solid var(--ax-gold-line);
  color: var(--ax-limestone);
  cursor: pointer;
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 5;
  transition: all 0.2s;
}

.ax-disconnect-btn:hover {
  background: rgba(217, 112, 79, 0.2);
  border-color: var(--ax-danger);
  color: var(--ax-danger);
}

/* Avatar Loading Overlay */
.ax-avatar-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(14, 14, 12, 0.95);
  color: var(--ax-lime-60);
  font-size: 0.85rem;
  z-index: 4;
}

.ax-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--ax-gold-dim);
  border-top-color: var(--ax-gold);
  border-radius: 50%;
  animation: ax-spin 0.8s linear infinite;
}

@keyframes ax-spin {
  to { transform: rotate(360deg); }
}

/* Messages Area */
.ax-messages-container {
  flex: 1;
  min-height: 180px;
  max-height: 340px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ax-messages-container::-webkit-scrollbar {
  width: 4px;
}
.ax-messages-container::-webkit-scrollbar-thumb {
  background: var(--ax-gold-dim);
  border-radius: 4px;
}

.ax-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.5;
  word-break: break-word;
}

.ax-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--ax-gold) 0%, var(--ax-gold-light) 100%);
  color: var(--ax-obsidian);
  font-weight: 500;
}

.ax-msg.assistant {
  align-self: flex-start;
  background: rgba(232, 227, 217, 0.07);
  border: 1px solid rgba(201, 171, 76, 0.15);
  color: var(--ax-limestone);
}

.ax-msg.thinking {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ax-lime-60);
  font-size: 0.8rem;
}

.ax-msg-image {
  max-width: 220px;
  max-height: 220px;
  border-radius: 8px;
  display: block;
  margin-bottom: 6px;
}

.ax-msg-error {
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(217, 112, 79, 0.12);
  border: 1px solid rgba(217, 112, 79, 0.35);
  color: var(--ax-danger);
  font-size: 0.78rem;
}

/* Input Area */
.ax-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid rgba(201, 171, 76, 0.15);
  background: rgba(14, 14, 12, 0.9);
}

.ax-mic-btn {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(201, 171, 76, 0.08);
  border: 1px solid rgba(201, 171, 76, 0.25);
  color: var(--ax-gold);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  position: relative;
}

.ax-mic-btn:hover {
  background: rgba(201, 171, 76, 0.18);
}

.ax-mic-btn.recording {
  background: rgba(217, 112, 79, 0.18);
  border-color: var(--ax-danger);
  color: var(--ax-danger);
}

.ax-mic-btn.recording::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 12px;
  border: 2px solid var(--ax-danger);
  animation: ax-pulse 1s infinite;
}

.ax-attach-btn {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(201, 171, 76, 0.08);
  border: 1px solid rgba(201, 171, 76, 0.25);
  color: var(--ax-gold);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.ax-attach-btn:hover {
  background: rgba(201, 171, 76, 0.18);
}

.ax-attach-btn.has-image {
  background: rgba(201, 171, 76, 0.22);
  border-color: var(--ax-gold);
}

.ax-image-preview {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 0;
  background: rgba(14, 14, 12, 0.9);
}

.ax-image-preview.active {
  display: flex;
}

.ax-image-preview img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(201, 171, 76, 0.3);
}

.ax-image-remove-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(217, 112, 79, 0.18);
  border: 1px solid var(--ax-danger);
  color: var(--ax-danger);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ax-text-input {
  flex: 1;
  background: rgba(232, 227, 217, 0.05);
  border: 1px solid rgba(201, 171, 76, 0.2);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--ax-limestone);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.25s;
}

.ax-text-input:focus {
  border-color: var(--ax-gold);
}

.ax-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--ax-gold);
  color: var(--ax-obsidian);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s;
}

.ax-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ax-send-btn svg {
  width: 18px;
  height: 18px;
}
