/* ===== CSS Variables ===== */
:root {
    --bg-primary: #0d0d12;
    --bg-secondary: #16161d;
    --bg-tertiary: #1e1e26;
    --bg-card: #1a1a22;
    --accent: #f5c518;
    --accent-hover: #e6b800;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --border-color: #2a2a35;
    --gradient-purple: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-pink: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-orange: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    --gradient-blue: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --gradient-green: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    --nav-height: 70px;
    --header-height: 60px;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

img {
    max-width: 100%;
    display: block;
}

/* ===== App Container ===== */
#app {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    background: var(--bg-primary);
}

/* ===== Header ===== */
.app-header {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: linear-gradient(to bottom, var(--bg-primary) 0%, var(--bg-primary) 60%, transparent 100%);
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    color: var(--accent);
}

.logo-icon svg {
    width: 100%;
    height: 100%;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-slogan {
    font-size: 11px;
    color: var(--text-secondary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition-fast);
}

.header-btn svg {
    width: 22px;
    height: 22px;
    color: var(--text-secondary);
}

.header-btn:active {
    background: var(--bg-tertiary);
}

/* ===== Filter Tabs ===== */
.filter-tabs {
    position: fixed;
    top: var(--header-height);
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-primary);
    z-index: 99;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.filter-tabs::-webkit-scrollbar {
    display: none;
}

.filter-tab {
    flex-shrink: 0;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 4px;
}

.filter-tab.active {
    background: var(--bg-tertiary);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.filter-tab.dropdown svg {
    opacity: 0.7;
}

/* ===== Pages Container ===== */
.pages-container {
    padding-top: calc(var(--header-height) + 52px);
    padding-bottom: calc(var(--nav-height) + 20px);
    min-height: 100vh;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Hero Slider ===== */
.hero-slider {
    position: relative;
    padding: 0 16px;
    margin-bottom: 24px;
}

.slider-container {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
    gap: 16px;
    scroll-behavior: smooth;
}

.slider-container::-webkit-scrollbar {
    display: none;
}

.slider-item {
    flex: 0 0 100%;
    scroll-snap-align: center;
}

.hero-card {
    position: relative;
    border-radius: var(--radius-xl);
    overflow: hidden;
    background: var(--bg-card);
}

.hero-poster-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    padding: 20px;
    padding-bottom: 0;
}

.hero-poster {
    width: 180px;
    height: 270px;
    object-fit: cover;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.hero-side-poster {
    position: absolute;
    width: 120px;
    height: 180px;
    object-fit: cover;
    border-radius: var(--radius-md);
    opacity: 0.4;
    filter: blur(1px);
    transition: var(--transition-normal);
}

.hero-side-poster.left {
    left: -40px;
    top: 50%;
    transform: translateY(-50%) rotate(-5deg);
}

.hero-side-poster.right {
    right: -40px;
    top: 50%;
    transform: translateY(-50%) rotate(5deg);
}

.hero-info {
    padding: 20px;
    text-align: center;
}

.hero-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hero-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.hero-buttons {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.hero-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-lg);
    transition: var(--transition-fast);
}

.hero-btn.primary {
    background: var(--accent);
    color: #000;
}

.hero-btn.primary:active {
    background: var(--accent-hover);
    transform: scale(0.98);
}

.hero-btn.secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.hero-btn.secondary:active {
    background: var(--bg-tertiary);
}

.hero-btn svg {
    width: 18px;
    height: 18px;
}

.hero-meta {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.meta-badge {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
}

.meta-badge.imdb {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
}

.hero-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.slider-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 16px;
}

.slider-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-color);
    transition: var(--transition-fast);
}

.slider-dot.active {
    width: 24px;
    border-radius: 4px;
    background: var(--text-primary);
}

/* ===== Sections ===== */
.section {
    margin-bottom: 28px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.see-all-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-secondary);
}

