/* ==========================================
   RESET Y ESCALA MAESTRA
   ========================================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: var(--tamano-base); }
body {
    background-color: var(--bg-lienzo);
    color: var(--texto-cuerpo);
    font-family: var(--fuente-principal);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { color: var(--texto-titulo); font-weight: 700; }
h1 { font-size: 2rem; } h2 { font-size: 1.5rem; } h3 { font-size: 1.25rem; }
a { text-decoration: none; color: inherit; }

/* ==========================================
   BARRAS DE DESPLAZAMIENTO (Scrollbars Universales)
   ========================================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-lienzo); }
::-webkit-scrollbar-thumb { background: var(--bg-tarjeta); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--texto-silenciado); }

/* ==========================================
   REGLAS DE ADAPTABILIDAD (Responsive Grid)
   ========================================== */
.contenedor-maestro { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 var(--espacio-sm); }
.rejilla-adaptable { display: grid; gap: var(--espacio-md); grid-template-columns: 1fr; }
@media (min-width: 768px) { .rejilla-adaptable { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .rejilla-adaptable { grid-template-columns: repeat(4, 1fr); } }

/* ==========================================
   COMPONENTES ESTRUCTURALES (Fichas Lego)
   ========================================== */
.tarjeta-modulo {
    background-color: var(--bg-tarjeta); border-radius: var(--radio-tarjetas);
    box-shadow: var(--sombra-modulo, 0 4px 15px rgba(0,0,0,0.1)); padding: var(--espacio-md); border: var(--borde-sutil);
}
.separador-linea { width: 100%; height: 1px; background: var(--borde-sutil); margin: var(--espacio-md) 0; }

/* ==========================================
   BOTONES UNIVERSALES
   ========================================== */
.btn-principal {
    background-color: var(--marca-primario); color: var(--texto-boton);
    border: none; border-radius: var(--radio-botones);
    padding: 0.75rem 1.25rem; font-weight: 600; font-size: 1rem;
    font-family: inherit; cursor: pointer;
    transition: background-color var(--velocidad-ui) ease, transform 0.1s ease;
}
.btn-principal:hover { background-color: var(--marca-hover); }
.btn-principal:active { transform: scale(0.97); }

/* ==========================================
   FORMULARIOS Y CONTROLES (Transparencias Dinámicas)
   ========================================== */
.form-grupo { margin-bottom: var(--espacio-md); }
.form-label { display: block; margin-bottom: 0.5rem; color: var(--texto-titulo); font-weight: bold; font-size: 0.9rem; }
.form-input, .form-select {
    width: 100%; padding: 0.75rem; border-radius: var(--radio-botones);
    background: var(--bg-transparente, rgba(0,0,0,0.15)); border: var(--borde-sutil);
    color: var(--texto-titulo); font-size: 1rem; outline: none; 
    transition: border-color var(--velocidad-ui) ease; font-family: inherit;
}
.form-input:focus, .form-select:focus { border-color: var(--marca-primario); }
.form-checkbox { width: 1.2rem; height: 1.2rem; cursor: pointer; accent-color: var(--marca-primario); }

/* ==========================================
   SISTEMA DE ALERTAS E ICONOS UNIVERSALES
   ========================================== */
.icono-estandar {
    fill: var(--menu-icono); width: 1.5rem; height: 1.5rem;
    min-width: 1.5rem; min-height: 1.5rem; flex-shrink: 0; 
    transition: fill var(--velocidad-ui) ease;
}
.icono-estandar:hover, .activo .icono-estandar { fill: var(--menu-activo); }

.texto-menu { color: var(--menu-texto); font-size: 0.875rem; transition: color var(--velocidad-ui) ease; }
.texto-menu:hover, .activo .texto-menu { color: var(--menu-activo); }
.texto-glow-activo { color: var(--menu-activo); text-shadow: var(--brillo-texto-activo); }


/* ==========================================
   ==========================================
   FIRMA UNIFICADA (Armonía Tienda y Comando)
   ==========================================
   ========================================== */
.firma-copyright, .firma-fija {
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    padding: 10px 15px; /* Delgadez Extrema */
    border-top: 1px solid var(--borde-sutil);
    line-height: 1.2;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 5px;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .firma-copyright, .firma-fija {
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
        padding: 10px 25px;
    }
    .firma-creador { text-align: right; }
}

.firma-copyright a, .firma-fija a {
    font-weight: 800;
    text-decoration: none;
    transition: opacity var(--velocidad-ui) ease;
}
.firma-copyright a:hover, .firma-fija a:hover { opacity: 0.7; }

/* Lógica Independiente de Colores y Hábitat */
.app-shell .firma-copyright {
    color: var(--firma-tienda-texto, var(--texto-silenciado));
    background: transparent;
    margin-top: auto; 
}
.app-shell .firma-copyright a {
    color: var(--firma-tienda-texto, var(--texto-titulo));
}

.layout-maestro .firma-fija {
    background: var(--bg-firma-comando, var(--bg-cabecera));
    color: var(--firma-comando-texto, var(--texto-silenciado));
    flex-shrink: 0; 
    z-index: 110;
}
.layout-maestro .firma-fija a {
    color: var(--firma-comando-texto, var(--texto-titulo));
}

/* ==========================================
   ==========================================
   GEOMETRÍA UNIVERSAL Y CALCULADORAS
   ==========================================
   ========================================== */

/* 1. Logos (Calculadora Dinámica para Tienda y Comando) */
.app-shell .header-logo img, 
.layout-maestro .logo-cabecera {
    max-height: var(--tamano-logo, 40px);
    width: auto;
    transition: max-height var(--velocidad-ui) ease;
}
@media (min-width: 768px) {
    .app-shell .header-logo img, 
    .layout-maestro .logo-cabecera {
        /* En PC el logo crece automáticamente un 15% */
        max-height: calc(var(--tamano-logo, 40px) * 1.15); 
    }
}

/* 2. SVG Comando (Menú Lateral) */
.layout-maestro .svg-menu,
.layout-maestro .icono-carpeta {
    width: var(--tamano-svg-comando, 18px);
    height: var(--tamano-svg-comando, 18px);
    transition: width var(--velocidad-ui) ease, height var(--velocidad-ui) ease, fill var(--velocidad-ui) ease;
}
@media (min-width: 768px) {
    .layout-maestro .svg-menu,
    .layout-maestro .icono-carpeta {
        /* En PC los iconos operativos crecen un 15% */
        width: calc(var(--tamano-svg-comando, 18px) * 1.15);
        height: calc(var(--tamano-svg-comando, 18px) * 1.15);
    }
}


/* ==========================================
   ==========================================
   1. CASCARÓN MUNDO PÚBLICO (tienda.php)
   ==========================================
   ========================================== */
.app-shell { display: flex; flex-direction: column; width: 100%; height: 100vh; height: 100dvh; position: relative; overflow: hidden; }

/* Cabecera Móvil Invisible con Logo Flotante */
.app-shell .app-header {
    position: absolute; top: 0; left: 0; width: 100%; padding: 15px 20px; z-index: 100;
    display: flex; justify-content: space-between; align-items: center; 
    pointer-events: none; 
    background: transparent;
}
.app-shell .header-logo { pointer-events: auto; } 
/* El tamaño ahora obedece a la Calculadora Universal de arriba */
.app-shell .header-logo img { display: block; filter: drop-shadow(0 2px 5px rgba(0,0,0,0.7)); }
.app-shell .header-nav { display: none; } 

/* Lienzo Público (Zona de Módulos) */
.app-shell .app-lienzo {
    flex: 1; overflow-y: auto; overflow-x: hidden; position: relative; width: 100%; box-sizing: border-box;
    -webkit-overflow-scrolling: touch; background: var(--bg-lienzo);
    padding: 60px 20px 70px 20px; 
    display: flex; flex-direction: column; 
}
.app-shell .contenedor-modulos { width: 100%; margin: 0 auto; flex: 1; }

.app-shell .estado-reposo {
    position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; 
    padding: 20px; text-align: center; pointer-events: none;
}
.app-shell .estado-reposo img { max-width: 180px; width: 100%; margin-bottom: 20px; opacity: 0.15; filter: grayscale(100%); }

/* Footer Móvil Público (Menú Inferior) */
.app-shell .footer-wrapper {
    position: fixed; bottom: 0; left: 0; width: 100%; display: flex; flex-direction: column; 
    background: var(--bg-menu-lateral); border-top: var(--borde-sutil); 
    z-index: var(--capa-alerta); padding-bottom: env(safe-area-inset-bottom);
    pointer-events: auto;
}
.app-shell .app-footer { display: flex; justify-content: space-evenly; align-items: center; height: 65px; width: 100%; }
.app-shell .footer-tab { 
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; 
    height: 100%; text-decoration: none; position: relative; 
}

/* El tamaño ahora obedece a la Calculadora Universal */
.app-shell .svg-menu { 
    width: var(--tamano-svg-tienda, 28px); 
    height: var(--tamano-svg-tienda, 28px); 
    fill: var(--menu-texto); 
    transition: all var(--velocidad-ui) ease; 
}
.app-shell .texto-nav-fuerte { display: none; } 
.app-shell .footer-tab.menu-activo .svg-menu { fill: var(--menu-activo); }

/* LEDs y Contadores Tienda */
.app-shell .badge-contador {
    position: absolute; top: 8px; right: 25%; background: var(--estado-error); color: var(--texto-boton);
    font-size: 0.65rem; font-weight: 900; padding: 2px 6px; border-radius: 12px; 
    border: 2px solid var(--bg-menu-lateral); display: none; box-shadow: var(--sombra-modulo);
}
.app-shell .led-notificacion {
    width: 10px; height: 10px; background-color: var(--alerta-led); border-radius: 50%;
    position: absolute; border: 2px solid var(--bg-menu-lateral); box-shadow: var(--alerta-glow);
}

/* Responsive Público Tienda (PC) */
@media (min-width: 768px) {
    .app-shell .footer-wrapper { display: none !important; } 
    .app-shell .app-header { 
        position: relative; height: auto; min-height: 60px; background: var(--bg-cabecera); 
        border-bottom: var(--borde-sutil); padding: 5px 25px; pointer-events: auto; 
    }
    .app-shell .header-logo img { filter: none; }
    .app-shell .header-nav { display: flex; gap: 8px; align-items: center; } 
    .app-shell .header-nav-link { 
        display: flex; align-items: center; gap: 8px; padding: 10px 15px; 
        border-radius: var(--radio-botones); text-decoration: none; transition: background var(--velocidad-ui) ease; 
    }
    .app-shell .header-nav-link:hover { background: var(--hover-sutil, rgba(255,255,255,0.05)); }
    .app-shell .texto-nav-fuerte { display: block; font-size: 0.8rem; font-weight: bold; color: var(--menu-texto); }
    .app-shell .header-nav-link.menu-activo .texto-nav-fuerte { color: var(--menu-activo); }
    
    .app-shell .svg-menu { 
        /* En PC el menú sube a la cabecera, así que se reduce el SVG al 80% */
        width: calc(var(--tamano-svg-tienda, 28px) * 0.8); 
        height: calc(var(--tamano-svg-tienda, 28px) * 0.8); 
        fill: var(--menu-texto); 
    }
    .app-shell .header-nav-link.menu-activo .svg-menu { fill: var(--menu-activo); }
    
    .app-shell .badge-contador { right: 5px; top: 2px; border-color: var(--bg-cabecera); }
    .app-shell .app-lienzo { padding: 30px; }
    .app-shell .contenedor-modulos { max-width: 1200px; }
}


/* ==========================================
   ==========================================
   3. ELEMENTOS GLOBALES COMPARTIDOS
   ==========================================
   ========================================== */

/* Pop-Up Interactivo (Para ambos) */
.alerta-flotante {
    position: fixed; top: -200px; left: 50%; transform: translateX(-50%);
    background: var(--bg-tarjeta); border: 1px solid var(--estado-exito);
    border-radius: var(--radio-tarjetas); padding: 15px; z-index: var(--capa-maxima);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5); display: flex; align-items: flex-start; gap: 12px;
    transition: top 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 90%; max-width: 450px; box-sizing: border-box; cursor: default;
}
.alerta-flotante.mostrar { top: 25px; }
.alerta-icono { background: rgba(16, 185, 129, 0.1); color: var(--estado-exito); width: 40px; height: 40px; border-radius: 50%; display: flex; justify-content: center; align-items: center; flex-shrink: 0; margin-top: 5px; }
.alerta-icono svg { width: 22px; height: 22px; fill: currentColor; }
.alerta-cuerpo { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.alerta-texto { color: var(--texto-titulo); font-weight: bold; font-size: 0.9rem; line-height: 1.4; }
.alerta-botones { display: flex; justify-content: flex-end; gap: 10px; }
.btn-pop { border: none; padding: 8px 16px; border-radius: 6px; font-weight: bold; font-size: 0.85rem; cursor: pointer; transition: transform 0.1s; text-transform: uppercase; }
.btn-pop:active { transform: scale(0.95); }
.btn-pop.cerrar { background: var(--hover-sutil, rgba(255,255,255,0.05)); color: var(--texto-silenciado); border: var(--borde-sutil); }
.btn-pop.ir { background: var(--marca-primario); color: var(--texto-boton); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3); }

