/* ==============================================================================
   ESTILOS DE LA APLICACIÓN JASHLEY - CHAT CON IA Y MEMORIA COGNITIVA
   ============================================================================== */

:root {
  --color-primary: #C62828;        /* Rojo carmesí principal */
  --color-primary-dark: #8E0000;   /* Rojo oscuro oriental */
  --color-primary-light: #FF5F52;  /* Rojo coral */
  --color-gold: #D4AF37;           /* Dorado oriental */
  --color-gold-light: #F9E79F;     /* Dorado suave */
  --color-bg-cream: #FAF4EB;       /* Crema apergaminado cálido */
  --color-bg-card: #FFFFFF;        /* Blanco puro */
  --color-text-main: #2C2C2C;      /* Gris carbón */
  --color-text-muted: #7A7A7A;     /* Gris medio */
  --color-bubble-bot: #F0EAE1;     /* Burbuja bot suave */
  --color-bubble-user: #C62828;    /* Burbuja usuario rojo */
  --color-border: #E8D8C8;         /* Borde suave */
  --shadow-soft: 0 10px 30px rgba(198, 40, 40, 0.12);
  --shadow-strong: 0 15px 40px rgba(0, 0, 0, 0.25);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 10px;
}

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

body {
  background: linear-gradient(135deg, #1A1A1A 0%, #2D1515 50%, #150A0A 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
  color: var(--color-text-main);
  overflow-x: hidden;
}

/* ------------------------------------------------------------------------------
   CONTENEDOR MÓVIL (MOCKUP DISPOSITIVO INTELIGENTE)
   ------------------------------------------------------------------------------ */
.device-wrapper {
  width: 100%;
  max-width: 420px;
  height: 860px;
  max-height: 94vh;
  background-color: var(--color-bg-cream);
  border-radius: 46px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.55), 0 0 0 10px #1E1E1E, 0 0 0 12px #333333;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Barra de estado superior estilo iPhone (Status Bar) */
.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: 50;
  background: transparent;
  user-select: none;
}

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

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

/* Dynamic Island / Notch superior decorativo */
.notch {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 110px;
  height: 26px;
  background: #000;
  border-radius: 20px;
  z-index: 60;
}

/* Contenedor de pantallas */
.screens-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Pantalla Genérica */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none !important;
  flex-direction: column;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  overflow-y: auto;
  pointer-events: none;
}

