/* ==========================================
   ESTILOS RESPONSIVE - StopTech Admin
   Mejoras responsivas para todos los dispositivos
   
   PRINCIPIOS:
   - Mobile-first approach
   - Touch targets mínimo 44x44px
   - Accesibilidad WCAG AA
   - Reducir movimiento para usuarios que lo prefieren
   ========================================== */

/* Soporte para usuarios que prefieren reducir movimiento */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========== BREAKPOINTS PRINCIPALES ========== */
/* Mobile:    < 480px (teléfonos pequeños) */
/* Mobile+:   480px - 768px (teléfonos grandes / tablets pequeñas) */
/* Tablet:    768px - 1024px (tablets) */
/* Desktop:   1024px - 1440px (desktop estándar) */
/* Desktop+:  > 1440px (monitores grandes) */

/* ========== AJUSTES GLOBALES RESPONSIVE ========== */

/* Móvil: Reducir tipografía */
@media (max-width: 768px) {
    :root {
        --text-4xl: 28px;
        --text-3xl: 24px;
        --text-2xl: 20px;
        --text-xl: 18px;
        --text-lg: 16px;
        --text-md: 14px;
        --text-base: 13px;
        --text-sm: 12px;
        --text-xs: 11px;
    }
}

/* Móvil pequeño: Reducción más agresiva */
@media (max-width: 480px) {
    :root {
        --text-4xl: 24px;
        --text-3xl: 20px;
        --text-2xl: 18px;
        --text-xl: 16px;
        --text-lg: 14px;
        --text-md: 13px;
        --text-base: 12px;
    }
}

/* ========== AJUSTES DE ESPACIADO RESPONSIVE ========== */

@media (max-width: 768px) {
    :root {
        --space-8: 32px;
        --space-7: 24px;
        --space-6: 20px;
        --space-5: 16px;
        --space-4: 12px;
    }
}

/* ========== BODY Y ELEMENTOS BASE ========== */

html {
    scroll-behavior: smooth;
}

body {
    /* overflow-x: hidden será manejado por fix-overflow.css */
}

@media (max-width: 768px) {
    body {
        font-size: 13px;
        line-height: 1.5;
    }
}

/* ========== PANEL LATERAL RESPONSIVE ========== */

@media (max-width: 768px) {
    .panel-lateral {
        display: none !important;
    }
    
    .contenido-principal {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .panel-expandido {
        display: none !important;
    }

    /* Mostrar menú móvil */
    .menu-movil {
        display: flex !important;
    }

    .panel-menu-movil {
        display: block !important;
        position: fixed !important;
        top: 0 !important;
        left: -320px !important; /* Oculto a la izquierda */
        width: 300px !important;
        max-width: 85vw !important;
        height: 100vh !important;
        background: #111111 !important;
        border-right: 1px solid rgba(255, 255, 255, 0.1);
        z-index: 10000 !important; /* Mayor que el overlay */
        transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
        overflow-y: auto !important;
        box-shadow: -4px 0 15px rgba(0, 0, 0, 0.3);
    }

    .panel-menu-movil.mostrar {
        left: 0 !important;
    }

    .overlay-menu {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.8);
        backdrop-filter: blur(5px);
        z-index: 9999 !important; /* Menor que el panel */
    }

    .overlay-menu.mostrar {
        display: block !important;
    }

.contenido-menu-movil,
    .contenido-menu-movil h3,
    .contenido-menu-movil p,
    .contenido-menu-movil i {
        opacity: 1 !important;
        visibility: visible !important;
        color: white !important; /* Forzar color blanco */
        display: block !important;
    }

}

