/* ================================================================
   CYBEL THEME — Mobile Responsive Fixes (7 Bugs)
   SOLO afecta a móvil (max-width: 768px)
   NO modifica estilos de desktop
   ================================================================ */

@media (max-width: 768px) {

    /* ============================================================
       BUG 1: HEADER — Menú hamburguesa + Search bar
       ============================================================ */

    .site-header .main-header .container {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        padding: 10px 16px;
        gap: 10px;
    }

    .mobile-menu-toggle {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 8px;
        z-index: 10010;
        order: 1;
        gap: 5px;
    }

    .mobile-menu-toggle span {
        display: block;
        width: 22px;
        height: 2px;
        background-color: #222222;
        margin: 0;
        transition: all 0.3s ease;
        border-radius: 1px;
    }

    .site-header .site-logo {
        order: 2;
        flex: 1;
        text-align: center;
        padding: 0 8px;
    }

    .site-header .site-logo img {
        max-height: 36px;
        width: auto;
    }

    .header-actions {
        display: flex;
        align-items: center;
        gap: 8px;
        order: 3;
        flex-shrink: 0;
    }

    .header-search {
        order: 10;
        width: 100%;
        flex-basis: 100%;
        margin-top: 8px;
        position: relative;
    }

    .header-search input[type="search"] {
        width: 100%;
        height: 40px;
        padding: 8px 40px 8px 12px;
        font-size: 16px;
        border: 1px solid #dddddd;
        border-radius: 4px;
        background: #ffffff;
    }

    .header-search input:focus {
        width: 100%;
    }

    .header-search button[type="submit"] {
        position: absolute;
        right: 4px;
        top: 50%;
        transform: translateY(-50%);
        width: 36px;
        height: 36px;
        background: none;
        border: none;
    }

    .main-navigation {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        background: #ffffff;
        z-index: 100020;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding: 20px;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
        display: block;
    }

    .main-navigation.active {
        transform: translateX(0);
    }

    .main-navigation.active ul {
        flex-direction: column;
    }

    .main-navigation.active ul li {
        width: 100%;
    }

    .main-navigation.active ul li a {
        display: block;
        padding: 14px 0;
        font-size: 15px;
        border-bottom: 1px solid #f0f0f0;
    }


    /* ============================================================
       BUG 2: MINI-CART — Botón de cierre + overlay cierra
       Ya existe .mini-cart__close en el HTML y mini-cart.js lo maneja.
       Asegurar visibilidad y touch target en móvil.
       ============================================================ */

    .mini-cart__close {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        font-size: 24px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    .mini-cart__header {
        padding: 16px 20px;
        position: sticky;
        top: 0;
        background: #ffffff;
        z-index: 5;
    }

    .mini-cart-overlay {
        background: rgba(0, 0, 0, 0.5);
    }


    /* ============================================================
       BUG 3-4: CART PAGE — Resumen separado del footer
       ============================================================ */

    .sf-cart__summary {
        margin-bottom: 40px;
        padding-bottom: 24px;
    }

    .sf-cart__checkout-btn {
        margin-bottom: 20px;
    }

    .woocommerce-cart .site-content,
    .woocommerce-cart main,
    .sf-cart {
        padding-bottom: 80px;
    }

    .sf-cart__items {
        padding-bottom: 20px;
    }


    /* ============================================================
       BUG 5: HEADER — Iconos wishlist/cart con badge posicionado
       ============================================================ */

    .cart-link {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    .cart-link .cart-count {
        position: absolute;
        top: 4px;
        right: 2px;
        min-width: 18px;
        height: 18px;
        font-size: 10px;
        font-weight: 700;
        line-height: 18px;
        text-align: center;
        background: #e74c3c;
        color: #ffffff;
        border-radius: 9px;
        padding: 0 4px;
        pointer-events: none;
    }

    .wishlist-icon {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    .wishlist-icon__svg {
        width: 20px;
        height: 20px;
    }

    .wishlist-count-badge {
        min-width: 17px;
        height: 17px;
        font-size: 10px;
        line-height: 17px;
        transform: translate(40%, -40%);
        top: 0;
        right: 0;
    }

    .header-actions a {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }


    /* ============================================================
       BUG 6: CHECKOUT — Botón confirmar pedido no funciona
       Causas posibles:
       1. overflow:hidden en ancestros corta el botón
       2. position:sticky en .cybel-right crea stacking context
       3. Elemento fijo (header/overlay) tapa el botón
       4. pointer-events:none heredado
       ============================================================ */

    .woocommerce-checkout #place_order,
    .wc-block-components-checkout-place-order-button {
        position: relative;
        z-index: 10;
        width: 100%;
        min-height: 48px;
        padding: 14px 20px;
        font-size: 16px;
        font-weight: 600;
        pointer-events: auto;
        cursor: pointer;
        display: block;
        visibility: visible;
        opacity: 1;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .woocommerce-checkout .form-row.place-order,
    .woocommerce-checkout #payment,
    .woocommerce-checkout .woocommerce-checkout-review-order,
    .woocommerce-checkout .cybel-right,
    .woocommerce-checkout .cybel-checkout__right,
    .woocommerce-checkout .cybel-checkout-grid,
    .woocommerce-checkout .cybel-checkout__grid {
        overflow: visible !important;
        position: relative !important;
        pointer-events: auto;
    }

    .woocommerce-checkout .cybel-right,
    .woocommerce-checkout .cybel-checkout__right {
        position: static !important;
        top: auto !important;
    }

    .woocommerce-checkout .site-content,
    .woocommerce-checkout main,
    .woocommerce-checkout .cybel-checkout,
    .wc-block-checkout {
        overflow-x: visible;
        padding-bottom: 100px;
    }

    .woocommerce-checkout .cybel-checkout-grid,
    .woocommerce-checkout .cybel-checkout__grid {
        display: block;
    }

    #payment ul.payment_methods li {
        pointer-events: auto;
    }

    #payment ul.payment_methods li label {
        min-height: 44px;
        padding: 12px 16px;
        cursor: pointer;
    }

    #payment ul.payment_methods li input[type="radio"]:checked + label {
        background: #111 !important;
        color: #fff !important;
    }


    /* ============================================================
       BUG 7: MI CUENTA — Pedidos recientes a cards + tabs horizontales
       ============================================================ */

    .sf-my-account__nav-item {
        padding: 12px 16px;
        font-size: 13px;
        white-space: nowrap;
        border: none;
        border-bottom: 2px solid transparent;
        background: transparent;
        border-left: none;
        border-radius: 0;
        margin-bottom: 0;
    }

    .sf-my-account__nav-item.is-active {
        border-left: none;
        border-bottom-color: var(--ma-sidebar-active-color, #111331);
        background: transparent;
    }

    .sf-my-account__nav {
        padding: 0;
        border: none;
        background: transparent;
        border-radius: 0;
        position: static;
    }

    .sf-my-account__nav .sf-my-account__nav-list,
    .sf-my-account__nav ul {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 0;
        padding: 0;
        margin: 0;
        scrollbar-width: none;
        -ms-overflow-style: none;
        border-bottom: 1px solid #eeeeee;
    }

    .sf-my-account__nav::-webkit-scrollbar {
        display: none;
    }

    .woocommerce-orders-table {
        display: block;
    }

    .woocommerce-orders-table thead {
        display: none;
    }

    .woocommerce-orders-table tbody {
        display: block;
    }

    .woocommerce-orders-table tbody tr {
        display: flex;
        flex-wrap: wrap;
        padding: 16px;
        border: 1px solid #eeeeee;
        border-radius: 8px;
        margin-bottom: 12px;
        gap: 8px;
        background: #ffffff;
    }

    .woocommerce-orders-table tbody td {
        padding: 4px 0;
        border: none;
        font-size: 13px;
    }

    .woocommerce-orders-table .order-number,
    .woocommerce-orders-table td:first-child {
        width: 100%;
        font-weight: 700;
        font-size: 15px;
    }

    .woocommerce-orders-table .order-number a {
        font-weight: 700;
    }

    .woocommerce-orders-table .order-date {
        width: 50%;
    }

    .woocommerce-orders-table .order-status {
        width: 50%;
        text-align: right;
    }

    .woocommerce-orders-table .order-total {
        width: 50%;
        font-weight: 700;
    }

    .woocommerce-orders-table .order-actions {
        width: 50%;
        text-align: right;
    }

    .woocommerce-orders-table .order-actions .button {
        min-height: 36px;
        padding: 6px 16px;
        font-size: 12px;
    }

    .sf-my-account__order-item {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 12px;
        border: 1px solid #eeeeee;
        border-radius: 8px;
        margin-bottom: 12px;
    }

    .sf-my-account__order-total {
        grid-column: 1 / -1;
        text-align: left;
        margin-top: 8px;
    }


    /* ============================================================
       GLOBAL — Touch targets y prevención de iOS zoom
       ============================================================ */

    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="search"],
    select,
    textarea {
        font-size: 16px;
    }

    .button,
    button,
    input[type="submit"],
    a.button {
        min-height: 44px;
    }

} /* END @media (max-width: 768px) */


/* ============================================================
   TABLET — Ajustes para 769px-1024px (sin cambiar desktop)
   ============================================================ */

@media (min-width: 769px) and (max-width: 1024px) {
    .mini-cart {
        width: 400px;
        max-width: 400px;
        right: -400px;
    }

    .sf-my-account__nav {
        width: 200px;
    }

    .sf-my-account__main {
        width: calc(100% - 240px);
    }
}
