/* ============================================
   RESPONSIVE GLOBAL - Smile Dental Lab
   Mobile, Tablet, Desktop
   ============================================ */

/* ---- HEADER / TOPBAR ---- */

/* Tablet: hide text labels, show only icons */
@media (max-width: 991.98px) {
    .site-header-top {
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 0;
    }

    .site-header-actions {
        gap: 10px !important;
    }

    .site-header-actions > a > span,
    .site-header-actions > .dropdown > a > span,
    .site-header-actions > .btn > span {
        display: none;
    }

    .site-header-actions > a,
    .site-header-actions > .dropdown > a,
    .site-header-actions .btn {
        font-size: 18px;
        padding: 6px 10px !important;
        gap: 0 !important;
    }

    .site-header-cart-badge {
        font-size: 10px;
        min-width: 16px;
        height: 16px;
        line-height: 16px;
    }

    /* Dropdown menus: full width on tablet */
    .site-header-actions .dropdown-menu {
        width: calc(100vw - 30px) !important;
        max-width: 360px !important;
        right: -10px !important;
    }

    /* Navbar brand logo smaller */
    .navbar-brand img {
        max-height: 36px !important;
    }
}

/* Mobile */
@media (max-width: 575.98px) {
    /* Solo diente en el logo — ocultar texto "Smile Dental" y tagline */
    .sdl-brand-text { display: none !important; }

    /* Ocultar búsqueda del header — se usa desde barra inferior */
    .site-header-search,
    .site-header-search--placeholder { display: none !important; }

    /* Header compacto */
    .site-header-top {
        padding: 6px 0 !important;
        flex-wrap: nowrap !important;
    }

    .site-header-actions {
        gap: 4px !important;
        flex-shrink: 0;
    }

    .site-header-actions > a,
    .site-header-actions > .dropdown > a {
        font-size: 18px;
        padding: 4px 6px !important;
    }

    /* Ocultar botón Laboratorio y Favoritos del header */
    .site-header-actions > a[href*="productos-y-servicios"],
    .site-header-actions > a.btn[href*="productos-y-servicios"],
    #wishlist-btn { display: none !important; }

    .navbar-brand img {
        height: 40px !important;
        width: 40px !important;
    }

    /* Mini cart dropdown centrado */
    .site-header-actions .dropdown-menu {
        width: calc(100vw - 20px) !important;
        max-width: 100vw !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
    }
}

/* ---- MEGAMENU ---- */
@media (max-width: 991.98px) {
    .megamenu-bar__list {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        gap: 0;
    }
    .megamenu-bar__list::-webkit-scrollbar { display: none; }

    .megamenu-bar__link {
        white-space: nowrap;
        font-size: 12px;
        padding: 10px 12px;
    }

    .megamenu-panel {
        position: fixed;
        left: 0;
        right: 0;
        width: 100vw;
        max-height: 70vh;
        overflow-y: auto;
    }
}

/* ---- MI CUENTA ---- */
@media (max-width: 991.98px) {
    .list_menu {
        margin-bottom: 20px;
    }

    .list_menu h5 {
        font-size: 16px;
    }

    .list-menu_user {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        padding: 0;
        margin: 0;
        list-style: none;
    }

    .list-menu_user li a {
        display: inline-block;
        padding: 6px 14px;
        background: #f0f2f5;
        border-radius: 20px;
        font-size: 13px;
        text-decoration: none;
        color: #333;
        white-space: nowrap;
    }

    .list-menu_user li a:hover {
        background: #0b5aa6;
        color: #fff;
    }
}

@media (max-width: 575.98px) {
    .list-menu_user li a {
        font-size: 12px;
        padding: 5px 10px;
    }
}

/* ---- CHECKOUT ---- */
@media (max-width: 991.98px) {
    .checkout-main {
        grid-template-columns: 1fr !important;
    }

    .cart-summary {
        position: static !important;
    }

    .checkout-form {
        padding: 1.25rem !important;
    }

    .shipping-methods {
        flex-direction: column !important;
    }

    .shipping-card {
        min-width: 0 !important;
    }

    .payment-methods {
        flex-direction: column !important;
    }

    .payment-option {
        flex: none !important;
        width: 100% !important;
    }
}

