/* ============================================
   RESET E ESTILOS BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: #121212;
    color: #fff;
    line-height: 1.4;
}

html {
    overflow-y: scroll;
}

/* ============================================
   HEADER E NAVEGAÇÃO
   ============================================ */
header {
    background-color: #1a1a1a;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #2c2c2c;
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #e50914;
    letter-spacing: -0.5px;
}

header h1 a,
header h1-link {
    text-decoration: none;
    color: inherit;
}

header h1 a:visited,
header h1-link:visited {
    color: inherit;
}

nav {
    display: flex;
    gap: 1.5rem;
}

nav a {
    color: #fff;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

nav a:hover {
    color: #e50914;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-right: auto;
}

.nav-and-auth {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: color 0.2s;
}

.back-button:hover {
    color: #e50914;
}

.back-icon {
    width: 28px;
    height: 28px;
    stroke: currentcolor;
    fill: none;
}

.user-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-dropdown {
    position: relative;
    display: inline-block;
}

.user-avatar {
    background-color: #4285F4;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    border: none;
    cursor: pointer;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: #1e1e1e;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
    border-radius: 4px;
    padding: 8px 0;
}

.dropdown-content span {
    display: block;
    padding: 8px 16px;
    color: #fff;
    border-bottom: 1px solid #333;
}

.dropdown-content button {
    background: none;
    border: none;
    color: #fff;
    padding: 8px 16px;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.dropdown-content button:hover {
    background-color: #333;
}

.user-dropdown:hover .dropdown-content {
    display: block;
}

.login-button {
    background-color: #4285F4;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
}

.dropdown-content .dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 16px;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    text-align: left;
    font-size: 0.9rem;
    transition: background 0.2s;
}
.dropdown-content .dropdown-item:hover {
    background-color: #333;
}
.dropdown-content .dropdown-item svg {
    flex-shrink: 0;
}

/* ============================================
   CATÁLOGO (GRADE DE CARDS)
   ============================================ */
main {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
}

.movie-card {
    position: relative;
    background-color: #1f1f1f;
    border-radius: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.movie-card:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 12px rgba(0,0,0,0.4);
}

.movie-card img {
    aspect-ratio: 2 / 3;
    width: 100%;
    height: auto;
    object-fit: cover;
}

.movie-card a,
.movie-card-link {
    text-decoration: none;
    color: inherit;
}

.movie-card a:visited,
.movie-card-link:visited {
    color: inherit;
}

.card-info {
    padding: 0.75rem;
}

/* Container flex para badge e título na mesma linha */
.title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.25rem;
}

.rank-badge {
    display: inline-block;
    background-color: #1e6df2; /* novo azul mais suave */
    color: #ffffff;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    letter-spacing: 0.5px;
    font-family: monospace;
    white-space: nowrap;
}

.card-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.card-info p {
    font-size: 0.85rem;
    color: #aaa;
    margin-top: 0.25rem;
}

.watchlist-btn, .watchlist-detail-btn {
    display: none; /* escondido inicialmente, o JS mostrará se logado */
}

/* Botão de bookmark (watchlist) no card */
.watchlist-btn {
    position: absolute;
    top: 0;
    left: 8px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;          
    margin: 0;
    display: flex;      
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.8);
    transition: color 0.2s, transform 0.1s;
    z-index: 2;
}

.watchlist-btn svg {
    width: 28px;      
    height: 28px;
    fill: currentColor;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.2));
    display: block;
}

.watchlist-btn:hover {
    color: rgba(255, 255, 255, 1);
    transform: scale(1.05);
}

.watchlist-btn.saved {
    color: #ffc107;
}

.watchlist-btn.saved:hover {
    color: #ffca2c;
}

/* ============================================
   PÁGINA DE DETALHES
   ============================================ */
.detail-container {
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    position: relative;
    min-height: 100vh;
}

.detail-overlay {
    background: linear-gradient(90deg, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.7) 50%, rgba(0,0,0,0.4) 100%);
    padding: 3rem 2rem;
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    min-height: 100vh;
    align-items: center;
}

.detail-poster {
    flex: 0 0 300px;
}

.detail-poster img {
    width: 100%;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.5);
}

.detail-info {
    flex: 1;
    max-width: 700px;
}

.detail-info h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.detail-info h1 span {
    font-size: 1.5rem;
    font-weight: 400;
    color: #ccc;
}

