/* =========================================================
   Nordvik TV - Public Site Stylesheet
   Modern dark IPTV theme
   ========================================================= */

:root {
    --bg: #090a0f;
    --bg-elevated: #12141c;
    --bg-card: #161925;
    --bg-card-hover: #1e2230;
    --bg-card-active: #202844;
    --border: #232739;
    --border-light: #2c3145;
    --text: #eef0f6;
    --text-dim: #8b91a7;
    --text-faint: #5a6079;
    --accent: #2dd4ee;
    --accent-2: #7c6bf2;
    --accent-grad: linear-gradient(135deg, #2dd4ee 0%, #7c6bf2 100%);
    --live: #f13a4b;
    --fav: #fbbf24;
    --success: #22c55e;
    --danger: #f13a4b;
    --warning: #f59e0b;
    --radius-lg: 16px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    --header-h: 68px;
}

* { box-sizing: border-box; }

/* Muss vor allen anderen Regeln stehen: einige Elemente setzen "display"
   direkt auf der Klasse (z.B. display:flex fuer Overlays). Ohne diese Regel
   gewinnt diese Klassenregel gegen die Browser-Standardregel [hidden]{display:none},
   da beide die gleiche Spezifitaet haben - das Element bliebe sichtbar,
   obwohl JS das hidden-Attribut korrekt setzt. */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-image:
        radial-gradient(circle at 15% 0%, rgba(124, 107, 242, 0.10), transparent 40%),
        radial-gradient(circle at 85% 10%, rgba(45, 212, 238, 0.08), transparent 40%);
}

a { color: var(--accent); }

button { font-family: inherit; }

/* ---------------------------------------------------------
   Header
   --------------------------------------------------------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: rgba(9, 10, 15, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    font-size: 26px;
    filter: drop-shadow(0 0 10px rgba(45, 212, 238, 0.5));
}

.brand-text h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.2px;
    background: var(--accent-grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.brand-tagline {
    font-size: 11px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.header-count {
    font-size: 13px;
    color: var(--text-dim);
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 999px;
}

/* ---------------------------------------------------------
   Layout
   --------------------------------------------------------- */
.layout {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 22px;
    padding: 22px;
    max-width: 1800px;
    width: 100%;
    margin: 0 auto;
    align-items: start;
}

/* ---------------------------------------------------------
   Player
   --------------------------------------------------------- */
.player-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: calc(var(--header-h) + 22px);
}

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

#video-player {
    width: 100%;
    height: 100%;
    display: block;
    background: #000;
    object-fit: contain;
}

.player-placeholder,
.player-loading,
.player-error {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    padding: 24px;
    background: radial-gradient(circle at 50% 40%, #14161f 0%, #08090c 100%);
    color: var(--text-dim);
}

.placeholder-icon {
    font-size: 44px;
    opacity: 0.5;
}

.player-placeholder p,
.player-error p {
    max-width: 320px;
    font-size: 14px;
    margin: 0;
}

.spinner {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}

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

.player-error {
    color: var(--text);
    background: radial-gradient(circle at 50% 40%, #1c1114 0%, #0a0708 100%);
}

.error-icon { font-size: 34px; }

/* ---------------------------------------------------------
   Now playing
   --------------------------------------------------------- */
.now-playing {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
}

.now-playing-logo {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.now-playing-logo img { width: 100%; height: 100%; object-fit: cover; }

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

.now-playing-info h2 {
    margin: 2px 0 2px;
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.now-playing-info p {
    margin: 0;
    font-size: 13px;
    color: var(--text-dim);
}

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.6px;
    color: var(--live);
    background: rgba(241, 58, 75, 0.12);
    border: 1px solid rgba(241, 58, 75, 0.35);
    padding: 3px 9px 3px 7px;
    border-radius: 999px;
    margin-bottom: 4px;
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--live);
    animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

.fav-toggle-btn {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.fav-toggle-btn:hover { transform: scale(1.08); color: var(--fav); }

.fav-toggle-btn.active {
    color: var(--fav);
    border-color: rgba(251, 191, 36, 0.5);
}

.fav-toggle-btn.active svg { fill: var(--fav); }
.fav-toggle-btn svg { fill: none; stroke: currentColor; stroke-width: 1.6; transition: fill 0.15s ease; }
.fav-toggle-btn.active svg { fill: var(--fav); stroke: var(--fav); }

/* ---------------------------------------------------------
   EPG (Programmuebersicht)
   --------------------------------------------------------- */
.epg-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    max-height: 420px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.epg-panel-title {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-faint);
}

.epg-list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.epg-day-header {
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-faint);
    padding: 10px 4px 4px;
}

.epg-day-header:first-child { padding-top: 2px; }

.epg-item {
    display: flex;
    gap: 12px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border-left: 2px solid transparent;
}

.epg-item.epg-current {
    background: rgba(45, 212, 238, 0.08);
    border-left-color: var(--accent);
}

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

.epg-time {
    flex-shrink: 0;
    width: 88px;
    font-size: 12.5px;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
}

.epg-item.epg-current .epg-time { color: var(--accent); font-weight: 700; }

.epg-item-body { flex: 1; min-width: 0; }

.epg-item-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
}

.epg-now-tag {
    display: inline-block;
    margin-left: 8px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--live);
    vertical-align: middle;
}

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