@media (max-width: 575.98px) {
    .checkout-container {
        padding: 1rem 0 !important;
    }

    .checkout-header {
        padding: 1rem 0 !important;
        margin-bottom: 1rem !important;
        border-radius: 0 !important;
    }

    .checkout-title {
        font-size: 1.3rem !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .checkout-form {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
        border-radius: 8px !important;
    }

    .section-title {
        font-size: 1rem !important;
    }

    .checkout-btn {
        font-size: 1rem !important;
        padding: 0.85rem !important;
    }

    .cart-summary {
        padding: 1rem !important;
    }

    .summary-row.total {
        font-size: 1.05rem !important;
    }

    .cart-item {
        grid-template-columns: 40px 1fr !important;
        padding: 0.75rem !important;
        gap: 0.75rem !important;
    }

    .cart-item-image {
        width: 40px !important;
        height: 40px !important;
        font-size: 1rem !important;
    }

    .mp-card-form{
        max-width: none !important;
        padding: 16px !important;
    }

    .mp-form-row{
        flex-direction: column !important;
        gap: 12px !important;
    }

    .coupon-input{
        flex-direction: column !important;
    }

    .coupon-input button{
        width: 100% !important;
    }
}

/* ---- TABLES (Admin + General) ---- */
@media (max-width: 767.98px) {
    .table-responsive-custom {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Make all tables in admin scrollable */
    .card-body > table,
    .container-fluid table.table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        font-size: 13px;
    }

    .card-body > table th,
    .card-body > table td {
        white-space: nowrap;
        padding: 8px 10px !important;
    }

    .card-body > table .btn-sm {
        padding: 3px 6px;
        font-size: 11px;
    }
}

/* ---- ADMIN PEDIDOS TIENDA ---- */
@media (max-width: 991.98px) {
    .content-wrapper {
        padding: 10px;
    }

    .content-wrapper .row.mb-3 .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
        margin-bottom: 10px;
    }

    .content-wrapper .card-body {
        padding: 0.75rem;
    }
}

@media (max-width: 575.98px) {
    .content-wrapper .row.mb-3 .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .content-wrapper .row.mb-3 .col-md-3 h3 {
        font-size: 1.3rem;
    }

    .content-wrapper .card-body {
        padding: 0.5rem;
        overflow-x: auto;
    }
}

/* ---- SURTIDOR PANEL ---- */
@media (max-width: 575.98px) {
    .topbar {
        padding: 10px 15px !important;
    }

    .topbar h1 {
        font-size: 16px !important;
    }

    .topbar .user-info {
        font-size: 12px !important;
        gap: 8px !important;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        padding: 12px !important;
    }

    .stat-card {
        padding: 12px !important;
    }

    .stat-card .number {
        font-size: 24px !important;
    }

    .stat-card .label {
        font-size: 11px !important;
    }

    .orders-container {
        padding: 0 12px 12px !important;
    }

    .order-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 8px;
        padding: 12px 15px !important;
    }

    .order-meta {
        flex-wrap: wrap !important;
        gap: 6px !important;
        font-size: 11px !important;
    }

    .order-body {
        padding: 12px 15px !important;
    }

    .order-actions {
        padding: 10px 15px !important;
    }

    .order-actions button {
        flex: 1;
        padding: 10px 12px !important;
        font-size: 13px !important;
    }

    .product-row {
        padding: 8px 0 !important;
    }

    .product-qty {
        width: 30px !important;
        height: 30px !important;
        font-size: 14px !important;
        margin-right: 10px !important;
    }

    .product-name {
        font-size: 13px !important;
    }

    .shipping-info {
        font-size: 12px !important;
    }
}

/* ---- PRODUCT DETAIL ---- */
@media (max-width: 767.98px) {
    .product-detail-container {
        flex-direction: column !important;
    }

    .product-gallery,
    .product-info {
        width: 100% !important;
        max-width: 100% !important;
    }

    .product-gallery img {
        max-height: 300px;
        object-fit: contain;
    }
}

/* ---- GENERAL UTILITIES ---- */
@media (max-width: 575.98px) {
    .container {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.3rem; }
    h3 { font-size: 1.1rem; }

    .btn {
        font-size: 14px;
    }

    .form-control,
    .form-select {
        font-size: 16px; /* evita el zoom automático de iOS Safari al enfocar el campo */
        padding: 8px 10px;
    }

    /* Ensure images don't overflow */
    img {
        max-width: 100%;
        height: auto;
    }
}

/* ---- FOOTER ---- */
@media (max-width: 767.98px) {
    footer .row > [class*="col-"] {
        margin-bottom: 20px;
    }
}

/* Fix horizontal overflow globally */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Smooth scrolling for all anchor links */
html {
    scroll-behavior: smooth;
}

/* Touch-friendly tap targets */
@media (max-width: 991.98px) {
    a, button, .btn, input, select, textarea {
        min-height: 38px;
    }

    .nav-link {
        padding: 10px 12px !important;
    }
}

/* ============================================
   iOS / MOBILE ANIMATION OPTIMIZATIONS
   Muchas animaciones simultáneas agotan la GPU
   del iPhone → reducir capas en móvil
   ============================================ */

