/* macOS / Apple TV Inspired Theme */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* macOS System Colors (Dark Mode - Default) */
    --macos-bg: #000000;
    --macos-sidebar: rgba(28, 28, 30, 0.75);
    --macos-card: rgba(44, 44, 46, 0.6);
    --macos-card-hover: rgba(58, 58, 60, 0.8);
    --macos-border: rgba(255, 255, 255, 0.1);
    --macos-accent: #0A84FF;
    --macos-text-primary: #FFFFFF;
    --macos-text-secondary: rgba(235, 235, 245, 0.6);
    --macos-text-tertiary: rgba(235, 235, 245, 0.3);

    --macos-item-hover: rgba(255, 255, 255, 0.08);
    --macos-item-active: rgba(255, 255, 255, 0.12);
    --header-bg: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
    --search-bg: rgba(255, 255, 255, 0.1);
    --modal-bg: rgba(30, 30, 30, 0.85);

    /* Materials */
    --glass-blur: blur(25px) saturate(180%);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);

    --sidebar-width: 260px;
    --sidebar-collapsed: 68px;
}

[data-theme="light"] {
    /* macOS System Colors (Light Mode) */
    --macos-bg: #F5F5F7;
    --macos-sidebar: rgba(255, 255, 255, 0.65);
    --macos-card: rgba(255, 255, 255, 0.6);
    --macos-card-hover: rgba(255, 255, 255, 0.9);
    --macos-border: rgba(0, 0, 0, 0.08);
    --macos-accent: #007AFF;
    --macos-text-primary: #1D1D1F;
    --macos-text-secondary: rgba(60, 60, 67, 0.7);
    --macos-text-tertiary: rgba(60, 60, 67, 0.4);

    --macos-item-hover: rgba(0, 0, 0, 0.05);
    --macos-item-active: rgba(0, 0, 0, 0.1);
    --header-bg: linear-gradient(to bottom, rgba(245, 245, 247, 0.9), transparent);
    --search-bg: rgba(0, 0, 0, 0.05);
    --modal-bg: rgba(255, 255, 255, 0.8);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.12);
}

* {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--macos-bg);
    color: var(--macos-text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", sans-serif;
    font-size: 13px;
    /* Standard macOS body size */
    margin: 0;
    height: 100vh;
    overflow: hidden;
    letter-spacing: -0.01em;
}

/* SF Pro Mimicry */
h1,
h2,
h3,
h4,
.font-title {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", sans-serif;
    letter-spacing: -0.02em;
}

/* Base Layout */
.main-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* --- SIDEBAR (macOS Style) --- */
#sidebar {
    width: var(--sidebar-collapsed);
    height: 100%;
    background: var(--macos-sidebar);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    /* Safari support */
    border-right: 1px solid rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    padding-top: 38px;
    /* Traffic lights space equiv */
    transition: width 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 100;
    position: relative;
    flex-shrink: 0;
}

/* Expand on hover logic if desired, or toggle */
#sidebar:hover {
    width: var(--sidebar-width);
}

.sidebar-logo {
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Centered when collapsed */
    margin-bottom: 20px;
    opacity: 0.9;
    transition: all 0.3s ease;
    overflow: hidden;
}

#sidebar:hover .sidebar-logo {
    justify-content: flex-start;
    padding-left: 24px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.logo-icon rect {
    fill: var(--macos-text-primary);
}

.logo-icon path {
    fill: var(--macos-bg);
}

/* Utilities */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 8px;
}

.gap-3 {
    gap: 12px;
}

.gap-4 {
    gap: 16px;
}

.w-full {
    width: 100%;
}

.h-full {
    height: 100%;
}

.absolute {
    position: absolute;
}

.relative {
    position: relative;
}

.inset-0 {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

.hidden {
    display: none !important;
}

.mr-auto {
    margin-right: auto;
}

.text-lg {
    font-size: 18px;
}

.font-semibold {
    font-weight: 600;
}

.logo-text {
    font-size: 17px;
    font-weight: 600;
    margin-left: 12px;
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.2s ease;
    white-space: nowrap;
}

#sidebar:hover .logo-text {
    opacity: 1;
    transform: translateX(0);
    transition-delay: 0.1s;
}

