/* ============================================================================
   SECUREACCESS AI - ESTILOS VISUALES (style.css)
   Inspirado en la interfaz de referencia: Estética pastel, limpia y mobile-first
   ============================================================================ */

:root {
  --bg-app: #F7F3EE;
  --bg-card: #FAF7F2;
  --primary-rose: #D49B95;
  --primary-rose-hover: #BF827C;
  --primary-rose-active: #AA6E68;
  --text-main: #2D2625;
  --text-muted: #827572;
  --accent-gold: #C59B58;
  --user-bubble: #E7DEEF;
  --user-text: #3D2D49;
  --bot-bubble: #F5EFEB;
  --bot-text: #3E3835;
  --border-light: rgba(180, 155, 145, 0.2);
  --shadow-soft: 0 10px 30px rgba(100, 70, 60, 0.08);
  --radius-screen: 38px;
  --radius-btn: 28px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: linear-gradient(135deg, #EBE5DC 0%, #DFD6CA 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  color: var(--text-main);
}

/* ============================================================================
   CONTENEDOR DISPOSITIVO MÓVIL
   ============================================================================ */
.mobile-wrapper {
  width: 100%;
  max-width: 400px;
  height: 820px;
  max-height: 94vh;
  background-color: var(--bg-app);
  border-radius: var(--radius-screen);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.18), 0 0 0 10px #2D2727, 0 0 0 12px rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-light);
}

/* Barra superior simulada (Island / Notch & Status) */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px 8px 24px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  z-index: 20;
}

.status-bar .notch {
  width: 100px;
  height: 24px;
  background: #111;
  border-radius: 20px;
  margin: 0 auto;
}

.status-icons {
  display: flex;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-main);
}

/* Contenedor de pantallas */
.screen-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* Estado de pantallas (Transiciones) */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  background-color: var(--bg-app);
}

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

/* ============================================================================
   PANTALLA 1: BIENVENIDA
   ============================================================================ */
.screen-1 {
  padding: 16px 28px 36px 28px;
  text-align: center;
  justify-content: space-between;
}

.brand-header {
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: var(--text-main);
  margin-top: 10px;
}

.welcome-title-group {
  margin-top: 20px;
}

.welcome-title {
  font-size: 1.9rem;
  font-weight: 400;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
  font-family: "Georgia", "Times New Roman", serif;
  color: var(--text-main);
}

.welcome-subtitle {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.4;
  max-width: 260px;
  margin: 0 auto;
}

.illustration-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 0;
}

.illustration-img {
  max-width: 240px;
  max-height: 240px;
  width: 100%;
  object-fit: contain;
  filter: drop-shadow(0 8px 16px rgba(212, 155, 149, 0.15));
  border-radius: 50%;
  transition: transform 0.3s ease;
}

.illustration-img:hover {
  transform: scale(1.03);
}

.screen-1-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.btn-primary {
  background-color: var(--primary-rose);
  color: #FFFFFF;
  border: none;
  padding: 16px 24px;
  border-radius: var(--radius-btn);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(212, 155, 149, 0.4);
  transition: all 0.25s ease;
}

.btn-primary:hover {
  background-color: var(--primary-rose-hover);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(212, 155, 149, 0.5);
}

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

.link-secondary {
  color: var(--primary-rose);
  font-size: 0.88rem;
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
}

.link-secondary:hover {
  text-decoration: underline;
}

/* ============================================================================
   PANTALLA 2: SEGURIDAD DE CUENTA / PREGUNTA
   ============================================================================ */
.screen-2 {
  padding: 12px 24px 36px 24px;
}

.screen-top-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px 0;
  margin-bottom: 24px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  user-select: none;
}

.screen-top-nav:hover {
  color: var(--text-main);
}

.back-arrow {
  font-size: 1.1rem;
  line-height: 1;
}

.security-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.identity-header-wrap {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.identity-title {
  font-size: 1.55rem;
  font-weight: 400;
  font-family: "Georgia", "Times New Roman", serif;
  color: var(--text-main);
}

.flower-accent {
  font-size: 1.4rem;
  opacity: 0.6;
}

.security-instruction {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 20px;
}

.security-question-box {
  background-color: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(212, 155, 149, 0.3);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 24px;
}

.security-question-text {
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.4;
  text-align: center;
}

.input-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: block;
}

.security-input {
  width: 100%;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid var(--border-light);
  background-color: #FFFFFF;
  font-size: 0.95rem;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  margin-bottom: 8px;
}