.detail-meta {
    font-size: 1rem;
    color: #ddd;
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.detail-meta span {
    background-color: rgba(255,255,255,0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
}

.detail-description {
    font-size: 1rem;
    line-height: 1.5;
    margin: 1rem 0;
    color: #e0e0e0;
}

.detail-cast, .detail-director, .detail-country, .detail-awards {
    margin: 0.5rem 0;
    font-size: 0.95rem;
}

.detail-cast strong, .detail-director strong, .detail-country strong, .detail-awards strong {
    color: #e50914;
    margin-right: 0.5rem;
}

/* Botão de bookmark na página de detalhes */
.watchlist-detail-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    margin-top: 1rem;
    transition: color 0.2s;
}
.watchlist-detail-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}
.watchlist-detail-btn.saved {
    color: #ffc107;
}
.watchlist-detail-btn:hover {
    color: #ffc107;
}

/* ============================================
   BOTÕES DA PÁGINA DE DETALHES
   ============================================ */
.detail-watch-buttons {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.watch-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.9rem 2rem;
    background: linear-gradient(135deg, #e50914, #b20710);
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
    text-decoration: none;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(229, 9, 20, 0.3), 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    backdrop-filter: blur(2px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    letter-spacing: 0.5px;
}

.watch-button:hover {
    transform: scale(1.02);
    background: linear-gradient(135deg, #ff1a24, #e50914);
    box-shadow: 0 8px 20px rgba(229, 9, 20, 0.4);
    border-color: rgba(255, 255, 255, 0.4);
}

.watch-button:active {
    transform: scale(0.98);
}

.watch-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
    transition: transform 0.2s ease;
}

.watch-button:hover .watch-icon {
    transform: rotate(5deg);
}

.trailer-button {
    display: inline-block;
    margin-top: 0.75rem;
    padding: 6px 12px;
    background-color: #2a2a2a;
    color: #ccc;
    border: 1px solid transparent;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: normal;
    cursor: pointer;
    transition: all 0.2s ease;
}

.trailer-button:hover {
    background-color: #3a3a3a;
    border-color: rgba(255,255,255,0.2);
    color: #fff;
}

.detail-logo {
    display: block;
    max-width: 100%;
    max-height: 9rem;
    width: auto;
    height: auto;
    margin: 0 auto 1rem auto;
    object-fit: contain;
}

/* ============================================
   MODAL DO TRAILER
   ============================================ */
.trailer-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    position: relative;
    width: 80%;
    max-width: 800px;
    background-color: #000;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    color: #fff;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
}
.modal-close:hover {
    color: #e50914;
}

#trailer-iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: none;
}

/* ============================================
   MODAL DO WATCHHUB
   ============================================ */
.watchhub-modal {
    display: none;
    position: fixed;
    z-index: 1003;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    align-items: center;
    justify-content: center;
}
.watchhub-modal.show {
    display: flex;
}
.watchhub-modal-content {
    background-color: #1e1e1e;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    border: 1px solid #333;
    position: relative;
}
.watchhub-modal-close {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 2rem;
    cursor: pointer;
    color: #aaa;
}
.watchhub-modal-close:hover {
    color: #e50914;
}
.stream-list {
    list-style: none;
    padding: 0;
}
.stream-list li {
    margin: 1rem 0;
}
.stream-btn {
    display: inline-block;
    background-color: #e50914;
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 30px;
    text-decoration: none;
    font-weight: bold;
    transition: 0.2s;
}
.stream-btn:hover {
    background-color: #ff0a1f;
}

/* ============================================
   MENU LATERAL DE EPISÓDIOS
   ============================================ */
.episodes-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background-color: #e50914;
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    transition: background 0.2s;
}
.episodes-button:hover {
    background-color: #ff0a1f;
}

.episodes-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100%;
    background-color: #1e1e1e;
    box-shadow: -2px 0 10px rgba(0,0,0,0.5);
    z-index: 1002;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.episodes-sidebar.open {
    right: 0;
}

.sidebar-header {
    padding: 1rem;
    background-color: #2a2a2a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
    position: sticky;
    top: 0;
    z-index: 10;
}

.close-sidebar-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #fff;
}

.episodes-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.episodes-fixed-header {
    background-color: #1e1e1e;
    padding: 1rem;
    border-bottom: 1px solid #333;
    position: sticky;
    top: 0;
    z-index: 5;
}