.nav-section {
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    height: 40px;
    border-radius: 8px;
    /* macOS rounded rect selection */
    display: flex;
    align-items: center;
    padding: 0 10px;
    cursor: pointer;
    color: var(--macos-text-secondary);
    transition: all 0.15s ease;
    text-decoration: none;
    position: relative;
}

.nav-item:hover {
    background: var(--macos-item-hover);
    /* Minimal hover state */
    color: var(--macos-text-primary);
}

.nav-item.active {
    background: var(--macos-item-active);
    /* Active state neutral */
    color: var(--macos-accent);
    /* Blue tint for active icon/text */
    font-weight: 500;
}

.nav-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s;
}

.nav-label {
    margin-left: 14px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.1s;
    white-space: nowrap;
}

#sidebar:hover .nav-label {
    opacity: 1;
    transition-delay: 0.1s;
}

.divider {
    height: 1px;
    background: var(--macos-border);
    margin: 12px 20px;
    opacity: 0.5;
}

/* --- CONTENT AREA --- */
.content-area {
    flex: 1;
    position: relative;
    background: var(--macos-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header / Toolbar */
.mac-header {
    height: 52px;
    display: flex;
    align-items: center;
    padding: 0 24px 0 24px;
    /* Transparent or subtle blur for scrolling content underneath */
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--header-bg);
}

.search-bar-container {
    background: var(--search-bg);
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    width: 280px;
    height: 32px;
    transition: background 0.2s;
    border: 1px solid transparent;
}

.search-bar-container:focus-within {
    background: var(--macos-item-active);
    border-color: var(--macos-accent);
}

.search-icon {
    color: var(--macos-text-tertiary);
    width: 14px;
    height: 14px;
}

.search-input {
    background: transparent;
    border: none;
    color: white;
    font-size: 13px;
    margin-left: 8px;
    width: 100%;
    outline: none;
}

.search-input::placeholder {
    color: var(--macos-text-tertiary);
}

/* --- SCROLL AREA --- */
#content-container {
    flex: 1;
    overflow-y: overlay;
    /* Chrome specific for overlay scrollbars logic */
    overflow-x: hidden;
    padding-top: 0;
    /* Hero goes full bleed to top */
}

/* Scrollbar styling */
#content-container::-webkit-scrollbar {
    width: 12px;
}

#content-container::-webkit-scrollbar-track {
    background: transparent;
}

#content-container::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    border: 4px solid transparent;
    /* Creates padding effect */
    background-clip: content-box;
    transition: background-color 0.2s;
}

#content-container::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* --- HERO SECTION (Apple TV Style) --- */
#hero-section {
    height: 70vh;
    /* Immersive large hero */
    min-height: 500px;
    position: relative;
    width: 100%;
    margin-bottom: 40px;
    mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
}

.hero-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 1.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

.hero-slide.active {
    opacity: 1;
    z-index: 2;
}

.hero-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 20%;
    /* Focus on upper part usually faces */
}

.hero-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, var(--macos-bg) 0%, transparent 60%);
    z-index: 3;
}

.hero-info {
    position: absolute;
    bottom: 80px;
    left: 40px;
    /* Aligns with grid padding */
    z-index: 10;
    /* max-width: 600px; */
    width: 60%;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
}

.hero-logo-text {
    font-size: 42px;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 12px;
    background: linear-gradient(to bottom, #fff, #ddd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    /* Fallback if needed */
    color: white;
}

.hero-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 20px;
}

.meta-badge {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hero-desc {
    font-size: 16px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.8);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 24px;
    font-weight: 400;
}

.action-btn {
    background: white;
    color: black;
    border: none;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.action-btn:hover {
    transform: scale(1.02);
    background: #f2f2f5;
}

.action-btn.secondary {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    backdrop-filter: blur(10px);
}

.action-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* --- GRIDS & CARDS --- */
.section-container {
    padding: 0 40px 40px 40px;
}

.section-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--macos-text-primary);
}

.horizontal-scroll {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 20px;
    /* Space for shadows */
    margin: 0 -40px;
    /* Bleed out */
    padding-left: 40px;
    /* Push in content */
    padding-right: 40px;
    scrollbar-width: none;
    /* Hide standard scrollbar */
}

.horizontal-scroll::-webkit-scrollbar {
    display: none;
}

/* Card - Modern Poster Style */
.media-card {
    flex-shrink: 0;
    width: 200px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    group: hover;
    /* Tailwind logic equivalent */
}

