:root {
    --bg-color: #101010;

    --surface-color: #181818;
    --card-bg: #222;
    --primary-color: #ff6600;
    --text-color: #f0f0f0;
    --text-muted: #aaa;
    --border-color: #333;
    --tile-bg-color: #313131;

    --tile-bg-hover-color: #333333
}

/* --- Grund-Layout & Helfer --- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    overflow-x: hidden;

    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
main {
    flex-grow: 1;
}
.hidden { display: none !important;
}
.container { max-width: 1400px; width: 100%; margin:0 auto; padding: 20px;
}

.continue-watching-container {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-start;
}
a#continue-watching-btn{
    padding: 4px 15px;
    line-height: 15px;
    height: 43px;
    border-radius: 5px 0px 0px 5px;
}
button#remove-from-history-btn {
    padding: 4px 15px;
    line-height: 15px;
    height: 43px;
    border-radius: 0px 5px 5px 0px;
}

/* General form and button styles */
.btn, button, input, select {
    font-family: inherit;
    padding: 10px 15px;

    font-size: 1rem;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-color);
    transition: background-color 0.2s, border-color 0.2s;
}

/* Styles specific to buttons and links styled as buttons */
.btn, button {
    cursor: pointer;
    background-color: var(--primary-color);

    color: white;
    border-color: var(--primary-color);
    text-decoration: none;
    display: inline-block;
    text-align: center;
    line-height: normal;
/* Ensure consistent line height */
}

.btn:hover:not(:disabled), button:hover:not(:disabled) {
    background-color: #ff8533;
}

.btn:disabled, button:disabled {
    background-color: #555;
    border-color: #444;
    color: #888;
    cursor: not-allowed;
}

select:hover, input:hover {
    border-color: var(--primary-color);
}


/* --- Header & Navigation --- */
.main-header {
    background-color: var(--surface-color);

    border-bottom: 1px solid var(--border-color);
    padding: 0 10px;
}
.main-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding-top: 15px;
    padding-bottom: 15px;
    gap: 20px;
}
.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    text-decoration: none;
}
.main-nav {
    display: flex;
    gap: 15px;
    flex-grow: 1;
}
.main-nav a {
    color: var(--text-muted);

    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}
.main-nav a:hover {
    color: var(--text-color);
}
.nav-right {
    display: flex;
    align-items: center;
    gap: 15px;
}
.nav-icon-btn {
    background: none;
    border: none;

    color: var(--text-muted);
    padding: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav-icon-btn:hover {
    color: var(--text-color);
}
.nav-icon-btn svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
}
.profile-menu {
    position: relative;
}
.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background-color: var(--surface-color);

    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 0;
    min-width: 200px;
    z-index: 1001;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}
.profile-menu.active .dropdown-menu {
    display: block;
}
.dropdown-menu a {
    display: block;
    padding: 10px 20px;

    color: var(--text-muted);
    text-decoration: none;
    white-space: nowrap;
}
.dropdown-menu a:hover {
    background-color: var(--primary-color);
    color: white;
}
.dropdown-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 10px 0;
}
.admin-link {
    color: var(--primary-color) !important;
}
.admin-link:hover {
    color: white !important;
}
.language-switcher {
    display: flex;
    align-items: center;
}
.language-switcher a {
    color: #fff;
    text-decoration: none;
    padding: 5px 8px;
    border-radius: 4px;
    font-weight: 500;

    transition: background-color 0.2s ease-in-out;
    margin: 0 2px;
}

.language-switcher a.active {
    background-color: rgba(255, 255, 255, 0.2);
    font-weight: 700;
}
.language-switcher a:not(.active):hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* --- Footer --- */
.main-footer {
    text-align: center;
    padding: 5px;
    color: var(--text-muted);
    font-size: 0.9rem;

    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

/* --- Formulare (Login/Register) --- */
.auth-form { max-width: 400px;
}
.notice { background-color: rgba(255, 102, 0, 0.1); border-left: 3px solid var(--primary-color); padding: 10px; border-radius: 5px;
}
.error { background-color: rgba(255, 0, 0, 0.1); border-left: 3px solid red; padding: 10px; border-radius: 5px;
}
.success { background-color: rgba(0, 255, 0, 0.1); border-left: 3px solid green; padding: 10px; border-radius: 5px;
}

/* --- Dashboard & Page Headers --- */
.page-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.page-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}
.page-header p {
    font-size: 1.1rem;
    color: var(--text-muted);

    max-width: 60ch;
}