@media (max-width: 768px) {
    .caracteristica-menu h3, 
    .caracteristica-menu p, 
    .titulo-menu-movil {
        color: white !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
}

/* ========== ENCABEZADO RESPONSIVE ========== */

@media (max-width: 1024px) {
    .encabezado-superior {
        flex-direction: column !important;
        gap: 15px !important;
        padding: 15px 20px !important;
    }

    .encabezado-izquierda {
        width: 100% !important;
    }

    .encabezado-derecha {
        width: 100% !important;
    }
}

@media (max-width: 768px) {
    .encabezado-superior {
        flex-direction: column-reverse;
        padding: 12px 15px;
    }

    .titulo-pagina {
        font-size: 18px !important;
        margin-top: 10px;
    }

    .ruta-navegacion {
        font-size: 11px;
        display: none;
    }

    .encabezado-derecha {
        width: 100%;
        justify-content: space-between;
    }
}

/* ========== GRID RESPONSIVE ========== */

@media (max-width: 1024px) {
    .grid-operaciones {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
    }
}

@media (max-width: 768px) {
    .grid-operaciones {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .tarjeta-operacion {
        padding: 15px !important;
    }
}

/* ========== TABLA RESPONSIVE ========== */

@media (max-width: 768px) {
    .contenedor-tabla {
        display: none !important;
    }

    .contenedor-tarjetas {
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 15px;
    }

    /* Tabla: Hacer scroll horizontal en móvil */
    .tabla-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Tabla: Reducir tamaño de fuente */
    table {
        font-size: 12px !important;
    }

    /* Tabla: Eliminar bordes visibles en móvil */
    table th,
    table td {
        padding: 8px 6px !important;
    }
}

/* ========== INPUTS Y BOTONES RESPONSIVE ========== */

@media (max-width: 768px) {
    input,
    textarea,
    select,
    .entrada-texto {
        font-size: 16px !important; /* Previene zoom en iOS */
        padding: 12px 12px !important;
        min-height: 44px !important; /* Mínimo para touch */
    }

    button,
    .boton-buscar,
    .boton-refrescar,
    .boton-exportar {
        min-height: 44px !important; /* Touch target mínimo */
        padding: 12px 16px !important;
        font-size: 14px !important;
    }

    /* Botones en móvil: Ocupar ancho completo si es posible */
    .grupo-entrada button {
        min-width: 44px !important;
        background: rgba(255, 255, 255, 0.1) !important;
    }
}

@media (max-width: 480px) {
    input,
    textarea,
    select,
    .entrada-texto {
        font-size: 16px !important;
        padding: 10px 10px !important;
    }

    button {
        padding: 10px 12px !important;
        font-size: 13px !important;
    }
}

/* ========== CONTENEDOR FLEXBOX RESPONSIVE ========== */

@media (max-width: 1024px) {
    .contenedor-entrada {
        flex-direction: column !important;
    }

    .contenedor-entrada input,
    .contenedor-entrada button {
        width: 100% !important;
        margin-bottom: 10px !important;
    }

    .contenedor-entrada button:last-child {
        margin-bottom: 0;
    }
}

@media (max-width: 768px) {
    .contenedor-entrada {
        flex-direction: row;
        gap: 8px;
        align-items: stretch;
    }

    .contenedor-entrada input {
        flex: 1;
        min-height: 44px;
    }

    .contenedor-entrada button {
        min-width: 44px;
        width: auto;
        padding: 0 12px;
    }
}

/* ========== FORMULARIOS RESPONSIVE ========== */

@media (max-width: 768px) {
    .grupo-entrada {
        margin-bottom: 12px !important;
    }

    .grupo-formulario {
        margin-bottom: 12px !important;
    }

    label {
        font-size: 12px !important;
    }
}

/* ========== SECCIONES CONTENEDORAS RESPONSIVE ========== */

@media (max-width: 1024px) {
    section,
    .panel-operaciones,
    .panel-domicilios {
        padding: 20px 15px !important;
        margin-bottom: 15px !important;
    }
}

@media (max-width: 768px) {
    section,
    .panel-operaciones,
    .panel-domicilios {
        padding: 15px 12px !important;
        margin-bottom: 12px !important;
        border-radius: 12px !important;
    }

    main {
        padding: 12px !important;
    }
}

@media (max-width: 480px) {
    section {
        padding: 12px 10px !important;
        margin-bottom: 10px !important;
    }
}

/* ========== ESTADÍSTICAS RESPONSIVE ========== */

@media (max-width: 1024px) {
    .estadisticas-domicilios {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .estadistica {
        flex: 1 !important;
    }
}

@media (max-width: 768px) {
    .estadisticas-domicilios {
        gap: 12px;
        flex-wrap: wrap;
    }

    .estadistica {
        flex: 1 1 48%;
        padding: 10px;
        text-align: center;
    }

    .valor-estadistica {
        font-size: 18px !important;
    }

    .texto-estadistica {
        font-size: 11px !important;
    }
}

/* ========== HEADER DOMICILIOS RESPONSIVE ========== */

@media (max-width: 1024px) {
    .encabezado-domicilios {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 15px !important;
    }

    .acciones-domicilios {
        width: 100% !important;
    }

    .acciones-domicilios button {
        flex: 1 !important;
    }
}

@media (max-width: 768px) {
    .encabezado-domicilios {
        flex-direction: column;
        gap: 10px;
    }

    .titulo-domicilios h2 {
        font-size: 16px !important;
    }

    .acciones-domicilios {
        display: flex;
        gap: 8px;
        width: 100%;
    }

    .acciones-domicilios button {
        flex: 1;
        padding: 10px !important;
        font-size: 12px !important;
    }

    .texto-boton {
        display: none;
    }

    .acciones-domicilios i {
        margin-right: 0;
    }
}

/* ========== DROPDOWN Y MODALES RESPONSIVE ========== */

@media (max-width: 768px) {
    .dropdown,
    .menu-dropdown {
        position: fixed !important;
        top: auto !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        right: auto !important;
        width: 90vw !important;
        max-width: 400px !important;
        z-index: 10000 !important;
    }

    .modal,
    .contenedor-modal {
        width: 95vw !important;
        max-height: 90vh !important;
        border-radius: 12px !important;
    }
}

/* ========== TARJETAS RESPONSIVE ========== */

@media (max-width: 768px) {
    .tarjeta,
    .card {
        padding: 12px !important;
        margin-bottom: 10px !important;
        border-radius: 12px !important;
    }

    .tarjeta h3,
    .card h3 {
        font-size: 14px !important;
        margin-bottom: 8px !important;
    }
}

/* ========== CONTENEDOR LOGIN RESPONSIVE ========== */

@media (max-width: 1200px) {
    .contenedor-login {
        grid-template-columns: 1fr !important;
    }

    .panel-izquierdo {
        min-height: 200px !important;
        padding: 30px 20px !important;
    }
}

@media (max-width: 768px) {
    .contenedor-login {
        display: flex !important;
        flex-direction: column !important;
        min-height: 100vh;
        padding: 12px;
    }

    .panel-izquierdo {
        display: none !important;
    }

    .panel-derecho {
        width: 100% !important;
        min-height: auto;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 20px 12px;
    }

    .contenedor-formulario {
        width: 100% !important;
        max-width: 100% !important;
        padding: 20px 15px !important;
    }

    .formulario-login {
        gap: 12px !important;
    }

    .grupo-entrada {
        margin-bottom: 12px !important;
    }

    .entrada-texto {
        font-size: 16px !important;
        padding: 12px 12px !important;
    }

    .boton-envio {
        font-size: 14px !important;
        padding: 12px !important;
        width: 100% !important;
    }
}

@media (max-width: 480px) {
    .panel-derecho {
        padding: 15px 10px;
    }

    .contenedor-formulario {
        padding: 15px 12px !important;
    }

    .encabezado-formulario {
        gap: 8px;
    }

    .titulo-formulario {
        font-size: 16px !important;
    }

    .subtitulo-formulario {
        font-size: 12px !important;
    }
}

/* ========== NOTIFICACIONES RESPONSIVE ========== */

@media (max-width: 768px) {
    .notificacion,
    .toast,
    .alerta {
        position: fixed !important;
        width: 90vw !important;
        max-width: 400px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        right: auto !important;
        z-index: 10001 !important;
    }
}

/* ========== OVERFLOW Y SCROLL RESPONSIVE ========== */

@media (max-width: 768px) {
    /* Scroll horizontal suave en iOS */
    .tabla-scroll,
    .contenedor-scroll {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
    }

    /* Scroll: Mostrar scrollbar en dispositivos tactiles */
    .tabla-scroll::-webkit-scrollbar {
        height: 6px;
    }

    .tabla-scroll::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.05);
        border-radius: 3px;
    }

    .tabla-scroll::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.15);
        border-radius: 3px;
    }
}

