/* Reglas base para elementos comunes (fuera de @media) */
.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%); /* Centra verticalmente respecto al modal */
    width: 36px;
    height: 36px;
    font-size: 20px;
    border-radius: 4px;
    background-color: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    cursor: pointer;
    z-index: 10;
    transition: width 0.3s ease, height 0.3s ease, font-size 0.3s ease;
    /* Centrar el contenido (símbolos < y >) dentro del botón */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0; /* Eliminar cualquier padding que pueda desplazar el contenido */
    line-height: 1; /* Asegurar que el line-height no afecte el centrado */
    text-align: center; /* Para casos donde el contenido sea texto directo */
}

/* Asegurar que los hijos (como <i> o texto directo) no tengan estilos que interfieran */
.modal-nav * {
    margin: 0;
    padding: 0;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: inherit; /* Heredar el font-size del botón */
}

.product-card {
    min-height: unset !important;
    height: clamp(300px, 48vw, 420px) !important;
    max-height: clamp(300px, 48vw, 420px);
    overflow: hidden;
    position: relative;
    background-color: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 4px 8px var(--card-shadow);
    border: 3px solid transparent;
    perspective: 1000px;
    transform-style: preserve-3d;
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

@keyframes multi-color-border {
    0% { border-color: #ff00ff; } /* Rosa */
    16.67% { border-color: #00f0ff; } /* Azul */
    33.33% { border-color: #00ff00; } /* Verde */
    50% { border-color: #ffff00; } /* Amarillo */
    66.67% { border-color: #8000ff; } /* Morado */
    83.33% { border-color: #ff0000; } /* Rojo */
    100% { border-color: #ff00ff; } /* Rosa */
}

.product-card:hover,
.product-card[data-view="back"]:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 3px solid;
    animation: multi-color-border 9s linear infinite;
}

[data-theme="dark"] .product-card:hover,
[data-theme="dark"] .product-card[data-view="back"]:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Ajustes para pantallas de hasta 768px (móviles y tablets pequeñas) */
@media (max-width: 768px) {
    .top-bar {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 5px;
        padding: 5px 10px;
        background-color: var(--header-bg);
        position: relative;
        flex-wrap: nowrap;
        transition: background-color 0.3s ease;
    }

    .top-bar > * {
        flex-shrink: 1;
    }

    .menu-toggle {
        background: none;
        border: none;
        padding: 5px;
        cursor: pointer;
        display: block;
        order: -2;
    }

    .menu-icon {
        font-size: clamp(16px, 2.5vw, 18px);
        color: var(--text-color);
        transition: color 0.3s ease;
    }

    .nombre-local {
        font-size: clamp(12px, 2vw, 14px);
        white-space: nowrap;
        text-align: center;
        color: var(--text-color);
        transition: color 0.3s ease;
        order: -1;
        flex: 0 1 auto;
    }

    .nombre-local .store-name {
        color: var(--text-color);
        text-decoration: none;
        transition: color 0.3s ease;
    }

    .barra-busqueda {
        display: block;
        width: 70%;
        margin: 0 5px;
        order: 0;
        flex: 1 1 auto;
    }

    .search-bar {
        width: 100%;
        padding: 6px;
        font-size: clamp(10px, 2vw, 12px);
        background: var(--search-bar-bg);
        border: none;
        color: var(--text-color);
        outline: none;
        border-radius: 5px;
        transition: background-color 0.3s ease, color 0.3s ease;
    }

    .search-bar::placeholder {
        color: var(--inventory-color);
    }

    .iconos-contacto {
        display: flex;
        align-items: center;
        gap: 10px;
        order: 1;
        flex: 0 1 auto;
    }

    .icono-ws {
        display: flex;
        align-items: center;
        font-size: 0;
        color: var(--text-color);
        transition: color 0.3s ease;
    }

    .icono-ws i {
        font-size: clamp(16px, 2.5vw, 18px);
        color: var(--icon-color);
        transition: color 0.3s ease;
    }

    .icono-ubicacion {
        display: none;
    }

    .theme-toggle {
        order: 2;
        background: none;
        border: none;
        padding: 5px;
        cursor: pointer;
    }

    .theme-icon {
        font-size: clamp(16px, 2.5vw, 18px);
        color: var(--text-color);
        transition: color 0.3s ease;
    }

    .nav-container {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 32%;
        background-color: var(--nav-bg);
        box-shadow: 0 4px 8px var(--card-shadow);
        z-index: 20;
        transition: background-color 0.3s ease;
        overflow: hidden;
    }

    .nav-container.active {
        display: block;
    }

    .nav-bar {
        padding: clamp(10px, 2vw, 15px);
        width: 100%;
        box-sizing: border-box;
        background: none;
    }

    .nav-bar ul {
        flex-direction: column;
        gap: 10px;
        padding: 0;
        align-items: flex-start;
        width: 100%;
        background: none;
        list-style: none;
        margin: 0;
    }

    .nav-bar a {
        padding: clamp(8px, 2vw, 10px) clamp(10px, 2vw, 15px);
        font-size: clamp(12px, 2vw, 14px);
        text-align: left;
        color: var(--text-color);
        background-color: rgba(255, 255, 255, 0.05);
        border-radius: 5px;
        transition: background-color 0.3s ease, color 0.3s ease, transform 0.2s ease;
        width: 100%;
        box-sizing: border-box;
        text-decoration: none;
    }

    .nav-bar a:hover,
    .nav-bar a:focus {
        background-color: var(--nav-hover-bg);
        color: var(--nav-hover-text);
        transform: translateX(5px);
    }

    .gallery-section {
        padding: clamp(15px, 3vw, 20px) clamp(8px, 2vw, 10px);
    }

    .gallery-section h2 {
        font-size: clamp(20px, 4vw, 24px);
        margin-bottom: clamp(15px, 3vw, 20px);
        padding-bottom: 8px;
    }

    .gallery-subsection {
        margin-bottom: clamp(15px, 3vw, 20px);
    }

    .gallery-subsection h3 {
        font-size: clamp(16px, 3vw, 18px);
        margin: clamp(10px, 2vw, 15px) 0 clamp(8px, 2vw, 10px);
        padding-left: 8px;
    }

    .subsection-icon {
        font-size: clamp(14px, 2.5vw, 16px);
    }

    .product-gallery {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: clamp(8px, 2vw, 10px);
    }

    .card-front {
        padding: clamp(6px, 2vw, 8px);
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        height: 100%;
        width: 100%;
        box-sizing: border-box;
        overflow: hidden;
        position: absolute;
        top: 0;
        left: 0;
        background-color: var(--card-bg);
        transform: rotateY(0deg);
        opacity: 1;
        z-index: 2;
    }

    .card-back {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        padding: clamp(6px, 2vw, 8px);
        box-sizing: border-box;
        text-align: center;
        background-color: var(--card-back-bg);
        transform: rotateY(-180deg);
        opacity: 0;
        overflow-y: auto;
        z-index: 1;
        pointer-events: none;
    }

    .product-card.flipped .card-front {
        transform: rotateY(180deg);
        opacity: 0;
    }

    .product-card.flipped .card-back {
        transform: rotateY(0deg);
        opacity: 1;
        z-index: 10;
        pointer-events: auto;
    }

    .product-image {
        width: auto;
        height: auto;
        max-height: 40%;
        object-fit: contain;
        margin-bottom: clamp(4px, 1.5vw, 5px);
    }

    .product-name {
        font-size: clamp(14px, 2.5vw, 18px);
        font-weight: 700;
        margin: clamp(2px, 1vw, 3px) 0;
        line-height: 1.4;
        color: var(--text-color);
        overflow: hidden;
        text-overflow: ellipsis;
        max-height: calc(clamp(14px, 2.5vw, 18px) * 1.4 * 2);
        white-space: normal;
    }

    .product-price {
        font-size: clamp(14px, 2.5vw, 18px);
        font-weight: bold;
        color: var(--price-color);
        margin: clamp(2px, 1vw, 3px) 0;
        line-height: 1.4;
    }

    .product-inventory {
        display: none;
    }

    .out-of-stock {
        font-size: clamp(12px, 2vw, 14px);
        padding: clamp(4px, 1vw, 5px) clamp(6px, 1.5vw, 7px);
        top: clamp(4px, 1vw, 5px);
        right: clamp(4px, 1vw, 5px);
        position: absolute;
        background-color: #ff3333;
        color: #ffffff;
        border-radius: 5px;
        font-weight: bold;
        z-index: 3;
        pointer-events: none;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        text-transform: uppercase;
    }

    .tech-specs-link,
    .back-link {
        font-size: clamp(12px, 2vw, 14px);
        color: var(--price-color);
        text-decoration: none;
        padding: clamp(6px, 1.5vw, 8px) clamp(12px, 2vw, 15px);
        border: 1px solid var(--price-color);
        border-radius: 5px;
        width: fit-content;
        transition: color 0.3s ease, background-color 0.3s ease;
        z-index: 20;
        cursor: pointer;
        pointer-events: auto;
        line-height: 1.4;
    }

    .tech-specs-link {
        margin-top: auto;
        align-self: center;
    }

    .back-link {
        position: absolute;
        bottom: clamp(6px, 1.5vw, 8px);
        left: 50%;
        transform: translateX(-50%);
    }

    .tech-specs {
        text-align: left;
        padding: clamp(10px, 2vw, 15px) clamp(8px, 1.5vw, 10px);
        flex-grow: 1;
        overflow-y: auto;
        margin-bottom: clamp(50px, 8vw, 60px);
        border-radius: 5px;
        background-color: rgba(0, 0, 0, 0.05);
        transition: background-color 0.3s ease;
    }

    [data-theme="dark"] .tech-specs {
        background-color: rgba(255, 255, 255, 0.05);
    }

    .tech-specs h4 {
        font-size: clamp(14px, 2.5vw, 18px);
        max-height: calc(clamp(14px, 2.5vw, 18px) * 1.4 * 2);
        line-height: 1;
        color: var(--text-color);
        margin-bottom: clamp(10px, 2vw, 15px);
        padding-bottom: 5px;
        transition: color 0.3s ease, border-color 0.3s ease;
    }

    .tech-specs ul {
        font-size: clamp(12px, 2vw, 14px);
        line-height: 1.6;
        list-style: none;
        padding-left: 0;
        margin: 0;
        color: var(--inventory-color);
        transition: color 0.3s ease;
    }

    .tech-specs li {
        margin-bottom: clamp(8px, 1.5vw, 10px);
        padding-left: clamp(20px, 3vw, 25px);
        position: relative;
        line-height: 1.6;
        padding: clamp(4px, 1vw, 5px) clamp(8px, 1.5vw, 10px);
    }

    .tech-specs li::before {
        content: "\2022";
        position: absolute;
        left: clamp(4px, 1vw, 5px);
        color: var(--border-color);
        font-size: clamp(14px, 2.5vw, 18px);
        line-height: 1;
        transition: color 0.3s ease;
    }


    /* Ajustes del modal para pantallas de hasta 768px */
    .modal-content {
        max-width: 95%;
        padding: 10px;
        max-height: 85vh;
        border-radius: 8px;
    }

    .modal-image {
        max-height: 60vh;
    }

    .modal-nav.prev {
        left: 8px;
    }

    .modal-nav.next {
        right: 8px;
    }

    .modal-close {
        top: -35px;
        right: 5px;
        width: 28px;
        height: 28px;
        font-size: 16px;
        border-radius: 4px;
    }

    .modal-caption {
        font-size: 14px;
        margin-top: 8px;
    }
}

/* Ajustes para pantallas más pequeñas (como Samsung A15) */
@media (max-width: 576px) {
    .product-gallery {
        gap: clamp(6px, 1.5vw, 8px);
    }

    .product-card {
        height: clamp(264px, 42vw, 336px) !important;
        max-height: clamp(264px, 42vw, 336px);
    }

    .product-image {
        max-height: 55%;
    }

    .tech-specs {
        padding: clamp(8px, 1.5vw, 10px) clamp(6px, 1vw, 8px);
        margin-bottom: clamp(40px, 7vw, 50px);
    }

    /* Ajustes del modal para pantallas de hasta 576px */
    .modal-content {
        max-width: 98%;
        padding: 8px;
        max-height: 80vh;
        border-radius: 6px;
    }

    .modal-image {
        max-height: 55vh;
    }

    .modal-nav {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    .modal-nav.prev {
        left: 5px;
    }

    .modal-nav.next {
        right: 5px;
    }

    .modal-close {
        top: -30px;
        right: 3px;
        width: 26px;
        height: 26px;
        font-size: 14px;
        border-radius: 4px;
    }

    .modal-caption {
        font-size: 12px;
        margin-top: 6px;
    }
}

/* Ajustes para tablets de hasta 7 pulgadas */
@media (min-width: 600px) and (max-width: 800px) {
    .product-gallery {
        gap: clamp(10px, 2vw, 12px);
    }

    .product-card {
        height: clamp(360px, 54vw, 456px) !important;
        max-height: clamp(360px, 54vw, 456px);
    }

    .product-image {
        max-height: 70%;
    }

    .tech-specs {
        padding: clamp(12px, 2vw, 15px) clamp(10px, 1.5vw, 12px);
        margin-bottom: clamp(60px, 8vw, 70px);
    }

    /* Ajustes del modal para tablets pequeñas */
    .modal-content {
        max-width: 92%;
        padding: 15px;
        max-height: 88vh;
        border-radius: 8px;
    }

    .modal-image {
        max-height: 65vh;
    }

    .modal-nav {
        width: 38px;
        height: 38px;
        font-size: 22px;
    }

    .modal-nav.prev {
        left: 10px;
    }

    .modal-nav.next {
        right: 10px;
    }

    .modal-close {
        top: -38px;
        right: 5px;
        width: 30px;
        height: 30px;
        font-size: 18px;
        border-radius: 4px;
    }

    .modal-caption {
        font-size: 15px;
        margin-top: 10px;
    }
}