/* --- Suche --- */
#search-section {
    background-color: var(--surface-color);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}
#search-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    align-items: flex-end;
}
.form-group { display: flex;

    flex-direction: column; gap: 0.5rem; }
.form-group label { font-weight: bold; font-size: 0.9rem; color: var(--text-muted); }
.range-group { display: flex; gap: 0.5rem;

    align-items: center; }
.range-group input { width: 100%; }
.full-width-search { grid-column: 1 / -1;
}
@media (min-width: 680px) { .full-width-search { grid-column: span 2; } }

/* --- Galerie / Kacheln --- */
#results-container { display: grid;

    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1.5rem; }
.tile {
    background-color: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;

    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    position: relative;
}
.tile:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}
.tile img { width: 100%; display: block; aspect-ratio: 2 / 3; object-fit: cover; background-color: var(--surface-color); }
.tile-info { padding: 1rem;
}
.tile-info h3 { margin: 0; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rating {
    position: absolute;

    top: 10px; left: 10px; background-color: rgba(0,0,0,0.8);
    color: var(--primary-color); padding: 5px 8px; border-radius: 5px; font-weight: bold;
}
.loader, #scroll-loader { text-align: center;

    font-size: 1.5rem; padding: 50px; grid-column: 1 / -1; }
#api-counter {
    position: fixed; top: 15px; right: 20px;

    background-color: rgba(0,0,0,0.7);
    color: var(--primary-color); padding: 8px 12px; border-radius: 5px; z-index: 1001;
}

/* --- Player --- */
#player-view {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;

    background-color: #000;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}
#video-player { width: 100%; height: 100%; cursor: pointer;
}
#player-placeholder {
    position: absolute;
    top: 0; bottom: 0; left: 0; right: 0;
    display: flex; flex-direction: column;

    justify-content: flex-end; align-items: center;
    padding-bottom: 100px;
    pointer-events: none;
}
.player-loader {
    color: var(--primary-color); font-size: 1.5rem; text-align: center;

    pointer-events: auto;
}
#resume-dialog {
    background: rgba(30,30,30,0.9);
    padding: 15px 25px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;

    pointer-events: auto;
}
#resume-dialog button { margin: 0 5px; }
.player-controls {
    position: absolute;
    left: 0;
    right: 0;

    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 10;
    pointer-events: none;
}
#player-view.controls-active .player-controls {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
#player-video-title {
    font-size: 1.2rem;

    font-weight: 500;
    margin-right: 50px;
    padding: 0 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
    flex-grow: 0;
}
#player-top-controls {
    top: 0;
    display: block;
    justify-content: flex-start;
    align-items: left;
    gap: 0.5rem;
    padding: 1rem;

    background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
    flex-wrap: nowrap;
    flex-direction: row;
}
#player-bottom-controls {
    bottom: 0;

    padding: 0 20px 10px 20px;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    display: flex;
    flex-direction: column;
}
.timeline-container {
    width: 100%; display: flex; align-items: center; gap: 10px; margin-bottom: 5px;
}
.timeline-container .time-display { font-size: 0.9em;

    color: var(--text-muted); width: 60px; text-align: center; }