/* ===== Interest Tags ===== */
.interest-tags {
    display: flex;
    gap: 12px;
    padding: 0 16px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.interest-tags::-webkit-scrollbar {
    display: none;
}

.interest-tag {
    flex-shrink: 0;
    padding: 16px 28px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    border-radius: var(--radius-lg);
    transition: var(--transition-fast);
}

.interest-tag:nth-child(1) {
    background: var(--gradient-purple);
}

.interest-tag:nth-child(2) {
    background: var(--gradient-pink);
}

.interest-tag:nth-child(3) {
    background: var(--gradient-orange);
}

.interest-tag:nth-child(4) {
    background: var(--gradient-blue);
}

.interest-tag:nth-child(5) {
    background: var(--gradient-green);
}

.interest-tag:active {
    transform: scale(0.95);
}

/* ===== Top 10 List ===== */
.top10-list {
    display: flex;
    gap: 16px;
    padding: 0 16px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.top10-list::-webkit-scrollbar {
    display: none;
}

.top10-card {
    flex-shrink: 0;
    width: 140px;
    cursor: pointer;
}

.top10-poster-wrapper {
    position: relative;
    margin-bottom: 8px;
}

.top10-poster {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.top10-rank {
    position: absolute;
    bottom: -10px;
    left: -8px;
    font-size: 48px;
    font-weight: 800;
    color: var(--text-primary);
    text-shadow:
        -2px -2px 0 var(--bg-primary),
        2px -2px 0 var(--bg-primary),
        -2px 2px 0 var(--bg-primary),
        2px 2px 0 var(--bg-primary),
        0 4px 8px rgba(0, 0, 0, 0.5);
    line-height: 1;
}

.top10-badges {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.episode-badge {
    padding: 3px 6px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.episode-badge.sub {
    background: rgba(76, 175, 80, 0.9);
}

.episode-badge.dub {
    background: rgba(255, 152, 0, 0.9);
}

.top10-info {
    padding-left: 4px;
}

.top10-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top10-subtitle {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Search Page ===== */
.search-container {
    padding: 0 16px;
    margin-bottom: 16px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.search-box svg {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    font-size: 15px;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.filter-options {
    display: flex;
    gap: 8px;
    padding: 0 16px;
    margin-bottom: 20px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.filter-options::-webkit-scrollbar {
    display: none;
}

.filter-options select {
    flex-shrink: 0;
    padding: 8px 14px;
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-secondary);
    outline: none;
    appearance: none;
    cursor: pointer;
}

/* ===== Movie Grid ===== */
.movie-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    padding: 0 16px;
}

.movie-card {
    cursor: pointer;
    transition: var(--transition-fast);
}

.movie-card:active {
    transform: scale(0.98);
}

.movie-poster {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-radius: var(--radius-md);
    margin-bottom: 8px;
}

.movie-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.movie-year {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== Account Page ===== */
.account-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 16px;
    margin-bottom: 16px;
}

.account-avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--accent);
}

.account-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.account-info {
    flex: 1;
}

.account-name {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.account-badge {
    display: inline-block;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    background: var(--bg-tertiary);
    border-radius: 20px;
    color: var(--text-secondary);
}

.account-menu {
    padding: 0 16px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition-fast);
}

.menu-item:active {
    opacity: 0.7;
}

.menu-item svg {
    width: 22px;
    height: 22px;
    color: var(--text-secondary);
}

.menu-item span {
    flex: 1;
    font-size: 15px;
}

.menu-item .chevron {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

/* ===== Page Title ===== */
.page-title {
    font-size: 24px;
    font-weight: 700;
    padding: 0 16px;
    margin-bottom: 20px;
}

.empty-text {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 16px;
}

/* ===== Bottom Navigation ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.nav-item.active {
    color: var(--accent);
}

.nav-icon {
    width: 44px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    transition: var(--transition-fast);
}

.nav-item.active .nav-icon {
    background: rgba(245, 197, 24, 0.15);
}

.nav-icon svg {
    width: 24px;
    height: 24px;
}

.nav-item span {
    font-size: 11px;
    font-weight: 500;
}

/* ===== Detail Overlay ===== */
.detail-overlay {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: 100%;
    background: var(--bg-primary);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-normal);
}

.detail-overlay.active {
    opacity: 1;
    visibility: visible;
}

.detail-container {
    height: 100%;
    overflow-y: auto;
}

.close-btn {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    z-index: 10;
}

.close-btn svg {
    width: 20px;
    height: 20px;
}

/* ===== Detail Content ===== */
.detail-hero {
    position: relative;
    height: 280px;
}

.detail-backdrop {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.detail-gradient {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 150px;
    background: linear-gradient(to top, var(--bg-primary), transparent);
}

.detail-main {
    padding: 0 16px;
    margin-top: -60px;
    position: relative;
}

.detail-buttons {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.detail-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--radius-lg);
    transition: var(--transition-fast);
}

.detail-btn.primary {
    background: var(--accent);
    color: #000;
}

.detail-btn.secondary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

.detail-btn svg {
    width: 20px;
    height: 20px;
}

.detail-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.detail-tag {
    padding: 6px 12px;
    font-size: 12px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-secondary);
}

.detail-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    color: #4caf50;
    font-size: 13px;
}

.detail-progress svg {
    width: 18px;
    height: 18px;
}

.detail-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 20px;
}

.detail-expand {
    color: var(--text-primary);
    font-weight: 500;
}

.detail-actions {
    display: flex;
    justify-content: space-around;
    padding: 16px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.action-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
}

.action-item svg {
    width: 24px;
    height: 24px;
}

.action-item span {
    font-size: 11px;
}

.action-item.rating {
    position: relative;
}

.rating-value {
    position: absolute;
    top: -4px;
    right: -8px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 700;
    background: var(--accent);
    color: #000;
    border-radius: 8px;
}

/* ===== Episodes Section ===== */
.episodes-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.tabs {
    display: flex;
    gap: 20px;
}

.tab {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    padding-bottom: 8px;
    border-bottom: 2px solid transparent;
}

.tab.active {
    color: var(--text-primary);
    border-color: var(--accent);
}

.episodes-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.season-select {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}

.season-select svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.language-select {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.language-select svg {
    width: 18px;
    height: 18px;
}

.episodes-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding-bottom: 100px;
}

.episode-btn {
    padding: 14px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: var(--transition-fast);
}

.episode-btn:active {
    transform: scale(0.95);
}

.episode-btn.watched {
    background: var(--bg-secondary);
    color: var(--text-muted);
}

.episode-btn.watching {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

/* ===== Responsive ===== */
@media (max-width: 380px) {
    .hero-poster {
        width: 160px;
        height: 240px;
    }

    .hero-title {
        font-size: 18px;
    }

    .top10-card {
        width: 120px;
    }

    .top10-poster {
        height: 170px;
    }

    .top10-rank {
        font-size: 40px;
    }
}

/* ===== Loading States ===== */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 0%, var(--bg-secondary) 50%, var(--bg-tertiary) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}