/* ============================================
   MovieHub — Dark Theme Movie Catalog
   Inspired by hdhub4u layout
   ============================================ */

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

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a2e;
    --bg-hover: #222240;
    --bg-modal: #16162a;
    --accent: #e50914;
    --accent-hover: #ff1a25;
    --accent-gold: #f5c518;
    --text-primary: #e5e5e5;
    --text-secondary: #999;
    --text-muted: #666;
    --border: #2a2a3e;
    --shadow: 0 8px 32px rgba(0,0,0,0.6);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.25s ease;
    --header-h: 64px;
    --max-w: 1400px;
}

html {
    scroll-behavior: smooth;
}

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

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
img { display: block; max-width: 100%; }
ul { list-style: none; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ---------- Header ---------- */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    background: rgba(10, 10, 15, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
}

.header-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 22px;
    font-weight: 800;
    flex-shrink: 0;
}

.logo-icon { font-size: 28px; }
.logo-accent { color: var(--accent); }

.nav { flex: 1; }

.nav-list {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
}

.nav-link {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: 6px;
    transition: var(--transition);
}

.nav-link:hover, .nav-link.active {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

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

.search-input {
    width: 0;
    padding: 0;
    border: none;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 14px;
    border-radius: 20px;
    outline: none;
    transition: width 0.35s ease, padding 0.35s ease;
}

.search-input.open {
    width: 240px;
    padding: 8px 40px 8px 16px;
    border: 1px solid var(--border);
}

.search-btn {
    position: absolute;
    right: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    border-radius: 50%;
    transition: var(--transition);
}

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

/* Mobile menu toggle */
.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    padding: 4px;
}
.menu-toggle span {
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
}

/* ---------- Hero Banner ---------- */
.hero {
    position: relative;
    height: 70vh;
    min-height: 500px;
    max-height: 750px;
    margin-top: var(--header-h);
    overflow: hidden;
    display: flex;
    align-items: flex-end;
}

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

.hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        var(--bg-primary) 0%,
        rgba(10,10,15,0.85) 30%,
        rgba(10,10,15,0.4) 60%,
        rgba(10,10,15,0.2) 100%
    );
}

.hero-content {
    position: relative;
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 24px 48px;
    width: 100%;
}

.hero-badges {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(4px);
}

.badge-quality { background: var(--accent); color: #fff; }
.badge-year { background: rgba(245,197,24,0.2); color: var(--accent-gold); }
.badge-rating { background: rgba(245,197,24,0.2); color: var(--accent-gold); }
.badge-lang { background: rgba(100,100,255,0.15); color: #aaf; }

.hero-title {
    font-size: clamp(28px, 5vw, 52px);
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 12px;
    max-width: 700px;
    text-shadow: 0 2px 20px rgba(0,0,0,0.7);
}

.hero-overview {
    font-size: 15px;
    color: var(--text-secondary);
    max-width: 600px;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hero-meta {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.hero-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.hero-actions {
    display: flex;
    gap: 12px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius);
    transition: var(--transition);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

.btn-secondary {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
    backdrop-filter: blur(4px);
}
.btn-secondary:hover { background: rgba(255,255,255,0.2); }

/* ---------- Filter Bar ---------- */
.filter-bar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
}

.filter-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.filter-select {
    padding: 6px 12px;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    min-width: 140px;
}

.filter-select:focus { border-color: var(--accent); }

.filter-select option { background: var(--bg-card); }

.quality-tags {
    display: flex;
    gap: 6px;
}

.quality-tag {
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.quality-tag:hover, .quality-tag.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ---------- Sections ---------- */
.main {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 32px 24px 64px;
}

.section { margin-bottom: 40px; }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
}

.section-more {
    font-size: 13px;
    color: var(--accent);
    font-weight: 500;
    transition: var(--transition);
}
.section-more:hover { color: var(--accent-hover); }

.result-count {
    font-size: 13px;
    color: var(--text-muted);
}

/* ---------- Movie Row (Horizontal Scroll) ---------- */
.movie-row {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
}

.movie-row::-webkit-scrollbar { height: 4px; }
.movie-row::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 2px; }

/* ---------- Movie Grid ---------- */
.movie-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 20px;
}

/* ---------- Movie Card ---------- */
.movie-card {
    flex: 0 0 185px;
    scroll-snap-align: start;
    cursor: pointer;
    transition: transform var(--transition);
    position: relative;
}

.movie-grid .movie-card {
    flex: none;
}

.movie-card:hover { transform: translateY(-6px); }

.card-poster {
    position: relative;
    aspect-ratio: 2/3;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
}

.card-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

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

.card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 50%);
    opacity: 0;
    transition: opacity var(--transition);
    display: flex;
    align-items: flex-end;
    padding: 12px;
}