input[type="range"] { -webkit-appearance: none; background: transparent; width: 100%; height: 15px; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { background: rgba(255,255,255,0.3); height: 5px; border-radius: 5px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; height: 15px; width: 15px; background: var(--primary-color); border-radius: 50%;

    margin-top: -5px; }
input[type="range"]:focus { outline: none; }

.buttons-container { display: flex; justify-content: space-between; align-items: center; }
.controls-left, .controls-right { display: flex;

    align-items: center; gap: 10px; }

.volume-container { position: relative; display: flex; align-items: center; }
.volume-slider {
    position: absolute;

    bottom: 36px;
    left: 45%;
    transform: translateX(-50%);
    writing-mode: vertical-lr;
    direction: rtl;
    width: 35px !important;
    height: 120px !important;
    background: var(--surface-color) !important;

    padding: 10px 5px;
    border-radius: 5px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s;
}
.volume-container:hover .volume-slider { opacity: 1; visibility: visible;
}

.icon-button { background: transparent; border: none; padding: 5px; color: var(--text-color); }
.icon-button svg { fill: currentColor; stroke: currentColor; width: 24px;

    height: 24px; }
.icon-button.large svg { width: 32px; height: 32px; }

/* --- Einstellungs-Overlay --- */
#player-settings-overlay {
    position: absolute;

    bottom: 0;
    left: 0;
    width: 100%;
    transform: translateY(100%);
    background-color: rgba(22,22,22,0.95);
    padding: 2.5rem 1rem 2rem 1rem;
    opacity: 0;
    visibility: hidden;

    transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
    z-index: 2147483647 !important;
    border-top: 1px solid var(--border-color);
}
#player-settings-overlay.visible {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}
#settings-close-btn {
    position: absolute;
    top: 8px;

    right: 8px;
    width: 32px;
    height: 32px;
    padding: 0px 0px !important;
    font-size: 1.5rem;
    line-height: 0px !important;
    text-align: center;
    background: transparent;

    border: none;
    color: var(--text-muted);
}
.settings-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 900px;
    margin: 0 auto;

    max-height: 85vh;
    overflow-y: visible;
}
.settings-block {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
}
.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.option-group label {
    font-size: 0.9rem;

    color: var(--text-muted);
}
.skip-group {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    background-color: var(--surface-color);
    padding: 10px;
    border-radius: 5px;
}
.skip-group input[type="number"] { width: 60px; padding: 5px; }
.skip-group input[type="checkbox"] { width: 20px; height: 20px;
}

@media (min-width: 768px) {
    .settings-container {
        flex-direction: row;
        align-items: flex-start;
}
    .settings-block {
        padding: 0 1rem;
}
    .settings-block + .settings-block {
        border-left: 1px solid var(--border-color);
}
}
/* --- Watchlist Checkbox auf Kacheln --- */
.watchlist-checkbox-label {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 30px;

    height: 30px;
    background-color: rgba(0,0,0,0.7);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5;
}
.watchlist-checkbox-label input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}
.checkmark {
    font-size: 1.2rem;
    color: white;
}
.watchlist-checkbox-label input:checked ~ .checkmark {
    color: var(--primary-color);
}
.watchlist-checkbox-label .checkmark::after {
    content: '+';
}
.watchlist-checkbox-label input:checked ~ .checkmark::after {
    content: '✓';
}

/* --- Fokus-Styling für TV --- */
.focused {
    outline: 3px solid var(--primary-color) !important;
    outline-offset: 2px;

    box-shadow: 0 0 15px var(--primary-color) !important;
}


/* --- Responsive Anpassungen --- */
.mobile-nav-toggle {
    display: none;
    background: none;

    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1001;
    position: relative;
    width: 45px;
    height: 45px;
}
.hamburger {
    width: 25px;
    height: 25px;
    fill: var(--text-color);
    transition: fill 0.2s ease-in-out;
}

/* Kachel-Grid */
@media (max-width: 576px) {
    #results-container {
        grid-template-columns: repeat(2, 1fr);

        gap: 1rem;
    }
}
@media (max-width: 992px) and (orientation: landscape) {
    #results-container {
        grid-template-columns: repeat(6, 1fr);

        gap: 1rem;
    }
}

/* Mobile Navigation (Tablet & kleiner) */
@media (max-width: 768px) {
    .main-nav {
        display: none;

        flex-direction: column;
        position: fixed;
        top: 0;
        right: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.95);
        backdrop-filter: blur(5px);
        justify-content: center;
        align-items: center;

        z-index: 1000;
        transform: translateX(100%);
        transition: transform 0.3s ease-in-out;
    }
    .main-nav.active {
        display: flex;

        transform: translateX(0);
    }
    .main-nav a {
        font-size: 1.5rem;
}
    .mobile-nav-toggle {
        display: block;
}
    .mobile-nav-toggle.active .hamburger {
        fill: var(--primary-color);
}
    body.mobile-nav-active {
        overflow: hidden;
}
}

