/* ═══════════════════════════════════════════════════════════
   SoloTV Smart TV — css/styles.css
   Compatible: Samsung Tizen 4+, LG webOS 3+, HbbTV 2+
   Resolución base: 1920×1080 (Full HD)
═══════════════════════════════════════════════════════════ */

/* ── VARIABLES ─────────────────────────────────────────── */
:root {
  --bg:        #0D0D0D;
  --surface:   #161616;
  --surface2:  #1E1E1E;
  --red:       #E8001C;
  --red-dim:   rgba(232,0,28,0.15);
  --white:     #FFFFFF;
  --gray:      #8A8A8A;
  --gray-dim:  #3A3A3A;
  --focus-ring: 3px solid #E8001C;

  --sidebar-w: 260px;
  --radius:    8px;
  --transition: 0.15s ease;

  font-size: 20px; /* base para rem en TV */
}

/* ── RESET ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--white);
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
img { display: block; max-width: 100%; }
ul { list-style: none; }
iframe { border: none; }

/* ── FOCUS (D-PAD) ─────────────────────────────────────── */
.focusable:focus {
  outline: var(--focus-ring);
  outline-offset: 2px;
}
/* Tizen/webOS a veces no dispara :focus — también manejamos clase */
.focusable.sn-focused {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

/* ══════════════════════════════════════════════════════════
   LAYOUT PRINCIPAL
══════════════════════════════════════════════════════════ */
#main-screen {
  display: flex;
  width: 100vw;
  height: 100vh;
}

/* ── SIDEBAR ───────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  padding: 40px 0 40px 0;
  border-right: 1px solid var(--gray-dim);
  flex-shrink: 0;
  z-index: 10;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px 40px;
  height: 160px;
}
.sidebar-logo img {
  max-height: 140px;
  max-width: 210px;
  object-fit: contain;
}
#sidebar-logo-text {
  color: var(--white);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

#nav-list { flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 28px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border-left: 4px solid transparent;
  outline: none;
}
.nav-item:hover,
.nav-item.sn-focused {
  background: var(--red-dim);
  border-left-color: var(--red);
  outline: none;
}
.nav-item.active {
  background: var(--red-dim);
  border-left-color: var(--red);
  color: var(--white);
}
.nav-item.sn-focused {
  outline: var(--focus-ring);
  outline-offset: -3px;
}
.nav-icon { font-size: 1.1rem; width: 24px; text-align: center; }
.nav-label { font-size: 0.85rem; font-weight: 500; letter-spacing: 0.04em; }

/* ── CONTENT AREA ──────────────────────────────────────── */
#content-area {
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 50px 60px 60px;
  scroll-behavior: smooth;
}
/* Ocultar scrollbar en TVs */
#content-area::-webkit-scrollbar { width: 4px; }
#content-area::-webkit-scrollbar-thumb { background: var(--gray-dim); border-radius: 2px; }

.content-section { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.section-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 36px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--red);
  display: inline-block;
}

/* ══════════════════════════════════════════════════════════
   SECCIÓN EN VIVO
══════════════════════════════════════════════════════════ */
.channel-grid {
  display: flex;
  gap: 30px;
  flex-wrap: wrap;
}

.channel-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  width: 320px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  outline: none;
  border: 2px solid transparent;
}
.channel-card:hover,
.channel-card.sn-focused {
  transform: scale(1.03);
  box-shadow: 0 0 0 3px var(--red);
  border-color: var(--red);
}

