/* ==========================================================================
   Página principal (resources/views/home-page.blade.php)
   --------------------------------------------------------------------------
   Los colores salen de las variables --sos-* definidas en
   resources/views/layouts/catalog.blade.php. Las clases llevan el prefijo
   "home-" para no chocar con el tema Nest (main.css) y no necesitar !important.

   Breakpoints:
     >= 1200px  escritorio amplio
     <  1200px  laptop
     <   992px  tablet
     <   768px  móvil
     <   576px  móvil pequeño

   Al editar este archivo, sube el ?v= del <link> en home-page.blade.php.
   ========================================================================== */

/* ---------- Estructura general ---------- */

.home-page {
    padding-bottom: 8px;
}

.home-page > section + section {
    margin-top: 28px;
}

/* El footer del layout abre con la franja de beneficios: en la home va
   pegada al contenido, sin el padding superior del tema. */
.featured.section-padding {
    padding-top: 0;
}

/* Animaciones que usan los bloques "wow" del footer (el tema no carga animate.css) */
.animate__fadeIn {
    animation: homeFadeIn 0.6s;
}

.animate__fadeInUp {
    animation: homeFadeInUp 0.6s forwards;
}

@keyframes homeFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes homeFadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes homeSlideUp {
    from { opacity: 0; transform: translateY(50px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Texto accesible para lectores de pantalla/SEO, oculto visualmente */
.home-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Cabecera de sección (título + flechas) ---------- */

.home-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.home-section-head__title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--sos-navy);
}

.home-section-head__title--small {
    font-size: 2.2rem;
}

.home-section-head__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-size: 0.95rem;
    color: #fff;
    background: var(--sos-green);
}

.home-products--top .home-section-head__icon {
    background: var(--sos-pink);
}

.home-products--247 .home-section-head__icon {
    background: var(--sos-sky);
}

.home-section-head__subtitle {
    margin: 4px 0 0;
    font-size: 0.9rem;
    line-height: 1.3;
    color: var(--sos-gray);
}

.home-section-head__actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.home-section-head__link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    color: var(--sos-green);
}

.home-section-head__link:hover {
    color: var(--sos-green-dark);
}

.home-section-head__link i {
    font-size: 0.75rem;
}

.home-arrows {
    display: flex;
    gap: 8px;
}

/* El carrusel no desborda: no hay nada que desplazar */
.home-arrows.is-static {
    display: none;
}

.home-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 50%;
    font-size: 1.1rem;
    color: var(--sos-gray);
    background: #F2F3F4;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, opacity 0.2s;
}

.home-arrow:hover:not(:disabled) {
    color: #fff;
    background: var(--sos-green);
}

.home-arrow:disabled {
    opacity: 0.4;
    cursor: default;
}

/* ---------- Pista horizontal compartida por los carruseles ---------- */

.home-track {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.home-track::-webkit-scrollbar {
    display: none;
}

.home-track > * {
    scroll-snap-align: start;
}

/* ---------- Categorías ---------- */

.home-cat {
    display: flex;
    flex: 0 0 110px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 110px;
    padding: 10px;
    border: 2px solid var(--sos-green);
    border-radius: 12px;
    color: inherit;
    background: #fff;
    transition: transform 0.2s, box-shadow 0.2s;
}

.home-cat:hover {
    color: inherit;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 61, 78, 0.12);
}

.home-cat--top {
    border-color: var(--sos-pink);
}

.home-cat--247 {
    border-color: var(--sos-sky);
}

.home-cat__figure {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 65px;
    margin: 0;
}

.home-cat__figure img {
    max-width: 65px;
    max-height: 55px;
    object-fit: contain;
}

.home-cat__figure i {
    font-size: 2.2rem;
}

.home-cat--top .home-cat__figure i {
    color: var(--sos-pink);
}

.home-cat--247 .home-cat__figure i {
    color: var(--sos-sky);
}

.home-cat__name {
    margin: 6px 0 0;
    font-size: 0.95rem;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
}

/* ---------- Hero con buscador ---------- */

.home-hero {
    position: relative;
    display: flex;
    align-items: center;
    height: 538px;
    padding: 0 6%;
    border-radius: 30px;
    background-color: var(--sos-green-soft);
    background-position: center;
    background-size: cover;
}

.home-hero__content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 430px;
}