/* ========== AJUSTE ALTURA HEADER RESPONSIVE ========== */

@media (max-width: 1024px) {
    .encabezado-superior,
    header {
        min-height: 60px !important;
    }
}

@media (max-width: 768px) {
    .encabezado-superior,
    header {
        min-height: 50px !important;
        padding: 12px 15px !important;
    }

    .menu-movil {
        height: 50px !important;
        padding: 8px 15px !important;
        justify-content: space-between !important;
    }
}

/* ========== AJUSTES DE SOMBRAS PARA MÓVIL ========== */

@media (max-width: 768px) {
    :root {
        --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
        --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
        --shadow-lg: 0 8px 20px rgba(0, 0, 0, 0.2);
        --sombra-suave: 0 2px 8px rgba(0, 0, 0, 0.1);
        --sombra-media: 0 4px 12px rgba(0, 0, 0, 0.15);
        --sombra-fuerte: 0 8px 20px rgba(0, 0, 0, 0.2);
    }
}

/* ========== BORDER-RADIUS RESPONSIVE ========== */

@media (max-width: 768px) {
    :root {
        --radius-2xl: 16px;
        --radius-xl: 12px;
        --radius-lg: 12px;
        --radius-md: 8px;
    }
}

/* ========== MÁRGENES RESPONSIVOS ========== */

