/* ====================================================================
   ESTILOS GENERALES Y TEMA ADHARA (STYLE.CSS)
   Inspirado en la estética mágica, romántica y lavanda de la referencia
   ==================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@600;700&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=Playfair+Display:ital,wght@0,600;1,600&display=swap');

:root {
  --primary-purple: #9d7cd8;
  --primary-light: #d8c7fa;
  --primary-dark: #2c2242;
  --accent-pink: #f7a8b8;
  --bg-gradient: linear-gradient(180deg, #dfd7ee 0%, #c4b5dc 50%, #9f8bb8 100%);
  --screen-bg: #f8f6fc;
  --chat-bg: #151320;
  --chat-bubble-bot: #282438;
  --chat-bubble-user: #c7aef5;
  --chat-text-user: #221538;
  --text-dark: #221c35;
  --text-muted: #746b85;
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-cursive: 'Caveat', cursive;
  --font-serif: 'Playfair Display', serif;
  --shadow-soft: 0 12px 36px rgba(45, 25, 75, 0.25);
  --shadow-bubble: 0 4px 15px rgba(0, 0, 0, 0.15);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-main);
  background: var(--bg-gradient);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--text-dark);
  padding: 10px;
  overflow-x: hidden;
}

/* Contenedor simulador de teléfono (Mobile First) */
.phone-wrapper {
  width: 100%;
  max-width: 400px;
  height: 840px;
  max-height: 96vh;
  background: #ffffff;
  border-radius: 44px;
  box-shadow: 0 25px 60px rgba(28, 14, 48, 0.4), 0 0 0 12px #201a2c;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Pantallas activas / inactivas */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  transition: opacity 0.35s ease, transform 0.35s ease;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.98);
  background-color: var(--screen-bg);
  overflow-y: auto;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
  z-index: 10;
}

/* Barra superior móvil simulada */
.status-bar {
  height: 44px;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: #333;
  z-index: 20;
}

.status-bar.dark-mode {
  color: #e2d9f3;
}

.status-icons {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ====================================================================
   PANTALLA 1: BIENVENIDA (WELCOME)
   ==================================================================== */
#screen-welcome {
  background: linear-gradient(180deg, #ede7f6 0%, #d1c4e9 100%);
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-bottom: 25px;
}

.welcome-header {
  padding: 10px 24px 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #5d4a75;
}

.date-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.welcome-hero-image-wrap {
  width: 100%;
  height: 380px;
  padding: 10px 20px 0 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.welcome-hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 28px;
  box-shadow: 0 10px 25px rgba(66, 36, 102, 0.2);
}

.welcome-content {
  padding: 20px 28px 10px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.app-cursive-logo {
  font-family: var(--font-cursive);
  font-size: 48px;
  color: #4a3469;
  line-height: 1.1;
  margin-bottom: 4px;
}

.welcome-title {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 22px;
  color: #2b1f3d;
  margin-bottom: 10px;
}

.welcome-desc {
  font-size: 14px;
  line-height: 1.5;
  color: #63537a;
  max-width: 280px;
  margin-bottom: 24px;
}

.btn-primary {
  width: 100%;
  padding: 15px 24px;
  background: #bfb0de;
  color: #2b1d3d;
  border: none;
  border-radius: 30px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(103, 76, 148, 0.25);
  transition: all 0.2s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.btn-primary:hover {
  background: #b2a0d6;
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(103, 76, 148, 0.35);
}

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

.link-secondary {
  margin-top: 14px;
  font-size: 13px;
  color: #6d5b88;
  text-decoration: underline;
  cursor: pointer;
}

/* ====================================================================
   PANTALLA 2: SEGURIDAD (SECURITY)
   ==================================================================== */
#screen-security {
  background: #fbf7f2;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0 28px 40px 28px;
}

.screen-nav-header {
  height: 48px;
  display: flex;
  align-items: center;
  z-index: 15;
  margin-top: 4px;
}

.nav-back-btn {
  background: none;
  border: none;
  color: #6d5b88;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.nav-back-btn:hover {
  background: rgba(109, 91, 136, 0.12);
  color: #2b1d3d;
  transform: translateX(-2px);
}

/* Fondos flotantes decorativos */
.security-bg-decor {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.2;
}

.decor-icon {
  position: absolute;
  font-size: 22px;
}
.decor-1 { top: 12%; left: 10%; }
.decor-2 { top: 20%; right: 12%; }
.decor-3 { bottom: 18%; left: 15%; }
.decor-4 { bottom: 25%; right: 10%; }

.security-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: auto;
  margin-bottom: auto;
  z-index: 5;
  width: 100%;
}

.security-key-wrap {
  width: 160px;
  height: 160px;
  margin-bottom: 25px;
  display: flex;
  justify-content: center;
  align-items: center;
  animation: floatKey 3.5s ease-in-out infinite;
}

@keyframes floatKey {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(2deg); }
}

