/* Mobile-first layout adjustments shared by every page. */
html {
    scroll-padding-top: 64px;
    -webkit-text-size-adjust: 100%;
}

body {
    max-width: 100%;
    overflow-x: hidden;
}

#mobile-menu {
    position: fixed !important;
    inset: 64px 12px auto auto !important;
    z-index: 60 !important;
    width: max-content !important;
    min-width: 200px;
    max-width: calc(100vw - 24px);
    height: auto !important;
    max-height: calc(100dvh - 76px);
    background-color: #232628 !important;
    color: #fff;
    opacity: 1 !important;
    align-items: stretch !important;
    gap: 4px !important;
    overflow-y: auto !important;
    padding: 48px 12px 12px !important;
    border: 1px solid rgb(255 255 255 / 0.12);
    border-radius: 10px;
    box-shadow: 0 12px 30px rgb(0 0 0 / 0.35);
    isolation: isolate;
}

#mobile-menu > button:first-child {
    position: absolute;
    top: 8px;
    right: 10px;
}

#mobile-menu > a,
#mobile-menu > button:not(:first-child) {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border-radius: 6px;
    text-align: left;
    white-space: nowrap;
}

img,
video,
iframe {
    max-width: 100%;
}

button,
input,
select,
textarea {
    font: inherit;
}

/* Match the desktop navigation typography used on producto.html. */
body:not(.product-page) header a,
body:not(.product-page) header button,
body:not(.product-page) header a span:not(.cart-count):not(.cart-count-mobile),
body:not(.product-page) header button span:not(.cart-count):not(.cart-count-mobile) {
    font-family: 'Inter', sans-serif !important;
    font-weight: 300 !important;
}