/* --- Custom Dropdown --- */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}
.custom-select {
    position: relative;
    cursor: pointer;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 10px 15px;

    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.custom-select-trigger {
    white-space: nowrap;
    overflow: hidden;

    text-overflow: ellipsis;
    flex-grow: 1;
}
.truncate {
  width: 100%; /* Deine gewünschte Breite */
  display: -webkit-box;
  -webkit-box-orient: vertical;

  -webkit-line-clamp: 3; /* Die Anzahl der Zeilen, die angezeigt werden sollen */
  overflow: hidden;
  text-overflow: ellipsis;
}
.custom-select-trigger::after {
    content: '▲';
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: transform 0.2s;
    transform-origin: center;
    display: inline-block;
    margin-left: 10px;
}
.custom-select.open .custom-select-trigger::after {
    transform: rotate(180deg);
}
.custom-options {
    position: absolute;
    bottom: calc(100% - 1px);

    left: 0;
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    z-index: 10;

    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}
.custom-option {
    padding: 10px 15px;
    cursor: pointer;
    transition: background-color 0.2s;

    border-bottom: 1px solid var(--border-color);
}
.custom-option:last-child {
    border-bottom: none;
}
.custom-option:hover {
    background-color: var(--primary-color);
}
.custom-option.selected {
    background-color: var(--primary-color);
    font-weight: bold;
}
.custom-option.focused {
    background-color: #ff8533 !important;
    outline: none;
}

/* --- Landing Page --- */
body.landing-page-active {
    overflow: hidden;
}
.landing-page {
    display: flex;

    align-items: center;
    justify-content: center;
    text-align: center;
    color: #fff;
    flex-grow: 1;
/* Allow it to take up space */
}
.landing-content {
    padding: 20px;
    max-width: 650px;
    width: 100%;
}
.landing-box {
    background: var(--surface-color);
    padding: 40px 50px;
    border-radius: 15px;
    border: 1px solid var(--border-color);

    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.landing-box h1 {
    font-size: 2.5rem;
    margin-bottom: 15px;
    font-weight: 700;
}
.landing-box p {
    font-size: 1.1rem;
    margin-bottom: 30px;
    color: var(--text-muted);
    line-height: 1.5;
}
.landing-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
}
.landing-buttons .btn {
    text-decoration: none;

    display: inline-block;
    border: none;
    transition: transform 0.2s, box-shadow 0.2s;
}
.landing-buttons .btn:hover {
    transform: translateY(-3px);

    box-shadow: 0 8px 15px rgba(0,0,0,0.3);
}
.btn.btn-lg {
    padding: 15px 35px;
    font-size: 1.1rem;
    border-radius: 8px;
    font-weight: bold;
}

/* --- Episoden-Panel --- */
#episode-list-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 350px;
    max-width: 80vw;

    height: 80vh;
    background-color: rgba(22, 22, 22, 0.98);
    backdrop-filter: blur(5px);
    z-index: 2147483647 !important;
    display: none;
    overflow-y: auto;
    padding: 20px;

    border-left: 1px solid var(--border-color);
}
#episode-list-panel.visible {
    display: block;
}
#episode-list-panel h3 {
    margin-top: 0;

    color: var(--primary-color);
}
#episode-list-panel h4 {
    margin-top: 20px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}
.episode-list-item {
    padding: 10px 5px;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.2s;
    white-space: nowrap;
    overflow: hidden;

    text-overflow: ellipsis;
}
.episode-list-item:hover {
    background-color: var(--surface-color);
}
.episode-list-item.active {
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
}


/* --- Dashboard (Startseite eingeloggt) --- */
.dashboard-container {
    width: 100%;
    padding: 0 20px;
/* Add horizontal padding */
}

#dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.content-row {
    width: 100%;
}

.content-row h2 {
    margin-bottom: 1rem;
    color: var(--primary-color);
    font-size: 1.5rem;
}

/* --- Hero Slider --- */
.hero-slider {
    grid-column: 1 / -1;
    position: relative;
    width: 100%;
    height: 50vh;

    min-height: 350px;
    max-height: 500px;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.hero-slider .slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;

    transition: opacity 1s ease-in-out;
    background-size: cover;
    background-position: center;
}
.hero-slider .slide.active {
    opacity: 1;
}
.hero-slider .slide-content {
    position: absolute;
    top: 50%; /* Vertikal mittig positionieren */
    transform: translateY(-50%);
/* Eigene Höhe berücksichtigen */
    left: 0;
    right: 0;
    color: #fff;
    text-decoration: none;
}
.hero-slider .slide-title {
    font-size: 2.2rem;
    font-weight: bold;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}
