/* ========================================
   POWDER - Premium Streaming UI
   Netflix-Inspired Design System
   ======================================== */

/* CSS Custom Properties */
:root {
    /* Colors */
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-tertiary: #1a1a1a;
    --bg-card: #181818;
    --bg-hover: #252525;

    --accent-primary: #e50914;
    --accent-secondary: #b20710;
    --accent-glow: rgba(229, 9, 20, 0.4);

    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-muted: #808080;

    --glass-bg: rgba(20, 20, 20, 0.85);
    --glass-border: rgba(255, 255, 255, 0.1);

    --rating-color: #46d369;

    /* Sizing */
    --header-height: 68px;
    --card-width: 200px;
    --card-height: 300px;
    --card-gap: 10px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;

    /* Shadows */
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.5);
    --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.8);
    --shadow-glow: 0 0 40px var(--accent-glow);
}

/* Reset & Base */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Typography */
h1,
h2,
h3,
h4 {
    font-weight: 700;
    letter-spacing: -0.02em;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

/* ========================================
   HEADER
   ======================================== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4%;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.7) 50%, transparent 100%);
    z-index: 1000;
    transition: background var(--transition-normal);
}

.header.scrolled {
    background: var(--bg-secondary);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 40px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.03em;
}

/* Logo Icon Style Updated for SVG */
.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    /* Removed background/box-shadow as we are using an SVG image now */
    border-radius: 8px;
    object-fit: contain;
}

.nav {
    display: flex;
    gap: 28px;
}

.nav-link {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    padding: 8px 4px;
}

.nav-link::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-primary), #ff6b35);
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: translateX(-50%);
    box-shadow: 0 0 10px var(--accent-glow);
}

.nav-link:hover {
    color: var(--text-primary);
    transform: translateY(-2px);
}

.nav-link:hover::before {
    width: 100%;
}

.nav-link.active {
    color: var(--text-primary);
    font-weight: 600;
}

.nav-link.active::before {
    width: 100%;
    animation: navGlow 2s ease-in-out infinite;
}

@keyframes navGlow {

    0%,
    100% {
        box-shadow: 0 0 10px var(--accent-glow);
        opacity: 1;
    }

    50% {
        box-shadow: 0 0 20px var(--accent-glow), 0 0 30px var(--accent-glow);
        opacity: 0.8;
    }
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

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

.search-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: color var(--transition-fast);
}

.search-toggle svg {
    width: 20px;
    height: 20px;
}

.search-toggle:hover {
    color: var(--accent-primary);
}

.search-input {
    width: 0;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all var(--transition-normal);
    opacity: 0;
}

.search-container.active .search-input {
    width: 250px;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    opacity: 1;
    margin-right: 10px;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.profile-btn {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color var(--transition-fast);
}

.profile-btn:hover {
    border-color: var(--accent-primary);
}

.profile-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ========================================
   HERO SECTION
   ======================================== */
.hero {
    position: relative;
    height: 85vh;
    min-height: 600px;
    display: flex;
    align-items: flex-end;
    padding-bottom: 15%;
    overflow: hidden;
}

.hero-backdrop {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center top;
    transition: opacity 0.8s ease;
}

.hero-gradient {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(0deg, var(--bg-primary) 0%, transparent 50%),
        linear-gradient(90deg, rgba(0, 0, 0, 0.8) 0%, transparent 60%),
        linear-gradient(180deg, rgba(0, 0, 0, 0.4) 0%, transparent 30%);
}

.hero-content {
    position: relative;
    z-index: 2;
    padding: 0 4%;
    max-width: 50%;
}

.hero-info {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    width: fit-content;
}

.hero-title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    line-height: 1.1;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.hero-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.95rem;
}

.hero-meta .rating {
    color: var(--rating-color);
    font-weight: 600;
}

.hero-meta .star {
    margin-right: 4px;
}

.hero-meta .year,
.hero-meta .runtime {
    color: var(--text-secondary);
}