/* The Image Container */
.card-img-container {
    width: 200px;
    height: 300px;
    /* 2:3 aspect */
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-md);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    background: var(--macos-card);
}

.media-card:hover .card-img-container {
    transform: scale(1.05);
    /* Apple standard focus scale */
    box-shadow: var(--shadow-lg);
    z-index: 10;
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s;
}

/* Text Below Card (Apple TV style) */
.card-info {
    opacity: 0.7;
    transition: opacity 0.3s;
    padding-left: 2px;
}

.media-card:hover .card-info {
    opacity: 1;
}

.card-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--macos-text-primary);
}

.card-subtitle {
    font-size: 12px;
    color: var(--macos-text-tertiary);
    margin-top: 2px;
}

/* Standard Grid */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    /* Slightly smaller for density */
    gap: 24px;
    row-gap: 32px;
}

.grid-container .media-card {
    width: 100%;
    /* Fill grid cell */
}

.grid-container .card-img-container {
    width: 100%;
    height: auto;
    aspect-ratio: 2/3;
}

/* --- DETAIL VIEW (Overlay/Modal Feel) --- */
#view-detail {
    position: absolute;
    inset: 0;
    background: var(--macos-bg);
    z-index: 200;
    overflow-y: auto;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
    animation: fadeIn 0.4s ease;
}

.detail-header {
    height: 50vh;
    position: relative;
    mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
}

.detail-img-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.4;
    filter: blur(20px);
    transform: scale(1.1);
}

.detail-content {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 40px 80px 40px;
    position: relative;
    z-index: 10;
    margin-top: -100px;
    /* Overlap header */
}

.detail-columns {
    display: flex;
    gap: 40px;
}

.detail-poster {
    width: 240px;
    height: 360px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    object-fit: cover;
    background: var(--macos-card);
    flex-shrink: 0;
}

.detail-text {
    flex: 1;
    padding-top: 20px;
}

.detail-title {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--macos-text-primary);
}

.detail-meta-row {
    display: flex;
    gap: 16px;
    font-size: 14px;
    color: var(--macos-text-secondary);
    margin-bottom: 24px;
    align-items: center;
}

.tag-pill {
    background: var(--macos-item-hover);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--macos-text-primary);
}

.detail-synopsis {
    font-size: 16px;
    line-height: 1.6;
    color: var(--macos-text-primary);
    opacity: 0.9;
    margin-bottom: 32px;
}

/* --- TABS & SEGMENTS --- */
.tab-nav {
    display: flex;
    gap: 24px;
    border-bottom: 1px solid var(--macos-border);
    margin-bottom: 32px;
    padding-bottom: 1px;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--macos-text-tertiary);
    font-size: 14px;
    font-weight: 600;
    padding: 12px 4px;
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}

.tab-btn:hover {
    color: var(--macos-text-primary);
}

.tab-btn.active {
    color: var(--macos-accent);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--macos-accent);
    border-radius: 2px;
}

/* Character Grid */
.char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 20px;
}

.char-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    overflow: hidden;
    text-align: center;
    padding-bottom: 12px;
    transition: background 0.2s;
}

.char-card:hover {
    background: rgba(255, 255, 255, 0.1);
}

.char-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    margin-bottom: 8px;
}

/* Episode List */
.ep-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ep-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: background 0.2s;
}

.ep-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.ep-number {
    font-weight: 600;
    color: var(--macos-accent);
    width: 40px;
}

.ep-title {
    flex: 1;
    font-weight: 500;
}

.ep-date {
    font-size: 12px;
    color: #888;
}


/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.hidden {
    display: none !important;
}

/* Settings Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--modal-bg);
    backdrop-filter: blur(40px) saturate(200%);
    width: 400px;
    border-radius: 12px;
    border: 1px solid var(--macos-border);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    color: var(--macos-text-primary);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--macos-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: var(--macos-text-tertiary);
    font-size: 20px;
    cursor: pointer;
}

.close-btn:hover {
    color: var(--macos-text-primary);
}

.modal-body {
    padding: 20px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

/* Toggle Switch (iOS style) */
.toggle-switch {
    appearance: none;
    width: 44px;
    height: 24px;
    background: rgba(120, 120, 128, 0.32);
    border-radius: 24px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.toggle-switch:checked {
    background: #34C759;
    /* Apple Green */
}

.toggle-switch:checked::after {
    transform: translateX(20px);
}