.hero-slider .slide-type {
    font-size: 1rem;
    font-weight: bold;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
    display: block;
}
.hero-slider .slider-nav {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    gap: 0.5rem;
}
.hero-slider .nav-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: rgba(255,255,255,0.5);
    cursor: pointer;
    transition: background-color 0.3s;
}
.hero-slider .nav-dot.active {
    background-color: #fff;
}
.hero-slider-container {
    width: 100%;
    position: relative;
    margin-bottom: 2rem;
}
.hero-slider {
    width: 100%;
    height: 70vh; /* Same height as detail hero */
    position: relative;

    overflow: hidden;
}
.hero-slider .slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;

    transition: opacity 0.8s ease-in-out;
    z-index: 1;
}
.hero-slider .slide.active {
    opacity: 1;
    z-index: 2;
}
.slider-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0,0,0,0.5);
    color: white;
    border: none;
    padding: 1rem;

    cursor: pointer;
    z-index: 10;
    font-size: 1.5rem;
    transition: background-color 0.3s;
}
.slider-arrow:hover {
    background-color: rgba(0,0,0,0.8);
}
.slider-arrow.prev { left: 10px;
}
.slider-arrow.next { right: 10px; }
.slider-nav {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;

    gap: 10px;
    z-index: 10;
}
.slider-nav .nav-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;

    background-color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: background-color 0.3s;
}
.slider-nav .nav-dot.active {
    background-color: white;
}

@media (max-width: 768px) {
    .hero-slider {
        grid-column: 1 / -1;

        position: relative;
        width: 100%;
        height: calc(100vh - 195px);
        min-height: 350px;
        max-height: 800px;
        border-radius: 0px;
        overflow: hidden;
        margin-bottom: 2rem;

        box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    }
    .hero-slider .slide {
        position: absolute;

        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        opacity: 0;
        transition: opacity 1s ease-in-out;
        background-size: cover;
        background-position: center;
}
    .hero-slider .slide.active {
        opacity: 1;
}
    .hero-slider .slide-content {
        position: absolute;
        top: 50%;
/* Vertikal mittig positionieren */
        transform: translateY(-50%);
/* Eigene Höhe berücksichtigen */
        left: 0;
        right: 0;
        color: #fff;
        text-decoration: none;
}
    .hero-slider .slide-title {
        font-size: 2.2rem;
        font-weight: bold;
        margin: 0;

        text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    }
    .hero-slider .slide-type {
        font-size: 1rem;

        font-weight: bold;
        color: var(--primary-color);
        text-transform: uppercase;
        letter-spacing: 1px;
        margin-bottom: 0.5rem;
        display: block;
}
    .hero-slider .slider-nav {
        position: absolute;
        bottom: 1rem;
        left: 50%;

        transform: translateX(-50%);
        z-index: 10;
        display: flex;
        gap: 0.5rem;
    }
    .hero-slider .nav-dot {
        width: 12px;

        height: 12px;
        border-radius: 50%;
        background-color: rgba(255,255,255,0.5);
        cursor: pointer;
        transition: background-color 0.3s;
}
    .hero-slider .nav-dot.active {
        background-color: #fff;
}
    .hero-slider-container {
        width: 100%;
        height: calc(100vh - 136px);

        position: relative;
        margin-bottom: 2rem;
    }
    .hero-slider .slide {
        position: absolute;

        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        opacity: 0;
        transition: opacity 0.8s ease-in-out;
        z-index: 1;
}
    .hero-slider .slide.active {
        opacity: 1;
        z-index: 2;
}
    .slider-arrow {
        position: absolute;
        top: 100%;
        transform: translateY(-100%);

        background-color: rgba(0,0,0,0.5);
        color: white;
        border: none;
        padding: 0.5rem;
        cursor: pointer;
        z-index: 10;
        font-size: 1.5rem;
        transition: background-color 0.3s;
}
    .slider-arrow:hover {
        background-color: rgba(0,0,0,0.8);
}
    .slider-arrow.prev { left: 10px; }
    .slider-arrow.next { right: 10px;
}
    .slider-nav {
        position: absolute;
        bottom: 20px;
        left: 50%;

        transform: translateX(-50%);
        display: flex;
        gap: 10px;
        z-index: 10;
    }
    .slider-nav .nav-dot {
        width: 12px;

        height: 12px;
        border-radius: 50%;
        background-color: rgba(255, 255, 255, 0.4);
        cursor: pointer;
        transition: background-color 0.3s;
}
    .slider-nav .nav-dot.active {
        background-color: white;
}
}

