/* Streaming-Portal — eigenständige Styling-Datei, NICHT aus app.css importiert
   damit die /login + /streaming Seiten kein hidden Cockpit-Footprint mitbringen.
   Dark-Theme, einfaches Layout, mobile-first. */

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: #000;
  color: #eee;
  font-family: "Fira Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  /* Hart gegen horizontalen Scroll: keine einzelne Komponente darf den
     Viewport sprengen. Wenn doch — abschneiden, nicht scrollen. Behebt
     das iPhone-Mini-Wackeln nach rechts. */
  overflow-x: hidden;
  max-width: 100vw;
}
/* iOS: text-size-adjust verhindert dass Safari font-sizes "smart" hochskaliert
   im Landscape-Mode — sonst ploppt das Layout. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

a { color: #4fc3f7; }
a.ghost-button { text-decoration: none; }
button, input { font-family: inherit; }

/* ── Login ──────────────────────────────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  background: #111;
  border: 1px solid #222;
  border-radius: 8px;
  padding: 32px;
  width: 100%;
  max-width: 360px;
}
.login-card h1 {
  margin: 0 0 4px 0;
  font-size: 1.25rem;
  font-weight: 600;
}
.login-hint { color: #888; margin: 0 0 24px 0; font-size: 0.9rem; }
.login-error {
  background: #2a0e0e;
  border: 1px solid #4a1a1a;
  color: #ff8a8a;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.9rem;
  margin: 0 0 16px 0;
}
.login-card label {
  display: block;
  margin-bottom: 14px;
}
.login-card label span {
  display: block;
  font-size: 0.85rem;
  color: #aaa;
  margin-bottom: 4px;
}
.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  background: #000;
  border: 1px solid #333;
  border-radius: 4px;
  color: #eee;
  font-size: 1rem;
}
.login-card input:focus { outline: 2px solid #4fc3f7; border-color: #4fc3f7; }
.login-card button {
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  background: #4fc3f7;
  color: #000;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}
.login-card button:hover { background: #67d2ff; }

/* ── Portal ─────────────────────────────────────────────────────────────── */
.portal-body { min-height: 100vh; display: flex; flex-direction: column; }

