/* ==========================================
    1. VARIABLES GLOBALES
   ========================================== */
:root {
    --bg-main: #f5f5f5;
    --header-main-bg: #191919;
    --white-text: rgb(224, 224, 224);
    --category-card-bg-hover: #19191921;
    --whatsapp-color: #25D366;
    --section-title-color: #565656;
    --select-bg: #ffffff;
    --skeleton-bg: #e0e0e0;
}

/* ==========================================
    2. CONFIGURACIÓN BASE Y RESETS
   ========================================== */
*, *::before, *::after {
    box-sizing: border-box; /* Unifica el modelo de caja globalmente */
}

body {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-main);
    margin: 0;
    font-family: "Inter", sans-serif; /* Fuente global por defecto */
}

body.dark-theme {
    /* Variables para modo oscuro */
}

/* ==========================================
    3. LAYOUT PRINCIPAL (Header, Main, Footer)
   ========================================== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 56px;
    padding: 0 16px;
    background-color: var(--header-main-bg);
    color: var(--white-text);
}

.app-header__logo-img {
    height: 40px;
    width: auto;
}

.app-header__logo a {
    text-decoration: none;
    color: var(--white-text);
}

.btn-location {
    border: none;
    padding: 6px 10px;
    border-radius: 10px;
    font-family: inherit;
    cursor: pointer;
}

.app-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1; 
    width: 100%;
}

.app-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 24px 16px;
    background-color: var(--header-main-bg);
    color: var(--white-text);
    text-align: center;
}

.app-footer__text {
    font-weight: 500;
    font-size: 1.2rem;
    margin: 0 0 16px 0;
}

.app-footer__btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 1.1rem;
    padding: 10px 24px;
    border-radius: 50px;
    background-color: var(--whatsapp-color);
    color: white;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.app-footer__btn:hover {
    background-color: #1ebe5a;
}

/* ==========================================
   4. UI GENÉRICA (Hero, Búsqueda, Títulos)
   ========================================== */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    padding-top: 16px;
}

.hero__title {
    font-size: 1.5rem;
    margin: 0;
}

.hero__subtitle {
    font-size: 0.85rem;
    margin: 0;
    color: #555;
}

.search {
    display: flex;
    justify-content: center;
    width: 100%;
    margin: 16px 0;
}

.search__wrapper {
    position: relative; /* Ancla del desplegable de búsqueda en vivo */
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 90%;
    max-width: 400px;
    background-color: white;
}

.search__input {
    flex: 1;
    padding: 8px 12px;
    background-color: transparent;
    border: none;
    font-family: inherit;
}

.search__input:focus {
    outline: none;
}

.search__btn {
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    background-color: transparent;
    cursor: pointer;
}

/* Desplegable de búsqueda en vivo */
.search__dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    max-height: 280px;
    overflow-y: auto;
}

.search__dropdown[hidden] {
    display: none;
}

.search__dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    color: #222;
}

.search__dropdown-item:hover,
.search__dropdown-item:active {
    background-color: #f0f0f0;
}

.search__dropdown-item img {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    object-fit: cover;
    border-radius: 6px;
}

.search__dropdown-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.section-title {
    color: var(--section-title-color);
    font-size: 1.2rem;
    margin: 0 0 8px 0;
    width: 90%;
    max-width: 400px;
}

/* ==========================================
   5. COMPONENTES: CARRUSEL Y CATEGORÍAS
   ========================================== */
.carousel {
    width: 100%;
    max-width: 400px;
    margin: 16px 0;
    overflow: hidden;
}

.carousel__track {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    gap: 12px;
    padding: 0 16px;
    scrollbar-width: none;
}

.carousel__track::-webkit-scrollbar {
    display: none;
}

.carousel__slide {
    flex: 0 0 90%;
    height: 220px;
    scroll-snap-align: center;
}

.carousel__slide a {
    display: block;
    width: 100%;
    height: 100%;
}

.carousel__slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    display: block;
}

.categories {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.categories__grid {
    display: flex;
    align-items: center;
    overflow-x: auto;
    width: 100%;
    max-width: 400px;
    padding: 4px 16px;
    gap: 8px;
    scrollbar-width: none;
}

.categories__grid::-webkit-scrollbar {
    display: none;
}

.categories__grid a {
    text-decoration: none;
    color: inherit;
}

.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    padding: 8px;
    border-radius: 8px;
    background-color: white;
    border: var(--category-card-bg-hover) 1px solid;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.category-card:hover,
.category-card:active {
    background-color: var(--category-card-bg-hover);
}

.category-card img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    margin-bottom: 4px;
}

.category-card h3 {
    font-size: 0.75rem;
    margin: 0;
    text-align: center;
}

/* ==========================================
    6. VISTA: LISTA DE NEGOCIOS (MÓVIL)
   ========================================== */
.category-toolbar {
    display: flex;
    justify-content: center;
    width: 100%;
    padding: 4px 16px;
    margin: 16px 0;
}

.category-toolbar__select-wrapper {
    display: flex;
    align-items: center;
    width: 80%;
    max-width: 320px;
    padding: 4px 16px;
    background-color: var(--select-bg);
    border-radius: 10px;
    gap: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.category-toolbar__select-wrapper img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

#category-select {
    flex: 1;
    padding: 8px;
    border-radius: 4px;
    background-color: transparent;
    border: none;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
}

.business-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.business-list__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
    max-width: 400px;
    gap: 16px;
    padding: 0 16px;
}

