/**
 * Mobile Improvements CSS
 * Mejoras globales de usabilidad movil para chicasindependientes.com
 */

/* ===== TOUCH TARGETS ===== */
/* Garantizar tamaño mínimo de 44x44px para elementos interactivos */
.touch-target,
button,
[role="button"],
a.btn,
.btn {
    min-height: 44px;
    min-width: 44px;
}

/* ===== SAFE AREA PARA NOTCH/BARRA NAVEGACION ===== */
.safe-area-top {
    padding-top: env(safe-area-inset-top, 0);
}

.safe-area-bottom {
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.safe-area-all {
    padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

/* ===== OPTIMIZACIONES DE TOUCH ===== */
.touch-manipulation {
    touch-action: manipulation;
}

/* Deshabilitar zoom en inputs en iOS */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    select,
    textarea,
    input[type="text"],
    input[type="password"],
    input[type="datetime"],
    input[type="datetime-local"],
    input[type="date"],
    input[type="month"],
    input[type="time"],
    input[type="week"],
    input[type="number"],
    input[type="email"],
    input[type="url"],
    input[type="search"],
    input[type="tel"],
    input[type="color"] {
        font-size: 16px !important;
    }
}

/* ===== MEJORAS DE SCROLL ===== */
.smooth-scroll {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Ocultar scrollbars en móvil pero mantener funcionalidad */
.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

/* ===== ANIMACIONES REDUCIDAS ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== MEJORAS PARA PANTALLAS XS (< 400px) ===== */
@media (max-width: 400px) {
    /* Reducir padding general */
    .container,
    .max-w-7xl {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* Textos más pequeños */
    .text-responsive-xs {
        font-size: 0.75rem;
    }

    /* Cards más compactas */
    .card-compact {
        padding: 0.75rem;
    }

    /* Gaps más pequeños */
    .gap-responsive {
        gap: 0.5rem;
    }
}

/* ===== MEJORAS PARA PANTALLAS SM (400-640px) ===== */
@media (min-width: 400px) and (max-width: 640px) {
    .gap-responsive {
        gap: 0.75rem;
    }
}

/* ===== HOVER STATES PARA TOUCH ===== */
@media (hover: none) {
    /* En dispositivos touch, usar active en lugar de hover */
    .hover\:bg-gray-100:active {
        background-color: rgb(243 244 246);
    }
    .hover\:bg-pink-50:active {
        background-color: rgb(253 242 248);
    }
    .hover\:text-pink-600:active {
        color: rgb(219 39 119);
    }
}

/* ===== FOCUS VISIBLE PARA ACCESIBILIDAD ===== */
:focus-visible {
    outline: 2px solid rgb(219 39 119);
    outline-offset: 2px;
}

/* ===== TIPOGRAFIA RESPONSIVE ===== */
@media (max-width: 640px) {
    /* Ajustar tamaños de fuente para móvil */
    h1, .text-3xl {
        font-size: 1.5rem;
        line-height: 2rem;
    }
    h2, .text-2xl {
        font-size: 1.25rem;
        line-height: 1.75rem;
    }
    h3, .text-xl {
        font-size: 1.125rem;
        line-height: 1.5rem;
    }
}

/* ===== BOTONES MÓVIL ===== */
@media (max-width: 640px) {
    .btn-mobile-full {
        width: 100%;
        justify-content: center;
    }

    /* Botones más grandes en móvil */
    .btn-mobile-lg {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
}

/* ===== FORMULARIOS MÓVIL ===== */
@media (max-width: 640px) {
    /* Inputs más altos para mejor touch */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="tel"],
    input[type="url"],
    input[type="number"],
    select,
    textarea {
        min-height: 48px;
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    /* Checkboxes y radios más grandes */
    input[type="checkbox"],
    input[type="radio"] {
        width: 1.25rem;
        height: 1.25rem;
    }
}

/* ===== CARDS RESPONSIVE ===== */
@media (max-width: 480px) {
    .card-responsive {
        border-radius: 0.5rem;
    }
    .card-responsive .card-body {
        padding: 0.75rem;
    }
}

/* ===== IMÁGENES RESPONSIVE ===== */
img {
    max-width: 100%;
    height: auto;
}

/* ===== TABLAS RESPONSIVE ===== */
@media (max-width: 640px) {
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ===== UTILIDADES DE ESPACIADO MÓVIL ===== */
@media (max-width: 640px) {
    .mobile-px-0 { padding-left: 0; padding-right: 0; }
    .mobile-py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
    .mobile-mt-4 { margin-top: 1rem; }
    .mobile-mb-4 { margin-bottom: 1rem; }
}

/* ===== FLEXBOX RESPONSIVE ===== */
@media (max-width: 640px) {
    .mobile-flex-col {
        flex-direction: column;
    }
    .mobile-items-stretch {
        align-items: stretch;
    }
    .mobile-w-full {
        width: 100%;
    }
}

/* ===== OCULTAR/MOSTRAR EN MÓVIL ===== */
@media (max-width: 640px) {
    .mobile-hidden { display: none !important; }
}
@media (min-width: 641px) {
    .mobile-only { display: none !important; }
}

/* ===== OPTIMIZACIÓN DE RENDIMIENTO ===== */
/* Hardware acceleration para animaciones */
.hw-accelerate {
    transform: translateZ(0);
    will-change: transform;
}

/* Optimizar imágenes */
img.lazy-load {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}
img.lazy-load.loaded {
    opacity: 1;
}

/* ===== MEJORAS DE LEGIBILIDAD ===== */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Contraste mejorado para textos pequeños */
.text-xs,
.text-sm {
    letter-spacing: 0.01em;
}

/* ===== DRAWER DE FILTROS AVANZADOS ===== */
/* Panel de filtros - comportamiento base */
#panel-filtros-avanzados {
    transition: all 0.3s ease;
}

/* En desktop, comportamiento normal */
@media (min-width: 768px) {
    #panel-filtros-avanzados {
        animation: slideDown 0.3s ease;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* En móvil, drawer lateral */
@media (max-width: 767px) {
    #panel-filtros-avanzados {
        position: fixed !important;
        top: 0 !important;
        right: -100% !important;
        width: 85% !important;
        max-width: 340px !important;
        height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        z-index: 1000 !important;
        overflow-y: auto !important;
        box-shadow: -4px 0 25px rgba(0, 0, 0, 0.2) !important;
        transition: right 0.3s ease !important;
    }

    #panel-filtros-avanzados.drawer-active {
        right: 0 !important;
    }

    /* Overlay oscuro detrás del drawer */
    #panel-filtros-avanzados.drawer-active::before {
        content: '';
        position: fixed;
        top: 0;
        left: -100vw;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
        animation: fadeIn 0.3s ease;
    }

    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    /* Header del drawer */
    #panel-filtros-avanzados > div:first-child {
        position: sticky;
        top: 0;
        background: linear-gradient(to right, #f9fafb, #fdf2f8);
        padding: 1rem;
        border-bottom: 1px solid #e5e7eb;
        z-index: 10;
    }

    /* Padding extra en la parte inferior para safe area */
    #panel-filtros-avanzados > form {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0));
    }

    /* Botones de acción fijos en la parte inferior */
    #panel-filtros-avanzados .flex.flex-col.sm\\:flex-row {
        position: sticky;
        bottom: 0;
        background: white;
        padding: 1rem;
        margin: 0 -1rem -1rem;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.05);
    }
}

