/* questionario-chat.css - Fullscreen chat */
:root {
  --chat-bg: #f8f4e8;
  --chat-card: #ffffff;
  --chat-text: #0f2a1e;
  --chat-primary: #1e3a2e;
  --chat-secondary: #2d5f3f;
  --chat-bot-start: #eef5f0;
  --chat-bot-end: #e2ede5;
}

#chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 42, 30, 0.95);
  opacity: 0;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#chat-overlay.active {
  opacity: 1;
}

.chat-wrapper {
  width: 100%;
  max-width: 720px;
  height: 100%;
  max-height: 90vh;
  background: var(--chat-card);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: translateY(30px);
  transition: transform 0.3s ease;
}

#chat-overlay.active .chat-wrapper {
  transform: translateY(0);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--chat-primary);
  color: #ffffff;
  font-weight: 600;
  font-size: 16px;
}

.chat-logo {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  object-fit: contain;
  background: #ffffff;
  padding: 2px;
}

.chat-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.25);
}

.chat-title {
  flex: 1;
}

.chat-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--chat-bg);
  scroll-behavior: smooth;
}

.chat-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  animation: fadeUp 0.3s ease both;
}

.chat-row.bot {
  justify-content: flex-start;
}

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

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: #ffffff;
  padding: 3px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.chat-bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 15px;
}

.chat-bubble.bot {
  background: linear-gradient(180deg, var(--chat-bot-start), var(--chat-bot-end));
  border: 1px solid #cfe2d6;
  color: var(--chat-text);
}

.chat-bubble.user {
  background: var(--chat-primary);
  color: #ffffff;
}

.chat-choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fadeUp 0.3s ease both;
}

.chat-btn {
  width: 100%;
  padding: 16px 20px;
  border-radius: 12px;
  background: var(--chat-primary);
  color: #ffffff;
  border: none;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  text-align: left;
}

.chat-btn:hover:not(:disabled) {
  background: var(--chat-secondary);
  transform: translateY(-1px);
}

.chat-btn:active {
  transform: scale(0.98);
}

.chat-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-btn-ghost {
  background: #ffffff;
  color: var(--chat-text);
  border: 1px solid #cce0d3;
}

.chat-btn-ghost:hover:not(:disabled) {
  background: #f0f7f3;
  border-color: #a0c1ad;
}

.chat-btn-close {
  background: #f3f4f6;
  color: #1f2937;
  border: 1px solid #e5e7eb;
}

.chat-btn-close:hover:not(:disabled) {
  background: #e5e7eb;
}

.chat-input-field {
  display: flex;
  gap: 10px;
  align-items: center;
}

.chat-input {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid #cce0d3;
  font-size: 16px;
  color: var(--chat-text);
  background: #ffffff;
  transition: border-color 0.2s;
}

.chat-input:focus {
  outline: none;
  border-color: var(--chat-primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 46, 0.1);
}

.chat-arrow {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 12px;
  border: none;
  background: var(--chat-primary);
  color: #ffffff;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-arrow:hover:not(:disabled) {
  background: var(--chat-secondary);
}

.chat-arrow:active {
  transform: scale(0.95);
}

.chat-arrow:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.typing {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.typing .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9fb5a9;
  opacity: 0.35;
  animation: blink 1.4s infinite ease-in-out;
}

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

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

@keyframes blink {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-3px); }
  70% { opacity: 0.4; transform: translateY(0); }
}

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

@media (max-width: 768px) {
  #chat-overlay {
    padding: 0;
  }
  
  .chat-wrapper {
    max-width: 100%;
    max-height: 100%;
    height: 100dvh;
    border-radius: 0;
  }
  
  .chat-body {
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  #chat-overlay,
  .chat-wrapper,
  .chat-row,
  .chat-choices,
  .typing .dot {
    animation: none !important;
    transition: none !important;
  }
  
  .chat-body {
    scroll-behavior: auto;
  }
}
