/* Reset y estilos base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

/* Contenedor principal */
.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

h1 {
    font-size: 3em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    animation: fadeInDown 1s ease;
}

.subtitle {
    font-size: 1.2em;
    opacity: 0.9;
    animation: fadeInUp 1s ease 0.3s both;
}

/* Buscador */
.search-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

#searchInput {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 25px;
    font-size: 1em;
    background: rgba(255,255,255,0.95);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

#searchBtn, #randomBtn {
    padding: 12px 25px;
    border: none;
    border-radius: 25px;
    background: white;
    color: #667eea;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

#searchBtn:hover, #randomBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

/* Filtros */
.filters {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

.filters select {
    padding: 8px 15px;
    border-radius: 20px;
    border: none;
    background: rgba(255,255,255,0.9);
    cursor: pointer;
}

/* Estados de carga y error */
.loading-state, .error-state {
    text-align: center;
    padding: 50px;
    color: white;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-state {
    background: rgba(255,0,0,0.1);
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.hidden {
    display: none !important;
}

/* Estadísticas */
.stats {
    background: rgba(255,255,255,0.1);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 30px;
    color: white;
    text-align: center;
    backdrop-filter: blur(10px);
}

/* Grid de películas */
.peliculas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 25px;
    padding: 20px 0;
    min-height: 400px;
}

/* Tarjeta de película */
.pelicula-card {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    animation: fadeInUp 0.6s ease both;
}

.pelicula-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);
}

/* Imagen de película */
.pelicula-imagen {
    width: 100%;
    height: 350px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.pelicula-card:hover .pelicula-imagen {
    transform: scale(1.05);
}

.no-poster {
    height: 350px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-size: 1.2em;
    text-align: center;
    padding: 20px;
}

/* Información de película */
.pelicula-info {
    padding: 15px;
}

.pelicula-titulo {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2; 
    overflow: hidden;
}

.pelicula-año {
    color: #666;
    font-size: 1em;
    margin-bottom: 5px;
}

.pelicula-tipo {
    display: inline-block;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.85em;
    text-transform: capitalize;
}

.pelicula-rating {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 215, 0, 0.95);
    color: #333;
    padding: 8px 12px;
    border-radius: 50px;
    font-weight: bold;
    font-size: 0.9em;
    backdrop-filter: blur(5px);
}

/* Paginación */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 40px;
    padding: 20px;
}

.pagination button {
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    background: white;
    color: #667eea;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pagination button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#pageInfo {
    color: white;
    font-weight: bold;
}

/* Animaciones */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    h1 {
        font-size: 2em;
    }
    
    .peliculas-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .search-container {
        flex-direction: column;
    }
    
    .filters {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .filters select {
        width: 100%;
    }
    
    .pagination {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .page-numbers {
        order: 3;
        width: 100%;
        justify-content: center;
        margin-top: 10px;
    }
    
    /* Ajustar tamaño de imágenes en móvil */
    .pelicula-imagen, .no-poster {
        height: 250px;
    }
    
    /* Reducir padding en tarjetas */
    .pelicula-info {
        padding: 10px;
    }
    
    .pelicula-titulo {
        font-size: 1em;
    }
}

@media (max-width: 480px) {
    .peliculas-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    h1 {
        font-size: 1.5em;
    }
    
    .subtitle {
        font-size: 1em;
    }
    
    .stats {
        font-size: 0.9em;
        padding: 10px;
    }
}

/* Mejoras paginacion */
.page-numbers {
    display: flex;
    gap: 5px;
}

.page-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 50%;
    background: white;
    color: #667eea;
    font-weight: bold;
    cursor: pointer;
    min-width: 35px;
    transition: all 0.3s ease;
}

.page-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.page-btn.active {
    background: #667eea;
    color: white;
}

.page-dots {
    padding: 8px;
    color: white;
    font-weight: bold;
}

/* Estilos para el modal de detalles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: white;
    border-radius: 15px;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s ease;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 1.2em;
    transition: transform 0.3s ease;
}

.modal-close:hover {
    transform: rotate(90deg);
}

.modal-header {
    padding: 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 15px 15px 0 0;
}

.modal-body {
    padding: 20px;
}

.detalle-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.detalle-poster {
    width: 100%;
    border-radius: 10px;
}

.no-poster-detail {
    width: 200px;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-size: 4em;
    border-radius: 10px;
}

.detalle-info p {
    margin: 10px 0;
}

.detalle-sinopsis {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.box-office {
    margin-top: 15px;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 5px;
    text-align: center;
}

.rating {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.btn-detalles {
    margin-top: 10px;
    padding: 8px 15px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: transform 0.3s ease;
    width: 100%;
}

.btn-detalles:hover {
    transform: scale(1.05);
}

.pelicula-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 10px 0;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive para modal */
@media (max-width: 768px) {
    .modal-content {
        margin: 20px;
        max-width: calc(100% - 40px);
    }
    
    .detalle-grid {
        grid-template-columns: 1fr;
    }
    
    .detalle-poster {
        max-width: 200px;
        margin: 0 auto;
    }
}

/* Estilos para canciones GraphQL */
.cancion-card {
    border: 2px solid #764BA2;
}

#graphqlBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(118, 75, 162, 0.4);
}

/* ======================================== */
/* ESTILOS PARA BOTONES FLOTANTES DEL CRUD  */
/* ======================================== */

/* Estilos para la vista de escritorio */
#crud-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column; /* Los apilo verticalmente */
    gap: 10px;
}

#crud-controls button {
    color: white;
    border: none;
    padding: 15px 25px; /* Tamaño grande para escritorio */
    border-radius: 50px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: transform 0.3s ease;
}

#crud-controls button:hover {
    transform: translateY(-2px);
}

/* Colores específicos para cada botón */
#leerCancionesBtn {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

#crud-controls button:last-child {
    background: linear-gradient(135deg, #27ae60, #229954);
}


/* ======================================== */
/* CRUD MEDIA QUERY PARA MÓVILES         */
/* ======================================== */
@media (max-width: 768px) {

    
    body {
        padding-bottom: 100px; /* colchón al final de la página */
    }

    #crud-controls {
        /* Los centro horizontalmente en la parte inferior */
        left: 50%;
        right: auto;
        bottom: 15px;
        transform: translateX(-50%);

        /* Los pongo uno al lado del otro */
        flex-direction: row;

        
        width: 95%; 
        flex-wrap: wrap; 
        justify-content: center; 
        gap: 8px;
    }

    #crud-controls button {
        /* Hago los botones más pequeños para que quepan */
        padding: 10px 15px;
        font-size: 0.8em;
    }
}