/* ========================================================
   ESTILOS GENERALES Y VARIABLES DE DISEÑO
   ======================================================== */
:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;
  --accent: #06b6d4;
  --accent-pink: #f43f5e;
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-white: #ffffff;
  --bot-bubble: #f1f5f9;
  --user-bubble: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow-card: 0 20px 40px -15px rgba(0, 0, 0, 0.3), 0 0 1px 1px rgba(255, 255, 255, 0.1);
  --shadow-bubble: 0 4px 12px rgba(0, 0, 0, 0.05);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  overflow-x: hidden;
}

/* ========================================================
   CONTENEDOR PRINCIPAL Y PANTALLAS
   ======================================================== */
.app-wrapper {
  width: 100%;
  max-width: 580px;
  min-height: 600px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.screen {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.screen.screen-active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
  position: relative;
}

.screen.screen-hidden {
  display: none;
}

/* Tarjeta estándar para pantallas 1 y 2 */
.screen-card {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-card);
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ========================================================
   PANTALLA 1: INICIO
   ======================================================== */
.hero-image-wrapper {
  width: 100%;
  max-height: 240px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 24px;
}

.hero-image-wrapper img {
  max-width: 100%;
  height: 220px;
  object-fit: contain;
  filter: drop-shadow(0 10px 20px rgba(79, 70, 229, 0.15));
  transition: transform 0.3s ease;
}

.hero-image-wrapper img:hover {
  transform: scale(1.02);
}

.badge {
  display: inline-block;
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 999px;
  margin-bottom: 14px;
}

.badge-accent {
  background: #fef2f2;
  color: var(--accent-pink);
}

.hero-content h1 {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
  margin-bottom: 12px;
}

.hero-content p {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 28px;
}

/* ========================================================
   BOTONES
   ======================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 14px 28px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--text-white);
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.35);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.45);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 18px;
  height: 18px;
}

/* ========================================================
   PANTALLA 2: SEGURIDAD
   ======================================================== */
.security-icon-wrapper {
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
}

.icon-circle {
  width: 68px;
  height: 68px;
  background: #fef2f2;
  color: var(--accent-pink);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(244, 63, 94, 0.15);
}

.icon-circle svg {
  width: 32px;
  height: 32px;
}

.security-content h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text-main);
  line-height: 1.35;
}

.security-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.security-form .input-group {
  margin-bottom: 16px;
}

.security-form input {
  width: 100%;
  padding: 14px 18px;
  font-size: 1rem;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface-alt);
  transition: var(--transition);
  outline: none;
}

.security-form input:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.alert-message {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  text-align: left;
}

.alert-error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fee2e2;
  animation: shake 0.4s ease;
}

.alert-error svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.hidden {
  display: none !important;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* ========================================================
   PANTALLA 3: CHAT Y MENSAJES
   ======================================================== */
.chat-card {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  height: 640px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.chat-header {
  padding: 16px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar-wrapper {
  position: relative;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.avatar-icon {
  width: 22px;
  height: 22px;
}

.avatar-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  background: #10b981;
  border: 2px solid white;
  border-radius: 50%;
}

.bot-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.bot-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.status-indicator {
  width: 7px;
  height: 7px;
  background: #10b981;
  border-radius: 50%;
  display: inline-block;
}

.btn-icon-action {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  position: relative;
}

.btn-icon-action:hover {
  background: var(--surface-alt);
  color: var(--accent-pink);
}

.btn-icon-action svg {
  width: 20px;
  height: 20px;
}

.action-tooltip {
  display: none;
  position: absolute;
  bottom: -28px;
  right: 0;
  background: #0f172a;
  color: #fff;
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
}

.btn-icon-action:hover .action-tooltip {
  display: block;
}

/* Área de mensajes */
.chat-messages-container {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #fafbfc;
  scroll-behavior: smooth;
}

.chat-messages-container::-webkit-scrollbar {
  width: 6px;
}

.chat-messages-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

.message-row {
  display: flex;
  width: 100%;
}

.message-bot {
  justify-content: flex-start;
}

.message-user {
  justify-content: flex-end;
}

.message-bubble {
  max-width: 82%;
  padding: 12px 18px;
  border-radius: 18px;
  font-size: 0.94rem;
  line-height: 1.5;
  box-shadow: var(--shadow-bubble);
  word-break: break-word;
  position: relative;
}

.message-bot .message-bubble {
  background: var(--bot-bubble);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}

.message-user .message-bubble {
  background: var(--user-bubble);
  color: var(--text-white);
  border-bottom-right-radius: 4px;
}

.message-time {
  display: block;
  font-size: 0.7rem;
  margin-top: 6px;
  opacity: 0.7;
  text-align: right;
}

/* Indicador de escritura (Thinking) */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: #fafbfc;
}

.typing-bubble {
  background: var(--bot-bubble);
  padding: 8px 14px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: typingBounce 1.3s infinite;
}

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

.typing-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* Input inferior */
.chat-footer {
  padding: 14px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.chat-input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 8px 6px 14px;
  transition: var(--transition);
}

.chat-input-wrapper:focus-within {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.chat-input-wrapper textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-main);
  resize: none;
  max-height: 100px;
  line-height: 1.4;
  padding: 4px 0;
}

.btn-send {
  background: var(--primary);
  border: none;
  border-radius: 12px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-send:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

.btn-send:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  transform: none;
}

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

.chat-footer-note {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  body {
    padding: 0;
  }

  .app-wrapper {
    height: 100vh;
    min-height: 100vh;
    border-radius: 0;
  }

  .screen-card, .chat-card {
    height: 100vh;
    border-radius: 0;
    padding: 24px 18px;
    box-shadow: none;
  }

  .chat-card {
    display: flex;
    flex-direction: column;
  }
}