.hero-description {
    font-size: 1.1rem;
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 600px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hero-actions {
    display: flex;
    gap: 14px;
    margin-top: 12px;
    animation: heroFadeUp 0.8s ease-out 0.6s both;
}

/* Hero Entrance Animations */
@keyframes heroFadeUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-badge {
    animation: heroFadeUp 0.6s ease-out 0.1s both;
}

.hero-title {
    animation: heroFadeUp 0.7s ease-out 0.2s both;
}

.hero-meta {
    animation: heroFadeUp 0.7s ease-out 0.3s both;
}

.hero-description {
    animation: heroFadeUp 0.7s ease-out 0.4s both;
}

/* Buttons */
.btn-play {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 32px;
    background: var(--text-primary);
    color: var(--bg-primary);
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.btn-play svg {
    width: 22px;
    height: 22px;
}

.btn-play:hover {
    background: rgba(255, 255, 255, 0.85);
    transform: scale(1.02);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    background: rgba(109, 109, 110, 0.7);
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.btn-secondary svg {
    width: 22px;
    height: 22px;
}

.btn-secondary:hover {
    background: rgba(109, 109, 110, 0.5);
}

.btn-primary {
    padding: 14px 32px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 50px var(--accent-glow);
}

.btn-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(42, 42, 42, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.btn-icon svg {
    width: 20px;
    height: 20px;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-primary);
    transform: scale(1.1);
}

.btn-icon.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.btn-icon.active svg {
    transform: rotate(45deg);
}

/* ========================================
   CONTENT ROWS
   ======================================== */
.content-rows {
    position: relative;
    z-index: 10;
    margin-top: -150px;
    padding-bottom: 60px;
}

.content-row {
    margin-bottom: 40px;
}

.row-title {
    font-size: 1.4rem;
    font-weight: 600;
    padding: 0 4%;
    margin-bottom: 16px;
}

.row-wrapper {
    position: relative;
    padding: 0 4%;
    overflow: visible;
}

.row-content {
    display: flex;
    gap: var(--card-gap);
    overflow-x: auto;
    overflow-y: visible;
    scroll-behavior: smooth;
    padding: 40px 0 60px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.row-content::-webkit-scrollbar {
    display: none;
}

.scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.8), transparent);
    color: var(--text-primary);
    font-size: 2.5rem;
    opacity: 0;
    transition: opacity var(--transition-fast);
    z-index: 10;
}

.scroll-btn.scroll-left {
    left: 0;
    padding-left: 4%;
    background: linear-gradient(90deg, var(--bg-primary) 30%, transparent);
}

.scroll-btn.scroll-right {
    right: 0;
    padding-right: 4%;
    background: linear-gradient(-90deg, var(--bg-primary) 30%, transparent);
}

.row-wrapper:hover .scroll-btn {
    opacity: 1;
}

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

/* ========================================
   MOVIE CARDS - Enhanced Netflix-Style
   ======================================== */
.movie-card {
    flex-shrink: 0;
    width: var(--card-width);
    position: relative;
    border-radius: 8px;
    overflow: visible;
    background: var(--bg-card);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-origin: center;
}

.movie-card::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent-primary), #ff6b35, var(--accent-primary));
    opacity: 0;
    z-index: -1;
    transition: opacity 0.4s ease;
}

.movie-card:hover {
    transform: scale(1.15) translateY(-10px);
    z-index: 50;
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.6),
        0 0 60px rgba(229, 9, 20, 0.3);
}

.movie-card:hover::before {
    opacity: 1;
    animation: borderGlow 2s ease-in-out infinite;
}

@keyframes borderGlow {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

.movie-card:first-child:hover {
    transform-origin: left center;
}

.movie-card:last-child:hover {
    transform-origin: right center;
}

.card-poster-wrapper {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
}

.card-poster {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.movie-card:hover .card-poster {
    transform: scale(1.05);
    filter: brightness(0.6);
}

.card-poster.loading {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Card Hover Actions - Netflix Style */
.card-hover-actions {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    display: flex;
    gap: 12px;
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
}

.movie-card:hover .card-hover-actions {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.card-action-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.card-action-btn svg {
    width: 22px;
    height: 22px;
    transition: transform 0.25s ease;
}

.card-action-btn.play-btn {
    background: var(--text-primary);
    color: var(--bg-primary);
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.3);
}

.card-action-btn.play-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 6px 30px rgba(255, 255, 255, 0.5);
}

.card-action-btn.play-btn:hover svg {
    transform: scale(1.1);
}

.card-action-btn.info-btn {
    background: rgba(109, 109, 110, 0.8);
    color: var(--text-primary);
    border: 2px solid rgba(255, 255, 255, 0.4);
}

.card-action-btn.info-btn:hover {
    transform: scale(1.15);
    background: rgba(109, 109, 110, 0.95);
    border-color: var(--text-primary);
}

/* Card Info Overlay */
.card-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 80px 14px 14px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.98) 0%, rgba(0, 0, 0, 0.8) 60%, transparent 100%);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border-radius: 0 0 8px 8px;
}

.movie-card:hover .card-info {
    opacity: 1;
    transform: translateY(0);
}

