/**
 * IPTV Web App - Main Stylesheet
 * Dark theme with RTL support
 */

/* === CSS Variables === */
:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2234;
    --bg-card: #1e293b;
    --bg-hover: #2a3a52;
    --bg-active: #334155;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.3);

    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;

    --border: #1e293b;
    --border-focus: #3b82f6;

    --sidebar-width: 60px;
    --sidebar-expanded: 240px;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 200ms ease;

    --font-family: 'Heebo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

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

button, input {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    border: none;
    outline: none;
    background: none;
}

img {
    display: block;
    max-width: 100%;
}

/* === Layout === */
.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* === Sidebar (Icon Rail) === */
#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: rgba(17, 24, 39, 0.85);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-inline-end: 1px solid rgba(255,255,255,0.04);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 300ms cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    overflow: hidden;
    position: relative;
}

#sidebar:hover,
#sidebar.expanded {
    width: var(--sidebar-expanded);
    background: rgba(17, 24, 39, 0.95);
}

/* Overlay expanded sidebar over content */
#sidebar:hover ~ #main-content,
#sidebar.expanded ~ #main-content {
    /* Content doesn't shift — sidebar overlays */
}

#sidebar.hidden {
    transform: translateX(calc(var(--sidebar-width) * -1));
    opacity: 0;
    position: absolute;
}

[dir="rtl"] #sidebar.hidden {
    transform: translateX(var(--sidebar-width));
}

.sidebar-header {
    padding: 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 58px;
    overflow: hidden;
}

.sidebar-logo {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 6px;
    overflow-y: auto;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
    margin-bottom: 2px;
    position: relative;
    justify-content: center;
    white-space: nowrap;
    overflow: hidden;
}

#sidebar:hover .sidebar-item,
#sidebar.expanded .sidebar-item {
    justify-content: flex-start;
    padding: 12px 16px;
}

.sidebar-item:hover,
.sidebar-item.focused {
    background: var(--bg-hover);
}

.sidebar-item.active {
    background: transparent;
    color: var(--accent);
}

.sidebar-item.active::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

[dir="rtl"] .sidebar-item.active::before {
    border-radius: 3px 0 0 3px;
}

.sidebar-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.sidebar-icon svg {
    width: 100%;
    height: 100%;
}

.sidebar-label {
    font-size: 15px;
    font-weight: 500;
    opacity: 0;
    transition: opacity 200ms ease;
    overflow: hidden;
}

#sidebar:hover .sidebar-label,
#sidebar.expanded .sidebar-label {
    opacity: 1;
}

/* --- Sidebar Key Map (Debug Reference) --- */
.sidebar-keymap {
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    overflow-y: auto;
    max-height: 260px;
    display: none;
}
#sidebar:hover .sidebar-keymap,
#sidebar.expanded .sidebar-keymap {
    display: block;
}

.sidebar-keymap-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.sidebar-keymap-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 10px;
    align-items: center;
    font-size: 11px;
}

.sidebar-keymap-grid kbd {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
    font-family: inherit;
    font-size: 10px;
    color: var(--text-primary);
    white-space: nowrap;
    text-align: center;
}

.sidebar-keymap-grid span {
    color: var(--text-secondary);
}

.sidebar-keymap-grid .key-red { color: #ef4444; }
.sidebar-keymap-grid .key-green { color: #22c55e; }
.sidebar-keymap-grid .key-yellow { color: #eab308; }
.sidebar-keymap-grid .key-blue { color: #3b82f6; }

.sidebar-footer {
    padding: 8px 6px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
}

.sidebar-lang-btn {
    width: 100%;
    padding: 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    text-align: center;
    transition: background var(--transition);
}

.sidebar-lang-btn:hover,
.sidebar-lang-btn.focused {
    background: var(--bg-hover);
}

/* === Main Content === */
#main-content {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}

#main-content::-webkit-scrollbar {
    width: 6px;
}

#main-content::-webkit-scrollbar-track {
    background: transparent;
}

#main-content::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
}

#main-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.15);
}