/* Botón Flotante Chat */
.btn-chat-flotante {
    position: fixed; bottom: 85px; right: 20px;
    background: var(--flotante-bg); color: var(--flotante-icono);
    width: 55px; height: 55px; border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    box-shadow: var(--flotante-glow); z-index: var(--capa-alerta); cursor: pointer;
    transition: transform 0.2s, background-color 0.2s; text-decoration: none;
    border: 1px solid var(--flotante-borde);
}
.btn-chat-flotante:hover { background: var(--flotante-hover-bg); transform: scale(1.05); }
.btn-chat-flotante:active { transform: scale(0.9); }
.btn-chat-flotante svg { width: 28px; height: 28px; fill: currentColor; }

@media (min-width: 768px) {
    .btn-chat-flotante { bottom: 30px; right: 30px; width: 60px; height: 60px; }
    .btn-chat-flotante svg { width: 30px; height: 30px; }
}

/* Animaciones Reutilizables */
@keyframes latido-punto { 0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); } 70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); } 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }
@keyframes brincoDinamico { 0% { transform: scale(1); } 40% { transform: scale(1.3) translateY(-4px); } 60% { transform: scale(0.9); } 80% { transform: scale(1.15); } 100% { transform: scale(1); } }
.animar-salto { animation: brincoDinamico 0.5s ease-in-out; }