/* ---- Reducir animaciones en móvil (< 768px) ---- */
@media (max-width: 767.98px) {
    /* Desactivar float en hp-cards del carrusel */
    .owl-carousel .owl-item .hp-card,
    .owl-carousel .owl-item:nth-child(2) .hp-card,
    .owl-carousel .owl-item:nth-child(3) .hp-card,
    .owl-carousel .owl-item:nth-child(4) .hp-card,
    .owl-carousel .owl-item:nth-child(5) .hp-card {
        animation: none !important;
        will-change: auto !important;
    }

    /* Desactivar float escalonado en servicios */
    .col-lg-4:nth-child(1) .service-item,
    .col-lg-4:nth-child(2) .service-item,
    .col-lg-4:nth-child(3) .service-item,
    .col-lg-4:nth-child(4) .service-item,
    .col-lg-4:nth-child(5) .service-item,
    .col-lg-4:nth-child(6) .service-item {
        animation: none !important;
        will-change: auto !important;
    }

    /* Desactivar twinkle en logos de marcas (muchos elementos) */
    .sdl-marca-item img {
        animation: none !important;
        will-change: auto !important;
    }

    /* Desactivar breathe en carrusel principal */
    #carouselExampleCaptions .carousel-item.active img {
        animation: none !important;
        will-change: auto !important;
    }

    /* Badge beat más lento para ahorrar GPU */
    .cat-card__discount {
        animation-duration: 2.4s !important;
    }
}

/* ---- iOS Safari: optimizaciones específicas ---- */
@supports (-webkit-touch-callout: none) {
    /* Girar anillo más lento en iOS */
    .service-icon::before {
        animation-duration: 20s !important;
    }

    /* Ripple de WhatsApp puede causar overflow en iOS */
    .btn-dark[href*="whatsapp"]::before,
    .btn-dark[href*="whatsapp"]::after {
        display: none !important;
    }

    /* Entrada de precios desactivada en iOS (animación corta causa glitch) */
    .cat-card__price,
    .cat-card__old-price {
        animation: none !important;
    }

    /* Quitar filter en imágenes animadas (filter+fixed+animation = bug iOS) */
    .service-icon img,
    .sdl-marca-item img {
        filter: none !important;
    }
}

/* ---- Dispositivos táctiles: :active en lugar de :hover ---- */
@media (hover: none) and (pointer: coarse) {
    /* Sin escala en hover de tarjetas (interfiere con scroll táctil) */
    .cat-card:hover {
        transform: none !important;
        box-shadow: none !important;
    }

    .hp-card:hover {
        transform: none !important;
        box-shadow: none !important;
    }

    /* Shine sweep en tap en vez de hover */
    .cat-card:active .cat-card__media::after {
        transform: skewX(-18deg) translateX(400%) !important;
        transition: transform 0.45s ease !important;
    }

    /* Social icons: sin hover spin en touch */
    a:hover .fa-facebook-f, a:hover .fa-instagram,
    a:hover .fa-twitter,    a:hover .fa-youtube,
    a:hover .fa-whatsapp,   a:hover .fa-linkedin {
        animation: none !important;
    }
}

/* ══════════════════════════════════════════════════════════
   TIENDA MÓVIL — Grid 2 columnas y tarjetas compactas
══════════════════════════════════════════════════════════ */
@media (max-width: 767.98px) {
    /* CRÍTICO: colapsar a 1 columna para evitar overflow horizontal
       que en iOS rompe position:fixed (nav inferior inutilizable) */
    .cat-layout {
        grid-template-columns: 1fr !important;
        gap: 0 !important;
    }
    .cat-products__grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .cat-card {
        border-radius: 10px;
    }

    /* Imagen más baja en móvil */
    .cat-card__media {
        height: 130px !important;
        min-height: 0 !important;
    }
    .cat-card__img-wrap {
        min-height: 0 !important;
        height: 130px;
    }

    /* Cuerpo compacto */
    .cat-card__body {
        padding: 8px 8px 10px !important;
    }

    /* Marca */
    .cat-card__brand {
        font-size: .68rem !important;
        margin-bottom: 2px !important;
    }

    /* Nombre — máximo 2 líneas */
    .cat-card__name {
        font-size: .72rem !important;
        line-height: 1.3 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        margin-bottom: 4px !important;
    }

    /* Precios */
    .cat-card__old-price {
        font-size: .65rem !important;
    }
    .cat-card__price {
        font-size: .88rem !important;
    }
    .cat-card__price-row {
        gap: 4px !important;
    }
    .cat-card__discount {
        font-size: .62rem !important;
        padding: 1px 5px !important;
    }

    /* Ocultar "Precio con IVA incluido" en móvil — ahorra espacio */
    .cat-card__body > small {
        display: none !important;
    }

    /* Controles de cantidad y botón */
    .cat-card__actions {
        flex-direction: column !important;
        gap: 5px !important;
        margin-top: 6px !important;
    }
    .store-qty {
        width: 100% !important;
        justify-content: center !important;
    }
    .store-qty__btn {
        width: 28px !important;
        height: 28px !important;
        font-size: .8rem !important;
    }
    .store-qty__input {
        width: 36px !important;
        height: 28px !important;
        font-size: .8rem !important;
    }
    .cat-card__add {
        width: 100% !important;
        padding: 7px 6px !important;
        font-size: .72rem !important;
        border-radius: 8px !important;
    }

    /* Corazón de favoritos */
    .cat-card__wish {
        width: 28px !important;
        height: 28px !important;
        top: 6px !important;
        right: 6px !important;
        font-size: .78rem !important;
    }
}
