:root {
    --bg-color: #0a0a0a;
    --card-bg: #1a1a1a;
    --accent-color: #e50914;
    --accent-hover: #ff0f1a;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --glass-bg: rgba(10, 10, 10, 0.85);
    --gold: #ffc107;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    line-height: 1.6;
    overflow-x: hidden;
}

.dynamic-bg {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: -1;
    background-size: cover;
    background-position: center 20%;
    filter: blur(35px) brightness(0.2);
    transform: scale(1.1); /* Evita vores transparents al difuminar */
    transition: background-image 1.5s ease-in-out;
    background-color: var(--bg-color);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #000; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-color); }

header {
    padding: 1.2rem 4%;
    background: linear-gradient(to bottom, rgba(0,0,0,0.9) 0%, transparent 100%);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

header.scrolled {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding: 0.8rem 4%;
}

.logo {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--accent-color);
    letter-spacing: -2px;
    text-transform: uppercase;
    text-decoration: none;
    display: flex;
    align-items: center;
}
.logo span { color: white; }

.install-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    font-weight: 800;
    font-size: 0.8rem;
    cursor: pointer;
    text-transform: uppercase;
    transition: var(--transition);
    margin-left: 20px;
    white-space: nowrap;
}
.install-btn:hover { transform: scale(1.05); filter: brightness(1.2); }

.search-container {
    position: relative;
    max-width: 450px;
    width: 100%;
    margin-left: auto;
}

.search-container input {
    width: 100%;
    padding: 12px 50px 12px 20px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 30px;
    color: white;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

.search-container input:focus {
    background: rgba(255,255,255,0.1);
    border-color: var(--accent-color);
    box-shadow: 0 0 20px rgba(229, 9, 20, 0.2);
}

.search-container button {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition);
    padding: 0;
}

.search-container button:hover {
    color: var(--accent-color);
    transform: translateY(-50%) scale(1.1);
}

#genres-filter {
    margin-top: 90px;
    padding: 15px 4%;
    display: flex;
    gap: 12px;
    flex-wrap: wrap; /* Ara es posen en diverses línies si no caben */
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.genre-pill {
    padding: 8px 20px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition);
    flex-shrink: 0;
    text-align: center;
}
.genre-pill:hover, .genre-pill.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.advanced-filters {
    padding: 10px 4%;
    display: flex;
    gap: 40px;
    align-items: center;
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-group { display: flex; align-items: center; gap: 15px; }
.filter-label { font-size: 0.8rem; font-weight: 800; text-transform: uppercase; color: #555; letter-spacing: 1px; }

.type-switcher {
    display: flex;
    background: rgba(255,255,255,0.05);
    padding: 4px;
    border-radius: 30px;
}
.type-btn {
    padding: 6px 16px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 20px;
    transition: var(--transition);
}
.type-btn.active { background: var(--accent-color); color: white; }

.year-select {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    outline: none;
    font-size: 0.85rem;
    cursor: pointer;
    color-scheme: dark; /* Força el navegador a usar controls fosc */
}
.year-select option {
    background: #1a1a1a;
    color: white;
}
.year-select:focus { border-color: var(--accent-color); }

main {
    margin-top: 20px;
    padding: 0 4%;
}

#results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 25px;
}

.movie-card {
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    aspect-ratio: 2/3;
    background: var(--card-bg);
}

.movie-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.8);
}
.movie-card img { width: 100%; height: 100%; object-fit: cover; }
.movie-card .info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px;
    background: linear-gradient(to top, rgba(0,0,0,1) 0%, transparent 100%);
    opacity: 0;
    transition: var(--transition);
}
.movie-card:hover .info { opacity: 1; }
.movie-card h3 { font-size: 0.9rem; margin-bottom: 4px; }
.card-meta { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-secondary); }
.rating { color: var(--gold); font-weight: 700; }

#details-section { display: none; margin-top: 20px; animation: fadeIn 0.6s ease; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.details-header { display: flex; gap: 40px; margin-bottom: 40px; flex-wrap: wrap; }
.details-poster { width: 280px; border-radius: 4px; box-shadow: 0 20px 50px rgba(0,0,0,0.9); }
.details-content { flex: 1; min-width: 300px; }
.details-content h2 { font-size: 3.5rem; font-weight: 900; margin-bottom: 5px; letter-spacing: -2px; line-height: 1.1; }