.tile-row.horizontal-scroll {
    display: flex;
    padding-bottom: 1rem;
    gap: 1rem;
    flex-direction: row;
    flex-wrap: wrap;
}
.tile-row.horizontal-scroll .tile {
    flex: 0 0 auto;
    width: 180px;
}

.tile-row {
    /* display: contents;
*/ /* This was causing issues */
}

.tile-row .tile {
    width: auto;
/* Let the grid control the tile size */
}

.hero-banner {
    position: relative;
    height: 400px;

    background: url('https://source.unsplash.com/random/1920x1080/?movie,cinema') no-repeat center center/cover;
    color: #fff;
    display: flex;
    align-items: flex-end;
    padding: 40px;
    margin-bottom: 30px;
    grid-column: 1 / -1;
/* Make hero span full width of the grid */
}

.hero-banner::after {
    content: '';
    position: absolute;
    top: 0;

    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
}

.hero-content {
    position: relative;
    z-index: 2;
}

.hero-content h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.hero-content p {
    font-size: 1.2rem;
    color: var(--text-color);
}

/* --- TV Optimizations --- */
/* Hide elements on TV, but keep the rule for clarity */
body.is-tv .nav-right {
    display:none;
}

body.is-tv #open-episode-panel-btn {
    display: none;
}

/* --- Admin Panel Responsive --- */
@media (max-width: 768px) {
    .tile-row.horizontal-scroll .tile,
    .tiles-container.horizontal-scroll .tile {
        flex: 0 0 auto;

        width: calc(50% - 8px) !important;
    }
    .admin-section {
        padding: 1rem;
}
    .stats-container, .stats-actions {
        flex-direction: column;
}
    .user-table, .user-table tbody, .user-table tr, .user-table td {
        display: block;

        width: 100% !important;
    }
    .user-table thead {
        display: none;
}
    .user-table tr {
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);

        border-radius: 8px;
        padding: 1rem;
    }
    .user-table td {
        display: flex;

        justify-content: space-between;
        align-items: center;
        padding: 0.5rem;
        border: none;
        border-bottom: 1px solid var(--border-color);
}
    .user-table td:last-child {
        border-bottom: none;
}
    .user-table td::before {
        content: attr(data-label);
        font-weight: bold;
        margin-right: 1rem;
}
    .user-table .actions {
        flex-direction: column;
        gap: 0.5rem;
}
    .user-table .actions button {
        width: 100%;
}
    .form-control-small {
        width: 100%;
}
}
.btn.btn-primary {
    background-color: var(--primary-color);
    color: white;
}
.btn.btn-secondary {
    background-color: transparent;
    border: 2px solid white;

    color: white;
}

/* TV-specific styles from Jules */
body.is-tv #open-episode-panel-btn {
    display: none;
}

