/* ═══════════════════════════════════════════════════════════════
   AI Chatbox — Premium Dark Luxury
   Shelter avatar, typing indicator, glassmorphism, animations
   ═══════════════════════════════════════════════════════════════ */

/* ─── Root container ─── */
.chatbox {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: 90;
  padding-bottom: var(--safe-bottom);
}

/* ─── Floating trigger (Shelter avatar) ─── */
.chatbox__trigger {
  width: 72px;
  height: 72px;
  border-radius: 0;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
  transition: transform var(--transition), filter var(--transition);
  padding: 0;
  overflow: visible;
  animation: chatBounce 3s ease-in-out infinite;
}

.chatbox__trigger:hover {
  transform: scale(1.15);
  filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.6));
  animation: none;
}

.chatbox__trigger-avatar {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@keyframes chatBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.chatbox__trigger[hidden] { display: none; }

/* ─── Panel container ─── */
.chatbox__panel {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  width: 360px;
  max-height: 520px;
  background: linear-gradient(170deg, #1a1a2e 0%, #0f0f1a 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 0 1px rgba(255, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: chatPanelIn 0.3s ease-out;
}

.chatbox__panel[hidden] { display: none; }

@keyframes chatPanelIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Mobile: full width bottom sheet */
@media (max-width: 480px) {
  .chatbox__panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 75vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}

/* ─── Header — glassmorphism + avatar ─── */
.chatbox__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chatbox__header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-width: 0;
}

.chatbox__header-avatar {
  position: relative;
  flex-shrink: 0;
}

.chatbox__header-avatar img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
}

.chatbox__header-status {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #34d399;
  border: 2px solid #1a1a2e;
  animation: statusPulse 3s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(52, 211, 153, 0); }
}

.chatbox__header-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chatbox__title {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: 1.2;
}

.chatbox__subtitle {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.2;
}

.chatbox__close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.chatbox__close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* ─── Disclaimer ─── */
.chatbox__disclaimer {
  padding: 6px var(--space-3);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-size: 9px;
  line-height: 1.4;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* ─── Messages area ─── */
.chatbox__messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 200px;
  scroll-behavior: smooth;
}

/* Custom scrollbar */
.chatbox__messages::-webkit-scrollbar {
  width: 4px;
}

.chatbox__messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbox__messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* ─── Message row (avatar + bubble) ─── */
.chatbox__msg-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: msgFadeIn 0.3s ease-out;
}

.chatbox__msg-row--bot {
  align-self: flex-start;
}

.chatbox__msg-row--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

@keyframes msgFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mini avatar next to bot messages */
.chatbox__msg-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  opacity: 0.9;
}

.chatbox__msg-row--user .chatbox__msg-avatar {
  display: none;
}

/* ─── Message bubbles ─── */
.chatbox__msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: var(--text-sm);
  line-height: 1.55;
  word-wrap: break-word;
}

.chatbox__msg--bot {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.chatbox__msg--user {
  background: var(--gradient-message-user);
  color: var(--color-message-user-text);
  border-bottom-right-radius: 4px;
  font-weight: 450;
}

/* ─── Typing indicator ─── */
.chatbox__typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 12px 16px;
}

.chatbox__typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.4s ease-in-out infinite;
}

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

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

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* ─── Input form ─── */
.chatbox__form {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.chatbox__input {
  flex: 1;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 16px;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  overflow-y: auto;
  line-height: 1.4;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.chatbox__input::placeholder {
  color: var(--text-muted);
}

.chatbox__input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}

.chatbox__input:disabled {
  opacity: 0.4;
}

.chatbox__send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--text-primary);
  color: var(--bg-start);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), transform var(--transition), opacity var(--transition);
  flex-shrink: 0;
}

.chatbox__send:hover {
  background: #ffffff;
  transform: scale(1.05);
}

.chatbox__send:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}
