/* Variables globales */
:root {
    /* Nueva paleta de color */
    --dark-gray: #434343;
    --medium-gray: #54595F;
    --light-gray: #7A7A7A;
    --off-white: #F2F2F2;
    --dark-purple: #650550;
    --medium-purple: #963582;
    --light-purple: #ECCAE5;
    --accent-yellow: #FFC82A;
    
    /* Mapeo a las variables usadas en el sitio */
    --primary-color: var(--dark-purple);
    --secondary-color: var(--medium-purple);
    --background-color: var(--off-white);
    --card-color: #ffffff;
    --text-color: var(--dark-gray);
    --highlight-color: var(--medium-purple);
}

/* Importar fuentes de Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Raleway:wght@400;500;600;700&family=Open+Sans:wght@400;500;600&display=swap');

/* Estilos base */
body {
    font-family: 'Open Sans', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--text-color);
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Raleway', sans-serif;
    font-weight: 600;
}

/* Header */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

h1 {
    margin: 0;
    font-size: 1.8rem;
}

/* Filtros */
.filter-container {
    padding: 1rem;
    background-color: var(--secondary-color);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    position: sticky;
    top: 60px;
    z-index: 90;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.filter-button {
    background-color: var(--card-color);
    border: none;
    border-radius: 20px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.filter-button:hover {
    background-color: var(--highlight-color);
    color: white;
}

.filter-button.active {
    background-color: var(--highlight-color);
    color: white;
}

/* Buscador */
.search-container {
    padding: 1rem;
    display: flex;
    justify-content: center;
}

.search-input {
    width: 80%;
    max-width: 500px;
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 1rem;
    font-family: 'Open Sans', sans-serif;
}

/* Grilla de películas */
.movie-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    padding: 1rem;
}

.movie-card {
    background-color: var(--card-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.movie-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.movie-poster {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    background-color: #ddd;
}

.movie-title {
    padding: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    min-height: 2.8rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--card-color);
    width: 90%;
    max-width: 500px;
    border-radius: 8px;
    overflow: hidden;
    animation: modalFadeIn 0.3s;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: var(--primary-color);
    color: white;
}

.close-modal {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.movie-details {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1rem;
}

.detail-poster {
    width: 100%;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.detail-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.movie-info-item {
    display: flex;
    flex-direction: column;
}

.info-label {
    font-weight: bold;
    font-size: 0.8rem;
    color: var(--light-gray);
}

.info-value {
    font-size: 1rem;
}

.disco-badge {
    display: inline-block;
    background-color: var(--accent-yellow);
    color: var(--dark-gray);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Estados de la aplicación */
.no-results {
    text-align: center;
    padding: 2rem;
    grid-column: 1 / -1;
    font-size: 1.2rem;
    color: var(--light-gray);
}

.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    grid-column: 1 / -1;
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid var(--secondary-color);
    border-bottom-color: transparent;
    border-radius: 50%;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.stats {
    display: flex;
    justify-content: center;
    padding: 0.5rem;
    font-size: 0.9rem;
    color: var(--light-gray);
    background-color: var(--off-white);
    border-top: 1px solid #ddd;
}

.detail-poster {
    width: 100%;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

a .detail-poster:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}


/* Responsive */
@media (max-width: 600px) {
    .movie-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
    
    .filter-button {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    
    .movie-details {
        grid-template-columns: 1fr;
    }
    
    .detail-poster {
        max-width: 200px;
        margin: 0 auto;
    }
}

/* Mejoras para dispositivos móviles */
@media (max-width: 768px) {
    /* Ajustes para el encabezado */
    header h1 {
        font-size: 1.4rem;
        padding: 0.5rem;
    }
    
    /* Contenedor de filtros scrollable horizontal */
    .filter-container {
        display: flex;
        padding: 0.5rem;
        overflow-x: auto;
        white-space: nowrap;
        justify-content: flex-start;
        position: sticky;
        top: 59px; /* Ajusta esto si tu header tiene diferente altura */
        z-index: 90;
        -webkit-overflow-scrolling: touch; /* Para mejor scroll en iOS */
        scrollbar-width: none; /* Firefox */
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    /* Ocultar la barra de desplazamiento pero mantener funcionalidad */
    .filter-container::-webkit-scrollbar {
        display: none;
    }
    
    .filter-button {
        flex: 0 0 auto;
        font-size: 0.8rem;
        padding: 0.3rem 0.7rem;
        margin-right: 0.3rem;
    }
    
    /* Añadir indicador visual de scroll */
    .filter-container::after {
        content: '';
        flex: 0 0 8px; /* Espacio al final para indicar que hay más */
    }
    
    /* Ajuste de la cuadrícula de películas */
    .movie-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.7rem;
        padding: 0.7rem;
        margin-top: 0.5rem;
    }
    
    /* Ajuste del modal para móviles */
    .modal-content {
        width: 95%;
        max-width: none;
    }
    
    .movie-details {
        grid-template-columns: 1fr;
    }
    
    .detail-poster {
        max-width: 180px;
        margin: 0 auto 1rem auto;
    }
}

/* Extra pequeño - teléfonos */
@media (max-width: 480px) {
    .movie-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .movie-title {
        font-size: 0.8rem;
    }
}