/* =========================================================
   EDU-IPTV PRO - Design tokens
   Identidad propia: negro profundo + cyan electrico
   ========================================================= */
:root {
  --bg: #05050a;
  --bg-1: #08080f;
  --bg-2: #0d0d18;
  --bg-3: #131324;
  --surface: #10101c;
  --surface-2: #181828;
  --surface-3: #202036;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);

  --text: #f4f7fb;
  --text-2: #c3c9d8;
  --muted: #8b93a7;
  --dim: #5b6378;

  --accent: #00f3ff;
  --accent-2: #00b8d4;
  --accent-3: #007f99;
  --accent-soft: rgba(0, 243, 255, 0.12);
  --accent-glow: 0 0 24px rgba(0, 243, 255, 0.28);

  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ff4d6d;
  --star: #ffd166;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.28);

  --topbar-h: 70px;
  --overscan: 28px;

  /* Safe Areas para smartphones con notch / camera cutout / gesture bar */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --font: "Inter", "Roboto", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}

/* Modificadores por tipo de dispositivo detectado */
.device-mobile {
  --overscan: 12px;
  --topbar-h: 56px;
}

.device-tv {
  --overscan: 28px;
  --topbar-h: 70px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  user-select: none;
  -webkit-user-select: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
}

a {
  color: var(--accent);
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

h1, h2, h3, h4, p {
  margin: 0;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 243, 255, 0.45);
}

:focus {
  outline: none;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 20px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}
.btn:hover {
  background: var(--surface-3);
}
.btn:active {
  transform: scale(0.98);
}
.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #001014;
  box-shadow: var(--accent-glow);
}
.btn--primary:hover {
  background: linear-gradient(135deg, #5bf8ff, var(--accent));
}
.btn--ghost {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--text-2);
}
.btn--ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn--danger {
  background: rgba(255, 77, 109, 0.14);
  color: var(--danger);
  border: 1px solid rgba(255, 77, 109, 0.35);
}
.btn--sm {
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.82rem;
}
.btn--icon {
  width: 46px;
  min-width: 46px;
  padding: 0;
  border-radius: 50%;
}
.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}
.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 26px; height: 26px; }

/* ---------- Inputs ---------- */
.field {
  display: grid;
  gap: 8px;
}
.field > label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.input {
  width: 100%;
  min-height: 50px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  user-select: text;
  -webkit-user-select: text;
}
.input::placeholder {
  color: var(--dim);
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: rgba(0, 243, 255, 0.04);
}
.input--search {
  padding-left: 46px;
}

/* ---------- Focus TV ---------- */
[data-focusable] {
  position: relative;
  transition: box-shadow 0.12s ease, transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
[data-focusable].is-focused,
[data-focusable]:focus-visible {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 5px var(--accent);
  z-index: 3;
}
.posters [data-focusable].is-focused {
  transform: scale(1.045);
}
.channel-row[data-focusable].is-focused {
  background: #181C26 !important;
  box-shadow: none !important;
  outline: none !important;
}
.cat[data-focusable].is-focused {
  background: var(--surface-3);
  color: var(--accent);
}

/* ---------- Soporte Táctil Móvil ---------- */
@media (pointer: coarse) {
  [data-focusable]:focus:not(:focus-visible):not(.is-focused) {
    box-shadow: none !important;
    outline: none !important;
  }
  .scroll-touch,
  .page,
  .screen,
  .live__cats,
  .live__list,
  .posters {
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y pinch-zoom;
  }
}

/* ---------- Utilidades ---------- */
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.accent { color: var(--accent); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.danger { color: var(--danger); }
.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.hidden { display: none !important; }