.security-instructions {
  font-size: 15px;
  color: #8c827a;
  margin-bottom: 6px;
  text-align: center;
}

.security-question {
  font-size: 18px;
  font-weight: 700;
  color: #272320;
  text-align: center;
  line-height: 1.4;
  margin-bottom: 28px;
  padding: 0 10px;
}

.security-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.input-group {
  position: relative;
  width: 100%;
}

.input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  pointer-events: none;
}

.security-input {
  width: 100%;
  padding: 16px 16px 16px 48px;
  border-radius: 28px;
  border: 1.5px solid #e5ded5;
  background: #ffffff;
  font-size: 15px;
  font-family: var(--font-main);
  outline: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.03);
  transition: all 0.2s ease;
}

.security-input:focus {
  border-color: #847596;
  box-shadow: 0 4px 16px rgba(132, 117, 150, 0.2);
}

.security-input.shake {
  animation: shakeInput 0.4s ease-in-out;
  border-color: #e57373;
}

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

.btn-dark {
  width: 100%;
  padding: 16px 20px;
  border-radius: 28px;
  background: #1f272e;
  color: #ffffff;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 6px 18px rgba(31, 39, 46, 0.2);
}

.btn-dark:hover {
  background: #2f3a44;
}

.security-error {
  min-height: 24px;
  margin-top: 10px;
  font-size: 13px;
  color: #d32f2f;
  text-align: center;
  font-weight: 500;
  transition: opacity 0.2s ease;
}

/* ====================================================================
   PANTALLA 3: CHAT CON INTELIGENCIA ARTIFICIAL
   ==================================================================== */
#screen-chat {
  background: var(--chat-bg);
  display: flex;
  flex-direction: column;
}

.chat-header {
  height: 68px;
  background: #1b172a;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 10;
}

.chat-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-back-btn {
  background: none;
  border: none;
  color: #d1c4e9;
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-container {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #a88be2;
  box-shadow: 0 2px 10px rgba(168, 139, 226, 0.3);
  background: #2a223f;
  flex-shrink: 0;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-text-details h4 {
  font-size: 15px;
  font-weight: 600;
  color: #f1edfa;
  line-height: 1.2;
}

.user-text-details span {
  font-size: 11px;
  color: #a49ab5;
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
}

.chat-header-actions {
  display: flex;
  gap: 12px;
  color: #b0a4c5;
  font-size: 18px;
}

.action-icon {
  cursor: pointer;
}

/* Área de mensajes */
.chat-messages {
  flex: 1;
  padding: 16px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

/* Burbuja de mensaje */
.msg-row {
  display: flex;
  gap: 8px;
  max-width: 82%;
  animation: fadeInMsg 0.3s ease;
}

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

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

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

.bot-avatar-mini {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  align-self: flex-end;
  border: 1px solid #7d65b1;
}

.bot-avatar-mini img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bubble {
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.45;
  border-radius: 20px;
  position: relative;
  word-wrap: break-word;
}

.msg-row.bot .bubble {
  background: var(--chat-bubble-bot);
  color: #ede9f7;
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-bubble);
}

.msg-row.user .bubble {
  background: var(--chat-bubble-user);
  color: var(--chat-text-user);
  border-bottom-right-radius: 4px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(189, 160, 234, 0.25);
}

.meta-status {
  font-size: 10px;
  text-align: right;
  margin-top: 4px;
  color: #554471;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
}

/* Indicador de "Escribiendo..." */
.typing-indicator {
  display: none;
  align-self: flex-start;
  background: var(--chat-bubble-bot);
  padding: 10px 16px;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  gap: 4px;
  align-items: center;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background: #a89bc2;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Barra inferior del chat */
.chat-footer {
  padding: 10px 14px 18px 14px;
  background: #191626;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-input-bar {
  display: flex;
  align-items: center;
  background: #252136;
  border-radius: 30px;
  padding: 6px 10px 6px 14px;
  gap: 10px;
}

.chat-input-bar input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-size: 14px;
  font-family: var(--font-main);
}

.chat-input-bar input::placeholder {
  color: #7d7293;
}

.bar-icon-btn {
  background: none;
  border: none;
  color: #9f91ba;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  transition: color 0.2s ease;
}

.bar-icon-btn:hover {
  color: #d1c4e9;
}

.btn-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #bfb0de;
  border: none;
  color: #26173d;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-send:hover {
  background: #d4c7f0;
  transform: scale(1.05);
}

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