@media (max-width: 767px) {
    header {
        min-height: 56px !important;
        height: 56px !important;
        padding-left: max(12px, env(safe-area-inset-left)) !important;
        padding-right: max(12px, env(safe-area-inset-right)) !important;
    }

    header img {
        height: 34px !important;
        width: auto;
        max-width: 40vw;
        object-fit: contain;
    }

    header button,
    header a {
        touch-action: manipulation;
    }

    /* Home */
    #home-hero {
        height: auto !important;
        min-height: 410px;
        padding: 56px 0 64px;
    }

    #home-hero-background {
        background-attachment: scroll !important;
    }

    #home-hero h1 {
        max-width: 12ch;
        font-size: clamp(2rem, 9vw, 2.65rem);
        line-height: 1.08;
    }

    #home-hero p {
        max-width: 34ch;
        font-size: 1rem;
        line-height: 1.55;
    }

    #home-hero .container-custom > div {
        flex-wrap: wrap;
    }

    #home-benefits {
        width: calc(100% - 24px);
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin-top: -24px !important;
        padding: 20px 12px !important;
        gap: 8px !important;
    }

    #home-benefits > div {
        padding: 16px 10px !important;
    }

    #featured-categories {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    #featured-categories article {
        height: 210px;
    }

    #featured-categories article > div:first-child {
        height: 132px;
    }

    #featured-categories article > div:last-child {
        height: 78px;
        padding: 12px;
    }

    #featured-categories h3 {
        font-size: 0.875rem;
        line-height: 1.25;
    }

    /* Catalog */
    #toggle-offers {
        padding: 6px 8px !important;
        gap: 5px !important;
        font-size: 12px !important;
    }

    #sticky-filter-bar > .w-full {
        padding: 8px 12px !important;
    }

    /* Keep the complete filter area pinned below the mobile navbar. */
    #sticky-filter-bar {
        position: sticky !important;
        z-index: 40 !important;
        box-shadow: 0 4px 16px rgb(0 0 0 / 0.25);
    }

    #catalog-filter-controls {
        display: grid !important;
        position: relative;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: stretch !important;
        gap: 8px !important;
    }

    #catalog-filter-controls > :first-child,
    #catalog-filter-controls > :last-child {
        grid-column: 1 / -1;
    }

    #catalog-filter-controls input,
    #catalog-filter-controls select,
    #catalog-filter-controls button {
        min-height: 42px;
    }

    #catalog-filter-controls select {
        padding-left: 8px !important;
        padding-right: 26px !important;
        font-size: 11px !important;
        letter-spacing: 0 !important;
        border-radius: 8px !important;
    }

    #catalog-filter-controls #globalSearch {
        padding-right: 48px !important;
        border-radius: 8px !important;
    }

    #catalog-filter-controls > :last-child {
        position: absolute;
        top: 0;
        right: 0;
        z-index: 2;
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
    }

    #catalog-filter-controls > :last-child #btnSearch {
        display: none !important;
    }

    #catalog-filter-controls > :last-child #btnReset {
        position: static;
        transform: none;
        flex: 0 0 42px !important;
        width: 42px !important;
        min-height: 42px;
        margin: 0;
        padding: 0 !important;
        border: 0 !important;
        border-radius: 8px !important;
        background: transparent !important;
        color: #64748b !important;
        box-shadow: none !important;
    }

    #catalog-filter-controls > :last-child #btnReset:hover {
        background: transparent !important;
    }

    #catalog-filter-controls > :last-child #btnReset i {
        margin: 0 !important;
        font-size: 16px !important;
    }

    #catalog-filter-controls > :last-child #btnReset .reset-button-label {
        display: none;
    }

    #catalog-filter-controls > :last-child button {
        flex: 1 1 0;
        width: auto !important;
    }

    #tableBody tr {
        display: block;
        margin: 0 12px 12px;
        padding: 12px 14px !important;
        overflow: hidden;
        border: 1px solid #cbd5e1 !important;
        border-radius: 8px;
        background: #f8fafc !important;
        box-shadow: 0 3px 10px rgb(0 0 0 / 0.2);
    }

    #tableBody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        min-width: 0;
        width: 100%;
        padding: 9px 0 !important;
        border: 0 !important;
        color: #1f2937;
        text-align: left !important;
    }

    #tableBody td::before {
        color: #64748b;
        font-size: 0.78rem;
        font-weight: 700;
        letter-spacing: 0.02em;
        text-transform: uppercase;
        flex: 0 0 auto;
    }

    #tableBody td[data-label="Código"] {
        border-bottom: 1px solid #cbd5e1 !important;
        margin: 0 0 2px !important;
    }

    #tableBody td[data-label="Código"]::before,
    #tableBody td[data-label="Acción"]::before {
        display: none;
    }

    #tableBody td[data-label="Código"] > div {
        display: flex;
        width: 100%;
        align-items: center;
        justify-content: space-between !important;
        gap: 10px !important;
    }

    #tableBody td[data-label="Código"] > div > span {
        display: flex;
        align-items: baseline;
        flex: 1 1 auto;
        gap: 8px;
        min-width: 0;
        color: #111827;
        font-size: 1rem;
        font-weight: 700;
        overflow-wrap: anywhere;
    }

    #tableBody td[data-label="Código"] > div > span::before {
        content: "CÓDIGO";
        flex: 0 0 auto;
        color: #1d4ed8;
        font: 700 0.78rem Inter, sans-serif;
    }

    #tableBody td[data-label="Código"] > div > a {
        order: 2;
        width: auto !important;
        height: 36px !important;
        padding: 0 10px !important;
        border-color: #374151 !important;
        border-radius: 4px !important;
        background: #374151 !important;
        color: #fff !important;
    }

    #tableBody td[data-label="Código"] > div > a::after {
        content: "VER PRODUCTO";
        margin-left: 7px;
        font: 700 0.68rem Inter, sans-serif;
        white-space: nowrap;
    }

    #tableBody td[data-label="Descripción"] {
        display: block;
        border-bottom: 1px solid #cbd5e1 !important;
        margin: 0 0 2px !important;
        padding: 10px 0 12px !important;
    }

    #tableBody td[data-label="Descripción"]::before {
        display: block;
        margin: 0 0 6px;
        content: "DESCRIPCIÓN";
        color: #1d4ed8;
    }

    #tableBody td[data-label="Descripción"] span {
        display: block;
        color: #1f2937;
        font-size: 1rem;
        font-weight: 500;
        line-height: 1.45;
        overflow-wrap: anywhere;
    }

    #tableBody td[data-label="Precio"]::before {
        content: "PRECIO";
        color: #111827;
    }

    #tableBody td[data-label="Precio"] {
        color: #111827;
        font-size: 1.08rem;
        font-weight: 700;
    }

    #tableBody td[data-label="Costo"]::before {
        content: "COSTO";
        color: #1d4ed8;
    }

    #tableBody td[data-label="Costo"] {
        color: #1d4ed8;
    }

    #tableBody td[data-label="Costo"] span {
        margin-left: auto;
        font-size: 1.08rem !important;
        color: #1d4ed8 !important;
    }

    #tableBody td[data-label="Acción"] {
        justify-content: center;
        border-top: 1px solid #cbd5e1 !important;
        margin-top: 5px;
        padding-top: 14px !important;
    }

    #tableBody td[data-label="Acción"] > div {
        justify-content: center !important;
        gap: 12px !important;
    }

    #tableBody td[data-label="Acción"] > div > div:first-child {
        min-height: 48px;
        padding: 3px 8px !important;
        border-radius: 7px !important;
    }

    #tableBody td[data-label="Acción"] > div > div:first-child button {
        width: 38px !important;
        height: 40px !important;
        font-size: 1.35rem !important;
        color: #1f2937 !important;
    }

    #tableBody td[data-label="Acción"] > div > div:first-child input {
        width: 34px !important;
        min-height: 40px;
        font-size: 1.15rem !important;
        color: #1f2937 !important;
    }

    #tableBody td[data-label="Acción"] button[title="Agregar al carrito"] {
        width: 48px !important;
        height: 48px !important;
        border-radius: 8px !important;
    }

    #tableBody td[data-label="Acción"] > div > div:last-child {
        width: 24px !important;
        height: 24px !important;
    }

    #tableBody td[data-label="Acción"] > div > div:last-child > div {
        width: 22px !important;
        height: 22px !important;
    }

    #results-section > .bg-white {
        background: transparent;
    }

    #productDetailsPanel {
        display: none !important;
    }

    #productModal .space-y-5 {
        display: none !important;
    }

    #productModal {
        padding: 0 !important;
    }

    #productModal > div.relative {
        width: 100%;
        height: 100%;
        max-height: 100dvh;
        border-radius: 0;
        overflow-y: auto;
    }

    #productModal > div.relative > div:nth-of-type(1) {
        min-height: 220px !important;
        flex: 0 0 220px;
    }

    #productModal > div.relative > div:nth-of-type(2) {
        padding: 18px !important;
        overflow: visible !important;
    }

    /* Cart */
    main.flex-grow.py-8 > .container-custom {
        padding-left: 12px;
        padding-right: 12px;
    }

    main.flex-grow.py-8 .sticky.top-24 {
        position: static;
        top: auto;
    }

    #btn-system {
        width: 100%;
        min-width: 0 !important;
        min-height: 48px;
    }

    /* Login */
    #login-navbar-logo {
        max-width: 34vw;
        height: 30px !important;
    }

    #login-navbar-links {
        gap: 8px !important;
    }

    #login-navbar-links a {
        min-height: 44px;
        font-size: 13px !important;
        gap: 4px !important;
        white-space: nowrap;
    }

    main.flex-grow.items-center {
        padding: 16px 12px !important;
    }

    main.flex-grow.items-center > div {
        max-width: 440px;
    }

    main.flex-grow.items-center form input,
    main.flex-grow.items-center form button {
        min-height: 44px;
    }

    /* Product page */
    html.product-document,
    body.product-page {
        width: 100% !important;
        min-height: 100%;
        height: auto !important;
    }

    #productContent.visible {
        width: 100% !important;
        min-height: calc(100dvh - 56px) !important;
        padding: 10px !important;
        gap: 10px !important;
    }

    #col-image {
        height: min(42vh, 320px) !important;
        min-height: 220px !important;
        padding: 12px !important;
    }

    #col-thumbs {
        height: 82px !important;
        gap: 8px;
    }

    .thumb-card {
        width: 82px !important;
        height: 82px !important;
    }

    #col-right,
    #col-info {
        min-width: 0;
    }

    #detailDescripcion {
        overflow-wrap: anywhere;
    }

    .cart-controls-row {
        flex-wrap: wrap;
    }

    .cart-controls-row > button {
        min-height: 44px;
    }
}

@media (max-width: 360px) {
    #home-benefits {
        grid-template-columns: 1fr;
    }

    #featured-categories {
        grid-template-columns: 1fr;
    }

    #toggle-offers i {
        display: none;
    }

    #login-navbar-links a {
        font-size: 12px !important;
    }
}

@media (min-width: 768px) {
    #catalog-filter-controls {
        display: flex;
    }
}