/* Padding for non-home views */
#main-content > :not(.home-screen) {
    padding: 24px;
}

/* === View Title === */
.view-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.view-count {
    font-size: 16px;
    font-weight: 400;
    color: var(--text-muted);
}

/* === Category Tabs === */
.category-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 16px;
    margin-bottom: 16px;
    scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar {
    display: none;
}

.category-tab {
    padding: 8px 18px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 20px;
    background: rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    flex-shrink: 0;
}

.category-tab:hover,
.category-tab.focused {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}

.category-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* === Channel Section Headers === */
.channel-section-header {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 18px 0 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.channel-section-header:first-of-type {
    padding-top: 0;
}

/* === Channel Grid === */
.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
    margin-bottom: 8px;
}

.channel-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    cursor: pointer;
    transition: all var(--transition);
    border: 2px solid transparent;
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.channel-card:hover,
.channel-card:focus,
.channel-card.focused {
    background: var(--bg-hover);
    border-color: var(--accent);
    box-shadow: 0 0 16px var(--accent-glow);
    outline: none;
}

.channel-logo-wrap {
    width: 42px;
    height: 42px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.channel-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.channel-logo-placeholder {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
}

.channel-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.channel-header-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.channel-num {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    min-width: 18px;
}

.channel-name {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.channel-fav-icon {
    color: var(--warning);
    font-size: 12px;
    flex-shrink: 0;
    margin-inline-start: auto;
}

/* === Channel EPG (current program) === */
.channel-epg {
    margin-top: 1px;
    overflow: hidden;
}

.epg-now {
    font-size: 12px;
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.epg-now.epg-placeholder {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 11px;
}

.epg-progress {
    height: 2px;
    background: var(--bg-tertiary);
    border-radius: 1px;
    margin-top: 3px;
    overflow: hidden;
}

.epg-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 1px;
    transition: width 1s linear;
}

/* === VOD Sections === */
.vod-section {
    margin-bottom: 24px;
}

.vod-section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* --- Continue Watching Row --- */
.vod-scroll-row {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-hover) transparent;
}

.resume-card {
    flex-shrink: 0;
    width: 160px;
    cursor: pointer;
    transition: all var(--transition);
    border-radius: var(--radius-sm);
}

.resume-card:hover,
.resume-card.focused {
    transform: scale(1.05);
    box-shadow: 0 0 16px var(--accent-glow);
}

.resume-poster {
    position: relative;
    aspect-ratio: 16/9;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 6px;
}

.resume-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.resume-poster-ph {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    background: var(--bg-tertiary);
}

.resume-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.4);
    color: white;
    font-size: 24px;
    opacity: 0;
    transition: opacity 200ms;
}

.resume-card:hover .resume-play-overlay {
    opacity: 1;
}

.resume-info {
    padding: 0 2px;
}

.resume-title {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.resume-time {
    font-size: 11px;
    color: var(--text-muted);
}

/* === VOD Grid === */
.vod-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}

.vod-card {
    cursor: pointer;
    transition: all var(--transition);
    border-radius: var(--radius);
    overflow: hidden;
}

.vod-card:hover,
.vod-card.focused {
    transform: scale(1.05);
    box-shadow: 0 0 20px var(--accent-glow);
}

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

.vod-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.vod-poster-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    font-weight: 700;
    color: var(--accent);
    background: var(--bg-tertiary);
}