.home-hero__title {
    min-height: 2.4em; /* reserva las dos líneas mientras se escribe el título */
    margin: 0 0 40px;
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--sos-navy);
}

.home-hero__lead {
    margin: 0 0 13px;
    font-size: 18px;
    font-weight: 500;
    color: var(--sos-gray);
}

.home-hero__form {
    display: flex;
    align-items: center;
    width: 100%;
    margin: 0;
    border-radius: 50px;
    background: #fff;
}

/* Doble selector: el tema estiliza los input[type="text"] con más peso */
.home-hero__form .home-hero__input {
    flex: 1;
    width: 100%;
    height: 64px;
    padding: 0 22px;
    border: 0;
    border-radius: 50px;
    outline: none;
    font-size: 18px;
    color: #333;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
}

.home-hero__form .home-hero__input::placeholder {
    font-size: 18px;
    color: #333;
    opacity: 1;
}

.home-hero__form:focus-within {
    box-shadow: 0 0 0 3px rgba(59, 183, 126, 0.35);
}

/* ---------- Modal de resultados de búsqueda ---------- */

.home-search {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    animation: homeFadeIn 0.3s ease-in-out;
}

.home-search.show {
    display: flex;
}

.home-search__dialog {
    position: relative;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    padding: 30px;
    overflow-y: auto;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: homeSlideUp 0.3s ease-in-out;
}

.home-search__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.home-search__title {
    margin: 0;
    font-size: 1.3rem;
    color: #333;
}

.home-search__query {
    font-weight: 600;
    color: var(--sos-green);
}

.home-search__close {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #999;
    background: none;
    cursor: pointer;
}

.home-search__close:hover {
    color: #333;
}

.home-search__results {
    max-height: 60vh;
    overflow-y: auto;
}

.home-search__group + .home-search__group {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.home-search__group-title {
    margin-bottom: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #999;
}

.home-search__item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
    padding: 12px 15px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.home-search__item:hover {
    background: #f5f5f5;
}

.home-search__item-icon {
    flex-shrink: 0;
    font-size: 16px;
    color: var(--sos-green);
}

.home-search__item-icon--muted {
    color: #999;
}

.home-search__item-image {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 6px;
    object-fit: cover;
}

.home-search__item-info {
    flex: 1;
    min-width: 0;
}

.home-search__item-name {
    margin-bottom: 4px;
    overflow: hidden;
    font-weight: 500;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: #333;
}

.home-search__item-price {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--sos-green);
}

.home-search__item-price-old {
    margin-right: 8px;
    font-size: 0.9em;
    font-weight: 400;
    text-decoration: line-through;
    color: #999;
}

.home-search__empty {
    padding: 30px;
    text-align: center;
    color: #999;
}

/* ---------- Carruseles de productos (Top y 24/7) ---------- */

.home-track--products {
    --home-cards: 5;      /* tarjetas visibles a la vez */
    --home-gap: 16px;
    gap: var(--home-gap);
    padding: 4px 2px 12px; /* aire para que no se corte la sombra al pasar el mouse */
}

.home-card {
    display: flex;
    flex: 0 0 calc((100% - (var(--home-cards) - 1) * var(--home-gap)) / var(--home-cards));
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    border: 1px solid #ececec;
    border-radius: 14px;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.home-card:hover {
    border-color: #BCE3C9;
    box-shadow: 0 6px 18px rgba(37, 61, 78, 0.1);
}

.home-card__media {
    position: relative;
    display: block;
    padding: 12px 12px 0;
}

.home-card__media img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    border-radius: 10px;
    object-fit: cover;
    background: #f4f6f8;
}

.home-card__badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 10px;
    border-radius: 10px 0 10px 0;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: #fff;
    background: var(--sos-pink);
}

.home-card__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 10px 12px 12px;
}

.home-card__category {
    margin-bottom: 4px;
    overflow: hidden;
    font-size: 0.8rem;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--sos-gray);
}

.home-card__name {
    display: -webkit-box;
    min-height: 2.6em; /* dos líneas siempre: las tarjetas quedan alineadas */
    margin: 0 0 8px;
    overflow: hidden;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.3;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.home-card__name a {
    color: var(--sos-navy);
}

.home-card__name a:hover {
    color: var(--sos-green);
}

.home-card__price {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 8px;
    margin-top: auto;
    margin-bottom: 10px;
}

.home-card__price-now {
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap;
    color: var(--sos-green);
}

.home-card__price-old {
    font-size: 0.85rem;
    white-space: nowrap;
    text-decoration: line-through;
    color: #adadad;
}

.home-card__form {
    margin: 0;
}

.home-card__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 9px 12px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    color: #fff;
    background-color: var(--sos-green);
    cursor: pointer;
    transition: filter 0.2s;
}