.card-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.card-meta .rating {
    color: var(--rating-color);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 3px;
}

.card-meta .rating::before {
    content: '★';
    font-size: 0.7rem;
}

.card-type-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 5px 10px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 10px rgba(229, 9, 20, 0.4);
    z-index: 5;
}

.card-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: rgba(255, 255, 255, 0.2);
    z-index: 15;
}

.card-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), #ff6b35);
    transition: width var(--transition-normal);
    box-shadow: 0 0 10px var(--accent-glow);
}

/* ========================================
   SEARCH RESULTS
   ======================================== */
.search-results {
    padding: calc(var(--header-height) + 40px) 4% 60px;
    min-height: 100vh;
}

.section-title {
    font-size: 1.8rem;
    margin-bottom: 24px;
}

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

.search-grid .movie-card {
    width: 100%;
}

/* ========================================
   MODALS
   ======================================== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
}

.modal-content {
    position: relative;
    z-index: 1;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 12px;
    transform: scale(0.95) translateY(20px);
    transition: transform var(--transition-normal);
}

.modal.active .modal-content {
    transform: scale(1) translateY(0);
}

.glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 1.5rem;
    z-index: 10;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--accent-primary);
    transform: rotate(90deg);
}

/* API Key Modal */
.api-key-modal .modal-content {
    background: var(--bg-secondary);
}

.api-key-content {
    width: 450px;
    padding: 48px;
    text-align: center;
}

.api-key-header {
    margin-bottom: 32px;
}

.logo-large {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent-primary);
    margin-bottom: 16px;
}

.logo-large .logo-icon {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
}

.api-key-header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.api-key-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.api-key-form input {
    width: 100%;
    padding: 16px 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    text-align: center;
    transition: border-color var(--transition-fast);
}