.vod-resume-badge {
    position: absolute;
    bottom: 6px;
    inset-inline-end: 6px;
    width: 28px;
    height: 28px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.vod-watched-count {
    position: absolute;
    bottom: 6px;
    inset-inline-start: 6px;
    background: rgba(0,0,0,0.7);
    color: var(--text-secondary);
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.vod-title {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vod-category {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === Series Detail === */
.series-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.series-meta {
    font-size: 14px;
    color: var(--text-muted);
}

.back-btn {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.back-btn:hover, .back-btn.focused {
    background: var(--bg-hover);
}

.season-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.season-tab {
    padding: 8px 20px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.season-tab.active {
    background: var(--accent);
    color: white;
}

.episode-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    cursor: pointer;
    transition: background var(--transition);
    border: 2px solid transparent;
}

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

.episode-card.has-progress {
    border-inline-start: 3px solid var(--accent);
}

.episode-num {
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

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

.episode-title {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.episode-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.episode-resume {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    color: var(--accent);
    font-size: 13px;
}

.episode-resume-icon {
    font-size: 14px;
}

.episode-resume-time {
    font-weight: 600;
}

/* === EPG Browser (VOD-style) === */
.epg-browser {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.epg-browser-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    gap: 1px;
    background: var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

/* --- EPG Channel Sidebar --- */
.epg-channel-sidebar {
    width: 260px;
    flex-shrink: 0;
    overflow-y: auto;
    background: var(--bg-secondary);
    scrollbar-width: thin;
    scrollbar-color: var(--bg-hover) transparent;
}

.epg-ch-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 150ms ease;
    border-inline-start: 3px solid transparent;
}

.epg-ch-row:hover {
    background: var(--bg-hover);
}

.epg-ch-row.active {
    background: rgba(59, 130, 246, 0.12);
    border-inline-start-color: var(--accent);
}

.epg-ch-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    object-fit: contain;
    flex-shrink: 0;
    background: var(--bg-tertiary);
}

.epg-ch-icon-ph {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(59,130,246,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--accent);
    font-size: 14px;
    flex-shrink: 0;
}

.epg-ch-row-info {
    flex: 1;
    min-width: 0;
}

.epg-ch-row-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.epg-ch-row-now {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

/* --- EPG Program Panel --- */
.epg-program-panel {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-primary);
    scrollbar-width: thin;
    scrollbar-color: var(--bg-hover) transparent;
}

.epg-select-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: 12px;
}

.epg-select-icon {
    font-size: 48px;
    opacity: 0.4;
}

.epg-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 5;
}

.epg-panel-ch-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.epg-panel-logo {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: contain;
}

.epg-panel-ch-name {
    font-size: 18px;
    font-weight: 700;
}

.epg-day-tabs {
    display: flex;
    gap: 4px;
}

.epg-day-tab {
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 13px;
    cursor: pointer;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    transition: all 150ms ease;
}

.epg-day-tab:hover {
    background: var(--bg-hover);
}

.epg-day-tab.active {
    background: var(--accent);
    color: white;
}

/* --- Program List Items --- */
.epg-programs-list {
    padding: 8px 0;
}

.epg-loading-programs,
.epg-no-data {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

.epg-program-item {
    display: flex;
    gap: 16px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    transition: background 150ms ease;
}

.epg-program-item:hover {
    background: var(--bg-secondary);
}

.epg-program-item.past {
    opacity: 0.45;
}

.epg-program-item.now {
    background: rgba(59, 130, 246, 0.08);
    border-inline-start: 3px solid var(--accent);
}

.epg-program-time-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 55px;
    flex-shrink: 0;
}

.epg-program-start {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.epg-program-end {
    font-size: 11px;
    color: var(--text-muted);
}

.epg-program-detail {
    flex: 1;
    min-width: 0;
}

.epg-program-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.epg-live-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--accent);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    flex-shrink: 0;
    letter-spacing: 0.3px;
}

.epg-program-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.epg-program-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.epg-program-cats {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.epg-program-progress {
    height: 3px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.epg-program-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 1s linear;
}

/* === Search === */
.search-view {
    max-width: 800px;
}

.search-bar {
    margin-bottom: 24px;
}

.search-input {
    width: 100%;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 16px;
    color: var(--text-primary);
    transition: border-color var(--transition);
}

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

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

.search-count {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.search-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-result-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    border: 2px solid transparent;
}

.search-result-card:hover, .search-result-card.focused {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.search-result-logo {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.search-result-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.search-result-logo span {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
}

.search-result-name {
    font-weight: 600;
}

.search-result-name mark {
    background: var(--accent);
    color: white;
    padding: 0 2px;
    border-radius: 2px;
}

.search-result-group {
    font-size: 13px;
    color: var(--text-secondary);
}

.search-result-type {
    font-size: 12px;
    color: var(--text-muted);
}

/* === Settings === */
.settings-view {
    max-width: 600px;
}

.settings-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.settings-section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 14px;
    color: var(--text-secondary);
}

.settings-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.settings-row:last-child {
    margin-bottom: 0;
}

.settings-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    min-width: 200px;
}

.settings-input:focus {
    border-color: var(--accent);
}

.settings-btn {
    padding: 10px 20px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: all var(--transition);
}

.settings-btn:hover, .settings-btn.focused {
    background: var(--bg-hover);
}

.settings-btn.primary {
    background: var(--accent);
    color: white;
}

.settings-btn.primary:hover, .settings-btn.primary.focused {
    background: var(--accent-hover);
}

.settings-btn.active {
    background: var(--accent);
    color: white;
}

.settings-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.settings-upload-btn {
    display: inline-block;
    padding: 10px 20px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.settings-upload-btn:hover, .settings-upload-btn.focused {
    background: var(--bg-hover);
}

.settings-status {
    font-size: 13px;
    padding: 4px 8px;
}

.settings-status.success { color: var(--success); }
.settings-status.error { color: var(--error); }

.settings-info {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.8;
}

.settings-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 14px;
}

.settings-toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.settings-select {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    min-width: 100px;
}

.log-filters {
    gap: 8px;
}

/* === Log Viewer === */
.log-entries-container {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 10px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    direction: ltr;
    text-align: left;
}

.log-entry {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: baseline;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
}

.log-entry:hover {
    background: var(--bg-hover, rgba(255,255,255,0.03));
}

.log-time {
    color: var(--text-muted);
    flex-shrink: 0;
    font-size: 11px;
}

.log-badge {
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 600;
}

.log-badge-info    { background: #1e3a5f; color: #7eb8f7; }
.log-badge-warning { background: #5f4b1e; color: #f7d77e; }
.log-badge-error   { background: #5f1e1e; color: #f77e7e; }
.log-badge-cat     { background: var(--bg-tertiary); color: var(--text-secondary); }

.log-msg {
    color: var(--text-primary);
    flex: 1;
}

.log-ctx {
    color: var(--text-muted);
    font-size: 11px;
    width: 100%;
    word-break: break-all;
}

.log-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
}

/* === Welcome Screen === */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70vh;
    text-align: center;
}

.welcome-icon {
    color: var(--accent);
    margin-bottom: 20px;
    opacity: 0.8;
}

.welcome-screen h1 {
    font-size: 32px;
    margin-bottom: 10px;
}

.welcome-screen p {
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-size: 16px;
}

.welcome-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 450px;
}

.welcome-input {
    width: 100%;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 16px;
    color: var(--text-primary);
    text-align: center;
}

.welcome-input:focus {
    border-color: var(--accent);
}

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

.welcome-btn {
    padding: 14px 30px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    transition: all var(--transition);
    width: 100%;
    text-align: center;
}

.welcome-btn.primary {
    background: var(--accent);
    color: white;
}

.welcome-btn.primary:hover {
    background: var(--accent-hover);
}

.welcome-btn.secondary {
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.welcome-btn.secondary:hover {
    background: var(--bg-hover);
}

.welcome-divider {
    color: var(--text-muted);
    font-size: 14px;
    padding: 4px 0;
}

/* === Password Gate === */
.password-gate {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.password-gate.hidden {
    display: none;
}

.password-gate-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    max-width: 320px;
    width: 100%;
    padding: 0 20px;
}

.password-gate-icon {
    font-size: 64px;
}

.password-gate-box h2 {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.password-gate-box .welcome-input {
    max-width: 200px;
}

.password-gate-box .welcome-btn {
    max-width: 200px;
}

.password-error {
    color: var(--error);
    font-size: 14px;
    min-height: 20px;
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    grid-column: 1 / -1;
}

/* === Loading === */
.global-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 23, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms;
}

.global-loader.visible {
    opacity: 1;
    pointer-events: auto;
}

.loader-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--bg-hover);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

.loader-text {
    color: var(--text-secondary);
    font-size: 16px;
}

/* === Toast === */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transition: all 300ms ease;
    pointer-events: none;
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-success {
    background: var(--success);
    color: white;
}

.toast-error {
    background: var(--error);
    color: white;
}

.toast-info {
    background: var(--accent);
    color: white;
}

/* === Global Update Progress Bar === */
.update-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 300ms ease;
}
.update-bar.visible {
    opacity: 1;
}
.update-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), #60a5fa);
    border-radius: 0 2px 2px 0;
    transition: width 400ms ease;
    box-shadow: 0 0 8px var(--accent-glow);
}
/* Subtle pulse when actively loading */
.update-bar.visible .update-bar-fill {
    animation: update-bar-pulse 2s ease-in-out infinite;
}
@keyframes update-bar-pulse {
    0%, 100% { box-shadow: 0 0 8px var(--accent-glow); }
    50% { box-shadow: 0 0 16px var(--accent-glow), 0 0 4px var(--accent); }
}
.update-bar-text {
    position: absolute;
    top: 3px;
    right: 12px;
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    padding: 3px 10px;
    border-radius: 0 0 6px 6px;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 300ms ease, transform 300ms ease;
    white-space: nowrap;
}
.update-bar.visible .update-bar-text:not(:empty) {
    opacity: 1;
    transform: translateY(0);
}

/* === Focus Styles (for TV navigation) === */
[data-focused="true"],
.focused {
    outline: 3px solid var(--accent) !important;
    outline-offset: 2px;
}

/* === VOD Catalog === */
.vod-catalog {
    padding: 20px;
}

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

.vod-catalog-search {
    flex: 0 1 300px;
}

.vod-search-input {
    width: 100%;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}

.vod-search-input:focus {
    border-color: var(--accent);
}

.vod-catalog-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.vod-cat-tab {
    padding: 6px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
}

.vod-cat-tab:hover,
.vod-cat-tab.focused {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.vod-cat-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.vod-catalog-count {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.vod-catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

.vod-show-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
}

.vod-show-card:hover,
.vod-show-card.focused {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.vod-show-poster {
    position: relative;
    aspect-ratio: 2/3;
    background: var(--bg-tertiary);
    overflow: hidden;
}

.vod-show-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.vod-poster-img {
    position: absolute;
    inset: 0;
}

.vod-show-poster-ph {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    color: var(--accent);
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
}

.vod-show-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 22px;
    text-align: center;
}

[dir="rtl"] .vod-show-badge {
    right: auto;
    left: 6px;
}

.vod-show-info {
    padding: 10px;
}

.vod-show-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.vod-show-cat {
    font-size: 11px;
    color: var(--accent);
    margin-bottom: 4px;
}

.vod-show-desc {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- VOD Catalog Detail --- */
.vod-detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}

.vod-back-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    transition: all var(--transition);
    white-space: nowrap;
}

.vod-back-btn:hover {
    background: var(--bg-hover);
}

.vod-detail-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.vod-detail-info {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.vod-detail-poster {
    width: 120px;
    height: 180px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.vod-detail-text {
    flex: 1;
    min-width: 0;
}

.vod-detail-desc {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 12px;
    max-width: 700px;
}

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

.vod-detail-meta span {
    background: var(--bg-tertiary);
    padding: 4px 12px;
    border-radius: 12px;
}

/* --- Season Tabs --- */
.vod-season-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
    flex-wrap: wrap;
}

.vod-season-tab {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: all var(--transition);
}

.vod-season-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.vod-season-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* --- Episodes list --- */
.vod-ep-group {
    margin-bottom: 20px;
}

.vod-ep-date {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.vod-ep-date.vod-season-header {
    font-size: 16px;
    color: var(--accent);
}

.vod-ep-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.vod-ep-item:hover,
.vod-ep-item.focused {
    background: var(--bg-hover);
}

.vod-ep-item.now {
    border-left: 3px solid var(--accent);
}

[dir="rtl"] .vod-ep-item.now {
    border-left: none;
    border-right: 3px solid var(--accent);
}

.vod-ep-item.past {
    opacity: 0.7;
}

.vod-ep-time {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 100px;
}

.vod-ep-content {
    flex: 1;
    min-width: 0;
}

.vod-ep-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.vod-ep-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.vod-ep-num {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    background: var(--bg-tertiary);
    padding: 4px 10px;
    border-radius: 12px;
    white-space: nowrap;
    align-self: center;
}

.vod-ep-meta {
    display: flex;
    gap: 12px;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.vod-ep-meta .vod-ep-channel {
    color: var(--accent);
    margin-top: 0;
}

.vod-ep-channel {
    font-size: 11px;
    color: var(--accent);
    margin-top: 4px;
}

.vod-ep-now-badge {
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    align-self: center;
}

.vod-ep-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--bg-tertiary);
}

.vod-ep-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 1px;
    transition: width 1s linear;
}

.vod-ep-timeshift {
    font-size: 14px;
    align-self: center;
    opacity: 0.5;
}

.vod-catalog-sentinel {
    height: 1px;
    width: 100%;
}

.vod-catalog-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 12px;
    color: var(--text-muted);
}