.screen.active {
  display: flex !important;
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

/* ------------------------------------------------------------------------------
   PANTALLA 1: INICIO (IMAGEN INTRO)
   ------------------------------------------------------------------------------ */
#screen-1 {
  background: linear-gradient(180deg, #FDF7F0 0%, #FAECEB 60%, #F5D7D7 100%);
  padding: 15px 24px 30px 24px;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  gap: 10px;
}

.intro-top-header {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.silhouette-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, #FFF0F0 0%, #FFF8EE 100%);
  border: 2px solid var(--color-gold);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 8px;
  box-shadow: 0 4px 15px rgba(198, 40, 40, 0.15);
}

.silhouette-svg {
  width: 36px;
  height: 36px;
  fill: var(--color-primary);
  filter: drop-shadow(0 2px 4px rgba(198, 40, 40, 0.3));
}

.intro-title {
  font-size: 38px;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.intro-subtitle {
  font-size: 15px;
  font-weight: 600;
  color: #4A4A4A;
}

/* Tarjeta de ilustración de Pucca y Garu */
.intro-illustration-card {
  width: 100%;
  max-width: 320px;
  height: 250px;
  background: #FFF;
  border-radius: 24px;
  padding: 12px;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border: 2px solid #F0DFDF;
  margin: 15px 0;
}

.intro-illustration-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 16px;
  transition: transform 0.4s ease;
}

.intro-illustration-card:hover img {
  transform: scale(1.04);
}

.floating-hearts-overlay {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 22px;
  animation: floatHeart 2.5s infinite ease-in-out alternate;
}

@keyframes floatHeart {
  0% { transform: translateY(0) scale(1); opacity: 0.8; }
  100% { transform: translateY(-10px) scale(1.15); opacity: 1; }
}

.romantic-quote {
  font-size: 13.5px;
  font-style: italic;
  color: #B71C1C;
  line-height: 1.5;
  margin: 0 10px 15px 10px;
  font-weight: 500;
}

.btn-intro-next {
  width: 100%;
  max-width: 290px;
  background: linear-gradient(135deg, #C62828 0%, #A91E1E 100%);
  color: #FFF;
  border: none;
  height: 54px;
  border-radius: 27px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(198, 40, 40, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-intro-next:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(198, 40, 40, 0.5);
}

.btn-intro-next:active {
  transform: translateY(1px);
}

.corner-mascot {
  position: absolute;
  right: -15px;
  bottom: -15px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 3px solid #FFF;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  object-fit: cover;
  background: #FFF;
}

/* ------------------------------------------------------------------------------
   PANTALLA 2: PREGUNTA DE SEGURIDAD (VERIFICACIÓN)
   ------------------------------------------------------------------------------ */
#screen-2 {
  background-color: var(--color-bg-cream);
  flex-direction: column;
}

.oriental-header-banner {
  background: linear-gradient(180deg, #8E0000 0%, #B71C1C 100%);
  padding: 16px 20px;
  text-align: center;
  position: relative;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  border-bottom: 2px solid var(--color-gold);
}

.banner-back-btn {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-gold-light);
  font-size: 20px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: none;
  cursor: pointer;
  transition: background 0.2s;
}

.banner-back-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.oriental-pattern-decor {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0.15;
  background-image: radial-gradient(var(--color-gold) 1.5px, transparent 1.5px);
  background-size: 12px 12px;
}

.banner-title {
  color: var(--color-gold-light);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.security-body-container {
  flex: 1;
  padding: 35px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
}

.security-question-text {
  font-size: 24px;
  font-weight: 700;
  color: #2F2626;
  margin-bottom: 30px;
  line-height: 1.35;
}

.security-input-box {
  width: 100%;
  max-width: 320px;
  background: #FFF;
  border: 1.5px solid #C4A482;
  border-radius: 16px;
  padding: 15px 18px;
  font-size: 16px;
  color: #333;
  outline: none;
  transition: all 0.3s ease;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.04);
}

.security-input-box:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(198, 40, 40, 0.15);
}

.btn-security-submit {
  margin-top: 25px;
  width: 100%;
  max-width: 320px;
  height: 58px;
  background: linear-gradient(180deg, #8E0000 0%, #A91E1E 50%, #670000 100%);
  border: 2px solid var(--color-gold);
  border-radius: 29px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  box-shadow: 0 8px 20px rgba(142, 0, 0, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-security-submit:hover {
  transform: scale(1.02);
  box-shadow: 0 10px 25px rgba(142, 0, 0, 0.45);
}

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

.heart-button-icon {
  font-size: 26px;
  filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.8));
  animation: pulseHeart 1.6s infinite ease-in-out;
}

@keyframes pulseHeart {
  0% { transform: scale(1); }
  50% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

.security-error-msg {
  margin-top: 18px;
  font-size: 13.5px;
  color: #C62828;
  font-weight: 600;
  min-height: 20px;
  transition: opacity 0.3s ease;
}

.security-hint {
  margin-top: 10px;
  font-size: 12px;
  color: #888;
}

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

.shake-animation {
  animation: shakeAnimation 0.45s ease-in-out;
}

/* ------------------------------------------------------------------------------
   PANTALLA 3: CHAT CON GPT-4o-mini Y MEMORIA
   ------------------------------------------------------------------------------ */
#screen-3 {
  background: #FDF9F3;
  flex-direction: column;
}

.chat-navbar {
  background: #FFF;
  height: 60px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #ECE0D1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.nav-back-btn {
  background: none;
  border: none;
  font-size: 22px;
  color: #444;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
}

.nav-back-btn:hover {
  background: #F0EAE1;
}

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

.chat-header-title {
  font-size: 15px;
  font-weight: 700;
  color: #222;
}

.chat-header-status {
  font-size: 11px;
  color: #2E7D32;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-primary);
  cursor: pointer;
}

/* Barra de estado de Memoria Persistente */
.memory-badge-bar {
  background: #FFF4E5;
  border-bottom: 1px solid #FFE0B2;
  padding: 6px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: #B78103;
  font-weight: 600;
}

.btn-open-memory {
  background: #FFF;
  border: 1px solid #F0C36D;
  color: #A36B00;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 11px;
  cursor: pointer;
  font-weight: 600;
}

.btn-open-memory:hover {
  background: #FFFBEA;
}

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

/* Mensajes individuales */
.message-row {
  display: flex;
  gap: 10px;
  max-width: 88%;
}

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

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

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.msg-content-wrapper {
  display: flex;
  flex-direction: column;
}

.msg-sender-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 3px;
  margin-left: 4px;
}

.message-row.user .msg-sender-name {
  text-align: right;
  margin-right: 4px;
}

.msg-bubble {
  padding: 12px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.45;
  position: relative;
  word-break: break-word;
}

.msg-bubble strong {
  font-weight: 700;
}

.msg-bubble em {
  font-style: italic;
}

.message-row.bot .msg-bubble {
  background-color: #EDE4D8;
  color: #2D2522;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.message-row.user .msg-bubble {
  background: linear-gradient(135deg, #C62828 0%, #A91E1E 100%);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
  box-shadow: 0 3px 10px rgba(198, 40, 40, 0.25);
}

.msg-time {
  font-size: 10px;
  opacity: 0.65;
  margin-top: 4px;
  text-align: right;
}

/* Notificación de recuerdo capturado */
.memory-saved-pill {
  font-size: 11px;
  background: #E8F5E9;
  color: #2E7D32;
  border: 1px solid #C8E6C9;
  border-radius: 12px;
  padding: 3px 8px;
  margin-top: 5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Respuestas Rápidas (Chips / Pills) */
.quick-replies-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  margin-bottom: 8px;
}

.quick-chip {
  background-color: #FFF;
  border: 1px solid #DFCEBE;
  color: #4A3B32;
  border-radius: 16px;
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
}

.quick-chip:hover {
  background-color: #F8ECE1;
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Botones rápidos de emoción (Bien / Mal) */
.sentiment-chips-wrapper {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.sentiment-chip {
  border: none;
  background: #C62828;
  color: #FFF;
  border-radius: 14px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.sentiment-chip:hover {
  background: #8E0000;
}

/* Indicador de escritura (Typing...) */
.message-row.typing-row {
  align-self: flex-start;
  margin-bottom: 4px;
}

.typing-bubble {
  background-color: #EDE4D8;
  padding: 12px 16px;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: #887B73;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

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

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

/* Barra inferior de entrada del Chat */
.chat-input-bar {
  background: #FFF;
  padding: 10px 14px;
  border-top: 1px solid #ECE0D1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-input-field {
  flex: 1;
  height: 44px;
  background: #F4EDE4;
  border: 1px solid #E2D3C4;
  border-radius: 22px;
  padding: 0 16px;
  font-size: 14px;
  color: #333;
  outline: none;
}

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

.btn-send-message {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #C62828 0%, #A91E1E 100%);
  border: none;
  color: #FFF;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(198, 40, 40, 0.35);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.btn-send-message:hover {
  transform: scale(1.06);
}

.btn-send-message svg {
  width: 20px;
  height: 20px;
  fill: #FFF;
}

/* ------------------------------------------------------------------------------
   MODAL INSPECTOR DE MEMORIA (DRAWER)
   ------------------------------------------------------------------------------ */
.memory-modal {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: none;
  justify-content: center;
  align-items: flex-end;
}

.memory-modal.active {
  display: flex;
}

.memory-sheet {
  width: 100%;
  max-height: 80%;
  background: #FFF;
  border-top-left-radius: 26px;
  border-top-right-radius: 26px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.25);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.sheet-title {
  font-size: 17px;
  font-weight: 700;
  color: #222;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sheet-close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: #888;
  cursor: pointer;
}

.memory-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0 15px 0;
  padding-right: 5px;
}

.memory-item {
  background: #FDF7F0;
  border-left: 4px solid var(--color-primary);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  color: #443;
  line-height: 1.4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.memory-item-content {
  flex: 1;
}

.btn-delete-memory-item {
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.5;
  font-size: 14px;
  padding: 4px;
  border-radius: 6px;
  transition: opacity 0.2s, transform 0.2s, background 0.2s;
  flex-shrink: 0;
}

.btn-delete-memory-item:hover {
  opacity: 1;
  transform: scale(1.15);
  background: #FFEBEE;
}

.btn-clear-memories {
  background: #FFF0F0;
  color: #C62828;
  border: 1px solid #FFCDD2;
  border-radius: 12px;
  padding: 10px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  text-align: center;
}

.btn-clear-memories:hover {
  background: #FFEBEE;
}

/* Responsive para pantallas muy pequeñas */
@media (max-width: 440px) {
  body {
    padding: 0;
  }
  .device-wrapper {
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    box-shadow: none;
    border: none;
  }
}