/* ==========================================
   ==========================================
   4. MÓDULO CHAT (Hereda Universal)
   ==========================================
   ========================================== */
.modulo-chat-wrapper {
    display: flex; flex-direction: column; height: calc(100vh - 180px); min-height: 500px;
    position: relative; animation: fadeIn var(--velocidad-ui) ease;
    background: var(--bg-tarjeta); border-radius: var(--radio-tarjetas); overflow: hidden;
    border: var(--borde-sutil);
}
.pantalla-cerrado { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--bg-lienzo); z-index: 20; padding: 20px; text-align: center; }
.icono-cerrado { width: 80px; height: 80px; fill: var(--texto-silenciado); margin-bottom: 20px; }
.titulo-cerrado { color: var(--texto-titulo); font-size: 1.5rem; margin-bottom: 10px; }
.texto-cerrado { color: var(--texto-silenciado); font-size: 1rem; line-height: 1.5; }
.badge-regreso { border: var(--borde-sutil); padding: 10px 20px; border-radius: var(--radio-botones); color: var(--marca-primario); font-weight: bold; margin-top: 20px; background: var(--bg-transparente, rgba(0,0,0,0.2)); }

.pantalla-bautizo { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--bg-lienzo); z-index: 10; padding: 20px; text-align: center; }
.bautizo-icono { width: 80px; height: 80px; fill: var(--marca-primario); margin-bottom: 20px; }
.bautizo-titulo { color: var(--texto-titulo); font-size: 1.5rem; margin-bottom: 10px; }
.bautizo-texto { color: var(--texto-silenciado); font-size: 0.95rem; margin-bottom: 30px; line-height: 1.5; }
.bautizo-input { width: 100%; max-width: 300px; background: var(--bg-transparente, rgba(0,0,0,0.2)); border: var(--borde-sutil); color: var(--texto-titulo); padding: 15px; border-radius: var(--radio-botones); font-size: 1.1rem; text-align: center; margin-bottom: 20px; outline: none; }
.bautizo-input:focus { border-color: var(--marca-primario); }
.btn-comenzar { background: var(--marca-primario); color: var(--texto-boton); font-weight: bold; font-size: 1.1rem; padding: 12px 30px; border: none; border-radius: var(--radio-botones); cursor: pointer; transition: transform var(--velocidad-ui); }
.btn-comenzar:active { transform: scale(0.95); }

