/* Homelab TV - Design Otimizado para Smart TV e Telas 1080p */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-color: #0b0e14;
  --surface-color: #151b26;
  --surface-hover: #1e2738;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent-color: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.4);
  --focus-border: #38bdf8;
  --badge-bg: #334155;
  --badge-text: #e2e8f0;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Header */
.tv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 30px 60px 15px 60px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.8) 0%, rgba(11, 14, 20, 0) 100%);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background-color: #0284c7;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 24px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.4);
}

.brand-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-subtitle {
  font-size: 16px;
  color: var(--text-muted);
  margin-top: 2px;
}

.info-section {
  display: flex;
  align-items: center;
  gap: 30px;
}

.clock-display {
  text-align: right;
}

.clock-time {
  font-size: 38px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 1px;
}

.clock-date {
  font-size: 16px;
  color: var(--text-muted);
  text-transform: capitalize;
}

/* Conteúdo Principal */
.tv-main {
  flex: 1;
  padding: 10px 60px 40px 60px;
  display: flex;
  flex-direction: column;
  gap: 35px;
}

.section-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 16px;
}

/* Grid de Cartões */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
}

/* Cartão do Aplicativo */
.app-card {
  position: relative;
  background-color: var(--surface-color);
  border: 3px solid transparent;
  border-radius: 18px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  text-decoration: none;
  color: var(--text-main);
  cursor: pointer;
  outline: none;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
  min-height: 190px;
}

.app-card:hover {
  background-color: var(--surface-hover);
  transform: translateY(-4px);
}

/* Foco Evidente para Controle Remoto / Teclado */
.app-card:focus,
.app-card.focused {
  border-color: var(--focus-border);
  background-color: var(--surface-hover);
  transform: scale(1.06) translateY(-4px);
  box-shadow: 0 0 0 4px var(--accent-glow), 0 16px 32px rgba(0, 0, 0, 0.6);
  z-index: 10;
}

.app-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  background-color: var(--badge-bg);
  color: var(--badge-text);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.app-badge.badge-homelab {
  background-color: #0369a1;
  color: #e0f2fe;
}

.app-badge.badge-drm {
  background-color: #831843;
  color: #fce7f3;
}

.app-badge.badge-local {
  background-color: #166534;
  color: #dcfce7;
}

.app-badge.badge-server,
.app-badge:not(.badge-homelab):not(.badge-drm):not(.badge-local) {
  background-color: #4f46e5;
  color: #e0e7ff;
}

/* Modal de Carregamento de App no Servidor */
.tv-loader-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11, 14, 20, 0.94);
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.tv-loader-box {
  background: #151b26;
  border: 3px solid #38bdf8;
  border-radius: 24px;
  padding: 40px 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  box-shadow: 0 0 40px rgba(56, 189, 248, 0.3);
}

.tv-loader-spinner {
  width: 56px;
  height: 56px;
  border: 6px solid #1e293b;
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: tv-spin 0.8s linear infinite;
}

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

.tv-loader-title {
  font-size: 28px;
  font-weight: 700;
  color: #f1f5f9;
}

.tv-loader-subtitle {
  font-size: 16px;
  color: #94a3b8;
}

.app-icon-wrap {
  width: 72px;
  height: 72px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-icon {
  width: 64px;
  height: 64px;
  object-fit: contain;
  transition: transform 0.18s ease;
}

.app-card:focus .app-icon,
.app-card.focused .app-icon {
  transform: scale(1.08);
}

.app-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
  line-height: 1.2;
}

.app-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Barra de Dicas de Controle da TV */
.tv-footer {
  background-color: #0f141d;
  border-top: 1px solid #1e293b;
  padding: 14px 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: var(--text-muted);
}

.remote-hints {
  display: flex;
  gap: 22px;
  align-items: center;
  flex-wrap: wrap;
}

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

.key-badge {
  display: inline-block;
  background-color: #1e293b;
  border: 1px solid #334155;
  color: #f8fafc;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.footer-link {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
}

.footer-link:focus {
  outline: 2px solid var(--accent-color);
  background-color: rgba(56, 189, 248, 0.1);
}

/* Responsividade e TV */
@media (max-width: 1024px) {
  .tv-header, .tv-main, .tv-footer {
    padding-left: 30px;
    padding-right: 30px;
  }
  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}