.epg-list::-webkit-scrollbar { width: 6px; }
.epg-list::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
.epg-list::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------
   Channel panel
   --------------------------------------------------------- */
.channel-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    max-height: calc(100vh - var(--header-h) - 44px);
    position: sticky;
    top: calc(var(--header-h) + 22px);
}

.channel-toolbar {
    display: flex;
    gap: 10px;
}

.search-box {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 9px 14px;
    color: var(--text-faint);
    transition: border-color 0.15s ease;
}

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

.search-box input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 14px;
}

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

.fav-filter-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 9px 14px;
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.fav-filter-btn svg { fill: none; stroke: currentColor; stroke-width: 1.6; }

.fav-filter-btn:hover { border-color: var(--border-light); color: var(--text); }

.fav-filter-btn[aria-pressed="true"] {
    background: rgba(251, 191, 36, 0.12);
    border-color: rgba(251, 191, 36, 0.5);
    color: var(--fav);
}

.fav-filter-btn[aria-pressed="true"] svg { fill: var(--fav); stroke: var(--fav); }

.filter-group { display: flex; flex-direction: column; gap: 8px; }

.filter-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-faint);
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    max-height: 84px;
    overflow-y: auto;
    padding-right: 2px;
}

.filter-chip {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 12.5px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.filter-chip:hover { border-color: var(--border-light); color: var(--text); }

.filter-chip.active {
    background: var(--accent-grad);
    border-color: transparent;
    color: #05121a;
}

.channel-list-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-faint);
    padding-top: 4px;
    border-top: 1px solid var(--border);
}

.result-count { text-transform: none; letter-spacing: 0; font-weight: 500; }

.channel-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 120px;
    padding-right: 2px;
}

.channel-card {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 8px 10px;
    cursor: pointer;
    text-align: left;
    color: var(--text);
    transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}

.channel-card:hover {
    background: var(--bg-card-hover);
    transform: translateX(2px);
}

.channel-card.active {
    background: var(--bg-card-active);
    border-color: rgba(45, 212, 238, 0.4);
}

.channel-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
}

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

.logo-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    color: #fff;
}

.channel-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }

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

.channel-meta {
    font-size: 12px;
    color: var(--text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-fav {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-faint);
    border-radius: 50%;
    transition: color 0.15s ease, transform 0.15s ease;
}

.channel-fav svg { fill: none; stroke: currentColor; stroke-width: 1.6; }

.channel-fav:hover { color: var(--fav); transform: scale(1.15); }

.channel-card.is-favorite .channel-fav { color: var(--fav); }
.channel-card.is-favorite .channel-fav svg { fill: var(--fav); stroke: var(--fav); }

.empty-state {
    text-align: center;
    color: var(--text-faint);
    font-size: 13.5px;
    padding: 30px 10px;
}

.btn {
    border: 1px solid var(--border-light);
    background: var(--bg-card);
    color: var(--text);
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }

.btn-ghost {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.25);
    color: var(--text);
}

.btn-load-more {
    width: 100%;
    text-align: center;
    background: var(--bg-card);
}

/* ---------------------------------------------------------
   Footer
   --------------------------------------------------------- */
.site-footer {
    text-align: center;
    padding: 18px;
    font-size: 12.5px;
    color: var(--text-faint);
}

.site-footer a { color: var(--text-faint); text-decoration: underline; }
.site-footer a:hover { color: var(--accent); }

/* ---------------------------------------------------------
   Scrollbars
   --------------------------------------------------------- */
.channel-list::-webkit-scrollbar,
.filter-row::-webkit-scrollbar { width: 6px; height: 6px; }
.channel-list::-webkit-scrollbar-thumb,
.filter-row::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
.channel-list::-webkit-scrollbar-track,
.filter-row::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */
@media (max-width: 1100px) {
    .layout {
        grid-template-columns: 1fr;
    }
    .player-section,
    .channel-panel {
        position: static;
        top: auto;
    }
    .channel-panel {
        max-height: none;
    }
    .channel-list {
        max-height: 62vh;
    }
}

@media (max-width: 640px) {
    .site-header { padding: 0 14px; }
    .brand-tagline { display: none; }
    .layout { padding: 14px; gap: 16px; }
    .now-playing { flex-wrap: wrap; }
    .brand-text h1 { font-size: 17px; }
    .header-count { font-size: 11px; padding: 5px 10px; }
    .channel-panel { padding: 14px; }
}