.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #0a0a0a;
  border-bottom: 1px solid #222;
}
.portal-header h1 { margin: 0; font-size: 1rem; font-weight: 600; color: #ddd; }
.portal-meta { display: flex; align-items: center; gap: 16px; }
.portal-user { color: #888; font-size: 0.85rem; }
.portal-user strong { color: #ddd; }
.portal-quota {
  font-size: 0.85rem;
  padding: 4px 10px;
  background: #112;
  border-radius: 12px;
  color: #4fc3f7;
}
.portal-quota.is-full { background: #2a0e0e; color: #ff8a8a; }
.portal-kill-btn {
  background: transparent;
  border: 1px solid #4a1a1a;
  color: #ff8a8a;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  margin-left: -4px;
}
.portal-kill-btn:hover { background: #2a0e0e; border-color: #6a2a2a; }
.portal-kill-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.portal-logout-form { display: inline; margin: 0; }

/* HQ / LQ Quality-Toggle — Pill-style, kompakt, im Header neben der Quota */
.portal-quality {
  display: inline-flex;
  border: 1px solid #333;
  border-radius: 12px;
  overflow: hidden;
}
.portal-quality-btn {
  background: transparent;
  border: 0;
  color: #aaa;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.portal-quality-btn:hover { background: #1a1a1a; color: #eee; }
.portal-quality-btn.is-active {
  background: #4fc3f7;
  color: #000;
  cursor: default;
}
.portal-quality-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.ghost-button {
  background: transparent;
  border: 1px solid #333;
  color: #ccc;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
}
.ghost-button:hover { border-color: #555; background: #161616; }
.ghost-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: #222;
}

/* ── Player ─────────────────────────────────────────────────────────────── */
.player-section[hidden] { display: none; }
.player-section {
  background: #050505;
  padding: 16px 20px;
  border-bottom: 1px solid #222;
}
.player-placeholder {
  padding: 24px 20px;
  border-bottom: 1px solid #222;
  color: #888;
  font-size: 0.9rem;
  text-align: center;
}
.player-placeholder[hidden] { display: none; }
.player-placeholder p { margin: 0; }
#player {
  width: 100%;
  max-height: 60vh;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 6px;
}
.player-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  color: #999;
  font-size: 0.9rem;
}

/* ── Channels-Liste ─────────────────────────────────────────────────────── */
.portal-channels { flex: 1; padding: 16px 20px; }
.channels-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
#channel-search {
  flex: 1;
  padding: 8px 12px;
  background: #111;
  border: 1px solid #333;
  border-radius: 4px;
  color: #eee;
  font-size: 0.9rem;
}
.channels-progress { color: #888; font-size: 0.85rem; min-width: 100px; text-align: right; }

.channels-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 6px;
}
.channels-loading {
  grid-column: 1 / -1;
  text-align: center;
  color: #777;
  padding: 30px;
}

.channel-card {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: #0e0e0e;
  border: 1px solid #1c1c1c;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

/* Linke Spalte: Nummer oben, Logo darunter — vertikales Stack, zentriert */
.channel-num-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.channel-logo {
  width: 48px;
  height: 28px;
  object-fit: contain;
  display: block;
  border-radius: 2px;
  /* Logos haben oft transparente Hintergründe + helle Farben — auf
     unserem schwarzen Theme verschwinden manche. Subtiler Box-Shadow
     hebt sie ab ohne aufdringlich zu wirken. */
  background: rgba(255, 255, 255, 0.04);
  padding: 2px;
}
.channel-card:hover { background: #161616; border-color: #2a2a2a; }
.channel-card.is-active {
  background: #0a1a2a;
  border-color: #4fc3f7;
  cursor: default;  /* aktiv = nicht klickbar (Re-Klick würde nur Session neu starten) */
}
.channel-card.is-active:hover { background: #0a1a2a; border-color: #4fc3f7; }
.channel-card.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: #0a0a0a;
}
.channel-card.is-disabled:hover { background: #0a0a0a; border-color: #1c1c1c; }
/* .is-paused: Sender ist in Sendepause (EPG-Filler-Slot). Stream liefert grad
   nichts, ABER der Sender bleibt klickbar — Click triggert Waiting-Mode der
   automatisch resumed sobald die echte Sendung startet. Visuell: leicht
   gedimmt + gelber Akzent — abgrenzbar von "is-disabled" (Tuner voll). */
.channel-card.is-paused {
  opacity: 0.7;
  background: #1a160a;
  border-color: #3a3010;
}
.channel-card.is-paused:hover { background: #221c0e; border-color: #4d3f15; }
.channel-num {
  text-align: right;
  color: #888;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
}
.channel-name {
  font-size: 0.95rem;
  color: #ddd;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.channel-name small {
  display: block;
  font-size: 0.75rem;
  color: #777;
  font-weight: 400;
  /* EPG-Titel können lang sein (z.B. Doku-Reihen "Wege durch …" mit Untertitel).
     Wir lassen sie umbrechen statt zu kürzen — der Operator will den vollen
     Titel sehen um Sendung wiederzuerkennen. */
  white-space: normal;
  line-height: 1.25;
}
.channel-name { white-space: normal; }
.channel-card {
  /* Höhe wachsen lassen damit mehrzeilige EPG-Titel reinpassen */
  align-items: start;
  padding: 10px 10px;
}
.channel-name small.epg-now { color: #b0b0b0; }
.channel-name small.epg-next { color: #666; font-size: 0.7rem; }
/* Filler-Pimp: "↳ ab 15:15 · FC St. Pauli - VfL Wolfsburg" unter dem
   eigentlichen Filler-Titel. Etwas heller als "next" damit klar ist:
   das ist die richtige kommende Sendung, nicht nur Vorschau. */
.channel-name small.epg-follows {
  display: block;
  color: #9ecbff;
  font-size: 0.72rem;
  line-height: 1.25;
}

/* VfL-Wolfsburg-Highlight: subtiler grüner Akzent statt "is-active"-cyan,
   so dass laufender Stream + Wolfsburg-Treffer kombinierbar sind. */
.channel-card.is-wob-highlight {
  background: #0e1a0d;
  border-color: #4caf50;
}
.channel-card.is-wob-highlight:hover { background: #142214; border-color: #66bb6a; }
/* Wolfsburg-Logo unterhalb des Senderlogos in der linken Spalte —
   größer als ein Inline-Badge, dynamisch eingeblendet. */
.channel-num-cell .epg-wob-badge {
  width: 36px;
  height: 36px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  padding: 2px;
  display: block;
  margin-top: 2px;
}

/* ── Bundesliga Live-Score Overlay ─────────────────────────────────────── */
.livescore {
  margin-top: 12px;
  background: linear-gradient(180deg, #111 0%, #0a0a0a 100%);
  border: 1px solid #1c1c1c;
  border-radius: 8px;
  padding: 14px 16px;
  color: #eee;
  font-size: 0.95rem;
}
.livescore[hidden] { display: none; }
.livescore-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 8px;
}
.livescore-team {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.livescore-team.t1 { justify-content: flex-end; text-align: right; }
.livescore-team.t2 { justify-content: flex-start; text-align: left; }
.livescore-logo {
  width: 36px; height: 36px;
  object-fit: contain;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  padding: 2px;
  flex-shrink: 0;
}
.livescore-team-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: #ddd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.livescore-score {
  font-family: "Fira Code", "SF Mono", "Menlo", monospace;
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
  padding: 0 10px;
  flex-shrink: 0;
}
.livescore-status {
  text-align: center;
  font-size: 0.85rem;
  color: #4fc3f7;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.livescore-status.is-live::before {
  content: "● ";
  color: #f44336;
  animation: pulse 1.4s ease-in-out infinite;
}
.livescore-status.is-halftime { color: #ffb74d; }
.livescore-status.is-fulltime { color: #888; }
.livescore-status.is-kickoff { color: #ffeb3b; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.livescore-goals {
  margin-top: 8px;
  border-top: 1px solid #1c1c1c;
  padding-top: 8px;
  font-size: 0.85rem;
  color: #bbb;
  display: grid;
  grid-template-columns: 32px 1fr 80px;
  row-gap: 4px;
  column-gap: 8px;
}
.livescore-goal-minute { color: #888; font-variant-numeric: tabular-nums; }
.livescore-goal-scorer { color: #ddd; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.livescore-goal-score {
  font-family: "Fira Code", "SF Mono", "Menlo", monospace;
  color: #4fc3f7;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.livescore-no-goals {
  margin-top: 8px;
  border-top: 1px solid #1c1c1c;
  padding-top: 8px;
  font-size: 0.8rem;
  color: #666;
  font-style: italic;
  text-align: center;
}

@media (max-width: 540px) {
  .livescore-team-name { font-size: 0.85rem; }
  .livescore-logo { width: 28px; height: 28px; }
  .livescore-score { font-size: 1.4rem; padding: 0 6px; }
}

/* ── Player Waiting-Mode Overlay ───────────────────────────────────────────
   Wird angezeigt wenn der IPTV-Provider beim ersten Versuch 0 Bytes liefert
   und wir alle 10 s automatisch retryen statt zu errorn. */
.player-waiting {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 60vh;
  background: linear-gradient(180deg, #0a0a0a 0%, #000 100%);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ddd;
  font-family: "Fira Sans", -apple-system, sans-serif;
}
.player-waiting-inner {
  text-align: center;
  padding: 20px;
  max-width: 90%;
}
.player-waiting-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid #1a1a1a;
  border-top-color: #4fc3f7;
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin 1s linear infinite;
}
.player-waiting-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: #eee;
  margin-bottom: 6px;
}
.player-waiting-sub {
  font-size: 0.9rem;
  color: #999;
  margin-bottom: 4px;
}
.player-waiting-meta {
  margin-top: 10px;
  font-size: 0.78rem;
  color: #666;
  font-family: "Fira Code", "SF Mono", monospace;
}

/* Progress-Bar für aktuell laufende Sendung — ASCII-style mit
   Box-Drawing-Characters. Filled = cyan accent (Apple-VLC-vibe),
   Rest = dim gray. Monospace damit alle Zeichen gleich breit sind. */
.epg-bar {
  display: block;
  font-family: "Fira Code", "SF Mono", "Menlo", monospace;
  font-size: 0.7rem;
  letter-spacing: -0.5px;
  line-height: 1;
  margin-top: 3px;
  white-space: nowrap;
}
.epg-bar-fill { color: #4fc3f7; text-shadow: 0 0 4px rgba(79, 195, 247, 0.4); }
.epg-bar-rest { color: #2a2a2a; }
.epg-bar-pct  { color: #888; font-family: "Fira Sans", sans-serif; font-size: 0.65rem; }
.channel-status {
  font-size: 0.75rem;
  color: #4fc3f7;
  white-space: nowrap;
}
.channel-status.is-warn { color: #ffb74d; }
.channel-status.is-blocked { color: #ff8a8a; }

/* Spinner für "Stream wird gerade gestartet" — pures CSS, keine externe Lib */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #333;
  border-top-color: #4fc3f7;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@media (max-width: 720px) {
  .portal-header {
    padding: 8px 10px;
    flex-wrap: wrap;
    gap: 6px;
    /* Header darf 2 Zeilen sein auf mobile (Titel + Meta), aber NICHTS darf
       nach rechts überlaufen — sonst wird "Cockpit"-Button abgeschnitten. */
    row-gap: 8px;
  }
  .portal-header h1 { font-size: 0.95rem; }
  .portal-meta {
    gap: 6px;
    flex-wrap: wrap;
    width: 100%;             /* Meta-Zeile bekommt volle Breite */
    justify-content: flex-end;
  }
  .portal-user { display: none; }   /* "Eingeloggt als X" — auf mobile weglassen */
  .portal-quality-btn { padding: 4px 8px; font-size: 0.72rem; }
  .ghost-button { padding: 5px 10px; font-size: 0.8rem; }
  .player-section, .portal-channels { padding: 12px; }
  .channels-list { grid-template-columns: 1fr; }
  /* Channel-Card content darf nicht über die Card hinausragen */
  .channel-card { min-width: 0; max-width: 100%; }
  .channel-name { min-width: 0; }
  .epg-bar { font-size: 0.65rem; letter-spacing: -0.6px; }
  /* Suchfeld auf mobile volle Breite — wrappt auf eigene Zeile.
     channels-progress (Status-Text rechts) springt mit auf eigene Zeile. */
  .channels-toolbar { flex-wrap: wrap; gap: 8px; }
  #channel-search { flex: 1 1 100%; width: 100%; }
  .channels-progress { flex: 1 1 100%; text-align: left; min-width: 0; }
}
