:root {
    --fondo: #d9d1be;
    --header-nav: #9CB990;
    --acento-principal: #6B7F5A;
    --acento-secundario: #7d5b2ebf;
    --texto: #2E2B24;
    --texto-secundario: white;
    --fondo-input: #cfd3de7b;
    --tarjetas: #7e916e7f;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

img {
    max-width: 100%;
    height: auto;
}

body {
    background-color: var(--fondo);
    transition: background-color 0.5s ease, color 0.5s ease;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

main {
    flex: 1;
}

body.dark {
    --fondo: #1C1F1A;
    --header-nav: #212d1e;
    --acento-principal: #324428;
    --acento-secundario: #C4A55A;
    --texto: #E8E4DC;
    --texto-secundario: #F5F2EC;
    --fondo-input: #3a3a3a;
    --tarjetas: #2d3a28;
}

header {
    position: sticky;
    top: 0;
    z-index: 1000;
}

nav {
    background-color: var(--header-nav);
    padding: 25px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    transition: background-color 0.5s ease;
}

.logo-titulo {
    display: flex;
    align-items: center;
    gap: 1px;
}

.marca-tema {
    display: flex;
    align-items: center;
    gap: 14px;
}

#logo {
    height: 60px;
    width: auto;
}

#tituloCabecera {
    color: var(--acento-secundario);
    font-size: 45px;
    font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
    font-weight: bold;
}

.buscador {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    min-width: 0;
}

#inputBuscador {
    padding: 6px;
    width: 220px;
    border-radius: 8px;
    border: none;
    outline: none;
    background-color: var(--fondo-input);
    font-size: 14px;
    color: var(--texto);
}

#btnLimpiar {
    padding: 10px;
    border-radius: 8px;
    background-color: var(--acento-principal);
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease;
    color: var(--texto);
}

#btnLimpiar:hover {
    transform: translateY(-2px);
    background-color: var(--acento-secundario);
}

#btnOscuro {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--acento-principal);
    color: var(--texto-secundario);
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    line-height: 1;
}

#btnOscuro:hover {
    transform: translateY(-2px);
    background-color: var(--acento-secundario);
}

#historialLista {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--tarjetas);
    border-radius: 8px;
    width: 220px;
    z-index: 999;
    display: none;
}

#historialLista p {
    padding: 8px 12px;
    color: var(--texto);
    cursor: pointer;
    font-size: 13px;
}

#historialLista p:hover {
    background-color: var(--acento-principal);
    color: var(--texto-secundario);
}

#tituloCatalogo {
    padding: 30px 20px;
    color: var(--texto);
    display: flex;
    justify-content: center;
    font-weight: bold;

}

.filtros {
    max-width: 1400px;
    margin: 0 auto 10px;
    padding: 0 20px;
    display: flex;
    justify-content: flex-start;
    gap: 14px;
    flex-wrap: wrap;
    width: 100%;
}

.filtros label {
    color: var(--texto);
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
    font-weight: bold;
    min-width: 150px;
}

.filtros select {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: none;
    outline: none;
    background-color: var(--fondo-input);
    color: var(--texto);
    cursor: pointer;
}

#catalogo {
    display: grid;
    grid-template-columns: repeat(5,1fr);
    gap: 20px;
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;

}

.tarjetaPeli {
    width: 100%;
    background-color: var(--tarjetas);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.tarjetaPeli:hover {
    transform: scale(1.05);
}

.tarjetaPeli img {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    display: block;
    border-radius: 8px 8px 0 0;
}



.titulo {
    color: var(--texto);
    padding: 8px;
    font-size: 16px;
}

.anio {
    color: var(--texto);
    padding: 0 8px 8px;
}

.score {
    color: var(--texto);
    padding: 0 8px 12px;
}

.fila-botones {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    position: relative;
}

.contenedor-cargar {
    display: flex;
    justify-content: center;
}

#btnCargar {
    padding: 10px 24px;
    border-radius: 8px;
    background-color: var(--acento-principal);
    color: var(--texto-secundario);
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease;
}

#btnCargar:hover {
    transform: translateY(-2px);
    background-color: var(--acento-secundario);
}

.graficos {
    display: flex;
    gap: 16px;
    padding: 16px;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
}

#grafico1 {
    width: min(450px, 100%);
    aspect-ratio: 1 / 1;

}

#grafico1 canvas,
#grafico2 canvas {
    width: 100% !important;
    height: 100% !important;
}

footer {
    background-color: var(--header-nav);
    padding: 30px 40px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.5s ease;
    margin-top: auto;
}

.logo-footer {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

#logoFooter {
    height: 45px;
    width: auto;
}

#nombreWeb {
    color: var(--acento-secundario);
    font-size: 20px;
    font-weight: bold;
    font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
}

.footer-derecha {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

#descripcion {
    color: var(--texto);
    font-size: 13px;
}