.business-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    height: auto; /* Corrección de altura fija */
}

.business-card__img-wrapper {
    width: 100%;
    height: 120px; /* Reducido de 200px para permitir el texto */
    overflow: hidden;
}

.business-card__img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.business-card__info {
    display: flex;
    flex-direction: column;
    padding: 12px 8px;
    flex: 1;
}

.business-card__title {
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.2;
}

.business-card__status {
    font-size: 0.8rem;
    margin: 4px 0;
    font-weight: 600;
}

.status-open { color: #2e7d32; }
.status-closed { color: #d32f2f; }

.business-card__desc {
    font-size: 0.8rem;
    margin: 0;
    color: #555;
    line-height: 1.3;
}

/* ==========================================
    7. VISTA: PERFIL DEL NEGOCIO
   ========================================== */
.business-header {
    width: 100%;
    max-width: 400px;
    display: flex;
    padding: 20px 16px 4px;
}

.business-header button {
    border: none;
    background-color: transparent;
    font-size: 1.5rem;
    cursor: pointer;
    color: #333;
}

.business-image {
    width: 100%;
    max-width: 400px;
    height: 250px;
    padding: 16px;
}

.business-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.business-info {
    width: 100%;
    max-width: 400px;
    padding: 0 16px;
}

.business-info__title {
    font-size: 1.5rem;
    margin: 0;
}

.business-info__status {
    display: inline-block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 4px;
}

.business-info__schedule {
    font-size: 0.95rem;
    margin: 8px 0 4px 0;
    color: #444;
}

.business-info__address {
    font-size: 0.95rem;
    margin: 0 0 8px 0;
    color: #444;
}

.business-info__desc {
    font-size: 0.95rem;
    color: #555;
    line-height: 1.4;
    margin: 0;
}

.business-image img {
    cursor: zoom-in;
}

.business-carousel .carousel__slide img {
    cursor: zoom-in;
}

/* Horarios semanales */
.business-hours-section {
    width: 100%;
    max-width: 400px;
    padding: 0 16px;
    margin: 8px 0 96px; /* Margen inferior para no chocar con el botón fijo */
}

.business-hours-section h3 {
    font-size: 1.1rem;
    margin: 0 0 8px 0;
    color: var(--section-title-color);
}

.hours-card {
    background-color: #ffffff;
    border: 1px solid #e6e6e6;
    border-radius: 12px;
    padding: 4px 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.hours-card__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 0.95rem;
}

.hours-card__row + .hours-card__row {
    border-top: 1px solid #f0f0f0;
}

.hours-card__day {
    font-weight: 600;
    color: #333;
}

.hours-card__time {
    color: #444;
    font-variant-numeric: tabular-nums;
}

.hours-card__time--closed {
    color: #c0392b;
    background-color: #fdecea;
    padding: 2px 10px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Lightbox de imágenes */
.image-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.85);
    animation: image-modal-fade 0.2s ease;
}

.image-modal[hidden] {
    display: none;
}

.image-modal img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
    animation: image-modal-zoom 0.25s ease;
}

.image-modal__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.image-modal__close:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

@keyframes image-modal-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes image-modal-zoom {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .image-modal,
    .image-modal img {
        animation: none;
    }
}

/* Botón flotante corregido */
.btn-whatsapp-fixed {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 90%;
    max-width: 360px;
    padding: 14px 24px;
    border-radius: 50px;
    border: none;
    background-color: var(--whatsapp-color);
    color: white;
    font-size: 1.05rem;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease;
    z-index: 50;
}

.btn-whatsapp-fixed:hover {
    background-color: #1ebe5a;
    transform: translateX(-50%) scale(1.02);
}

/* ==========================================
    8. SKELETON LOADER
   ========================================== */
.skeleton {
    background-color: var(--skeleton-bg);
    color: transparent;
    border-radius: 6px;
    pointer-events: none;
    -webkit-user-select: none;
    user-select: none;
    animation: skeleton-pulse 1.4s ease-in-out infinite;
}

.skeleton * {
    visibility: hidden;
}

/* Tamaños de los bloques en el perfil del negocio */
.business-info__title.skeleton {
    width: 65%;
}

.business-info__status.skeleton {
    width: 70px;
}

.business-info__schedule.skeleton {
    width: 80%;
}

.business-info__address.skeleton {
    width: 60%;
}

.business-info__desc.skeleton {
    min-height: 2.8em; /* Dos líneas de texto (line-height 1.4) */
}

.carousel__slide.skeleton {
    border-radius: 12px;
}

.btn-whatsapp-fixed.skeleton {
    background-color: var(--skeleton-bg);
    box-shadow: none;
}

@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

@media (prefers-reduced-motion: reduce) {
    .skeleton {
        animation: none;
    }
}

/* ALINEACIÓN HORIZONTAL BARRA SUPERIOR CON BOTÓN REGRESAR */
.search--with-back,
.category-toolbar--with-back {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.search--with-back .search__wrapper,
.category-toolbar--with-back .category-toolbar__select-wrapper {
    flex: 1; /* Ocupa todo el espacio horizontal restante */
    margin-bottom: 0; /* Anula márgenes inferiores previos */
}

/* ESTILO DEL BOTÓN REGRESAR */
.btn-back {
    background-color: #262626;
    border: 1px solid #333;
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0; /* Evita que el botón se reduzca si la pantalla es muy angosta */
    font-size: 1rem;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.btn-back:active {
    background-color: #333;
}