.movie-card:hover .card-overlay { opacity: 1; }

.card-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 48px;
    height: 48px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

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

.card-play svg { fill: #fff; width: 20px; margin-left: 3px; }

.card-badges {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 2;
}

.card-badge {
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 700;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.card-badge-quality { background: var(--accent); color: #fff; }
.card-badge-rating {
    background: rgba(0,0,0,0.7);
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    gap: 3px;
}

.card-info {
    padding: 10px 2px 0;
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.card-meta {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    gap: 8px;
}

/* ---------- Loading Skeleton ---------- */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
}

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

.skeleton-card { width: 185px; height: 320px; flex-shrink: 0; }

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 32px;
    flex-wrap: wrap;
}

.page-btn {
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: var(--transition);
    padding: 0 12px;
}

.page-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    padding: 24px;
    overflow-y: auto;
}

.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
    width: 100%;
    max-width: 900px;
    background: var(--bg-modal);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    transform: translateY(30px);
    transition: transform 0.35s ease;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-overlay.open .modal { transform: translateY(0); }

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

.modal-close:hover { background: var(--accent); }

.modal-backdrop {
    width: 100%;
    height: 300px;
    background-size: cover;
    background-position: center;
    position: relative;
}

.modal-backdrop::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, var(--bg-modal) 0%, transparent 100%);
}

.modal-body {
    display: flex;
    gap: 24px;
    padding: 0 32px 32px;
    margin-top: -80px;
    position: relative;
}

.modal-poster {
    flex-shrink: 0;
    width: 200px;
    position: relative;
}

.modal-poster img {
    width: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.modal-rating {
    position: absolute;
    top: -12px;
    right: -12px;
    background: var(--accent-gold);
    color: #000;
    font-weight: 800;
    font-size: 14px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.modal-info { flex: 1; min-width: 0; }

.modal-title {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 8px;
    line-height: 1.2;
}

.modal-meta {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.modal-genres {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.genre-tag {
    padding: 4px 12px;
    font-size: 12px;
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
}

.modal-overview {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 20px;
}

.modal-cast { margin-bottom: 20px; }
.modal-cast h4 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.cast-list {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.cast-item {
    flex-shrink: 0;
    text-align: center;
    width: 70px;
}

.cast-img {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 6px;
    background: var(--bg-card);
}

.cast-name {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
}

.modal-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.detail-item {
    padding: 12px;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.detail-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.detail-value {
    font-size: 14px;
    font-weight: 600;
}

/* ---------- Trailer Overlay ---------- */
.trailer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.95);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.trailer-overlay.open { opacity: 1; visibility: visible; }

.trailer-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    font-size: 28px;
    color: #fff;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.trailer-container {
    width: 90vw;
    max-width: 1000px;
    aspect-ratio: 16/9;
}

.trailer-container iframe {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-lg);
}

/* ---------- Footer ---------- */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 48px 0 24px;
}

.footer-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 24px;
}

.footer-brand {
    margin-bottom: 32px;
}

.footer-brand .logo-text { font-size: 22px; font-weight: 800; }
.footer-desc {
    font-size: 13px;
    color: var(--text-muted);
    max-width: 400px;
    margin-top: 8px;
}

.footer-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 32px;
    margin-bottom: 32px;
}

.footer-col h4 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.footer-col a {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 4px 0;
    transition: var(--transition);
}

.footer-col a:hover { color: var(--accent); }

.footer-bottom {
    border-top: 1px solid var(--border);
    padding-top: 20px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}

.footer-bottom a { color: var(--accent); }