.home-card__btn:hover:not(:disabled) {
    filter: brightness(0.92);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Laptop */
@media (max-width: 1199.98px) {
    .home-hero {
        height: 480px;
    }

    .home-track--products {
        --home-cards: 4;
    }
}

/* Tablet */
@media (max-width: 991.98px) {
    .home-hero {
        height: 400px;
        border-radius: 24px;
    }

    .home-hero__title {
        margin-bottom: 28px;
        font-size: 2.1rem;
    }

    .home-track--products {
        --home-cards: 3.2; /* la tarjeta cortada indica que se puede deslizar */
    }
}

/* Móvil */
@media (max-width: 767.98px) {
    .home-page > section + section {
        margin-top: 20px;
    }

    /* En pantallas táctiles se desliza con el dedo: las flechas sobran */
    .home-arrows {
        display: none;
    }

    .home-section-head__title {
        font-size: 1.15rem;
    }

    .home-section-head__title--small {
        font-size: 2.1rem;
    }

    .home-section-head__icon {
        width: 30px;
        height: 30px;
        font-size: 0.85rem;
    }

    .home-section-head__subtitle {
        font-size: 0.8rem;
    }

    .home-track {
        gap: 10px;
    }

    .home-hero {
        height: 280px;
        padding: 0 18px;
        border-radius: 20px;
    }

    .home-hero__content {
        max-width: 300px;
    }

    .home-hero__title {
        margin-bottom: 14px;
        font-size: 1.6rem;
    }

    .home-hero__lead {
        margin-bottom: 10px;
        font-size: 14px;
    }

    .home-hero__form .home-hero__input {
        height: 46px;
        padding: 0 18px;
        font-size: 16px; /* 16px evita el zoom automático de iOS al enfocar */
    }

    .home-hero__form .home-hero__input::placeholder {
        font-size: 14px;
    }

    .home-track--products {
        --home-cards: 2.3;
        --home-gap: 10px;
    }

    .home-search {
        align-items: flex-start;
        padding-top: 20px;
        overflow-y: auto;
        background: rgba(0, 0, 0, 0.7);
    }

    .home-search__dialog {
        width: 95%;
        max-height: 90vh;
        padding: 20px;
    }

    .home-search__title {
        font-size: 1.1rem;
    }

    .home-search__results {
        max-height: calc(90vh - 80px);
    }

    .home-search__item {
        padding: 10px;
    }

    .home-search__item-image {
        width: 64px;
        height: 64px;
    }
}

/* Móvil pequeño */
@media (max-width: 575.98px) {
    .home-cat {
        flex-basis: 96px;
        height: 100px;
        padding: 8px;
    }

    .home-cat__figure {
        height: 56px;
    }

    .home-cat__figure i {
        font-size: 1.9rem;
    }

    .home-cat__name {
        font-size: 0.85rem;
    }

    .home-hero {
        height: 250px;
        padding: 0 16px;
        background-position: 25% center; /* aleja el paracaídas del texto */
    }

    .home-hero__content {
        max-width: 250px;
    }

    .home-hero__title {
        font-size: 1.35rem;
    }

    .home-track--products {
        --home-cards: 2.15;
    }

    .home-card {
        border-radius: 12px;
    }

    .home-card__media {
        padding: 8px 8px 0;
    }

    .home-card__badge {
        top: 8px;
        left: 8px;
        padding: 3px 8px;
        font-size: 0.7rem;
    }

    .home-card__body {
        padding: 8px 8px 10px;
    }

    .home-card__category {
        font-size: 0.72rem;
    }

    .home-card__name {
        font-size: 0.85rem;
    }

    .home-card__price-now {
        font-size: 1rem;
    }

    .home-card__price-old {
        font-size: 0.78rem;
    }

    .home-card__btn {
        padding: 8px;
        font-size: 0.82rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .home-track {
        scroll-behavior: auto;
    }

    .home-search,
    .home-search__dialog,
    .animate__fadeIn,
    .animate__fadeInUp {
        animation: none;
    }
}