.channel-thumb {
  width: 100%;
  height: 180px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.channel-thumb img { max-height: 120px; max-width: 200px; object-fit: contain; padding: 16px; }
.channel-thumb.no-thumb::after {
  content: '📺';
  font-size: 3rem;
  opacity: 0.4;
}

.channel-info { padding: 16px 20px 20px; }
.channel-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.live-badge { background: var(--red); color: var(--white); }

.channel-name {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.channel-quality { font-size: 0.7rem; color: var(--gray); }

/* ══════════════════════════════════════════════════════════
   SECCIÓN EPG
══════════════════════════════════════════════════════════ */
#epg-list { max-width: 900px; }

.epg-item {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 18px 20px;
  border-radius: var(--radius);
  margin-bottom: 6px;
  background: var(--surface);
  transition: background var(--transition);
}
.epg-item.current { background: var(--red-dim); border-left: 3px solid var(--red); }

.epg-time {
  font-size: 0.75rem;
  color: var(--gray);
  font-feature-settings: 'tnum';
  min-width: 100px;
  font-weight: 500;
}
.epg-title {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--white);
  line-height: 1.3;
}
.epg-live-badge {
  background: var(--red);
  color: var(--white);
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 3px;
  white-space: nowrap;
}
.epg-day-separator {
  padding: 28px 0 12px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--red);
  text-transform: uppercase;
}

/* ══════════════════════════════════════════════════════════
   SECCIÓN EN DIFERIDO
══════════════════════════════════════════════════════════ */
.playlist-row-wrapper { margin-bottom: 30px; }
.row-label {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--gray);
  text-transform: uppercase;
  margin-bottom: 12px;
}
.playlist-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.playlist-row::-webkit-scrollbar { height: 3px; }
.playlist-row::-webkit-scrollbar-thumb { background: var(--gray-dim); }

.playlist-chip {
  white-space: nowrap;
  padding: 8px 20px;
  border-radius: 20px;
  background: var(--surface2);
  color: var(--gray);
  font-size: 0.72rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  outline: none;
}
.playlist-chip.active,
.playlist-chip:hover {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--white);
}
.playlist-chip.sn-focused {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
  margin-bottom: 30px;
}

.video-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--transition), box-shadow var(--transition);
  outline: none;
}
.video-card:hover,
.video-card.sn-focused {
  transform: scale(1.03);
  box-shadow: 0 0 0 3px var(--red);
  border-color: var(--red);
}

.video-thumb {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 */
  background: var(--surface2);
  overflow: hidden;
}
.video-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.video-thumb-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  opacity: 0.3;
}

.video-info { padding: 12px 14px 16px; }
.video-title {
  font-size: 0.75rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--white);
  font-weight: 500;
}
.video-date { font-size: 0.62rem; color: var(--gray); margin-top: 6px; }

.more-row {
  display: flex;
  gap: 20px;
  align-items: center;
  padding: 10px 0 30px;
}

.more-btn {
  padding: 12px 36px;
  background: var(--surface2);
  color: var(--white);
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 2px solid var(--gray-dim);
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  letter-spacing: 0.04em;
}
.more-btn:hover, .more-btn.sn-focused {
  border-color: var(--red);
  background: var(--red-dim);
}

.subscribe-btn {
  padding: 12px 36px;
  background: var(--red);
  color: var(--white);
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  letter-spacing: 0.04em;
  border: 2px solid var(--red);
}
.subscribe-btn:hover, .subscribe-btn.sn-focused {
  background: transparent;
  color: var(--red);
}

/* ══════════════════════════════════════════════════════════
   SECCIÓN CONTACTO
══════════════════════════════════════════════════════════ */
.contact-grid {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.contact-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 30px 28px;
  min-width: 200px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  outline: none;
  text-align: center;
}
.contact-card:hover,
.contact-card.sn-focused {
  border-color: var(--red);
  background: var(--red-dim);
}

.contact-icon { font-size: 2rem; display: block; margin-bottom: 12px; }
.contact-name { font-size: 0.8rem; font-weight: 600; color: var(--white); margin-bottom: 4px; }
.contact-handle { font-size: 0.68rem; color: var(--gray); }

/* ══════════════════════════════════════════════════════════
   REPRODUCTOR
══════════════════════════════════════════════════════════ */
#player-screen {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 100;
}

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

#player-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

