/* ==========================================================================
   Android TV / Fire TV 10-Foot UI Stylesheet (tv.css)
   Optimiert für Fernbedienung (D-Pad), OLED-Displays & TV-Browser
   Fixed Header Menü - KEIN horizontales Scrollen (Vertikaler Flow)
   ========================================================================== */

:root {
    --tv-bg: #050811;
    --tv-bg-alt: #0a0f1d;
    --tv-bg-surface: #111827;
    --tv-bg-surface-elevated: #1e293b;
    --tv-header-bg: rgba(8, 12, 22, 0.95);
    --tv-border: rgba(255, 255, 255, 0.08);
    --tv-border-active: #38bdf8;
    
    --tv-text: #f8fafc;
    --tv-text-muted: #94a3b8;
    --tv-text-dim: #64748b;

    --tv-primary: #38bdf8;
    --tv-primary-glow: rgba(56, 189, 248, 0.45);
    --tv-accent: #f43f5e;
    --tv-accent-glow: rgba(244, 63, 94, 0.45);
    --tv-gold: #fbbf24;
    --tv-green: #10b981;

    --tv-radius: 12px;
    --tv-radius-sm: 8px;
    --tv-radius-lg: 18px;

    --tv-header-height: 72px;
}

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

html, body {
    width: 100%;
    min-height: 100%;
    background-color: var(--tv-bg);
    color: var(--tv-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    overflow-x: hidden !important;
    user-select: none;
    -webkit-font-smoothing: antialiased;
}

/* Verstecke Standard-Scrollbalken auf TV */
::-webkit-scrollbar {
    display: none;
}
* {
    scrollbar-width: none;
}

/* ==========================================================================
   D-Pad Focus States (Kritisch für Fernbedienungssteuerung)
   ========================================================================== */

.tv-focusable {
    outline: none !important;
    position: relative;
    transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.18s cubic-bezier(0.16, 1, 0.3, 1),
                border-color 0.18s ease,
                background-color 0.18s ease;
    cursor: pointer;
}

.tv-focusable:focus,
.tv-focusable.tv-focused {
    outline: none !important;
    transform: scale(1.06) translateY(-3px);
    box-shadow: 0 0 0 3px var(--tv-primary),
                0 14px 30px var(--tv-primary-glow),
                0 0 20px rgba(56, 189, 248, 0.35) !important;
    z-index: 50 !important;
    border-color: var(--tv-primary) !important;
}

/* Buttons & Navigations-Links bei Fokus */
button.tv-focusable:focus,
button.tv-focusable.tv-focused,
a.tv-focusable:focus,
a.tv-focusable.tv-focused {
    background-color: var(--tv-primary) !important;
    color: #030712 !important;
}

button.tv-focusable:focus svg,
button.tv-focusable.tv-focused svg,
a.tv-focusable:focus svg,
a.tv-focusable.tv-focused svg {
    stroke: #030712 !important;
    fill: none !important;
}

/* Karten bei Fokus */
.tv-card.tv-focusable:focus,
.tv-card.tv-focusable.tv-focused {
    background-color: var(--tv-bg-surface-elevated) !important;
    color: var(--tv-text) !important;
    transform: scale(1.06) translateY(-5px);
}

.tv-card.tv-focusable:focus .tv-card-title,
.tv-card.tv-focusable.tv-focused .tv-card-title {
    color: var(--tv-primary) !important;
}

/* ==========================================================================
   TV App Shell & Dynamischer Hintergrund
   ========================================================================== */

.tv-app {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
    background: radial-gradient(circle at 80% 20%, #172554 0%, #050811 50%, #030712 100%);
    position: relative;
    overflow-x: hidden;
}

.tv-backdrop-glow {
    position: fixed;
    top: 0;
    right: 0;
    width: 70vw;
    height: 70vh;
    background-size: cover;
    background-position: center;
    opacity: 0.16;
    filter: blur(50px);
    pointer-events: none;
    z-index: 0;
    transition: background-image 0.5s ease;
}

/* ==========================================================================
   Fixed Header Menü (D-Pad optimiert)
   ========================================================================== */

.tv-fixed-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--tv-header-height);
    background: var(--tv-header-bg);
    border-bottom: 1px solid var(--tv-border);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    z-index: 1000;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.6);
}

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

