/* Serviflex TV — UI 10-foot (Smart TV / control remoto) */

:root {
  --tv-bg: #070b14;
  --tv-surface: #121a2b;
  --tv-surface2: #1a2438;
  --tv-border: #2a3650;
  --tv-text: #e8eef8;
  --tv-muted: #8b9bb8;
  --tv-accent: #5b9cff;
  --tv-accent-glow: rgba(91, 156, 255, 0.45);
  --tv-focus: #ffffff;
  --tv-radius: 14px;
  --tv-gap: 20px;
  --tv-focus-ring: 0 0 0 4px var(--tv-accent), 0 0 24px var(--tv-accent-glow);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--tv-bg);
  color: var(--tv-text);
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 22px;
  overflow: hidden;
}

body {
  background: radial-gradient(ellipse 120% 80% at 50% -20%, #152040 0%, var(--tv-bg) 55%);
}

.tv-screen {
  display: none;
  height: 100vh;
  width: 100vw;
}

.tv-screen--active {
  display: flex;
  flex-direction: column;
}

.tv-screen--player.tv-screen--active {
  display: block;
}

/* Focus (control remoto / teclado) */
.tv-focusable {
  outline: none;
}

.tv-focusable:focus-visible,
.tv-focusable.is-focused {
  box-shadow: var(--tv-focus-ring);
  border-color: var(--tv-accent) !important;
  z-index: 2;
}

/* Login */
.tv-login {
  margin: auto;
  width: min(520px, 92vw);
  padding: 48px 40px;
  background: var(--tv-surface);
  border: 1px solid var(--tv-border);
  border-radius: calc(var(--tv-radius) + 4px);
}

.tv-login__brand {
  text-align: center;
  margin-bottom: 36px;
}

.tv-login__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: var(--tv-surface2);
  font-size: 28px;
  margin-bottom: 16px;
}

.tv-login__brand h1 {
  margin: 0 0 8px;
  font-size: 2rem;
  font-weight: 700;
}

.tv-login__brand h1 span {
  color: var(--tv-accent);
}

.tv-login__brand p,
.tv-login__hint {
  color: var(--tv-muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.tv-login__hint {
  text-align: center;
  margin-top: 24px;
}

.tv-field {
  display: block;
  margin-bottom: 20px;
}

.tv-field span {
  display: block;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--tv-muted);
}

.tv-field input {
  width: 100%;
  padding: 16px 18px;
  font-size: 1.1rem;
  border-radius: var(--tv-radius);
  border: 2px solid var(--tv-border);
  background: var(--tv-bg);
  color: var(--tv-text);
}

.tv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 999px;
  border: 2px solid transparent;
  cursor: pointer;
  background: var(--tv-surface2);
  color: var(--tv-text);
}

.tv-btn--primary {
  width: 100%;
  background: linear-gradient(135deg, #3d7ee8, #5b9cff);
  border-color: #6aabff;
  margin-top: 8px;
}

.tv-btn--ghost {
  background: transparent;
  border-color: var(--tv-border);
}

.tv-error {
  color: #ff7b7b;
  font-size: 0.85rem;
  margin: 8px 0;
}

/* Topbar */
.tv-topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 20px 40px;
  border-bottom: 1px solid var(--tv-border);
  background: rgba(7, 11, 20, 0.85);
}

.tv-topbar__brand {
  font-weight: 700;
  font-size: 1.2rem;
}

.tv-topbar__brand span {
  color: var(--tv-accent);
}

.tv-topbar__user {
  flex: 1;
  color: var(--tv-muted);
  font-size: 0.9rem;
}

/* Home layout */
.tv-home {
  display: flex;
  flex: 1;
  min-height: 0;
}

.tv-nav {
  width: 220px;
  flex-shrink: 0;
  padding: 24px 16px;
  border-right: 1px solid var(--tv-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tv-nav__item {
  text-align: left;
  padding: 16px 20px;
  border-radius: var(--tv-radius);
  border: 2px solid transparent;
  background: transparent;
  color: var(--tv-muted);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.tv-nav__item--active {
  background: var(--tv-surface2);
  color: var(--tv-text);
  border-color: var(--tv-border);
}

.tv-main {
  flex: 1;
  padding: 24px 40px 40px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tv-main__title {
  margin: 0 0 4px;
  font-size: 1.6rem;
}

.tv-main__count {
  margin: 0 0 20px;
  color: var(--tv-muted);
  font-size: 0.85rem;
}

.tv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--tv-gap);
  overflow-y: auto;
  flex: 1;
  padding: 4px;
  align-content: start;
}

.tv-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 12px;
  border-radius: var(--tv-radius);
  border: 2px solid var(--tv-border);
  background: var(--tv-surface);
  cursor: pointer;
  text-align: center;
}

.tv-card__logo {
  width: 88px;
  height: 88px;
  border-radius: 12px;
  object-fit: contain;
  background: #0d1220;
}

.tv-card__name {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tv-empty {
  color: var(--tv-muted);
  text-align: center;
  margin: auto;
}

/* Player */
.tv-player {
  position: relative;
  width: 100%;
  height: 100vh;
  background: #000;
}

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

.tv-player__overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 48px 56px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.4s;
}

.tv-player__overlay.is-hidden {
  opacity: 0;
}

.tv-player__title {
  margin: 0 0 8px;
  font-size: 1.4rem;
  font-weight: 700;
}

.tv-player__hint {
  margin: 0;
  color: var(--tv-muted);
  font-size: 0.8rem;
}

.tv-player__loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.7);
}

.tv-player__error {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: #ff7b7b;
  text-align: center;
  max-width: 80%;
}

.tv-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--tv-border);
  border-top-color: var(--tv-accent);
  border-radius: 50%;
  animation: tv-spin 0.8s linear infinite;
}

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

/* PIN dialog */
.tv-dialog {
  border: none;
  padding: 0;
  background: transparent;
  max-width: none;
}

.tv-dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
}

.tv-pin {
  width: min(440px, 90vw);
  padding: 40px;
  background: var(--tv-surface);
  border: 1px solid var(--tv-border);
  border-radius: calc(var(--tv-radius) + 4px);
  color: var(--tv-text);
}

.tv-pin h2 {
  margin: 0 0 8px;
}

.tv-pin p {
  color: var(--tv-muted);
  margin: 0 0 20px;
}

.tv-pin__input {
  width: 100%;
  text-align: center;
  letter-spacing: 0.4em;
  font-size: 1.6rem;
  padding: 16px;
  border-radius: var(--tv-radius);
  border: 2px solid var(--tv-border);
  background: var(--tv-bg);
  color: var(--tv-text);
  margin-bottom: 12px;
}

.tv-pin__actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 16px;
}