/* === Catch-Up Page === */
.catchup-page {
    padding: 20px 24px;
}

.catchup-header {
    margin-bottom: 20px;
}

/* Channel section — one row per channel */
.catchup-channel-section {
    margin-bottom: 32px;
}

.catchup-channel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    padding: 0 4px;
}

.catchup-ch-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    border: 2px solid var(--bg-tertiary);
}

.catchup-ch-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.catchup-ch-icon-ph {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 700;
    border-radius: 50%;
}

.catchup-channel-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.2px;
}

.catchup-channel-count {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 500;
}

/* Horizontal scroll row */
.catchup-scroll-row {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 8px;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.catchup-scroll-row::-webkit-scrollbar {
    display: none;
}

/* Program card — landscape oriented */
.catchup-card {
    width: 200px;
    flex-shrink: 0;
    scroll-snap-align: start;
    background: var(--bg-card);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    border: 2px solid transparent;
}

.catchup-card:hover,
.catchup-card:focus {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
    border-color: var(--accent);
    outline: none;
}

/* Poster / thumbnail area — 16:9 landscape */
.catchup-card-poster {
    position: relative;
    aspect-ratio: 16/10;
    background: linear-gradient(135deg, #1a2040 0%, #0d1220 100%);
    overflow: hidden;
}

.catchup-poster-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.catchup-poster-ph {
    position: absolute;
    inset: 0;
    display: none;
}

/* Day badge on poster */
.catchup-card-day {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.65);
    color: rgba(255, 255, 255, 0.9);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

[dir="rtl"] .catchup-card-day {
    right: auto;
    left: 8px;
}

/* Card info below poster */
.catchup-card-info {
    padding: 10px 12px;
}

.catchup-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.35;
    min-height: 2.7em;
}

.catchup-card-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 5px;
    font-variant-numeric: tabular-nums;
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

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

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

/* === Global Search Bar (Desktop) === */
.global-search-bar {
    position: fixed;
    top: 12px;
    inset-inline-end: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    z-index: 100;
    width: 280px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.global-search-bar:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.global-search-icon {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    flex-shrink: 0;
}

#global-search-input {
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 14px;
    width: 100%;
    outline: none;
    font-family: inherit;
}

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

/* Hide mobile search icon on desktop */
.search-btn-mobile {
    display: none;
}

/* On desktop, hide the search view's own search bar (global bar handles it) */
@media (min-width: 1025px) {
    .search-view > .search-bar {
        display: none;
    }
}

/* ======================================== */
/* === Home Screen (Netflix-style)     === */
/* ======================================== */

.home-screen {
    min-height: 100vh;
    background: var(--bg-primary);
}

/* ── Hero Banner ── */
.home-hero {
    position: relative;
    width: 100%;
    height: 56vh;
    min-height: 380px;
    max-height: 600px;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    --hero-c1: #0d1b2a;
    --hero-c2: #1a1a2e;
    --hero-c3: #16213e;
}

.home-hero--empty {
    height: 200px;
    min-height: 0;
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-primary));
}