#autor {
    color: var(--texto);
    font-size: 13px;
}

.modal {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.75);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
}

.modal-contenido {
    background-color: var(--header-nav);
    width: 80%;
    max-width: 900px;
    border-radius: 16px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}


.modal-contenido img {
    width: 250px;
    border-radius: 12px;
    align-self: center;
}

.modal-superior {
    display: flex;
    gap: 30px;
    align-items: center;
}

.modalInfo {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    color: var(--texto);
    flex: 1;
    min-width: 0;
}

.modal-trailer {
    width: 100%;
    margin-top: 12px;
    color: var(--texto);
    font-size: 14px;
}

.trailer-frame {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: none;
    border-radius: 8px;
    display: block;
    background-color: #000;
}

#cerrarModal {
    position: absolute;
    top: 15px;
    right: 15px;
    border: none;
    background-color: var(--acento-principal);
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
}

@media (max-width: 768px) {

    header {
        width: 100%;
    }

    nav {
        padding: 16px 18px;
        width: 100%;
        box-sizing: border-box;
        gap: 12px;
        flex-wrap: wrap;
    }

    html,
    body {
        overflow-x: hidden;
        width: 100%;
    }

    #logo {
        height: 45px;
    }

    #tituloCabecera {
        font-size: 30px;
    }

    .buscador {
        flex: 1 1 280px;
    }

    #inputBuscador {
        width: min(100%, 260px);
    }

    #btnOscuro {
        width: 40px;
        height: 40px;
        font-size: 22px;
    }

    #catalogo {
        grid-template-columns: repeat(3, 1fr);
        padding: 12px;
        gap: 12px;
    }

    .filtros {
        padding: 0 12px;
    }

    .filtros label {
        flex: 1 1 190px;
    }

    #grafico1 {
        width: min(360px, calc(100vw - 32px));
    }

    footer {
        padding: 20px;
    }

    #nombreWeb {
        font-size: 16px;
    }

    #logoFooter {
        height: 35px;
    }

    .modal-contenido {
        width: 90%;
        padding: 20px;
        gap: 20px;
        flex-direction: column;
        align-items: center;
    }

    .modal-superior {
        flex-direction: column;
        align-items: center;
    }

    .modal-contenido img {
        width: 200px;
    }

    .modalInfo {
        text-align: center;
        width: 100%;
    }

    .modal-trailer {
        text-align: center;
    }
}

@media (max-width: 600px) {

    nav {
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 10px;
        padding: 10px 12px;
    }

    .marca-tema {
        order: 1;
        justify-content: space-between;
        width: 100%;
    }

    .logo-titulo {
        justify-content: flex-start;
        width: auto;
    }

    #logo {
        height: 28px;
    }

    #tituloCabecera {
        font-size: 25px;
    }

    #btnOscuro {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }

    .buscador {
        order: 2;
        flex: none;
        width: 100%;
        justify-content: flex-start;
        gap: 8px;
    }

    #inputBuscador {
        flex: 1;
        width: auto;
        min-width: 0;
        padding: 8px;
    }

    #btnLimpiar {
        flex: 0 0 auto;
        padding: 9px 10px;
    }

    #tituloCatalogo {
        padding: 24px 16px 20px;
    }

    #catalogo {
        grid-template-columns: 1fr;
        max-width: 380px;
        padding: 12px;
        gap: 16px;
    }
}

@media (max-width: 480px) {

    nav {
        padding: 10px 12px;
    }

    .logo-titulo {
        justify-content: flex-start;
        width: auto;
    }

    #logo {
        height: 26px;
    }

    #tituloCabecera {
        font-size: 24px;
    }

    #inputBuscador {
        flex: 1;
        width: auto;
        min-width: 0;
    }

    #catalogo {
        grid-template-columns: 1fr;
        max-width: 380px;
    }

    .filtros {
        gap: 10px;
        padding: 0 12px;
        margin-bottom: 4px;
    }

    .marca-tema {
        justify-content: space-between;
        width: 100%;
    }

    .filtros label {
        width: 100%;
    }

    .filtros select {
        width: 100%;
    }

    .titulo {
        font-size: 14px;
    }

    .anio,
    .score {
        font-size: 13px;
    }

    .fila-botones {
        padding: 20px 16px;
    }

    footer {
        flex-direction: column;
        gap: 16px;
        text-align: center;
        padding: 24px 16px;
    }

    .logo-footer {
        flex-direction: column;
        align-items: center;
        gap: 6px;
    }

    .footer-derecha {
        align-items: center;
    }

    .modal-contenido {
        width: 95%;
        padding: 16px;
    }

    .modal-contenido img {
        width: 160px;
    }

    .trailer-frame {
        border-radius: 6px;
    }

    #cerrarModal {
        top: 10px;
        right: 10px;
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    #grafico1 {
        width: min(300px, calc(100vw - 32px));
    }
}