.security-input:focus {
  border-color: var(--primary-rose);
  box-shadow: 0 0 0 3px rgba(212, 155, 149, 0.25);
}

.security-error-msg {
  font-size: 0.8rem;
  color: #C0392B;
  min-height: 20px;
  margin-bottom: 16px;
  text-align: center;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.security-error-msg.visible {
  opacity: 1;
}

/* ============================================================================
   PANTALLA 3: CHAT CON IA (SOPORTE TÉCNICO)
   ============================================================================ */
.screen-3 {
  padding: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-app);
}

.chat-header {
  padding: 12px 18px 12px 18px;
  background-color: rgba(247, 243, 238, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-header-info {
  display: flex;
  flex-direction: column;
}

.chat-header-title {
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 1px;
  font-family: "Georgia", "Times New Roman", serif;
  text-transform: uppercase;
  color: var(--text-main);
}

.chat-status {
  font-size: 0.72rem;
  color: #27AE60;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}

.status-dot {
  width: 6px;
  height: 6px;
  background-color: #27AE60;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 6px #27AE60;
}

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

.memory-pill {
  background-color: rgba(197, 155, 88, 0.15);
  color: var(--accent-gold);
  border: 1px solid rgba(197, 155, 88, 0.3);
  border-radius: 12px;
  padding: 4px 8px;
  font-size: 0.68rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  title: "Memoria de hechos activa";
}

.chat-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* Burbujas de chat */
.message-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: fadeInMsg 0.3s ease;
}

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

.message-row.user {
  align-self: flex-end;
}

.message-row.assistant {
  align-self: flex-start;
}

.message-card {
  padding: 12px 14px;
  border-radius: 18px;
  position: relative;
  font-size: 0.88rem;
  line-height: 1.45;
}

.message-row.user .message-card {
  background-color: var(--user-bubble);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(100, 70, 110, 0.05);
}

.message-row.assistant .message-card {
  background-color: var(--bot-bubble);
  color: var(--bot-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(90, 70, 50, 0.05);
  border: 1px solid rgba(220, 210, 200, 0.5);
}

.message-sender {
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.message-row.user .message-sender {
  color: #6C497B;
}

.message-row.assistant .message-sender {
  color: var(--accent-gold);
}

.sender-badge {
  width: 18px;
  height: 18px;
  background-color: var(--accent-gold);
  color: #FFF;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: bold;
}

.message-body {
  word-break: break-word;
}

.message-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 4px;
  display: block;
}

/* Indicador de escritura "Escribiendo..." */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background-color: var(--bot-bubble);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  border: 1px solid rgba(220, 210, 200, 0.5);
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 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 typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Barra inferior de envío */
.chat-input-bar {
  padding: 10px 16px 14px 16px;
  background-color: #FFFFFF;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-input-field {
  flex: 1;
  background-color: #F8F4EE;
  border: 1px solid rgba(212, 155, 149, 0.25);
  border-radius: 22px;
  padding: 12px 18px;
  font-size: 0.88rem;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s ease;
}

.chat-input-field:focus {
  border-color: var(--primary-rose);
  background-color: #FFFFFF;
}

.chat-action-btn {
  background: none;
  border: none;
  color: var(--primary-rose);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 50%;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.chat-action-btn:hover {
  background-color: rgba(212, 155, 149, 0.12);
  transform: scale(1.08);
}

.chat-action-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Modal o Alerta de Memoria */
.memory-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.memory-modal.open {
  opacity: 1;
  pointer-events: all;
}

.memory-modal-card {
  background: #FFF;
  border-radius: 20px;
  padding: 22px;
  width: 100%;
  max-height: 80%;
  overflow-y: auto;
  box-shadow: 0 16px 40px rgba(0,0,0,0.2);
}

.memory-modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.memory-list {
  list-style: none;
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.memory-list li {
  background: #FAF6F0;
  padding: 10px 12px;
  border-radius: 10px;
  border-left: 3px solid var(--accent-gold);
}

.memory-close-btn {
  width: 100%;
  padding: 10px;
  background: var(--primary-rose);
  color: #FFF;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* Responsividad para móviles reales */
@media (max-width: 450px) {
  body {
    padding: 0;
    background: var(--bg-app);
  }
  .mobile-wrapper {
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    box-shadow: none;
    border: none;
  }
}