.home-hero--transition .home-hero__content,
.home-hero--transition .home-hero__logo-wrap {
    opacity: 0;
    transform: translateY(6px);
}

.home-hero__bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.home-hero__bg-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 20%;
    opacity: 0.25;
    filter: blur(40px) saturate(1.8) brightness(0.8);
    transform: scale(1.4);
}

.home-hero__gradient {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(0deg,   var(--bg-primary) 0%, transparent 50%),
        linear-gradient(90deg,  rgba(10,14,23,0.9) 0%, transparent 60%),
        linear-gradient(135deg, var(--hero-c1) 0%, var(--hero-c2) 50%, var(--hero-c3) 100%);
    transition: background 500ms ease;
}

[dir="rtl"] .home-hero__gradient {
    background:
        linear-gradient(0deg,   var(--bg-primary) 0%, transparent 50%),
        linear-gradient(270deg, rgba(10,14,23,0.9) 0%, transparent 60%),
        linear-gradient(135deg, var(--hero-c1) 0%, var(--hero-c2) 50%, var(--hero-c3) 100%);
}

.home-hero__content {
    position: relative;
    z-index: 2;
    padding: 0 48px 40px;
    width: 100%;
    max-width: 650px;
    transition: opacity 250ms ease, transform 250ms ease;
}

