/**
 * Mejoras de responsive para todo el sitio
 * Complementa Bootstrap 5 con ajustes específicos del proyecto
 */

/* ========================================
   GLOBAL RESPONSIVE UTILITIES
   ======================================== */

/* Asegurar que las imágenes nunca excedan su contenedor */
img {
    max-width: 100%;
    height: auto;
}

/* Prevenir desbordamiento horizontal */
body {
    overflow-x: hidden;
}

/* Contenedores responsivos */
.container,
.container-fluid {
    padding-left: 15px;
    padding-right: 15px;
}

/* ========================================
   NAVEGACIÓN MÓVIL
   ======================================== */

@media (max-width: 991px) {
    /* Navbar más compacta en móvil */
    .navbar {
        padding: 0.5rem 0;
    }

    .navbar-brand {
        font-size: 1.2rem;
    }

    /* Menú collapse con mejor espaciado */
    .navbar-collapse {
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid rgba(0,0,0,0.1);
    }

    .navbar-nav {
        margin-top: 0.5rem;
    }

    .nav-link {
        padding: 0.75rem 0;
        border-bottom: 1px solid rgba(0,0,0,0.05);
    }

    /* Ocultar elementos no esenciales en móvil */
    .d-mobile-none {
        display: none !important;
    }
}

/* ========================================
   PRODUCTOS Y GRIDS
   ======================================== */

/* Mejorar grid de productos en móvil */
@media (max-width: 575px) {
    /* Una columna en móviles pequeños */
    .product-grid .col-md-4,
    .product-grid .col-sm-6 {
        width: 100%;
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Cards de productos con mejor padding */
    .card {
        margin-bottom: 1.5rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Títulos de productos más pequeños */
    .card-title {
        font-size: 1rem;
    }

    /* Precios destacados */
    .product-price {
        font-size: 1.25rem;
        font-weight: 700;
    }
}

@media (min-width: 576px) and (max-width: 767px) {
    /* Dos columnas en tablets pequeñas */
    .product-grid .col-md-4 {
        width: 50%;
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* ========================================
   TABLAS RESPONSIVE
   ======================================== */

@media (max-width: 767px) {
    /* Tablas con scroll horizontal */
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        font-size: 0.875rem;
    }

    /* Reducir padding de celdas */
    table td,
    table th {
        padding: 0.5rem;
    }
}

/* ========================================
   FORMULARIOS RESPONSIVE
   ======================================== */

@media (max-width: 575px) {
    /* Formularios de una columna en móvil */
    .row .col-md-6,
    .row .col-md-4,
    .row .col-md-3 {
        margin-bottom: 1rem;
    }

    /* Labels más visibles */
    label, .form-label {
        font-weight: 600;
        margin-bottom: 0.5rem;
    }

    /* Inputs más grandes para touch */
    .form-control,
    .form-select {
        font-size: 16px; /* Previene zoom en iOS */
        padding: 0.75rem;
        height: auto;
        min-height: 48px; /* Tamaño mínimo touch-friendly */
    }

    /* Botones más grandes */
    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
        min-height: 48px;
    }

    .btn-sm {
        min-height: 40px;
    }
}

/* ========================================
   CHECKOUT RESPONSIVE
   ======================================== */

@media (max-width: 991px) {
    /* Resumen de compra debajo del formulario en móvil */
    .order-summary {
        position: relative;
        top: 0;
        margin-top: 2rem;
        margin-bottom: 2rem;
    }

    /* Indicador de progreso más compacto */
    .checkout-progress {
        margin-bottom: 1.5rem;
    }

    .progress-step-label {
        font-size: 11px;
    }

    .progress-step-circle {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    /* Cards de checkout con menos padding */
    .checkout-card {
        padding: 1rem;
    }

    .checkout-card h3 {
        font-size: 1.1rem;
    }
}

@media (max-width: 575px) {
    /* Opciones de entrega y pago en una columna */
    .delivery-option,
    .payment-option {
        font-size: 0.9rem;
        padding: 12px;
    }

    /* Botones de navegación full-width */
    .btn-continue,
    .btn-back {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .d-flex.justify-content-between {
        flex-direction: column-reverse;
    }
}

/* ========================================
   CARRITO RESPONSIVE
   ======================================== */

@media (max-width: 767px) {
    /* Ocultar columnas no esenciales */
    .cart-table .d-md-table-cell {
        display: none !important;
    }

    /* Simplificar visualización del carrito */
    .cart-item {
        display: flex;
        flex-direction: column;
        padding: 1rem;
        border-bottom: 1px solid #eee;
    }

    .cart-item-image {
        width: 100%;
        max-width: 150px;
        margin: 0 auto 1rem;
    }

    .cart-item-details {
        text-align: center;
    }

    .cart-item-quantity {
        margin: 1rem 0;
    }
}

/* ========================================
   BOTONES Y ACCIONES
   ======================================== */

@media (max-width: 575px) {
    /* Grupo de botones en vertical */
    .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .btn-group > .btn {
        width: 100%;
        border-radius: 0.25rem !important;
        margin-bottom: 0.5rem;
    }

    /* Botones flotantes para acciones principales */
    .btn-fixed-mobile {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        border-radius: 0;
        padding: 1rem;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
}

/* ========================================
   TIPOGRAFÍA RESPONSIVE
   ======================================== */

@media (max-width: 767px) {
    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    h4 {
        font-size: 1.1rem;
    }

    /* Ajustar line-height para mejor legibilidad */
    body {
        line-height: 1.6;
    }

    p {
        margin-bottom: 1rem;
    }
}

/* ========================================
   MODALES RESPONSIVE
   ======================================== */

@media (max-width: 575px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }

    .modal-title {
        font-size: 1.1rem;
    }
}

/* ========================================
   FOOTER RESPONSIVE
   ======================================== */

@media (max-width: 767px) {
    footer .row > div {
        margin-bottom: 2rem;
        text-align: center;
    }

    footer ul {
        padding-left: 0;
        list-style: none;
    }

    footer .col-md-3 {
        width: 100%;
    }
}

/* ========================================
   UTILIDADES RESPONSIVE ADICIONALES
   ======================================== */

/* Espaciado responsive */
@media (max-width: 575px) {
    .container,
    .container-fluid {
        padding-left: 15px;
        padding-right: 15px;
    }

    section {
        padding-top: 2rem;
        padding-bottom: 2rem;
    }

    .mt-5, .my-5 {
        margin-top: 2rem !important;
    }

    .mb-5, .my-5 {
        margin-bottom: 2rem !important;
    }

    .pt-5, .py-5 {
        padding-top: 2rem !important;
    }

    .pb-5, .py-5 {
        padding-bottom: 2rem !important;
    }
}

/* Ocultar elementos en diferentes breakpoints */
.hide-mobile {
    display: block;
}

@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }

    .show-mobile {
        display: block !important;
    }
}

.show-mobile {
    display: none;
}

/* ========================================
   OPTIMIZACIONES DE PERFORMANCE
   ======================================== */

/* Reducir animaciones en dispositivos de bajo rendimiento */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Mejorar renderizado de textos */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   LANDSCAPE MODE (Móviles horizontales)
   ======================================== */

@media (max-height: 500px) and (orientation: landscape) {
    /* Reducir altura de elementos */
    .navbar {
        padding: 0.25rem 0;
    }

    section {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }

    .modal-dialog {
        margin: 0.5rem auto;
    }
}