#player-back {
  position: absolute;
  top: 36px;
  left: 48px;
  background: rgba(0,0,0,0.6);
  color: var(--white);
  font-size: 0.82rem;
  padding: 10px 22px;
  border-radius: var(--radius);
  pointer-events: all;
  border: 2px solid transparent;
  transition: all var(--transition);
  opacity: 0;
  outline: none;
}
#player-back.visible { opacity: 1; }
#player-back.sn-focused, #player-back:hover {
  border-color: var(--red);
  background: rgba(232,0,28,0.3);
}

#player-channel-name {
  position: absolute;
  top: 36px;
  right: 48px;
  background: rgba(0,0,0,0.6);
  color: var(--white);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius);
  opacity: 0;
  transition: opacity 0.4s ease;
  letter-spacing: 0.05em;
}
#player-channel-name.visible { opacity: 1; }

#player-center-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  background: rgba(0,0,0,0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: opacity 0.6s ease;
}
#player-center-icon.fade-in { opacity: 1; }
#player-center-icon.fade-out { opacity: 0; }
#player-center-icon svg { width: 36px; height: 36px; fill: var(--white); }

#stream-error-dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border: 2px solid var(--red);
  border-radius: var(--radius);
  padding: 40px 50px;
  text-align: center;
  z-index: 30;
}
#stream-error-dialog p {
  font-size: 0.85rem;
  margin-bottom: 28px;
  color: var(--white);
}
#stream-error-dialog .modal-btn { margin: 0 10px; }

/* ══════════════════════════════════════════════════════════
   MODALES
══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}
.modal-overlay[hidden] { display: none !important; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--gray-dim);
  border-radius: 12px;
  padding: 44px 56px;
  text-align: center;
  min-width: 340px;
  max-width: 600px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}
.modal-box--wide {
  max-width: 900px;
  width: 80vw;
}
.modal-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--white);
}
.modal-body {
  font-size: 0.78rem;
  color: var(--gray);
  margin-bottom: 28px;
  line-height: 1.6;
}
.modal-body strong { color: var(--white); }
.modal-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 28px;
}
.modal-btn {
  padding: 12px 32px;
  border-radius: var(--radius);
  font-size: 0.78rem;
  font-weight: 600;
  border: 2px solid var(--gray-dim);
  background: var(--surface2);
  color: var(--white);
  transition: all var(--transition);
  cursor: pointer;
  outline: none;
  letter-spacing: 0.04em;
}
.modal-btn:first-child { border-color: var(--red); }
.modal-btn:first-child:hover,
.modal-btn:first-child.sn-focused { background: var(--red); border-color: var(--red); }
.modal-btn:not(:first-child):hover,
.modal-btn:not(:first-child).sn-focused { border-color: var(--white); }

#privacy-iframe {
  width: 100%;
  height: 400px;
  margin-top: 16px;
  border-radius: var(--radius);
  background: #fff;
}

#privacy-content {
  max-height: 420px;
  overflow-y: auto;
  text-align: left;
  padding: 0 8px;
  margin: 16px 0;
  line-height: 1.7;
  font-size: 0.72rem;
  color: var(--gray);
}
#privacy-content p { margin-bottom: 14px; }
#privacy-content strong { color: var(--white); }
#privacy-content::-webkit-scrollbar { width: 4px; }
#privacy-content::-webkit-scrollbar-thumb { background: var(--gray-dim); border-radius: 2px; }

/* ── UTILIDADES ────────────────────────────────────────── */
.loading-msg {
  color: var(--gray);
  font-size: 0.78rem;
  padding: 40px 0;
  text-align: center;
}
.error-msg {
  color: var(--red);
  font-size: 0.78rem;
  padding: 20px 0;
  text-align: center;
}
[hidden] { display: none !important; }

/* ── TIZEN / webOS ESPECÍFICO ──────────────────────────── */
/* En Tizen el cursor no existe */
@media (hover: none) {
  .channel-card:hover, .video-card:hover,
  .contact-card:hover, .nav-item:hover { transform: none; }
}