@media (max-width: 768px) {
    h1, h2, h3, h4, h5, h6 {
        margin-bottom: 8px !important;
    }

    p {
        margin-bottom: 6px !important;
    }
}

/* ========== VISIBILIDAD DE ELEMENTOS RESPONSIVE ========== */

@media (max-width: 1024px) {
    .solo-desktop {
        display: none !important;
    }
}

@media (min-width: 1025px) {
    .solo-movil,
    .solo-tablet {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .solo-desktop,
    .ocultar-movil {
        display: none !important;
    }

    .solo-movil {
        display: block !important;
    }
}

@media (max-width: 480px) {
    .ocultar-movil-pequeno {
        display: none !important;
    }
}

/* ========== LANDSCAPE MÓVIL ========== */

@media (max-height: 600px) and (max-width: 768px) {
    .encabezado-superior {
        min-height: 40px !important;
        padding: 8px 12px !important;
    }

    header {
        padding: 8px 12px !important;
    }

    main {
        padding: 10px !important;
    }

    section {
        padding: 10px !important;
        margin-bottom: 8px !important;
    }

    .formulario-operacion,
    .contenedor-entrada {
        gap: 6px !important;
    }
}

/* ========== UTILIDADES RESPONSIVE ========== */

/* Mostra solamente en desktop */
.show-desktop {
    display: none !important;
}

@media (min-width: 1025px) {
    .show-desktop {
        display: block !important;
    }

    .hide-desktop {
        display: none !important;
    }
}

/* Mostrar solo en tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .show-tablet {
        display: block !important;
    }

    .hide-tablet {
        display: none !important;
    }
}

/* Mostrar solo en móvil */
@media (max-width: 768px) {
    .show-mobile {
        display: block !important;
    }

    .hide-mobile {
        display: none !important;
    }
}

/* ========== TOUCH TARGETS ========== */

/* Asegurar que los elementos interactivos sean clickeables */
@media (max-width: 768px) {
    button,
    a,
    input[type="checkbox"],
    input[type="radio"],
    .clickeable {
        min-width: 44px;
        min-height: 44px;
        padding: 8px;
    }

    .nav-item,
    .menu-item {
        padding: 12px;
        min-height: 44px;
    }
}

/* ========== AJUSTES DE ESPACIADO CONTENEDOR ========== */

@media (max-width: 1024px) {
    main {
        padding: 15px !important;
    }
}

@media (max-width: 768px) {
    main {
        padding: 10px !important;
        margin-left: 0 !important;
    }

    .contenido-principal {
        padding: 0;
        margin-left: 0 !important;
    }
}

/* ========== ÍCONOS RESPONSIVE ========== */

@media (max-width: 768px) {
    i[class*="fa-"] {
        font-size: 16px !important;
    }

    .icono-grande {
        font-size: 32px !important;
    }

    .icono-pequeno {
        font-size: 12px !important;
    }
}

/* ========== CARDS/GRILLAS RESPONSIVE ========== */

@media (max-width: 1440px) {
    [class*="grid"],
    [class*="Grid"] {
        gap: 16px !important;
    }
}

@media (max-width: 1024px) {
    [class*="grid"],
    [class*="Grid"] {
        gap: 12px !important;
    }
}

@media (max-width: 768px) {
    [class*="grid"],
    [class*="Grid"] {
        gap: 10px !important;
    }

    [class*="grid-2"],
    [class*="grid-3"],
    [class*="grid-4"] {
        grid-template-columns: 1fr !important;
    }
}

/* ========== MEJORA PARA KEYBOARDS VIRTUALES EN MÓVIL ========== */

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-primario) !important;
    box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.1);
}

@media (max-width: 768px) {
    input:focus,
    textarea:focus,
    select:focus {
        font-size: 16px !important; /* Prevenir zoom en iOS */
    }
}

/* ========== MEJORAS PARA TABLET LANDSCAPE ========== */

@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    main {
        padding: 12px !important;
    }

    section {
        padding: 10px !important;
    }

    .grid-operaciones,
    [class*="grid"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ========== AJUSTES PARA PANTALLAS MUY GRANDES ========== */

@media (min-width: 1440px) {
    :root {
        --space-16: 100px;
    }

    main {
        max-width: 1400px;
        margin: 0 auto;
    }

    .contenido-principal {
        margin-right: auto;
        margin-left: auto;
    }
}
