body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f6f8;
    color: #333;
    text-align: center;
}

.product-link a:hover {
    text-decoration: underline;
}

h1 {
    margin-top: 120px;
    color: #2c3e50;
    font-size: 28px;
    text-align: center;
}

/* --- CONTENEDOR FIJO DEL BUSCADOR --- */
.search-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    justify-content: center;
    padding: 15px 0;
    box-sizing: border-box; /* evita desbordes */
}

/* --- CONTENEDOR INTERNO CENTRADO --- */
.search-inner {
    width: 90%;
    max-width: 1000px;
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}

input[type="text"] {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #ccc;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

input[type="text"]:focus {
    border-color: #007bff;
    outline: none;
}

.resultados {
    margin-top: 40px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 30px;
    row-gap: 70px; /* Mayor separación vertical entre tarjetas */
    grid-auto-rows: minmax(0, auto);
    padding: 24px;
    align-items: stretch; /* Mantener altura uniforme en cada fila */
}

@media (min-width: 1200px) {
    .resultados {
        grid-template-columns: repeat(4, minmax(240px, 1fr));
    }
}

.card {
    background: #ffffff;
    border-radius: 14px;
    box-shadow:
        0 12px 20px rgba(0, 0, 0, 0.10),
        0 0 0 1px rgba(0, 0, 0, 0.04),
        7px 7px 18px rgba(0, 0, 0, 0.08); /* efecto profundidad lateral */
    border: solid 1px rgba(0, 0, 0, 0.06);
    padding: 20px;
    text-align: left;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    height: 100%; /* Igualar altura de las tarjetas en la misma fila */
    position: relative;
    z-index: 1;
    /* margin-bottom no es necesario en grid, gap ya separa verticalmente */
}


.card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow:
        10px 12px 24px rgba(0, 0, 0, 0.22),
        0 0 0 1px rgba(0, 0, 0, 0.06),
        inset 0 0 0 1px rgba(255, 255, 255, 0.10);
    z-index: 2;
}

.card img {
    width: 100%;
    height: auto;
    max-height: 220px;
    object-fit: contain; /* No recorta, mantiene proporción */
    border-radius: 10px;
    margin-bottom: 12px;
}

.card h1 {
    font-size: 18px;
    margin: 0 0 8px;
    line-height: 1.2;
    min-height: 44px;
}

.card strong {
    display: block;
    margin-top: 8px;
    font-weight: 600;
}

.card p {
    margin: 4px 0 0;
    padding-right: 2px;
    font-size: 14px;
    line-height: 1.4;
    max-height: 80px;
    overflow: auto;
}

.ean-tags {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ean-tag {
    background-color: #000000;
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.image-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    padding: 22px;
}

.image-modal.open {
    display: flex;
}

.image-modal__content {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    background: #fff;
    padding: 14px;
    border-radius: 13px;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.35), 0 10px 10px rgba(0, 0, 0, 0.22);
}

.image-modal__img {
    display: block;
    max-width: 100%;
    max-height: 80vh;
    width: auto;
    height: auto;
    border-radius: 10px;
    margin-bottom: 8px;
}

.image-modal__close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
}

.image-modal__close:hover {
    background: rgba(0, 0, 0, 0.8);
}

.ean-tag {
    background-color: #000000;
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 14px;
}

button { 
    padding: 10px 20px; 
    background-color: #3498db; 
    color: white; 
    border: none; 
    border-radius: 4px; 
    cursor: pointer; 
    font-size: 16px;
    transition: background-color 0.3s;
}
button:hover {
    background-color: #2980b9;
}

.btn-inicio {
    padding: 12px 20px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    background-color: #007bff;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s ease;
    text-decoration: none;
    white-space: nowrap;
    box-sizing: border-box;
}
.btn-inicio:hover {
    background-color: #0056b3;
}


@media (max-width: 600px) {
    .search-inner {
        flex-direction: column;
        align-items: center;
        gap: 8px;
        width: 95%; /* un poco más de espacio útil */
    }

    input[type="text"] {
        width: 100%;
        font-size: 15px;
        padding: 10px 14px;
    }

    .btn-inicio {
        width: 80%; /* ocupa menos que 100% y evita desbordes */
        max-width: 300px; /* limita el tamaño visual */
        font-size: 14px;
        padding: 9px 14px;
        border-radius: 6px;
        text-align: center;
        display: block;
        margin: 0 auto; /* centra perfectamente el botón */
    }

    h1 {
        margin-top: 160px;
        font-size: 22px;
    }
}

.page-controls {
    max-width: 1200px;
    margin: 0 auto 16px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.page-size-controls,
.order-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-size-controls label,
.order-controls label {
    font-weight: 600;
    font-size: 0.95rem;
}

.page-size-controls select,
.order-controls select {
    padding: 6px 10px;
    font-size: 0.95rem;
    border: 1px solid #ccc;
    border-radius: 6px;
}

.pagination-controls,
.pagination-info {
    max-width: 1200px;
    margin: 0 auto 16px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    color: #2c3e50;
    font-size: 0.95rem;
}

.pagination-controls button,
.page-size-controls select {
    min-width: 70px;
}

.pagination-controls button.active-page {
    background-color: #2c3e50;
    font-weight: 700;
}

.pagination-ellipsis {
    font-size: 1rem;
    padding: 0 8px;
}

.pagination-info {
    font-size: 0.9rem;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 6px;
}

/* Botón Scroll to Top */
.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    z-index: 999;
}

.scroll-to-top:hover {
    background-color: #0056b3;
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.scroll-to-top:active {
    transform: translateY(-1px);
}

.scroll-to-top.show {
    display: flex;
}

@media (max-width: 768px) {
    .scroll-to-top {
        display: none !important;
    }
}