.home-hero__badge {
    display: inline-block;
    background: rgba(255,255,255,0.12);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    color: var(--text-primary);
    padding: 5px 16px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 14px;
    border: 1px solid rgba(255,255,255,0.08);
}

.home-hero__title {
    font-size: 42px;
    font-weight: 900;
    line-height: 1.15;
    margin-bottom: 12px;
    text-shadow: 0 4px 20px rgba(0,0,0,0.6);
    letter-spacing: -0.5px;
}

.home-hero__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.home-hero__live-dot {
    width: 8px;
    height: 8px;
    background: #e50914;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(229,9,20,0.6);
    animation: hero-pulse 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes hero-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

.home-hero__program-text {
    font-size: 15px;
    color: rgba(255,255,255,0.75);
    font-weight: 400;
}

.home-hero__progress {
    width: 240px;
    height: 3px;
    background: rgba(255,255,255,0.12);
    border-radius: 2px;
    margin-bottom: 22px;
    overflow: hidden;
}

.home-hero__progress-bar {
    height: 100%;
    background: #e50914;
    border-radius: 2px;
    transition: width 1s ease;
}

.home-hero__actions {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.home-hero__btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 28px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 200ms ease;
    border: none;
    outline: none;
    letter-spacing: 0.3px;
}

.home-hero__btn svg {
    flex-shrink: 0;
}

.home-hero__btn--play {
    background: #fff;
    color: #111;
}

.home-hero__btn--play:hover,
.home-hero__btn--play:focus {
    background: rgba(255,255,255,0.85);
    transform: scale(1.04);
}

.home-hero__btn--info {
    background: rgba(255,255,255,0.15);
    color: #fff;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.1);
}

.home-hero__btn--info:hover,
.home-hero__btn--info:focus {
    background: rgba(255,255,255,0.25);
    transform: scale(1.04);
}

.home-hero__btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(255,255,255,0.5);
}