/* --- Detail Page & Hero Styles --- */
.hero-meta { margin-bottom: 1rem; color: var(--text-muted); }
.hero-meta .separator { margin: 0 0.5rem;
}
.hero-actors { margin-bottom: 1.5rem; color: var(--text-muted); font-size: 0.9rem;}
.hero-actors strong { color: var(--text-color); }
.detail-page-main { width: 100%; }
.detail-hero { position: relative;

    width: 100%; height: 70vh; background-size: cover; background-position: center; color: #fff; display: flex; align-items: center; padding: 2rem; }
.hero-overlay { position: absolute;

    top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(to top, rgba(0,0,0,0.9) 10%, rgba(0,0,0,0.2) 100%); }
.hero-content { position: relative;

    z-index: 2; display: flex; gap: 2rem; width: 100%; max-width: 1200px; margin: 0 auto; }
.hero-poster img { width: 200px; height: auto;

    border-radius: 8px; }
.hero-info { flex: 1; }
.hero-info h1 { font-size: 2.5rem; margin-bottom: 1rem; }
.hero-info p { font-size: 1.1rem; margin-bottom: 1.5rem;

    max-width: 80%; }
.hero-info p a#read-more-btn { color: var(--text-muted); text-decoration: underline; font-weight: normal; cursor: pointer; margin-left: 5px;
}
.hero-info p a#read-more-btn:hover { color: var(--primary-color); }
.hero-actions { display: flex; gap: 1rem; align-items: center;
}
@media (min-width: 768px) {
    /* --- Detail Page & Hero Styles --- */
    .hero-meta { margin-bottom: 1rem;

        color: var(--text-muted); }
    .hero-meta .separator { margin: 0 0.5rem; }
    .hero-actors { margin-bottom: 1.5rem;

        color: var(--text-muted); font-size: 0.9rem;}
    .hero-actors strong { color: var(--text-color); }
    .detail-page-main { width: 100%;
}
    .detail-hero { position: relative; width: 100%; height: 70vh; background-size: cover; background-position: center; color: #fff; display: flex;

        align-items: center; padding: 2rem; }
    .hero-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%;

        background: linear-gradient(to top, rgba(0,0,0,0.9) 10%, rgba(0,0,0,0.2) 100%); }
    .hero-content { position: relative; z-index: 2; display: flex;

        gap: 2rem; width: 100%; max-width: 1200px; margin: 0 auto; }
    .hero-poster img { width: 200px; height: auto;

        border-radius: 8px; }
    .hero-info { flex: 1; }
    .hero-info h1 { font-size: 2.5rem;

        margin-bottom: 1rem; }
    .hero-info p { font-size: 1.1rem; margin-bottom: 1.5rem; max-width: 80%;
}
    .hero-info p a#read-more-btn { color: var(--text-muted); text-decoration: underline; font-weight: normal; cursor: pointer; margin-left: 5px;
}
    .hero-info p a#read-more-btn:hover { color: var(--primary-color); }
    .hero-actions { display: flex; gap: 1rem;

        align-items: center; }
}
.btn-success { background-color: #28a745; border-color: #28a745; }
.btn-danger { background-color: #dc3545; border-color: #dc3545; }
.detail-content { padding-top: 2rem; padding-bottom: 2rem;
}
.seasons-episodes h2 { margin-bottom: 1.5rem; }
.season { margin-bottom: 2rem; }
.season h3 { margin-bottom: 1rem; border-bottom: 2px solid var(--primary-color); padding-bottom: 0.5rem;
}
.episode-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.episode-item { background-color: var(--tile-bg-color);
    padding: 1rem;
    border-radius: 5px;
    text-decoration: none;

    color: var(--text-color);
    transition: background-color: 0.3s;
    display: flex;
    flex-direction: column;
    border: none;
    font-family: inherit;
    font-size: inherit;
    text-align: left;}
.movie-item { background-color: #ff6600;

    padding: 0.5rem;
    border-radius: 5px;
    text-decoration: none;
    color: #000;
    transition: background-color: 0.3s;
    display: flex;
    flex-direction: column;
    border: none;
    font-family: inherit;

    font-size: inherit;
    text-align: left;}
.episode-list.movie{grid-template-columns: 100%;}
.movie-number{text-align: center;font-weight: 800;color: #fff;font-size: 1.4em;text-transform: uppercase;letter-spacing: 2px;}
.episode-item:hover { background-color: var(--tile-bg-hover-color); }
.episode-number { font-weight: 800; color: var(--primary-color);

    margin-bottom: 0.5rem; font-size: 1.4em; }
.similar-section { margin-top: 2rem; }
.tiles-container.horizontal-scroll { display: flex; padding-bottom: 1rem; gap: 1rem; flex-wrap: wrap; flex-direction: row;
}
.tiles-container.horizontal-scroll .tile { flex: 0 0 auto; width: 180px; }
.horizontal-scroll::-webkit-scrollbar { height: 8px; }
.horizontal-scroll::-webkit-scrollbar-track { background: var(--surface-color);
}
.horizontal-scroll::-webkit-scrollbar-thumb { background: var(--primary-color); border-radius: 4px; }
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.8);

    backdrop-filter: blur(5px); display: flex; justify-content: center; align-items: center; z-index: 2000; }
.modal-content { background-color: var(--surface-color); padding: 2rem; border-radius: 8px; max-width: 800px;

    width: 90%; max-height: 80vh; overflow-y: auto; position: relative; }
.modal-close-btn { position: absolute; top: 10px; right: 15px; background: none; border: none;

    color: var(--text-muted); font-size: 2rem; cursor: pointer; }
.remote-tabs { display: flex; border-bottom: 1px solid #444; margin-bottom: 1rem; }
.tab-link { background: none;

    border: none; color: var(--text-muted); padding: 1rem; font-size: 1rem; cursor: pointer; border-bottom: 2px solid transparent; }
.tab-link.active { color: var(--text-color); border-bottom-color: var(--primary-color);
}
.tab-content { display: none; }
.tab-content.active { display: block; }
.setting-item { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0;
}
#remote-episode-list .episode-item.active { background-color: var(--primary-color); color: #fff; }
#connection-status-indicator { font-size: 0.7rem; padding: 0.2rem 0.5rem; border-radius: 5px; position: absolute; top: 0;

    left: 0;}
#connection-status-indicator.connected { background-color: #28a745; color: white; }
#connection-status-indicator.disconnected { background-color: #dc3545; color: white;
}
@media (max-width: 768px) { .detail-hero { height: auto; padding: 1.5rem;} .hero-content { flex-direction: column; align-items: center; gap: 0rem; text-align: center;
} .hero-poster img { width: 150px; } .hero-info p { max-width: 90%; margin-left: auto; margin-right: auto;
} .hero-actions { justify-content: center; flex-wrap: wrap; } }
@media (max-width: 480px) { .hero-info h1 { font-size: 1.8rem;
} .hero-info p { font-size: 1rem; } .episode-list { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
} }