/* ===== ANIMACIÓN PARA EL CONTADOR DE FILTROS ===== */
#contador-filtros {
    animation: pulse 0.3s ease;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ===== MEJORAS PARA LOS CHIPS DE FILTROS ===== */
.filtro-grupo label:has(input:checked) {
    background-color: rgb(253 242 248);
    border-color: rgb(244 114 182);
}

/* Transición suave al marcar/desmarcar */
.filtro-grupo label {
    transition: all 0.15s ease;
}

.filtro-grupo label:active {
    transform: scale(0.98);
}

/* ===== MEJORAS PARA PANTALLAS ULTRA-PEQUEÑAS (< 360px) ===== */
/* Galaxy S3, BlackBerry Z30, Note 2, etc. */
@media (max-width: 359px) {
    /* Reducir padding global aún más */
    .container,
    .max-w-7xl,
    [class*="px-4"] {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    /* Botones de contacto más compactos */
    .bg-gradient-to-r.from-green-500,
    .bg-gradient-to-r.from-blue-500,
    .bg-gradient-to-r.from-purple-500 {
        padding: 0.625rem 0.75rem !important;
        font-size: 0.875rem !important;
    }

    .bg-gradient-to-r.from-green-500 svg,
    .bg-gradient-to-r.from-blue-500 svg,
    .bg-gradient-to-r.from-purple-500 svg {
        width: 1.125rem !important;
        height: 1.125rem !important;
    }

    /* Tags más pequeños */
    .rounded-full[class*="px-2"],
    .rounded-full[class*="px-3"] {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.65rem !important;
    }

    .rounded-full i {
        font-size: 0.5rem !important;
        margin-right: 0.25rem !important;
    }

    /* Títulos más pequeños */
    h1, .text-2xl {
        font-size: 1.125rem !important;
        line-height: 1.5rem !important;
    }

    h2, .text-xl {
        font-size: 1rem !important;
        line-height: 1.375rem !important;
    }

    /* Emojis más pequeños */
    .text-4xl {
        font-size: 1.5rem !important;
    }

    .text-2xl:not(h1):not(h2) {
        font-size: 1.25rem !important;
    }

    /* Cards con menos padding */
    .p-4, .p-6 {
        padding: 0.75rem !important;
    }

    /* Gap reducido en flex/grid */
    .gap-2, .gap-3, .gap-4 {
        gap: 0.375rem !important;
    }

    /* Barra inferior fija más compacta */
    .fixed.bottom-0 .py-3,
    .fixed.bottom-0 .py-4 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }

    .fixed.bottom-0 .text-xl,
    .fixed.bottom-0 .text-2xl {
        font-size: 1rem !important;
    }

    .fixed.bottom-0 .text-xs,
    .fixed.bottom-0 .text-sm {
        font-size: 0.625rem !important;
    }

    /* Globito de chat anónimo más pequeño */
    .fixed.bottom-24 .w-16 {
        width: 3rem !important;
        height: 3rem !important;
    }

    .fixed.bottom-24 .text-2xl {
        font-size: 1rem !important;
    }

    /* Ajustar posición del globito */
    .fixed.bottom-24.right-4 {
        right: 0.5rem !important;
        bottom: 5rem !important;
    }

    /* Modals más compactos */
    .modal-content,
    [class*="rounded-lg"].p-6 {
        padding: 0.75rem !important;
    }

    /* Scroll horizontal para tags si hay muchos */
    .flex.flex-wrap.gap-1\\.5 {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        padding-bottom: 0.25rem !important;
    }

    .flex.flex-wrap.gap-1\\.5::-webkit-scrollbar {
        display: none !important;
    }
}

/* ===== MEJORAS PARA GALAXY S8/S9 Y SIMILARES (360-400px) ===== */
@media (min-width: 360px) and (max-width: 399px) {
    /* Ajustes intermedios */
    .container,
    .max-w-7xl {
        padding-left: 10px;
        padding-right: 10px;
    }

    /* Tags ligeramente más pequeños */
    .rounded-full[class*="px-2"],
    .rounded-full[class*="px-3"] {
        font-size: 0.7rem;
    }

    /* Botones con padding intermedio */
    .bg-gradient-to-r.from-green-500,
    .bg-gradient-to-r.from-blue-500,
    .bg-gradient-to-r.from-purple-500 {
        padding: 0.75rem 1rem;
    }
}