.tv-header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--tv-text);
    padding: 8px 12px;
    border-radius: var(--tv-radius-sm);
}

.tv-header-brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #0284c7, #38bdf8);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.4);
}

.tv-header-brand-text {
    font-size: 18px;
    font-weight: 800;
    white-space: nowrap;
}

.tv-header-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tv-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: var(--tv-radius-sm);
    color: var(--tv-text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
}

.tv-nav-link.active {
    background: rgba(56, 189, 248, 0.15);
    color: var(--tv-primary);
    border-color: rgba(56, 189, 248, 0.3);
    font-weight: 700;
}

.tv-nav-exit {
    border: 1px dashed rgba(255, 255, 255, 0.2);
    color: #cbd5e1;
}

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

.tv-user-tag {
    font-size: 13px;
    font-weight: 700;
    color: var(--tv-text-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tv-topbar-weather {
    font-size: 14px;
    font-weight: 700;
    color: var(--tv-text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--tv-border);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.tv-weather-icon {
    font-size: 16px;
    line-height: 1;
}

.tv-weather-temp {
    color: var(--tv-primary);
    font-weight: 800;
}

.tv-weather-city {
    font-size: 12px;
    color: var(--tv-text-dim);
    font-weight: 600;
}

.tv-topbar-clock {
    font-size: 15px;
    font-weight: 700;
    color: var(--tv-text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--tv-border);
}

/* ==========================================================================
   TV Main Content Area (Volle Breite, kein Horizontales Scrollen)
   ========================================================================== */

.tv-main {
    width: 100%;
    min-height: 100vh;
    padding-top: calc(var(--tv-header-height) + 15px);
    padding-bottom: 70px;
    display: flex;
    flex-direction: column;
    z-index: 10;
    overflow-x: hidden;
}

.tv-content {
    width: 100%;
    max-width: 1720px;
    margin: 0 auto;
    padding: 15px 40px;
    display: flex;
    flex-direction: column;
    gap: 40px;
    overflow-x: hidden;
}

/* ==========================================================================
   Hero Billboard (Startseite Highlight)
   ========================================================================== */

.tv-hero {
    position: relative;
    border-radius: var(--tv-radius-lg);
    min-height: 380px;
    display: flex;
    align-items: flex-end;
    padding: 40px;
    background-size: cover;
    background-position: center;
    border: 1px solid var(--tv-border);
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
    width: 100%;
}

.tv-hero-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, #050811 0%, rgba(5, 8, 17, 0.75) 50%, rgba(5, 8, 17, 0.2) 100%),
                linear-gradient(90deg, #050811 0%, rgba(5, 8, 17, 0.7) 40%, transparent 100%);
}

.tv-hero-body {
    position: relative;
    z-index: 2;
    max-width: 750px;
}

.tv-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(244, 63, 94, 0.9);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 6px;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.tv-hero-title {
    font-size: 38px;
    font-weight: 900;
    line-height: 1.15;
    margin-bottom: 10px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.tv-hero-desc {
    font-size: 15px;
    color: #cbd5e1;
    margin-bottom: 20px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tv-hero-actions {
    display: flex;
    gap: 14px;
    align-items: center;
}

/* ==========================================================================
   TV Sections & Grids (Vertikaler Flow, KEIN horizontales Scrollen)
   ========================================================================== */

.tv-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.tv-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tv-section-title {
    font-size: 20px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.2px;
}

.tv-section-title-dot {
    width: 6px;
    height: 20px;
    background: var(--tv-primary);
    border-radius: 3px;
}

/* Responsive Media Grids (Wrap statt horizontales Scrollen) */
.tv-grid,
.tv-media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
    gap: 20px;
    width: 100%;
}

.tv-news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    width: 100%;
}

/* TV Media Card */
.tv-card {
    width: 100%;
    background: var(--tv-bg-surface);
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius);
    overflow: hidden;
    text-decoration: none;
    color: var(--tv-text);
    display: flex;
    flex-direction: column;
}

.tv-card-poster {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    background-color: var(--tv-bg-alt);
    display: block;
}

.tv-card-body {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--tv-bg-surface);
}

.tv-card-title {
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tv-card-meta {
    font-size: 12px;
    color: var(--tv-text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tv-badge-score {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: var(--tv-gold);
    font-weight: 700;
}

/* ==========================================================================
   TV Filter Pills (Genres / Tabs - Umbruch statt Horizontales Scrollen)
   ========================================================================== */

.tv-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
    margin-bottom: 20px;
}

.tv-pill {
    padding: 8px 18px;
    background: var(--tv-bg-surface);
    border: 1px solid var(--tv-border);
    border-radius: 30px;
    color: var(--tv-text);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.tv-pill.active {
    background: var(--tv-primary);
    color: #030712;
    border-color: var(--tv-primary);
    font-weight: 700;
}

/* ==========================================================================
   TV Detail & Player View
   ========================================================================== */

.tv-detail-wrap {
    display: flex;
    gap: 35px;
    margin-bottom: 30px;
    width: 100%;
}

.tv-detail-poster-wrap {
    flex: 0 0 240px;
    width: 240px;
    border-radius: var(--tv-radius);
    overflow: hidden;
    border: 1px solid var(--tv-border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.tv-detail-poster {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    display: block;
}

.tv-detail-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.tv-detail-title {
    font-size: 32px;
    font-weight: 900;
    line-height: 1.2;
}

.tv-detail-meta-row {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    font-size: 14px;
    color: var(--tv-text-muted);
}

.tv-detail-overview {
    font-size: 15px;
    line-height: 1.6;
    color: #cbd5e1;
    max-width: 900px;
}

/* TV Player & Hoster Selector */
.tv-player-card {
    background: var(--tv-bg-surface);
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    width: 100%;
}

.tv-hoster-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.tv-hoster-btn {
    padding: 10px 18px;
    background: var(--tv-bg-surface-elevated);
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius-sm);
    color: var(--tv-text);
    font-size: 14px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.tv-hoster-btn.active {
    background: rgba(56, 189, 248, 0.2);
    border-color: var(--tv-primary);
    color: var(--tv-primary);
}

.tv-player-frame-wrap {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000000;
    border-radius: var(--tv-radius);
    overflow: hidden;
    position: relative;
    border: 1px solid var(--tv-border);
}

.tv-player-frame-wrap iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ==========================================================================
   TV On-Screen D-Pad Keyboard (Suche per Fernbedienung)
   ========================================================================== */

.tv-search-container {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 35px;
    align-items: start;
    width: 100%;
}

.tv-osk-box {
    background: var(--tv-bg-surface);
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.tv-osk-display {
    background: var(--tv-bg-alt);
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius-sm);
    padding: 12px 16px;
    font-size: 18px;
    font-weight: 700;
    color: var(--tv-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 52px;
}

.tv-osk-cursor {
    display: inline-block;
    width: 2px;
    height: 20px;
    background-color: var(--tv-primary);
    margin-left: 4px;
    animation: tvBlink 1s infinite;
}

@keyframes tvBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.tv-osk-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.tv-osk-key {
    background: var(--tv-bg-surface-elevated);
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius-sm);
    color: var(--tv-text);
    font-size: 16px;
    font-weight: 700;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tv-osk-key.wide-2 {
    grid-column: span 2;
}

.tv-osk-key.wide-3 {
    grid-column: span 3;
}

/* ==========================================================================
   TV Remote Helper Bar (Unten fixiert)
   ========================================================================== */

.tv-remote-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: rgba(5, 8, 17, 0.94);
    border-top: 1px solid var(--tv-border);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    font-size: 13px;
    color: var(--tv-text-muted);
    z-index: 900;
}

.tv-remote-hint-group {
    display: flex;
    align-items: center;
    gap: 20px;
}

.tv-remote-hint {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tv-key-badge {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* TV Button Styles */
.tv-btn {
    padding: 10px 20px;
    border-radius: var(--tv-radius-sm);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid transparent;
}

.tv-btn-primary {
    background: var(--tv-primary);
    color: #030712;
}

.tv-btn-secondary {
    background: var(--tv-bg-surface-elevated);
    color: var(--tv-text);
    border-color: var(--tv-border);
}

.tv-btn-accent {
    background: var(--tv-accent);
    color: #ffffff;
}