.api-key-form input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.api-key-help {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.api-key-help a {
    color: var(--accent-primary);
    transition: color var(--transition-fast);
}

.api-key-help a:hover {
    color: var(--text-primary);
}

/* Detail Modal */
.detail-content {
    width: 900px;
    overflow-y: auto;
}

.detail-backdrop {
    width: 100%;
    height: 400px;
    background-size: cover;
    background-position: center top;
}

.detail-gradient {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 450px;
    background: linear-gradient(transparent 50%, var(--glass-bg) 100%);
    pointer-events: none;
}

.detail-body {
    position: relative;
    padding: 0 40px 40px;
    margin-top: -80px;
}

.detail-title {
    font-size: 2.5rem;
    margin-bottom: 12px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.detail-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.detail-meta .rating {
    color: var(--rating-color);
    font-weight: 600;
}

.detail-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.detail-description {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 32px;
}

/* Episode Selector */
.episode-selector {
    margin-bottom: 32px;
}

.season-select-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.season-select-container label {
    font-weight: 600;
}

.season-select {
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
}

.season-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.episodes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.episode-card {
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.episode-card:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

.episode-card.active {
    border-color: var(--accent-primary);
    background: rgba(229, 9, 20, 0.1);
}

.episode-number {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.episode-name {
    font-weight: 600;
    margin-bottom: 6px;
}

.episode-runtime {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Similar Section */
.similar-section h3 {
    font-size: 1.2rem;
    margin-bottom: 16px;
}

.similar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.similar-grid .movie-card {
    width: 100%;
}

/* Player Modal */
.player-modal {
    background: var(--bg-primary);
    flex-direction: column;
}

.player-modal.active {
    display: flex;
}

.player-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 16px 24px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.8), transparent);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.player-modal:hover .player-header {
    opacity: 1;
}

.player-back {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.player-back svg {
    width: 24px;
    height: 24px;
}

.player-back:hover {
    color: var(--accent-primary);
}

.player-title {
    font-size: 1.1rem;
    font-weight: 500;
}

.player-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.player-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ========================================
   LOADING
   ======================================== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader {
    position: relative;
    width: 80px;
    height: 80px;
}

.loader-ring {
    position: absolute;
    inset: 0;
    border: 3px solid transparent;
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    50% {
        transform: translate(-50%, -50%) scale(0.9);
        opacity: 0.7;
    }
}

/* ========================================
   TV REMOTE CONTROLS
   ======================================== */

/* Row highlight when navigating with remote */
.tv-remote-highlight {
    position: relative;
    animation: rowPulse 0.6s ease-out;
}

.tv-remote-highlight::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: -10px;
    bottom: -10px;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(229, 9, 20, 0.15) 20%,
            rgba(229, 9, 20, 0.15) 80%,
            transparent 100%);
    border-left: 3px solid var(--accent-primary);
    border-radius: 8px;
    pointer-events: none;
    animation: glowPulse 1.5s ease-in-out;
}

@keyframes rowPulse {
    0% {
        transform: translateX(-10px);
        opacity: 0.8;
    }

    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes glowPulse {

    0%,
    100% {
        opacity: 0.6;
        box-shadow: 0 0 20px rgba(229, 9, 20, 0.3);
    }

    50% {
        opacity: 1;
        box-shadow: 0 0 40px rgba(229, 9, 20, 0.6);
    }
}

/* Focused movie card */
.movie-card.tv-focused {
    transform: scale(1.15);
    z-index: 100;
    box-shadow: 0 0 30px rgba(229, 9, 20, 0.6),
        0 8px 40px rgba(0, 0, 0, 0.8);
    border: 3px solid var(--accent-primary);
    outline: none;
}

.movie-card.tv-focused .card-info {
    opacity: 1;
    transform: translateY(0);
}

.movie-card.tv-focused .card-hover-actions {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.movie-card.tv-focused .card-poster {
    transform: scale(1.05);
    filter: brightness(0.6);
}

/* TV Remote Indicator - Bottom left, subtle */
.tv-remote-indicator {
    position: fixed;
    bottom: 30px;
    left: 30px;
    transform: translateY(20px);
    background: rgba(20, 20, 20, 0.9);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: left;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    opacity: 0;
    transition: all 0.25s ease;
    pointer-events: none;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 3px solid var(--accent-primary);
}

.tv-remote-indicator.show {
    opacity: 1;
    transform: translateY(0);
}

/* Focused nav link for TV remote */
.nav-link.tv-nav-focused {
    color: var(--text-primary);
    background: rgba(229, 9, 20, 0.2);
    padding: 8px 12px;
    border-radius: 6px;
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Modal TV navigation focus states */
.detail-modal .btn-play.tv-modal-focused,
.detail-modal .btn-icon.tv-modal-focused {
    outline: 3px solid var(--accent-primary);
    outline-offset: 3px;
    box-shadow: 0 0 20px rgba(229, 9, 20, 0.5);
}

.episode-card.tv-modal-focused {
    border-color: var(--accent-primary) !important;
    background: rgba(229, 9, 20, 0.2) !important;
    box-shadow: 0 0 20px rgba(229, 9, 20, 0.4);
}

.season-select.tv-modal-focused {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Navigation hint overlay */
.tv-nav-hint {
    position: fixed;
    bottom: 40px;
    right: 40px;
    background: rgba(20, 20, 20, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px 24px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    z-index: 9000;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    pointer-events: none;
    backdrop-filter: blur(10px);
}

.tv-nav-hint.show {
    opacity: 1;
    transform: translateY(0);
}

.tv-nav-hint .hint-keys {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
}

.tv-nav-hint .hint-key {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 0.8rem;
}

.tv-nav-hint .hint-key kbd {
    background: var(--bg-hover);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 1200px) {
    .similar-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .nav {
        display: none;
    }

    .hero-content {
        max-width: 70%;
    }

    .detail-content {
        width: 95%;
        /* Ensure there's enough space to scroll to the bottom on mobile */
        max-height: 85vh;
        padding-bottom: 40px;
    }

    .similar-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    :root {
        --card-width: 140px;
        --header-height: 56px;
    }

    .hero {
        height: 70vh;
        min-height: 500px;
        padding-bottom: 25%;
    }

    .hero-content {
        max-width: 90%;
    }

    .hero-title {
        font-size: 1.8rem;
    }

    .hero-description {
        font-size: 0.95rem;
        -webkit-line-clamp: 2;
    }

    .hero-actions {
        flex-direction: column;
    }

    .btn-play,
    .btn-secondary {
        width: 100%;
        justify-content: center;
    }

    .row-title {
        font-size: 1.1rem;
    }

    /* Fix spacing between featured banner and content below on phones */
    .content-rows {
        margin-top: -60px;
    }

    .api-key-content {
        width: 95%;
        padding: 32px 24px;
    }

    .detail-body {
        padding: 0 24px 24px;
    }

    .detail-title {
        font-size: 1.8rem;
    }

    .episodes-grid {
        grid-template-columns: 1fr;
    }

    .similar-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    :root {
        --card-width: 120px;
    }

    .logo span:not(.logo-icon) {
        display: none;
    }

    .search-container.active .search-input {
        width: 180px;
    }
}



/* Search toggle focus state */
.search-toggle.tv-nav-focused {
    background: rgba(229, 9, 20, 0.2);
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    border-radius: 50%;
}