.home-hero__dots {
    display: flex;
    gap: 8px;
}

.home-hero__dot {
    width: 28px;
    height: 3px;
    border-radius: 2px;
    background: rgba(255,255,255,0.2);
    transition: all 300ms ease;
    cursor: pointer;
    border: none;
    padding: 0;
}

.home-hero__dot.active {
    background: #fff;
    width: 36px;
}

.home-hero__logo-wrap {
    position: absolute;
    inset-inline-end: 48px;
    bottom: 60px;
    z-index: 2;
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 250ms ease, transform 250ms ease;
}

.home-hero__logo {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 24px rgba(0,0,0,0.5));
}

/* ── Carousel Rows ── */
.home-rows {
    position: relative;
    padding: 8px 0 60px;
    margin-top: -30px;
    z-index: 3;
}

.home-row {
    margin-bottom: 32px;
    animation: row-slide-in 500ms ease both;
}

.home-row:nth-child(1) { animation-delay: 0ms; }
.home-row:nth-child(2) { animation-delay: 80ms; }
.home-row:nth-child(3) { animation-delay: 160ms; }
.home-row:nth-child(4) { animation-delay: 240ms; }
.home-row:nth-child(5) { animation-delay: 320ms; }
.home-row:nth-child(6) { animation-delay: 400ms; }

