* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --text-primary: black;
    --text-secondary: white;
    --bg-black: rgb(0 0 0);
    --bg-beige: #E2D9C2;
    --shadow: rgb(0 0 0 / 75%);
    --shadow-card: rgb(0 0 0 / 40%);
    --bg-gray: #D9D9D9;
    --bg-card: #F1F1F1;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

.main-header {
    width: 100vw;
    height: auto;
    padding: 8px;
    background-color: #f3f3f3;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    position: relative; /* necesario para posicionar el menú */

    img { /* Logo de Chef Ya! */
        width: 150px;
        height: auto;
    }

    #menu-button, #user-login, #shopping-cart {
        margin: 0;
        padding: 0;
        background-color: transparent;
        border: none;
        cursor: pointer;
    }

    div {
        display: inherit;
        align-items: center;
        justify-content: center;
        text-align: center;
        gap: 0.3rem;
    }

    .search-bar {
        width: 20vw;
        height: 25px;
        border: none;
        border-radius: 1rem;
        padding: 0.5rem;
        box-shadow: 0px 5px 13px var(--shadow);
    }
}

/* ==========================
   MENÚ DE USUARIO (HEADER)
   ========================== */

.user-menu {
    position: absolute;
    top: 60px;
    right: 0.75rem;
    background-color: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0.75rem 1rem;
    min-width: 230px;
    z-index: 200;

    /* el display lo controla JS (none/flex) */
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.user-menu-label {
    margin-bottom: 0.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.user-menu-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.user-menu-actions button {
    width: 100%;
    padding: 0.45rem 0.5rem;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    background-color: var(--bg-beige);
    color: var(--bg-black);
}

.user-menu-actions button:hover {
    filter: brightness(0.95);
}

main {
    margin-top: 2rem;
    .filtros {
        display: flex;
        flex-direction: row;
        align-items: center;
        margin-bottom: 1rem;
        padding: 0;
        gap: 0.8rem;
        margin-left: 1rem;

        select {
            height: 2rem;
            border-radius: 1rem;
            border: none;
            background-color: var(--bg-beige);
            font-weight: 600;
        }

        button {
            height: 2rem;
            width: auto;
            border: none;
            border-radius: 1rem;
            padding: 0.3rem;
            background-color: var(--bg-beige);
            font-weight: 600;
        }
    }

    /* ESTO YA NO SE USA PERO LO DEJAMOS POR SI TIENES OTRO HTML */
    .separacion {
        display: flex;
        flex-direction: row;
        margin-bottom: 2rem;
    }

    .opciones {
        display: flex;
        flex-direction: column;
        width: 20vw;
        margin-left: 1rem;
        margin-right: 5rem;
        padding-top: 0.4rem;
        gap: 0.5rem;
        border-top: 1px solid lightgray;
        height: 28vh;
        margin-bottom: 40px;
        nav {
            display: inherit;
            flex-direction: inherit;
            gap: inherit;
            width: fit-content;
            height: 1.5rem;

            a {
                text-decoration: none;
                color: var(--text-primary);
                background-color: var(--bg-gray);
                text-align: center;
                border-radius: 1rem;
                padding: 0.4rem;
            }
        }
    }

    .cartas {
        display: grid;
        grid-template-columns: repeat(3,1fr);
        grid-template-rows: 0.5fr ;
        gap: 8px;
        header {
            display: flex;
            flex-direction: row;
            justify-content: space-between;
            align-items: center;
            width: 1100px;
            height: 35px;
            grid-column: span 3 / span 3;

            button {
                width: 23px;
                height: 23px;
                background-color: var(--bg-gray);
                border: none;
                border-radius: 1rem;
                cursor: pointer;

                svg {
                    width: 20px;
                    height: 20px;
                }
            }

            nav a {
                text-decoration: none;
                color: var(--text-primary);
            }
        }

        .tarjeta {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            background-color: var(--bg-card);
            box-shadow: 5px 5px 10px var(--shadow-card);
            padding: 1rem;
            font-size: 12px;
            border-radius: 1rem;

            img {
                width: 130px;
                height: auto;
                border-radius: 1rem;
            }

            grid-row-start: 2;
        }
    }
}

/* 🔹 NUEVO: layout que mantiene las categorías siempre al lado */
.layout-principal {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
}

.sidebar-opciones {
    display: flex;
    flex-direction: column;
}

.columnas-cartas {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    /* Remover ese padding extraño */
}

/* ------------------------------------------- */
/* --- ESTILOS AÑADIDOS PARA RESPONSIVE --- */
/* ------------------------------------------- */

/* 1. Ocultar elementos de móvil en desktop por defecto */
.mobile-nav {
    display: none;
}

.card-mobile-info {
    display: none;
}


@media (max-width: 768px) {

    body {
        background-color: #f9f9f9; 
    }

    .main-header {
        display: flex !important; /* Lo hacemos visible */
        padding: 8px 12px;
        gap: 0.5rem;
        position: relative; /* Para que el menú de usuario se posicione bien */
        background-color: #f3f3f3;
    }

    .main-header .logo {
        width: 120px;
    }

    .main-header > div p {
        display: none;
    }

    .main-header form {
        display: none;
    }

    .mobile-nav {
        display: none !important;
    }

    .mobile-track {
        display: flex;
        flex-direction: row; /* Las tarjetas van de lado */
        gap: 1rem;
        overflow-x: auto; /* Scroll horizontal AQUÍ */
        scroll-snap-type: x mandatory;
        padding: 0.5rem 1rem 1.5rem 1rem; /* Padding para que se vea la sombra y margen izq */
        scrollbar-width: none; /* Ocultar scrollbar Firefox */
        width: 100%;
    }

    .mobile-track::-webkit-scrollbar {
        display: none; /* Ocultar scrollbar Chrome/Safari */
    }

    main {
        height: auto !important;
        min-height: auto !important;
        display: block !important;
        padding-top: 1rem !important;
        /* Quitamos el margen top 0 que suelen tener los reset si molesta */
        margin-top: 0; 
    }

    .filtros,
    .opciones {
        display: none !important;
    }
    .columnas-cartas {
        display: block !important;
        padding-right: 0 !important;
    }
    .separacion {
        flex-direction: column;
        margin-left: 0;
        margin-right: 0;
        gap: 1.5rem;
    }

    .cartas {
        display: flex !important;
        flex-direction: column !important; /* <--- ESTA ES LA CLAVE */
        width: 100% !important;
        margin-bottom: 2rem;
        gap: 0.5rem !important; /* Espacio entre el título y las tarjetas */
        padding-bottom: 0;
        overflow: hidden; /* Para que no salga barra de scroll en el padre */
    }
    
    .cartas header {
        display: block !important;
        width: 100%;
        padding-left: 1rem; /* Un poco de margen izquierdo para que no pegue al borde */
    }

    .cartas header div {
        display: none !important;
    }

    .cartas header h1 {
        font-size: 1.5rem;
        font-weight: 700;
        color: #333;
    }

    .cartas::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }

    .tarjeta {
        flex: 0 0 85vw;
        max-width: 300px;
        margin: 0 !important;
        scroll-snap-align: center;
        /* Estilos visuales */
        background-color: white;
        border-radius: 1rem;
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        display: flex;
        flex-direction: column;
    }

    .tarjeta:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    }

    .cartas .tarjeta:nth-of-type(n+2) {
        display: flex; /* Ahora mostramos todas */
    }

    .tarjeta img {
        width: 100%;
        height: 180px;
        object-fit: cover;
        border-radius: 1rem 1rem 0 0;
        margin-bottom: 0.75rem;
    }

    .tarjeta h2 {
        font-size: 1.25rem;
        font-weight: 600;
        padding: 0 1rem;
        margin-bottom: 0.5rem;
    }

    .card-mobile-info {
        display: block;
        padding: 0 1rem 1rem;
    }

    .card-info-top {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-bottom: 0.75rem;
        color: #333;
        align-items: center;
    }

    .card-info-top span {
        background-color: var(--bg-gray, #D9D9D9);
        padding: 0.25rem 0.6rem;
        border-radius: 0.5rem;
        font-size: 0.9rem;
        font-weight: 500;
    }

    .card-rating {
        background-color: transparent;
        padding-left: 0;
    }

    .card-cost {
        font-size: 0.9rem;
        font-weight: 500;
        color: #333;
        background-color: var(--bg-gray, #D9D9D9);
        padding: 0.25rem 0.6rem;
        border-radius: 0.5rem;
        display: inline-block;
    }

    .layout-principal {
        display: block !important;
    }
}

.cartas {
    position: relative;
}

.cartas .carousel-track {
    display: flex;
    gap: 1rem;
    overflow: hidden;
    padding-top: 1rem;
}

.cartas .tarjeta {
    flex: 0 0 calc((100% - 2rem) / 3);
    box-sizing: border-box;
}

/*Ocultamos la barra del scroll horizontal de las categorias*/
/* Firefox */
#nav-categorias {
    scrollbar-width: none;
}
/* Chrome, Edge, Safari */
#nav-categorias::-webkit-scrollbar {
    display: none;
}

.card-order-button-desktop{
    padding: 0.5rem 0.75rem;
    border-radius: 10%;
    border: none;
    background-color: var(--bg-beige);
    color: var(--bg-black);
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 600;
}

.active-categoria {
    font-weight: 700;
    text-decoration: underline;
}

.logo{
    cursor: pointer;
}