/* ---------- Back to Top ---------- */
.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    background: var(--accent);
    color: #fff;
    font-size: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 900;
}

.back-to-top.visible { opacity: 1; visibility: visible; }
.back-to-top:hover { transform: translateY(-2px); background: var(--accent-hover); }

/* ---------- No Results ---------- */
.no-results {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-muted);
}

.no-results-icon { font-size: 64px; margin-bottom: 16px; }
.no-results h3 { font-size: 20px; color: var(--text-secondary); margin-bottom: 8px; }
.no-results p { font-size: 14px; }

/* ---------- Responsive & Mobile Optimization ---------- */
@media (max-width: 992px) {
    .header-inner { padding: 0 16px; gap: 12px; }
    .hero { height: 60vh; min-height: 440px; }
    .hero-title { font-size: 32px; }
}

@media (max-width: 768px) {
    :root {
        --header-h: 58px;
    }
    .header-inner { padding: 0 12px; gap: 8px; }
    .nav { display: none; }
    .nav.open {
        display: flex;
        position: absolute;
        top: var(--header-h);
        left: 0;
        right: 0;
        background: rgba(18, 18, 26, 0.98);
        backdrop-filter: blur(16px);
        border-bottom: 1px solid var(--border);
        padding: 16px 20px;
        box-shadow: 0 10px 25px rgba(0,0,0,0.8);
        z-index: 1001;
    }
    .nav.open .nav-list {
        flex-direction: column;
        width: 100%;
        align-items: stretch;
        gap: 6px;
    }
    .nav-link {
        padding: 10px 14px;
        font-size: 15px;
        background: rgba(255,255,255,0.03);
        border-radius: 8px;
    }
    .menu-toggle { display: flex; }

    /* Total Content Badge on Mobile */
    .total-content-badge {
        font-size: 10px !important;
        padding: 3px 8px !important;
    }

    .hero {
        height: 52vh;
        min-height: 380px;
        margin-top: var(--header-h);
    }
    .hero-content { padding: 0 16px 24px; }
    .hero-title { font-size: 24px; line-height: 1.25; }
    .hero-overview { font-size: 13px; -webkit-line-clamp: 2; margin-bottom: 12px; }
    .hero-actions { display: flex; gap: 10px; width: 100%; }
    .hero-actions .btn { flex: 1; justify-content: center; padding: 10px 16px; font-size: 13px; }

    .main { padding: 20px 12px 48px; }
    .section-title { font-size: 17px; }

    .filter-inner { padding: 0 12px; gap: 10px; }
    .filter-group { flex: 1 1 45%; }
    .filter-select { width: 100%; min-width: 0; font-size: 12px; }

    /* Compact Mobile Touch-Friendly Card Grid */
    .movie-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    .movie-card {
        flex: 0 0 135px;
        border-radius: 6px;
    }
    .card-poster {
        border-radius: 6px;
    }
    .card-title {
        font-size: 12px;
        line-height: 1.2;
        margin-top: 4px;
    }
    .card-meta {
        font-size: 10px;
    }

    /* Modal Mobile */
    .modal-overlay { padding: 12px; }
    .modal { border-radius: 12px; max-height: 94vh; }
    .modal-backdrop { height: 160px; }
    .modal-body {
        flex-direction: column;
        padding: 0 16px 20px;
        margin-top: -50px;
        gap: 16px;
    }
    .modal-poster { width: 110px; margin: 0 auto; }
    .modal-title { font-size: 20px; text-align: center; }
    .modal-meta { justify-content: center; font-size: 12px; }
    .modal-genres { justify-content: center; }
    .modal-overview { font-size: 13px; text-align: center; }
    .modal-details-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }

    .search-input.open { width: 160px; }
}

@media (max-width: 480px) {
    .movie-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .movie-card {
        flex: 0 0 125px;
    }
    .card-badges {
        top: 4px;
        left: 4px;
        gap: 3px;
    }
    .card-badge {
        padding: 1px 5px;
        font-size: 9px;
    }
    .hero-title { font-size: 21px; }
    .search-input.open { width: 130px; }
    .total-content-badge span:last-child {
        font-size: 10px;
    }
}