@keyframes row-slide-in {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

.home-row__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 48px 12px;
}

.home-row__title {
    font-size: 19px;
    font-weight: 700;
    color: #e5e5e5;
    letter-spacing: 0.2px;
}

.home-row__count {
    font-size: 12px;
    color: var(--text-muted);
    background: rgba(255,255,255,0.06);
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 500;
}

.home-row__arrow {
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 200ms ease, transform 200ms ease;
    margin-inline-start: 2px;
}

[dir="rtl"] .home-row__arrow {
    transform: scaleX(-1);
}

.home-row:hover .home-row__arrow {
    opacity: 1;
}

.home-row__scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: visible;
    padding: 8px 48px 20px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-padding-inline-start: 48px;
}

.home-row__scroll::-webkit-scrollbar {
    display: none;
}

/* ── Channel Cards ── */
.home-card {
    flex: 0 0 185px;
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    scroll-snap-align: start;
    transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 250ms ease,
                border-color 250ms ease;
    position: relative;
    outline: none;
    border: 2px solid transparent;
}

.home-card:hover,
.home-card:focus {
    transform: scale(1.1) translateY(-4px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.6), 0 0 0 0 var(--accent);
    z-index: 4;
    border-color: rgba(255,255,255,0.2);
}

.home-card:focus-visible {
    border-color: #fff;
    box-shadow: 0 12px 40px rgba(0,0,0,0.6), 0 0 20px rgba(255,255,255,0.15);
}

.home-card__poster {
    width: 100%;
    aspect-ratio: 16 / 10;
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.home-card__img {
    max-width: 75%;
    max-height: 70%;
    object-fit: contain;
    transition: transform 300ms ease;
}

.home-card:hover .home-card__img,
.home-card:focus .home-card__img {
    transform: scale(1.08);
}

.home-card__placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 900;
    color: rgba(255,255,255,0.15);
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
}

.home-card__fav-badge {
    position: absolute;
    top: 8px;
    inset-inline-end: 8px;
    color: #fbbf24;
    font-size: 14px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

.home-card__body {
    padding: 10px 12px 14px;
}

.home-card__name {
    font-size: 13px;
    font-weight: 600;
    color: #e5e5e5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
    line-height: 1.3;
}

.home-card__epg {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 16px;
}

.home-card__live-dot {
    width: 5px;
    height: 5px;
    background: #e50914;
    border-radius: 50%;
    flex-shrink: 0;
}

.home-card__epg-text {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.home-card__progress {
    margin-top: 8px;
    height: 2px;
    background: rgba(255,255,255,0.08);
    border-radius: 1px;
    overflow: hidden;
}

.home-card__progress-bar {
    height: 100%;
    background: #e50914;
    border-radius: 1px;
    transition: width 1s ease;
}