.movie-meta {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
}
.movie-meta span { display: flex; align-items: center; gap: 5px; }
.movie-meta .rating-pill { color: var(--gold); }

.details-content p { color: var(--text-secondary); font-size: 1.1rem; margin-bottom: 25px; max-width: 900px; line-height: 1.8; }

.movie-info-extra {
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.95rem;
}
.movie-info-extra div { color: var(--text-secondary); }
.movie-info-extra strong { color: white; margin-right: 5px; }
.clickable-info { cursor: pointer; transition: var(--transition); }
.clickable-info:hover { color: var(--accent-color); text-decoration: underline; }

.player-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 50px;
    box-shadow: 0 30px 60px rgba(0,0,0,0.8);
}

.player-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.details-extra {
    margin-bottom: 50px;
}

.details-extra h3 {
    font-size: 1.5rem;
    margin-bottom: 25px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.horizontal-scroll {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 20px;
    scrollbar-width: thin;
}
.horizontal-scroll::-webkit-scrollbar { height: 4px; }
.horizontal-scroll::-webkit-scrollbar-thumb { background: #333; border-radius: 10px; }

/* Cast Styles */
.cast-card {
    min-width: 140px;
    text-align: center;
}
.cast-card img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 12px;
    border: 2px solid rgba(255,255,255,0.1);
    transition: var(--transition);
}
.cast-card:hover img { border-color: var(--accent-color); transform: scale(1.05); }
.cast-card h4 { font-size: 0.9rem; font-weight: 600; margin-bottom: 2px; }
.cast-card p { font-size: 0.8rem; color: var(--text-secondary); }

/* Similar Styles */
.similar-card {
    min-width: 180px;
    width: 180px;
}

.server-selector { display: flex; gap: 10px; margin-bottom: 20px; }
.server-btn, #tv-controls select {
    padding: 10px 20px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}
.server-btn:hover { background: rgba(255,255,255,0.12); }
.server-btn.active { background: var(--accent-color); border-color: var(--accent-color); }

/* =========================================
   RESPONSIVE DESIGN (MOBIL & TABLETS)
   ========================================= */
@media (max-width: 768px) {
    /* Header & Navbar */
    header {
        flex-direction: column;
        gap: 15px;
        padding: 15px 4%;
    }
    header.scrolled {
        padding: 10px 4%;
    }
    
    .logo {
        font-size: 1.5rem;
    }
    
    .search-container {
        max-width: 100%;
        margin-left: 0;
    }

    .install-btn {
        margin-left: 0;
        width: 100%;
        text-align: center;
        padding: 10px;
    }

    /* Filters */
    #genres-filter {
        margin-top: 130px; /* Offset pel header mòbil més alt */
        justify-content: center;
    }

    .advanced-filters {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .type-switcher {
        width: 100%;
        display: flex;
    }
    .type-btn {
        flex: 1;
        text-align: center;
        padding: 8px 10px;
    }

    .year-select {
        width: 100%;
    }

    .filter-group {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    /* Grid i Cards */
    #results {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); 
        gap: 12px;
    }

    .movie-card h3 {
        font-size: 0.85rem;
    }

    .card-meta {
        font-size: 0.7rem;
    }

    /* Fitxa Detalls (Movie View) */
    .details-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 20px;
    }

    .details-poster {
        width: 180px; /* Més petita pel mòbil */
    }

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

    .details-content h2 {
        font-size: 2.2rem;
        text-align: center;
    }

    .movie-meta {
        justify-content: center;
        flex-wrap: wrap;
    }

    .details-content p {
        font-size: 1rem;
        text-align: center;
    }

    .movie-info-extra {
        align-items: center;
        text-align: center;
    }
    
    /* Reproductor i Controls Sèries */
    .player-wrapper {
        margin-bottom: 30px;
    }

    .server-selector, #tv-controls {
        flex-direction: column;
        width: 100%;
    }

    .server-btn, #tv-controls select {
        width: 100%;
        text-align: center;
    }

    /* Cast & Similars */
    .cast-card {
        min-width: 110px;
    }
    .cast-card img {
        width: 80px;
        height: 80px;
    }
    
    .similar-card {
        min-width: 130px;
        width: 130px;
    }
}

footer { padding: 80px 4%; text-align: center; color: #444; border-top: 1px solid #111; margin-top: 40px; }
