/**
 * ESTILOS PRINCIPALES PARA SEG-APO
 * Sistema de seguridad ciudadana con interfaz tipo WhatsApp
 * Todos los comentarios y nombres en español
 */

/* Variables CSS para tema consistente */
:root {
    --color-primario: #dc3545;      /* Rojo para emergencias */
    --color-secundario: #6c757d;    /* Gris */
    --color-exito: #198754;         /* Verde */
    --color-advertencia: #ffc107;   /* Amarillo */
    --color-info: #0dcaf0;          /* Azul claro */
    --color-peligro: #dc3545;       /* Rojo peligro */
    --color-fondo: #f8f9fa;         /* Fondo claro */
    --color-texto: #212529;         /* Texto oscuro */
    --sombra-suave: 0 2px 4px rgba(0,0,0,0.1);
    --sombra-elevada: 0 8px 25px rgba(0,0,0,0.15);
    --sombra-flotante: 0 15px 35px rgba(0,0,0,0.1), 0 5px 15px rgba(0,0,0,0.07);
    --radio-border: 8px;
    --radio-border-lg: 16px;
    --transicion-suave: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transicion-rapida: all 0.15s ease-out;
    --transicion-bounce: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Animaciones globales mejoradas */
@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    0% {
        opacity: 0;
        transform: translateY(-30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInScale {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4);
    }
    50% {
        box-shadow: 0 0 0 20px rgba(220, 53, 69, 0);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: 200px 0;
    }
}

@keyframes slideInRight {
    0% {
        opacity: 0;
        transform: translateX(100px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    0% {
        opacity: 0;
        transform: translateX(-100px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Estilos base del body mejorados */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--color-fondo);
    color: var(--color-texto);
    line-height: 1.6;
    transition: var(--transicion-suave);
    overflow-x: hidden; /* Evitar scroll horizontal en animaciones */
}

/* Animación de entrada para elementos principales */
.modern-app {
    animation: fadeInUp 0.6s ease-out;
}

/* Header fijo con logo administrable mejorado */
.navbar {
    box-shadow: var(--sombra-elevada);
    z-index: 1030;
    backdrop-filter: blur(10px);
    background-color: rgba(13, 110, 253, 0.95) !important;
    transition: var(--transicion-suave);
}

.navbar:hover {
    box-shadow: var(--sombra-flotante);
}

.navbar-brand {
    transition: var(--transicion-bounce);
}

.navbar-brand:hover {
    transform: scale(1.05);
}

.navbar-brand img {
    max-height: 40px;
    width: auto;
    transition: var(--transicion-bounce);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.navbar-brand img:hover {
    transform: scale(1.1) rotate(2deg);
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}

/* Navegación mejorada */
.nav-link {
    transition: var(--transicion-suave);
    position: relative;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #ffffff, transparent);
    transition: var(--transicion-suave);
    transform: translateX(-50%);
}

.nav-link:hover::before {
    width: 100%;
}

.nav-link:hover {
    transform: translateY(-2px);
    color: #ffffff !important;
}

.nav-link.active {
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
    border-radius: var(--radio-border);
    backdrop-filter: blur(5px);
}

/* Estilos para el contenido principal mejorados */
main {
    min-height: calc(100vh - 140px);
    padding-bottom: 100px; /* Espacio para botón pánico */
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

/* Mejoras en secciones */
section {
    animation: fadeInUp 0.6s ease-out both;
    transition: var(--transicion-suave);
}

section:nth-child(even) {
    animation-delay: 0.1s;
}

section:nth-child(odd) {
    animation-delay: 0.2s;
}

/* Cards mejoradas con efectos */
.card {
    transition: var(--transicion-suave);
    border: none;
    border-radius: var(--radio-border-lg);
    box-shadow: var(--sombra-suave);
    overflow: hidden;
    position: relative;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    transition: var(--transicion-suave);
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: var(--sombra-flotante);
}

.card:hover::before {
    left: 100%;
}

/* Botones mejorados */
.btn {
    transition: var(--transicion-suave);
    border-radius: var(--radio-border);
    font-weight: 500;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: var(--transicion-rapida);
    z-index: -1;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--sombra-elevada);
}

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

/* Botones primarios con gradiente */
.btn-primary {
    background: linear-gradient(135deg, #0d6efd, #0a58ca);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0a58ca, #084298);
    transform: translateY(-2px);
}

/* Botones de peligro mejorados */
.btn-danger {
    background: linear-gradient(135deg, #dc3545, #b02a37);
    border: none;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #b02a37, #842025);
    animation: pulseGlow 2s infinite;
}

/* SECCIÓN 2: CARRUSEL SUPERIOR */
.carrusel-superior {
    height: 150px;
    overflow: hidden;
    border-radius: var(--radio-border);
    box-shadow: var(--sombra-suave);
}

.carrusel-superior .carousel-item {
    height: 150px;
}

.carrusel-superior .carousel-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.carrusel-superior .carousel-item img:hover {
    transform: scale(1.02);
}

/* SECCIÓN 3: REPRODUCTOR DE AUDIO */
.reproductor-audio {
    position: sticky;
    top: 70px;
    z-index: 1020;
    background: white;
    border-radius: var(--radio-border);
    box-shadow: var(--sombra-suave);
}

.reproductor-container {
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Botones de selección de audio */
.btn-group .btn-check:checked + .btn {
    background-color: var(--color-primario);
    border-color: var(--color-primario);
    color: white;
}

/* SECCIÓN 4: GALERÍA PRINCIPAL */
.galeria-principal {
    height: 440px;
    border-radius: var(--radio-border);
    overflow: hidden;
    box-shadow: var(--sombra-suave);
}

.galeria-principal .carousel-item {
    height: 440px;
}

.galeria-principal .carousel-item img {
    width: 100%;
    height: 440px;
    object-fit: cover;
    cursor: pointer;
}

/* Controles del carrusel con mejor visibilidad */
.carousel-control-prev,
.carousel-control-next {
    width: 5%;
    background: linear-gradient(90deg, rgba(0,0,0,0.3), transparent);
}

.carousel-control-next {
    background: linear-gradient(270deg, rgba(0,0,0,0.3), transparent);
}

/* SECCIÓN 5: CARRUSEL DE SERVICIOS */
.carrusel-servicios {
    height: 150px;
    overflow: hidden;
    border-radius: var(--radio-border);
    box-shadow: var(--sombra-suave);
}

.carrusel-servicios .carousel-item {
    height: 150px;
    background: rgba(255,255,255,0.9);
}

.carrusel-servicios .carousel-item img {
    width: 100%;
    height: 150px;
    object-fit: contain; /* Para PNG con transparencia */
    cursor: pointer;
    padding: 10px;
}

/* BOTÓN DE PÁNICO FLOTANTE */
.panic-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    animation: pulso-panico 2s infinite;
}

.panic-button .btn {
    width: 70px;
    height: 70px;
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.4);
    border: 3px solid white;
    position: relative;
    overflow: hidden;
}

.panic-button .btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.panic-button .btn:hover::before {
    width: 100%;
    height: 100%;
}

/* Animación de pulso para el botón de pánico */
@keyframes pulso-panico {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
    }
    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 15px rgba(220, 53, 69, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
    }
}

/* Estilos para modales */
.modal-content {
    border-radius: var(--radio-border);
    border: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.modal-header {
    border-radius: var(--radio-border) var(--radio-border) 0 0;
    border-bottom: none;
}

.modal-body {
    padding: 2rem;
}

/* Alertas personalizadas */
.alert {
    border-radius: var(--radio-border);
    border: none;
    box-shadow: var(--sombra-suave);
}

/* Botones personalizados */
.btn {
    border-radius: var(--radio-border);
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--sombra-suave);
}

/* Cards con sombra suave */
.card {
    border: none;
    border-radius: var(--radio-border);
    box-shadow: var(--sombra-suave);
}

/* Formularios mejorados */
.form-control,
.form-select {
    border-radius: var(--radio-border);
    border: 1px solid #dee2e6;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--color-primario);
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

/* Menú lateral deslizable */
.offcanvas {
    width: 300px;
}

.offcanvas-header {
    padding: 1rem 1.5rem;
}

.offcanvas-body {
    padding: 0;
}

.offcanvas-body .nav-link {
    padding: 1rem 1.5rem;
    color: var(--color-texto);
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s ease;
}

.offcanvas-body .nav-link:hover {
    background-color: var(--color-fondo);
    color: var(--color-primario);
}

.offcanvas-body .nav-link i {
    width: 20px;
    margin-right: 10px;
}

/* Responsive design */
@media (max-width: 768px) {
    .navbar-brand img {
        height: 35px;
    }
    
    .panic-button .btn {
        width: 60px;
        height: 60px;
    }
    
    .galeria-principal {
        height: 300px;
    }
    
    .galeria-principal .carousel-item {
        height: 300px;
    }
    
    .galeria-principal .carousel-item img {
        height: 300px;
    }
    
    .carrusel-superior,
    .carrusel-servicios {
        height: 120px;
    }
    
    .carrusel-superior .carousel-item,
    .carrusel-servicios .carousel-item {
        height: 120px;
    }
    
    .carrusel-superior .carousel-item img,
    .carrusel-servicios .carousel-item img {
        height: 120px;
    }
}

/* Estilos para indicador de carga */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--color-primario);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Estados de conexión */
.estado-conexion {
    position: fixed;
    top: 60px;
    right: 20px;
    z-index: 1025;
    padding: 0.5rem 1rem;
    border-radius: var(--radio-border);
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.estado-conexion.conectado {
    background-color: var(--color-exito);
    color: white;
}

.estado-conexion.desconectado {
    background-color: var(--color-peligro);
    color: white;
}

.estado-conexion.reconectando {
    background-color: var(--color-advertencia);
    color: var(--color-texto);
}

/* Efectos de hover para elementos interactivos */
.cursor-pointer {
    cursor: pointer;
}

.hover-shadow:hover {
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transform: translateY(-2px);
    transition: all 0.2s ease;
}

/* Estilos para elementos multimedia en carruseles */
.carousel-item[data-url] {
    position: relative;
}

.carousel-item[data-url]::after {
    content: '🔗';
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 50%;
    font-size: 0.875rem;
}

/* Estilos para modo oscuro (opcional) */
@media (prefers-color-scheme: dark) {
    :root {
        --color-fondo: #212529;
        --color-texto: #f8f9fa;
    }
    
    body {
        background-color: var(--color-fondo);
        color: var(--color-texto);
    }
    
    .card,
    .modal-content {
        background-color: #343a40;
        color: var(--color-texto);
    }
    
    .form-control,
    .form-select {
        background-color: #495057;
        border-color: #6c757d;
        color: var(--color-texto);
    }
}

/* ================================
   LOADER DE APLICACIÓN MEJORADO
   ================================ */

/* Loader principal con overlay */
.app-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, 
        rgba(13, 110, 253, 0.95), 
        rgba(220, 53, 69, 0.95)
    );
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    backdrop-filter: blur(10px);
    transition: var(--transicion-suave);
}

.app-loader.hide {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8);
}

/* Contenido del loader */
.loader-content {
    text-align: center;
    color: white;
    animation: fadeInScale 0.8s ease-out;
}

/* Logo del loader con animación */
.loader-logo {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: pulseGlow 2s infinite, fadeInDown 0.6s ease-out;
}

.loader-logo i {
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
    animation: var(--transicion-bounce);
}

/* Texto del loader */
.loader-text h3 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    animation: slideInLeft 0.8s ease-out 0.2s both;
    letter-spacing: 2px;
}

.loader-text p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    opacity: 0.9;
    animation: slideInRight 0.8s ease-out 0.4s both;
}

/* Barra de progreso mejorada */
.loader-progress {
    width: 300px;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    overflow: hidden;
    margin: 0 auto;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
    animation: fadeInUp 0.8s ease-out 0.6s both;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, 
        #ffffff, 
        rgba(255, 255, 255, 0.8),
        #ffffff
    );
    border-radius: 50px;
    width: 0%;
    animation: loadingProgress 3s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

@keyframes loadingProgress {
    0% {
        width: 0%;
        opacity: 0.7;
    }
    50% {
        width: 70%;
        opacity: 1;
    }
    100% {
        width: 100%;
        opacity: 0.7;
    }
}

/* Efecto de partículas en el loader */
.loader-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
    animation: shimmer 4s ease-in-out infinite;
    pointer-events: none;
}

/* Responsividad del loader */
@media (max-width: 768px) {
    .loader-text h3 {
        font-size: 2rem;
    }
    
    .loader-text p {
        font-size: 1rem;
    }
    
    .loader-logo {
        font-size: 3rem;
    }
    
    .loader-progress {
        width: 250px;
    }
}

/* ================================
   MEJORAS EN RESPONSIVIDAD GENERAL
   ================================ */

/* Animaciones de entrada para elementos móviles */
@media (max-width: 992px) {
    .navbar-nav {
        animation: slideInDown 0.5s ease-out;
    }
    
    .navbar-collapse.show .nav-item {
        animation: slideInLeft 0.3s ease-out both;
    }
    
    .navbar-collapse.show .nav-item:nth-child(2) {
        animation-delay: 0.1s;
    }
    
    .navbar-collapse.show .nav-item:nth-child(3) {
        animation-delay: 0.2s;
    }
    
    .navbar-collapse.show .nav-item:nth-child(4) {
        animation-delay: 0.3s;
    }
}