.pantalla-chat { display: none; flex-direction: column; height: 100%; width: 100%; }
.chat-header { background: var(--bg-cabecera); padding: 15px 20px; display: flex; align-items: center; gap: 15px; border-bottom: var(--borde-sutil); flex-shrink: 0; }
.chat-avatar { width: 45px; height: 45px; background: var(--marca-primario); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.chat-avatar svg { width: 24px; height: 24px; fill: var(--texto-boton); }
.chat-info h3 { margin: 0; color: var(--texto-titulo); font-size: 1.1rem; }
.chat-info p { margin: 0; color: var(--estado-exito); font-size: 0.8rem; font-weight: bold; display: flex; align-items: center; gap: 5px; }
.punto-online { width: 8px; height: 8px; background: var(--estado-exito); border-radius: 50%; display: inline-block; animation: latido-online 2s infinite; }

.chat-mensajes { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; background: var(--bg-lienzo); scroll-behavior: smooth; }
.mensaje-fila { display: flex; flex-direction: column; max-width: 85%; }
.mensaje-fila.mio { align-self: flex-end; }
.mensaje-fila.asesor { align-self: flex-start; }
.burbuja { padding: 12px 16px; font-size: 0.95rem; line-height: 1.4; position: relative; word-wrap: break-word; }
.mio .burbuja { background: var(--marca-primario); color: var(--texto-boton); border-radius: 15px 15px 0 15px; font-weight: 500; }
.asesor .burbuja { background: var(--bg-tarjeta); color: var(--texto-cuerpo); border-radius: 15px 15px 15px 0; border: var(--borde-sutil); }
.mensaje-hora { font-size: 0.65rem; margin-top: 5px; opacity: 0.7; }
.mio .mensaje-hora { text-align: right; color: var(--texto-silenciado); }
.asesor .mensaje-hora { text-align: left; color: var(--texto-silenciado); }
.burbuja-img { max-width: 100%; border-radius: 10px; margin-top: 5px; display: block; }
.burbuja-audio { width: 220px; height: 40px; margin-top: 5px; outline: none; }

.chat-controles { background: var(--bg-cabecera); padding: 15px; display: flex; align-items: center; gap: 10px; border-top: var(--borde-sutil); flex-shrink: 0; }
.btn-accion { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-tarjeta); border: var(--borde-sutil); display: flex; justify-content: center; align-items: center; cursor: pointer; transition: background var(--velocidad-ui); flex-shrink: 0; }
.btn-accion:hover { background: var(--bg-transparente, rgba(0,0,0,0.2)); }
.btn-accion svg { width: 20px; height: 20px; fill: var(--texto-silenciado); }
.input-mensaje { flex: 1; background: var(--bg-lienzo); border: var(--borde-sutil); color: var(--texto-titulo); padding: 12px 15px; border-radius: 20px; font-size: 0.95rem; outline: none; transition: border-color var(--velocidad-ui); }
.input-mensaje:focus { border-color: var(--marca-primario); }
.btn-enviar { width: 40px; height: 40px; border-radius: 50%; background: var(--marca-primario); border: none; display: flex; justify-content: center; align-items: center; cursor: pointer; transition: transform var(--velocidad-ui); flex-shrink: 0; }
.btn-enviar:active { transform: scale(0.9); }
.btn-enviar svg { width: 20px; height: 20px; fill: var(--texto-boton); transform: translateX(2px); }

.grabando { background: var(--estado-error) !important; border-color: var(--estado-error) !important; animation: latido-grabacion 1s infinite; }
.grabando svg { fill: var(--texto-boton) !important; }
.enviando-archivo { opacity: 0.5; pointer-events: none; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes latido-online { 0% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(1.2); } 100% { opacity: 1; transform: scale(1); } }
