/* ==============================================================================
   TeleVix Smart TV - Stylesheet para Samsung Tizen, LG webOS y Hisense VIDAA
   Diseño 10-Foot UI Optimizado para Control Remoto D-Pad (1920x1080 / 4K)
   ============================================================================== */

:root {
  --bg-primary: #0a0c10;
  --bg-secondary: #12161f;
  --bg-card: #181d28;
  --bg-card-hover: #222938;
  --accent-red: #e50914;
  --accent-red-glow: rgba(229, 9, 20, 0.45);
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-subtle: #252e3d;
  --focus-outline: #e50914;
  --focus-glow: 0 0 25px rgba(229, 9, 20, 0.7);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 18px;
}

/* Base focusable element */
.focusable {
  outline: none;
  transition: transform 0.18s cubic-bezier(0.2, 0, 0, 1), 
              box-shadow 0.18s cubic-bezier(0.2, 0, 0, 1), 
              border-color 0.18s cubic-bezier(0.2, 0, 0, 1),
              background-color 0.18s ease;
  cursor: pointer;
}

.focusable:focus,
.focusable.focused {
  outline: none;
  border-color: var(--focus-outline) !important;
  box-shadow: var(--focus-glow) !important;
  transform: scale(1.04);
  z-index: 10;
}

/* App Container */
#app-container {
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* ==============================================================================
   1. Pantalla de Login (Autenticación Xtream Codes)
   ============================================================================== */
#login-screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, #1b2230 0%, #0a0c10 100%);
  z-index: 100;
}

.login-box {
  width: 580px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 45px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  text-align: center;
}

.login-logo {
  max-width: 260px;
  margin-bottom: 25px;
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 30px;
}

.input-group {
  margin-bottom: 20px;
  text-align: left;
}

.input-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-control {
  width: 100%;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 2px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 16px;
}

.btn-primary {
  width: 100%;
  padding: 16px;
  margin-top: 15px;
  background: var(--accent-red);
  color: #ffffff;
  border: 2px solid transparent;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.login-status {
  margin-top: 15px;
  font-size: 14px;
  min-height: 20px;
}
.login-status.error { color: #ef4444; }
.login-status.info { color: #38bdf8; }

/* ==============================================================================
   2. Vista Principal (Header + Categorías + Grilla de Canales)
   ============================================================================== */
#main-screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  z-index: 10;
}

/* Header */
.top-header {
  height: 90px;
  padding: 0 45px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(18, 22, 31, 0.7);
  backdrop-filter: blur(10px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 30px;
}

.app-logo {
  height: 48px;
}

.header-nav {
  display: flex;
  gap: 15px;
}

.nav-pill {
  padding: 10px 22px;
  border-radius: 30px;
  background: var(--bg-card);
  border: 2px solid transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 15px;
}

.nav-pill.active {
  background: var(--accent-red);
  color: #ffffff;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.user-badge {
  font-size: 14px;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
}

.btn-header-action {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* Content Area */
.main-content {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Sidebar de Categorías */
.category-sidebar {
  width: 320px;
  height: 100%;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  padding: 20px 15px;
  scrollbar-width: none;
}
.category-sidebar::-webkit-scrollbar { display: none; }

.category-item {
  width: 100%;
  padding: 14px 18px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: transparent;
  border: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.category-item.active {
  background: rgba(229, 9, 20, 0.15);
  border-left: 4px solid var(--accent-red);
  color: #ffffff;
}

.category-badge {
  font-size: 12px;
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: 10px;
  color: var(--text-muted);
}

/* Grilla de Canales / Streams */
.channel-container {
  flex: 1;
  height: 100%;
  padding: 30px 40px;
  overflow-y: auto;
  scrollbar-width: none;
}
.channel-container::-webkit-scrollbar { display: none; }

.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  padding-bottom: 60px;
}

.channel-card {
  background: var(--bg-card);
  border: 2px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.channel-num {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent-red);
  min-width: 36px;
}

.channel-icon {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 8px;
  background: #000000;
  padding: 4px;
}

.channel-info {
  flex: 1;
  overflow: hidden;
}

.channel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-epg-now {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==============================================================================
   3. Reproductor a Pantalla Completa (Full Screen Video Player)
   ============================================================================== */
#player-screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: #000000;
  z-index: 50;
  display: none;
}

#video-element {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* OSD (On-Screen Display) */
.player-osd {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%;
  padding: 30px 50px 40px;
  background: linear-gradient(to top, rgba(0,0,0,0.92) 0%, rgba(0,0,0,0.6) 60%, transparent 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.player-osd.hidden {
  opacity: 0;
}

.osd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.osd-channel-meta {
  display: flex;
  align-items: center;
  gap: 15px;
}

.osd-number {
  font-size: 32px;
  font-weight: 900;
  color: var(--accent-red);
}

.osd-name {
  font-size: 28px;
  font-weight: 700;
  color: #ffffff;
}

.osd-badge {
  background: var(--accent-red);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 4px;
  text-transform: uppercase;
}

.osd-clock {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-secondary);
}

.osd-footer-keys {
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  gap: 25px;
}

.key-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.key-badge {
  background: #2a3342;
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 11px;
}

/* Loader Spinner */
.video-loader {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 60px; height: 60px;
  border: 5px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

@keyframes spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}
