/* ============================================
   TV-System — Einfaches Fernsehen fuer Mama
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: #1a1a2e;
  color: #f0f0f0;
  font-size: 22px;
  line-height: 1.4;
  user-select: none;
  -webkit-user-select: none;
}

/* ─── Header ─────────────────────────────── */

.header {
  background: #16213e;
  padding: 18px 24px;
  text-align: center;
  border-bottom: 3px solid #0f3460;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header h1 {
  font-size: 32px;
  font-weight: 700;
  color: #e2e8f0;
  letter-spacing: 1px;
}

.header .clock {
  font-size: 26px;
  color: #94a3b8;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* ─── Sendergruppen ──────────────────────── */

.channel-group {
  padding: 12px 20px 4px;
}

.group-label {
  font-size: 20px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 2px;
  padding: 8px 0;
  border-bottom: 1px solid #334155;
  margin-bottom: 4px;
}

/* ─── Senderliste ────────────────────────── */

.channel-list {
  padding: 0 12px 24px;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  margin: 4px 0;
  background: #16213e;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  border: 2px solid transparent;
  min-height: 72px;
}

.channel-item:hover,
.channel-item:focus {
  background: #1e3a5f;
  border-color: #3b82f6;
  transform: scale(1.01);
}

.channel-item:active {
  transform: scale(0.99);
  background: #2563eb;
}

.channel-logo {
  width: 64px;
  height: 48px;
  object-fit: contain;
  flex-shrink: 0;
  background: #fff;
  border-radius: 8px;
  padding: 4px;
}

.channel-logo-placeholder {
  width: 64px;
  height: 48px;
  flex-shrink: 0;
  background: #334155;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #94a3b8;
}

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

.channel-name {
  font-size: 26px;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-program {
  font-size: 21px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.channel-arrow {
  font-size: 28px;
  color: #475569;
  flex-shrink: 0;
  padding-right: 4px;
}

/* ─── Player (Vollbild) ──────────────────── */

.player-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 1000;
  display: none;
  flex-direction: column;
}

.player-overlay.active {
  display: flex;
}

.player-video-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

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

/* PiP-Button und sonstige Browser-Controls verstecken */
video::-webkit-media-controls-pip-button,
video::-webkit-media-controls-panel-pip-button,
video::-webkit-media-controls-overlay-pip-button {
  display: none !important;
}

/* Close-Button */
.player-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1020;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  font-size: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s, background 0.2s;
  backdrop-filter: blur(4px);
}

.player-close:hover {
  background: rgba(220, 38, 38, 0.8);
  border-color: rgba(255, 255, 255, 0.6);
}

/* Pfeil-Navigation */
.player-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1010;
  width: 70px;
  height: 120px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: #fff;
  font-size: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s, background 0.2s;
  backdrop-filter: blur(4px);
}

.player-nav:hover {
  background: rgba(0, 0, 0, 0.8);
}

.player-nav.prev {
  left: 0;
  border-radius: 0 14px 14px 0;
}

.player-nav.next {
  right: 0;
  border-radius: 14px 0 0 14px;
}

/* Info-Overlay unten */
.player-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1010;
  background: rgba(0, 0, 0, 0.92);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: opacity 0.5s ease;
  opacity: 0;
  pointer-events: none;
}

.player-info.visible {
  opacity: 1;
}

.player-info-logo {
  width: 56px;
  height: 42px;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
  padding: 3px;
  flex-shrink: 0;
}

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

.player-info-name {
  font-size: 30px;
  font-weight: 700;
  color: #fff;
}

.player-info-program {
  font-size: 24px;
  color: #e2e8f0;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Ladeindikator */
.player-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1005;
  display: none;
}

.player-loading.active {
  display: block;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 5px solid rgba(255, 255, 255, 0.2);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Fehlermeldung */
.player-error {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1005;
  text-align: center;
  color: #f87171;
  font-size: 22px;
  display: none;
  padding: 20px;
}

.player-error.active {
  display: block;
}

.player-error .retry-btn {
  margin-top: 16px;
  padding: 12px 32px;
  font-size: 22px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}

/* Controls auto-hide (Player) */
.player-controls-layer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1002;
  cursor: pointer;
}

.player-overlay .auto-hide {
  transition: opacity 0.4s ease;
}

.player-overlay.controls-hidden .auto-hide {
  opacity: 0;
  pointer-events: none;
}

/* ─── Iframe-Overlay (externe Seiten) ────── */

.iframe-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 1000;
  display: none;
}

.iframe-overlay.active {
  display: block;
}

.iframe-overlay iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.iframe-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1020;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.iframe-close:hover {
  background: rgba(220, 38, 38, 0.8);
}

/* ─── Responsive ─────────────────────────── */

@media (max-width: 600px) {
  .header h1 { font-size: 26px; }
  .header .clock { font-size: 22px; }

  .channel-item {
    padding: 12px 14px;
    gap: 12px;
    min-height: 64px;
  }

  .channel-logo,
  .channel-logo-placeholder {
    width: 52px;
    height: 38px;
  }

  .channel-name { font-size: 22px; }
  .channel-program { font-size: 17px; }

  .player-nav {
    width: 54px;
    height: 90px;
    font-size: 32px;
  }

  .player-close {
    width: 50px;
    height: 50px;
    font-size: 28px;
  }
}

@media (min-width: 900px) {
  .channel-list {
    max-width: 800px;
    margin: 0 auto;
  }
}
