/* ── Chat-specific styles ── */

/* Full-page chat layout */
.chat-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.chat-page nav {
  flex-shrink: 0;
}

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  overflow: hidden;
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-messages .bubble {
  animation: fadeIn 0.3s ease;
}

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

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 14px 18px;
  align-self: flex-start;
}

.typing-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite;
}

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

.typing-indicator .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; }
}

/* Dark theme typing dots */
.typing-indicator .dot {
  background: #666;
}

/* Chat input bar */
.chat-input-bar {
  flex-shrink: 0;
  padding: 16px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-input-form {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 800px;
  margin: 0 auto;
}

.chat-input-form input {
  flex: 1;
  padding: 14px 18px;
  border-radius: 14px;
  border: none;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  outline: none;
}

.chat-input-form button {
  width: 44px;
  height: 44px;
  background: #EB1414;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.chat-input-form button:hover {
  background: #d41111;
}

.chat-input-form button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-input-form button svg {
  width: 20px;
  height: 20px;
}

/* Quick action buttons for chat page */
.chat-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 16px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.chat-quick-actions .quick-btn {
  font-size: 0.8rem;
  padding: 8px 16px;
}

/* ── Initial view (State 1) ── */
.chat-initial {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px 24px;
  gap: 24px;
  overflow-y: auto;
}

.chat-welcome-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 560px;
  width: 100%;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  background: #3b82f6;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
}

.chat-welcome-row .bubble {
  animation: none;
}

.chat-initial-form {
  width: 100%;
  max-width: 560px;
}

.chat-initial-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 9999px;
  padding: 6px 6px 6px 20px;
}

.chat-initial-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  padding: 10px 0;
}

.chat-initial-input-wrap button {
  width: 40px;
  height: 40px;
  background: #EB1414;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.chat-initial-input-wrap button:hover {
  background: #d41111;
}

.chat-initial-input-wrap button svg {
  width: 18px;
  height: 18px;
}

.chat-popular-label {
  font-size: 0.85rem;
  opacity: 0.5;
  margin: 0;
  text-align: center;
}

.chat-initial .chat-quick-actions {
  justify-content: center;
  padding: 0;
  max-width: 560px;
}

.chat-disclaimer {
  font-size: 0.75rem;
  opacity: 0.35;
  margin: 0;
  text-align: center;
  max-width: 560px;
}

/* Conversation view (State 2) */
.chat-conversation {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Dark theme — initial view */
.theme-dark .chat-initial-input-wrap {
  background: #262626;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.theme-dark .chat-initial-input-wrap input {
  color: #fafafa;
}

/* Light theme — initial view */
.theme-light .chat-initial-input-wrap {
  background: #fff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.theme-light .chat-initial-input-wrap input {
  color: #1a1a1a;
}

/* Banners */
.chat-banner {
  padding: 16px 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.chat-banner-escalation {
  background: #3d2f00;
  border-bottom: 1px solid #5a4500;
}

.chat-banner-callback {
  background: #0a3d0a;
  border-bottom: 1px solid #0d4d0d;
}

.chat-banner-content {
  flex: 1;
}

.chat-banner-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.chat-banner-detail {
  font-size: 0.85rem;
  opacity: 0.7;
}

.chat-banner-link {
  color: #EB1414;
  text-decoration: underline;
  font-size: 0.85rem;
}

.chat-banner-close {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px;
}

.chat-banner-close:hover {
  opacity: 1;
}

/* Hero mini-chat */
#hero-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 300px;
  overflow-y: auto;
  padding: 4px 0;
}

#hero-chat-messages::-webkit-scrollbar {
  width: 4px;
}

#hero-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.hero-chat-input {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-radius: 14px;
  margin-top: 8px;
}

.hero-chat-input input {
  flex: 1;
  background: transparent;
  border: none;
  color: inherit;
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  outline: none;
}

.hero-chat-input input::placeholder {
  opacity: 0.8;
}

.hero-chat-input button {
  width: 36px;
  height: 36px;
  background: #EB1414;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-chat-open-full {
  text-align: center;
  margin-top: 8px;
}

.hero-chat-open-full a {
  font-size: 0.8rem;
  color: #EB1414;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.hero-chat-open-full a:hover {
  opacity: 1;
}

/* Dark theme specific */
.theme-dark .chat-input-form input {
  background: #262626;
  color: #fafafa;
}

.theme-dark .hero-chat-input {
  background: #262626;
}

/* Light theme specific */
.theme-light .chat-input-form input {
  background: #f0f0f0;
  color: #1a1a1a;
}

.theme-light .hero-chat-input {
  background: #f0f0f0;
}

.theme-light .chat-input-bar {
  border-top-color: rgba(0, 0, 0, 0.08);
}

.theme-light .typing-indicator .dot {
  background: #999;
}

.theme-light .chat-banner-escalation {
  background: #fff8e1;
  border-bottom-color: #ffe082;
  color: #1a1a1a;
}

.theme-light .chat-banner-callback {
  background: #e8f5e9;
  border-bottom-color: #a5d6a7;
  color: #1a1a1a;
}

.theme-light #hero-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
}

/* Responsive */
@media (max-width: 900px) {
  .chat-messages {
    padding: 16px 12px;
  }

  .chat-input-bar {
    padding: 12px 16px;
  }
}
