:root {
    --primary-color: #e50914;
    --background-color: #141414;
    --text-color: #ffffff;
    --card-bg: #1f1f1f;
    --radius: 12px; /* Capas arredondadas */
}

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

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    overflow-x: hidden;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 50px;
    background-color: rgba(0, 0, 0, 0.9);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 20px;
    align-items: center;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: var(--primary-color);
}

/* Dropdown Menu */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #1f1f1f;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1001;
    border-radius: 8px;
    max-height: 400px;
    overflow-y: auto;
}

.dropdown-content a {
    color: var(--text-color);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    font-size: 14px;
}

.dropdown-content a:hover {
    background-color: #333;
    color: var(--primary-color);
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* Search Bar */
.search-container {
    display: flex;
    align-items: center;
    background-color: #333;
    border-radius: 20px;
    padding: 5px 15px;
    margin-left: 20px;
}

.search-container input {
    background: transparent;
    border: none;
    color: #fff;
    outline: none;
    padding: 5px;
    font-size: 14px;
    width: 200px;
}

#search-btn {
    background: transparent;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 16px;
}

#search-btn:hover {
    color: #fff;
}

/* Results Section (Grid) */
.results-section {
    padding: 100px 50px 50px; /* Top padding p/ compensar navbar */
    min-height: 100vh;
    background-color: var(--background-color);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 30px;
    border-bottom: 1px solid #333;
    padding-bottom: 15px;
}

.filter-container {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-btn {
    background-color: #333;
    color: #fff;
    border: 1px solid #444;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.filter-btn:hover {
    background-color: #444;
}

.filter-btn.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.close-search-btn {
    background-color: transparent;
    border: 1px solid #555;
    color: #fff;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    margin-left: 10px;
}

.close-search-btn:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
}

/* Load More Button */
.load-more-container {
    text-align: center;
    margin-top: 40px;
    padding: 20px 0;
    display: flex;
    justify-content: center;
}

.load-more-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(229, 9, 20, 0.4);
}

.load-more-btn:hover {
    background-color: #ff0f1f;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(229, 9, 20, 0.6);
}

.load-more-btn:disabled {
    background-color: #555;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Reusing movie-card styles for grid */
.results-grid .movie-card {
    width: 100%;
}

.results-grid .movie-card img {
    height: 240px;
}

/* Hero Carousel */
.hero-carousel {
    height: 80vh;
    position: relative;
    overflow: hidden;
    margin-top: 60px; /* Offset navbar */
}

.hero-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    display: flex;
    align-items: flex-end;
}

.hero-slide.active {
    opacity: 1;
}