/* --- TV Manager Styles --- */
.tv-manager-container { display: flex; gap: 2rem; }
.tv-manager-sidebar { flex: 0 0 350px; }
.tv-manager-main { flex-grow: 1; }
.manager-list { list-style: none; padding: 0; }
.manager-list li { background-color: var(--surface-color); padding: 10px 15px; border-radius: 5px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: background-color 0.2s; }
.manager-list li:hover { background-color: #333; }
.manager-list li.active { background-color: var(--primary-color); color: white; }
.schedule-list { list-style: none; padding: 0; }
.schedule-item { background-color: var(--surface-color); border: 1px solid var(--border-color); border-radius: 8px; margin-bottom: 1.5rem; }
.schedule-item-header { padding: 1rem; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; cursor: grab; }
.schedule-item-header:active { cursor: grabbing; }
.schedule-item-header h4 { margin: 0; }
.schedule-item-content { padding: 1rem; }
.schedule-item-content ul { list-style: none; padding: 0; }
.schedule-item-content li { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.schedule-item-content img { width: 40px; height: 60px; object-fit: cover; border-radius: 4px; }

/* --- Streaming TV EPG Styles --- */
#epg-container {
    display: grid;
    grid-template-columns: 150px 1fr; /* Channel names and timeline */
    overflow-x: auto;
    background-color: var(--surface-color);
    border-radius: 8px;
}
.epg-channels {
    position: sticky;
    left: 0;
    z-index: 2;
    background-color: var(--surface-color);
}
.epg-channel-header, .epg-timeline-header {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background-color: var(--surface-color);
    z-index: 3;
}
.epg-channel-cell {
    height: 80px;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}
.epg-channel-cell:hover {
    background-color: #2a2a2a;
}
.epg-timeline {
    position: relative;
}
.epg-timeline-header {
    display: grid;
    grid-template-columns: repeat(12, 10fr); /* 12 hours view */
}
.epg-timeline-hour {
    text-align: center;
    color: var(--text-muted);
}
.epg-channel-row {
    height: 80px;
    position: relative;
    border-bottom: 1px solid var(--border-color);
}
.epg-program {
    position: absolute;
    height: 100%;
    background-color: var(--card-bg);
    border-left: 3px solid var(--primary-color);
    padding: 8px;
    border-radius: 4px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    /* cursor: pointer; */ /* No longer clickable */
    transition: background-color 0.2s;
    font-size: 0.9rem;
    pointer-events: none; /* Make sure it doesn't intercept clicks meant for the row/cell */
}
.epg-program:hover {
    background-color: #444; /* This won't trigger anymore due to pointer-events: none, which is fine */
}
.epg-program-title {
    font-weight: bold;
}
.epg-program-time {
    font-size: 0.8rem;
    color: var(--text-muted);
}

#epg-container::-webkit-scrollbar {
    height: 12px;
}
#epg-container::-webkit-scrollbar-track {
    background: var(--surface-color);
    border-radius: 10px;
}
#epg-container::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 10px;
    border: 3px solid var(--surface-color);
}

.epg-time-indicator {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: #cc3333;
    z-index: 4;
    pointer-events: none;
}