/* TeslaTube — pensado para la pantalla táctil del coche: oscuro, grande, simple */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0e0f13;
  --card: #1a1c22;
  --card2: #23262e;
  --text: #f2f3f5;
  --muted: #9aa0ab;
  --accent: #e63946;
  --accent2: #3a86ff;
  --radius: 14px;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 18px;
}

.hidden { display: none !important; }
.view { min-height: 100vh; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }

/* ---------- LOGIN ---------- */
#view-login { display: flex; align-items: center; justify-content: center; }
.login-card { text-align: center; padding: 32px; }
.login-card h1 { font-size: 42px; margin-bottom: 8px; }
.login-card h1 span, .logo span { color: var(--accent); }
.login-hint { color: var(--muted); margin-bottom: 20px; }
#pin-input {
  width: 260px; text-align: center; font-size: 34px; letter-spacing: 12px;
  background: var(--card); color: var(--text); border: 2px solid var(--card2);
  border-radius: var(--radius); padding: 12px; margin-bottom: 20px;
}
.numpad { display: grid; grid-template-columns: repeat(3, 92px); gap: 12px; justify-content: center; }
.numpad button {
  height: 72px; font-size: 28px; background: var(--card); border-radius: var(--radius);
}
.numpad button:active { background: var(--card2); }
.numpad .ok { background: var(--accent); font-weight: 700; }
.login-error { color: var(--accent); margin-top: 16px; min-height: 24px; }

/* ---------- HOME ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 18px 28px; position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.logo { font-size: 28px; white-space: nowrap; }
.searchbox { display: flex; flex: 1; gap: 12px; }
.searchbox input {
  flex: 1; height: 64px; font-size: 22px; padding: 0 20px;
  background: var(--card); color: var(--text);
  border: 2px solid var(--card2); border-radius: var(--radius);
}
.searchbox button {
  height: 64px; padding: 0 32px; font-size: 22px; font-weight: 600;
  background: var(--accent); border-radius: var(--radius);
}
.home-main { padding: 8px 28px 40px; }
section { margin-bottom: 28px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; }
h2 { font-size: 22px; margin-bottom: 14px; color: var(--text); }
.pill {
  background: var(--card2); border-radius: 999px; padding: 10px 22px; font-size: 17px;
}
.status { color: var(--muted); font-size: 20px; padding: 20px 0; }

.cards-row { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 8px; }
.cards-grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.card {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  text-align: left; display: flex; flex-direction: column; position: relative;
}
.cards-row .card { min-width: 300px; max-width: 300px; }
.card:active { background: var(--card2); }
.thumb-wrap { position: relative; aspect-ratio: 16/9; background: #000; }
.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge {
  position: absolute; bottom: 8px; right: 8px; font-size: 14px; font-weight: 700;
  padding: 3px 10px; border-radius: 6px; background: rgba(0,0,0,.8);
}
.badge.live { background: var(--accent); }
.card-body { padding: 12px 14px 14px; }
.card-title {
  font-size: 18px; line-height: 1.3; max-height: 2.6em; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.card-channel { color: var(--muted); font-size: 16px; margin-top: 6px; }
.card-fav {
  position: absolute; top: 8px; left: 8px; width: 48px; height: 48px; font-size: 22px;
  border-radius: 12px; background: rgba(0,0,0,.65);
}
.card-fav.active { color: var(--accent); }
.card-progress { height: 5px; background: var(--card2); }
.card-progress > div { height: 100%; background: var(--accent); }

/* tarjeta de canal favorito */
.chan-card {
  background: var(--card); border-radius: var(--radius); min-width: 280px;
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.chan-name { font-size: 19px; font-weight: 600; }
.chan-state { color: var(--muted); font-size: 16px; min-height: 22px; }
.chan-live-btn {
  background: var(--accent); border-radius: 10px; padding: 12px; font-size: 17px;
  font-weight: 700; text-align: left; line-height: 1.25;
}
.chan-actions { display: flex; gap: 10px; }
.chan-actions .pill { flex: 1; }

/* ---------- PLAYER ---------- */
#view-player { display: flex; flex-direction: column; height: 100vh; }
.player-top { display: flex; align-items: center; gap: 18px; padding: 12px 20px; }
.big-icon {
  width: 72px; height: 64px; font-size: 30px; background: var(--card);
  border-radius: var(--radius); flex-shrink: 0;
}
.player-meta { flex: 1; min-width: 0; }
.p-title { font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-channel { color: var(--muted); font-size: 16px; }
.live-badge {
  background: var(--accent); font-weight: 700; padding: 8px 16px;
  border-radius: 8px; font-size: 16px; white-space: nowrap;
}

.video-wrap {
  position: relative; flex: 1; min-height: 0; background: #000;
  display: flex; align-items: center; justify-content: center;
}
video { width: 100%; height: 100%; object-fit: contain; }
.poster-overlay {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  background: #000;
}
.big-play {
  position: absolute; width: 132px; height: 132px; border-radius: 50%;
  background: rgba(230,57,70,.92); font-size: 52px; padding-left: 10px;
}
.p-status {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.75); padding: 10px 20px; border-radius: 10px; font-size: 17px;
}

.controls { padding: 10px 24px 20px; background: var(--bg); }
.progress-row { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.time { color: var(--muted); font-size: 17px; min-width: 62px; text-align: center; font-variant-numeric: tabular-nums; }
.progress {
  flex: 1; height: 34px; display: flex; align-items: center; position: relative; cursor: pointer;
}
.progress::before {
  content: ""; position: absolute; left: 0; right: 0; height: 8px; top: 13px;
  background: var(--card2); border-radius: 4px;
}
.prog-buf, .prog-fill, #prog-sponsors > div {
  position: absolute; height: 8px; top: 13px; border-radius: 4px;
}
.prog-buf { background: #3d414c; width: 0; }
.prog-fill { background: var(--accent); width: 0; }
#prog-sponsors > div { background: #2ec4b6; opacity: .85; }

.btn-row { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; }
.ctl {
  height: 76px; min-width: 108px; padding: 0 22px; font-size: 22px; font-weight: 600;
  background: var(--card); border-radius: var(--radius);
}
.ctl:active { background: var(--card2); }
.ctl-main { min-width: 132px; font-size: 34px; background: var(--accent); }
.ctl-sm { font-size: 18px; min-width: 92px; }
.ctl.active { outline: 3px solid var(--accent2); }

.toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  background: var(--card2); border-left: 6px solid #2ec4b6;
  padding: 14px 26px; border-radius: 10px; font-size: 19px; z-index: 50;
}