.hero-overlay {
    background: linear-gradient(to top, #141414, transparent);
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.hero-content {
    position: relative;
    z-index: 2;
    padding: 50px;
    max-width: 600px;
    margin-bottom: 50px;
}

.hero-title {
    font-size: 48px;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
}

.hero-desc {
    font-size: 16px;
    line-height: 1.5;
    margin-bottom: 20px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Categories */
.category-section {
    padding: 20px 50px;
    margin-bottom: 30px;
}

.category-section h2 {
    margin-bottom: 15px;
    font-size: 24px;
    border-left: 5px solid var(--primary-color);
    padding-left: 10px;
}

.carousel-container {
    position: relative;
    display: flex;
    align-items: center;
}

.movie-list {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 10px 0;
    scrollbar-width: none; /* Firefox */
}

.movie-list::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.movie-card {
    min-width: 160px;
    cursor: pointer;
    transition: transform 0.3s;
}

.movie-card:hover {
    transform: scale(1.05);
}

.movie-card img {
    width: 100%;
    height: 240px;
    object-fit: cover;
    border-radius: var(--radius); /* Capas arredondadas */
    box-shadow: 0 4px 8px rgba(0,0,0,0.5);
}

.movie-title {
    margin-top: 10px;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

/* Navigation Buttons */
.nav-btn {
    background-color: rgba(0,0,0,0.5);
    border: none;
    color: white;
    font-size: 24px;
    padding: 10px;
    cursor: pointer;
    position: absolute;
    z-index: 10;
    height: 100%;
    top: 0;
    transition: background 0.3s;
}

.nav-btn:hover {
    background-color: rgba(0,0,0,0.8);
}

.prev-btn { left: -40px; }
.next-btn { right: -40px; }

/* Modal */
.modal {
    display: none; 
    position: fixed; 
    z-index: 2000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    background-color: rgba(0,0,0,0.9); 
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
    backdrop-filter: blur(5px);
    overflow-y: auto; /* Permitir scroll se a tela for pequena */
}

.modal.show {
    display: flex;
    opacity: 1;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    filter: blur(20px) brightness(0.3);
    z-index: -1;
}

.modal-content {
    background-color: rgba(24, 24, 24, 0.95);
    margin: auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 1000px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid #333;
}

.modal-content::-webkit-scrollbar {
    width: 8px;
}
.modal-content::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #fff;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
    text-shadow: 0 0 10px #000;
}

.close-btn:hover {
    color: var(--primary-color);
}

.modal-header-content {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.modal-poster-container img {
    width: 250px;
    border-radius: 10px;
    object-fit: cover;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    margin-bottom: 20px;
}

/* Cast Section removed */

.modal-info {
    flex: 1;
    color: #fff;
}

.modal-info h2 {
    font-size: 36px;
    margin-bottom: 15px;
    line-height: 1.2;
}

.modal-meta-data {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}

.meta-tag {
    background: rgba(255,255,255,0.1);
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 14px;
    color: #ddd;
}

.meta-tag.rating {
    color: #FFD700;
    font-weight: bold;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

#modal-overview {
    font-size: 16px;
    line-height: 1.6;
    color: #ccc;
    margin-bottom: 30px;
}

.trailer-container {
    margin-top: 30px;
    width: 100%;
}

.trailer-container h3 {
    margin-bottom: 15px;
    font-size: 20px;
    border-left: 4px solid var(--primary-color);
    padding-left: 10px;
}

.video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
}

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

@media (max-width: 768px) {
    .modal-header-content {
        flex-direction: column;
        align-items: center;
    }
    
    .modal-poster-container img {
        width: 180px;
        margin-bottom: 20px;
    }

    .modal-info h2 {
        text-align: center;
        font-size: 24px;
    }

    .modal-meta-data {
        justify-content: center;
    }

    .modal-content {
        padding: 20px;
        width: 95%;
    }
}

/* ===============================
   RESPONSIVIDADE GERAL OTIMIZADA
================================ */

@media (max-width: 768px) {
    /* Navbar Mobile Compacta */
    .navbar {
        flex-direction: column;
        padding: 15px 10px;
        gap: 10px;
        background-color: rgba(0, 0, 0, 0.98); /* Mais escuro p/ leitura */
    }

    .logo {
        font-size: 28px; /* Destaque maior */
    }

    .nav-links {
        width: 100%;
        justify-content: center;
        gap: 15px;
        flex-wrap: wrap;
        font-size: 13px;
        padding: 0;
    }

    .search-container {
        margin-left: 0;
        width: 100%;
        justify-content: center;
        padding: 0 10px;
    }

    .search-container input {
        width: 100%;
        font-size: 16px; /* Evita zoom no iOS */
    }

    .search-container input:focus {
        width: 100%; /* Mantém 100% no mobile */
    }

    /* Dropdown Mobile Expansivo (Acordeão) */
    .dropdown {
        width: 100%;
        text-align: center;
    }

    .dropdown-content {
        position: static; /* Flui com o documento */
        width: 100%;
        min-width: auto;
        box-shadow: none;
        background-color: rgba(255,255,255,0.03);
        max-height: 0; /* Oculto por padrão via altura */
        overflow: hidden;
        display: block; /* Sobrescreve o grid padrão do desktop para controlar via height */
        padding: 0;
        border: none;
        transition: max-height 0.4s ease-out; /* Animação suave */
    }

    /* Sobrescreve comportamento de hover do desktop para não atrapalhar */
    .dropdown:hover .dropdown-content {
        display: block;
    }

    /* Quando a classe .show é adicionada via JS */
    .dropdown-content.show {
        display: grid; /* Volta a ser grid */
        max-height: 500px; /* Altura suficiente para mostrar itens */
        padding: 10px;
        margin-top: 10px;
        grid-template-columns: 1fr 1fr; /* 2 colunas também no mobile */
    }

    .dropdown-content a {
        padding: 8px;
        font-size: 13px;
        background-color: rgba(0,0,0,0.2);
    }

    /* Hero Mobile Expansivo */
    .hero-carousel {
        height: 50vh; /* Menor altura para ver conteúdo abaixo */
        margin-top: 160px; /* Espaço seguro para navbar empilhada */
    }

    .hero-content {
        padding: 15px;
        bottom: 0;
        width: 100%;
        background: linear-gradient(to top, #141414, transparent); /* Legibilidade */
    }

    .hero-title {
        font-size: 26px;
        margin-bottom: 10px;
    }

    .hero-desc {
        font-size: 13px;
        display: none; /* Ocultar descrição no mobile p/ limpar visual */
    }

    /* Listas Mobile "Full Bleed" */
    .category-section {
        padding: 20px 15px; /* Menos borda lateral */
    }

    .category-section h2 {
        font-size: 18px;
        margin-bottom: 10px;
    }

    .nav-btn {
        display: none; /* Swipe nativo */
    }

    .movie-list {
        gap: 10px;
        padding-right: 15px; /* Espaço final */
    }

    .movie-card {
        min-width: 130px; /* Tamanho fixo confortável */
        width: 130px;
    }

    .movie-card img {
        height: 195px; /* Proporção 2:3 */
        box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    }

    /* Modal Mobile Otimizado */
    .modal-content {
        padding: 15px;
        width: 95%;
        margin: 10px auto;
        max-height: 85vh;
    }

    .modal-poster-container img {
        width: 140px; /* Menor capa */
        margin-bottom: 15px;
        box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    }
    
    .modal-info h2 {
        font-size: 22px;
        text-align: center;
    }

    .modal-meta-data {
        justify-content: center;
        gap: 8px;
    }

    .meta-tag {
        font-size: 12px;
        padding: 4px 8px;
    }

    #modal-overview {
        font-size: 14px;
        text-align: justify;
    }
    
    /* Filtros Mobile */
    .results-header {
        flex-direction: column;
        align-items: center; /* Centralizar header no mobile */
        gap: 15px;
        text-align: center;
    }

    .results-header h2 {
        font-size: 20px;
        margin-bottom: 5px;
    }
    
    .filter-container {
        width: 100%;
        justify-content: center; /* Centralizar botões */
        flex-wrap: wrap; /* Permitir quebra de linha */
        gap: 8px; /* Espaçamento menor */
        overflow-x: visible; /* Remover scroll horizontal */
        white-space: normal;
    }

    .filter-btn {
        flex-grow: 1; /* Botões ocupam espaço disponível */
        text-align: center;
        max-width: 120px; /* Limite para não ficarem gigantes */
    }

    .close-search-btn {
        margin-left: 0; /* Remove margem lateral no mobile */
        flex-grow: 0; /* Botão fechar não estica tanto */
        padding: 8px 12px;
    }
}

@media (max-width: 480px) {
    /* Ajustes Finos para Telas Pequenas */
    .hero-carousel {
        margin-top: 170px; /* Navbar pode quebrar linha */
    }

    .results-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 colunas fixas */
        gap: 10px;
    }

    .results-grid .movie-card {
        width: 100%; /* Ocupa coluna inteira */
        min-width: auto;
    }

    .results-grid .movie-card img {
        height: auto;
        aspect-ratio: 2/3;
    }
}