.season-select {
    width: 100%;
    padding: 8px;
    background-color: #2a2a2a;
    color: #fff;
    border: 1px solid #444;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}
.season-select:hover {
    background-color: #333;
}

.episodes-scrollable {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.episode-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.episode-list li {
    padding: 0.8rem;
    border-bottom: 1px solid #333;
    cursor: pointer;
}
.episode-list li:hover {
    background-color: #2c2c2c;
}

.episode-item {
    display: flex;
    gap: 12px;
    align-items: center;    /* alterado para centralizar verticalmente */
}

.ep-thumb {
    width: 80px;
    height: auto;
    border-radius: 4px;
    object-fit: cover;
}

.ep-placeholder {
    width: 80px;
    height: 112px;
    background: linear-gradient(135deg, #2a2a2a, #1a1a1a);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #aaa;
    text-align: center;
    box-shadow: inset 0 0 0 1px #333;
    padding: 8px;
    line-height: 1.2;
    gap: 4px;               /* espaço entre SVG e texto */
}
.ep-placeholder svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.ep-info {
    flex: 1;
}

.ep-info strong {
    display: block;
    margin-bottom: 4px;
}

.ep-info small {
    color: #aaa;
}

.loading, .error {
    text-align: center;
    padding: 2rem;
    color: #aaa;
}

/* Botão de episódio assistido (watched check) */
.watched-check {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffc107;
    transition: transform 0.1s;
}
.watched-check svg {
    width: 20px;
    height: 20px;
    display: block;
}
.watched-check:hover {
    transform: scale(1.1);
}

.season-progress-fixed {
    margin-top: 0.5rem;
    padding: 0 0.5rem;
}
.season-progress-text {
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 0.25rem;
}
.progress-bar-bg {
    background-color: #333;
    border-radius: 4px;
    height: 6px;
    overflow: hidden;
}
.progress-bar-fill {
    background-color: #e50914;
    height: 100%;
    width: 0%;
    transition: width 0.2s;
}

/* ============================================
   ÍCONE DE SINO (NOTIFICAÇÕES)
   ============================================ */
.notifications-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: color 0.2s;
    padding: 0;
    margin: 0;
}

.notifications-btn svg {
    width: 24px;
    height: 24px;
}

.notifications-btn:hover {
    color: #e50914;
}

.bell-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.notification-badge {
    position: absolute;
    top: -8px;
    right: -12px;
    background-color: #e50914;
    color: white;
    border-radius: 50%;
    font-size: 10px;
    font-weight: bold;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 0 2px rgba(0,0,0,0.5);
}

/* Sidebar de notificações */
.notifications-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100%;
    background-color: #1e1e1e;
    box-shadow: -2px 0 10px rgba(0,0,0,0.5);
    z-index: 1002;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.notifications-sidebar.open {
    right: 0;
}
.sidebar-header {
    padding: 1rem;
    background-color: #2a2a2a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
    position: sticky;
    top: 0;
    z-index: 10;
}
.sidebar-header h3 {
    margin: 0;
    font-size: 1.2rem;
}
.close-sidebar-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #fff;
}
.notifications-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}
.notification-item {
    padding: 0.8rem;
    border-bottom: 1px solid #333;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.notification-item img {
    width: 80px;
    height: auto;
    border-radius: 4px;
    object-fit: cover;
}
.notification-item p {
    margin: 0;
}

@media (max-width: 768px) {
    .notifications-sidebar {
        width: 100%;
        right: -100%;
    }
}

/* ============================================
   RESPONSIVIDADE (CORRIGIDA)
   ============================================ */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding: 1rem;
    }
    .header-left {
        justify-content: flex-start;
        margin-right: 0;
    }
    .back-icon {
        width: 24px;
        height: 24px;
    }
    .nav-and-auth {
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    nav {
        flex: none;
        flex-wrap: nowrap;
        gap: 0.75rem;
        font-size: 0.85rem;
    }
    .user-area {
        margin-left: 0;
        justify-content: flex-end;
    }
    main {
        padding: 0 1rem;
    }
    .catalog-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 1rem;
    }
    .detail-overlay {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 2rem 1rem;
    }
    .detail-poster {
        flex: 0 0 auto;
        max-width: 250px;
    }
    .detail-info h1 {
        font-size: 1.8rem;
    }
    .detail-meta {
        justify-content: center;
    }
    .episodes-sidebar {
        width: 100%;
        right: -100%;
    }
    .ep-thumb, .ep-placeholder {
        width: 60px;
        height: 84px;
    }
    .watch-button {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
        gap: 0.5rem;
    }
    .watch-icon {
        width: 20px;
        height: 20px;
    }
    .modal-content, .watchhub-modal-content {
        width: 95%;
    }
}

/* ============================================
   SCROLLBAR PERSONALIZADA
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #1a1a1a;
}
::-webkit-scrollbar-thumb {
    background: #e50914;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #ff0a1f;
}