/* ================================================
   OConnectorTVTech - style.css
   Otimizado para TV, monitor e navegador
   Zero frameworks | Pure CSS
   ================================================ */

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

:root {
  /* Nova Paleta Premium: Midnight Navy & Electric Blue */
  --bg-deep: #050508;
  --bg-panel: #0a0a0f;
  --bg-card: #12121a;
  --bg-hover: #1c1c2b;
  --bg-active: #2563eb;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.4);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #475569;
  --border: rgba(255, 255, 255, 0.08);
  --red: #f43f5e;
  --green: #10b981;
  --radius: 12px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html,
body {
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-dim);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ================================================
   LAYOUT PRINCIPAL
   ================================================ */

#app {
  display: grid;
  grid-template-rows: 52px 1fr;
  grid-template-columns: 280px 1fr;
  grid-template-areas:
    "header header"
    "sidebar player";
  height: 100vh;
  gap: 0;
}

/* ---- HEADER ---- */
#header {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

#header .logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
  white-space: nowrap;
}

#header .logo span {
  color: var(--text-main);
}

#search-wrap {
  flex: 1;
  max-width: 360px;
  position: relative;
}

#search-input {
  width: 100%;
  padding: 7px 14px 7px 36px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}

#search-input:focus {
  border-color: var(--accent);
}

#search-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#search-input::placeholder {
  color: var(--text-muted);
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

#btn-m3u {
  margin-left: auto;
  padding: 7px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition);
  white-space: nowrap;
}

#btn-m3u:hover {
  opacity: 0.85;
}

#now-playing-badge {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

#now-playing-badge span {
  color: var(--accent);
  font-weight: 600;
}

/* ---- SIDEBAR ---- */
#sidebar {
  grid-area: sidebar;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  margin: 6px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.category-header:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.15);
}

.category-header.active {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--text-main);
}

.channel-list {
  list-style: none;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.channel-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 14px;
  cursor: pointer;
  border-radius: 10px;
  margin: 2px 12px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
  /* Ultra-levez: Browser não renderiza o que não vê */
  content-visibility: auto;
  contain-intrinsic-size: 1px 48px;
}

.channel-item:hover {
  background: var(--bg-hover);
  transform: translateX(4px);
}

.channel-item.active {
  background: var(--bg-active);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 20px var(--accent-glow);
  animation: pulse-glow 2s infinite alternate;
}

@keyframes pulse-glow {
  0% {
    box-shadow: 0 0 10px var(--accent-glow);
  }

  100% {
    box-shadow: 0 0 25px var(--accent-glow);
  }
}

.channel-item:focus-visible {
  outline: none;
  background: var(--bg-hover);
  border-color: #fff;
  transform: scale(1.02);
  z-index: 2;
}

.channel-item.active .ch-name {
  color: #fff;
  font-weight: 600;
}

.ch-num {
  font-size: 10px;
  color: var(--text-dim);
  min-width: 22px;
  text-align: right;
}

.ch-name {
  font-size: 13px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.ch-status {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}

.ch-status.online {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.ch-status.error {
  background: var(--red);
}

/* ---- PLAYER AREA ---- */
#player-area {
  grid-area: player;
  display: flex;
  flex-direction: column;
  background: #000;
  position: relative;
  overflow: hidden;
}

#video-container {
  flex: 1;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#main-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* ---- PLACEHOLDER ---- */
#placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #000;
  z-index: 2;
}

#placeholder .ph-icon {
  font-size: 64px;
  opacity: 0.15;
}

#placeholder p {
  color: var(--text-muted);
  font-size: 14px;
}

#placeholder.hidden {
  display: none;
}

/* ---- LOADING OVERLAY ---- */
#loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

#loading-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

#loading-overlay p {
  color: var(--text-muted);
  font-size: 13px;
}

/* ---- CONTROLS BAR ---- */
#controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.ctrl-btn {
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 18px;
  padding: 6px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  line-height: 1;
}

.ctrl-btn:hover {
  background: var(--bg-card);
  color: #fff;
}

.ctrl-btn:focus-visible {
  outline: 2px solid var(--accent);
  background: var(--bg-card);
}

.ctrl-btn:active {
  transform: scale(0.93);
}

.ctrl-btn.active {
  color: var(--accent);
}

#vol-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 4px;
  background: var(--bg-card);
  border-radius: 99px;
  outline: none;
  cursor: pointer;
}

#vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

#ch-info {
  flex: 1;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#ch-info strong {
  color: var(--text-main);
}

#btn-fullscreen {
  margin-left: auto;
}

/* ---- TOAST NOTIFICATION ---- */
#toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 10px 20px;
  border-radius: 99px;
  font-size: 13px;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  white-space: nowrap;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- MODAL M3U ---- */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

#modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

#modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 500px;
  max-width: 95vw;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#modal h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

#modal p {
  font-size: 13px;
  color: var(--text-muted);
}

.modal-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}

.modal-input:focus {
  border-color: var(--accent);
}

.modal-input::placeholder {
  color: var(--text-dim);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-btn {
  padding: 9px 20px;
  border-radius: 99px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition);
}

.modal-btn.primary {
  background: var(--accent);
  color: #fff;
}

.modal-btn.secondary {
  background: var(--bg-card);
  color: var(--text-main);
}

.modal-btn:hover {
  opacity: 0.85;
}

.modal-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 12px;
}

.modal-divider::before,
.modal-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---- OSD (On Screen Display) ---- */
#osd {
  position: absolute;
  bottom: 80px;
  /* Movido para baixo estilo modern player */
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 10, 15, 0.85);
  /* Glassmorphism darker */
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 500;
  color: #fff;
  z-index: 20;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

#osd.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(-10px);
}

/* ---- ERROR BANNER ---- */
#error-banner {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--red);
  color: #fca5a5;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 20;
  display: none;
}

#error-banner.visible {
  display: block;
}

/* ---- KEYBOARD HINTS ---- */
#kbd-hints {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  display: flex;
  gap: 10px;
}

.kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--text-dim);
  border-radius: 4px;
  font-size: 10px;
  color: var(--text-dim);
}

/* ---- SIDEBAR STATS ---- */
.sidebar-stats {
  padding: 8px 16px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.02em;
}

/* ---- LOAD MORE BUTTON ---- */
.load-more-btn {
  list-style: none;
  padding: 10px 16px;
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  text-align: center;
  border-top: 1px solid var(--border);
  transition: background var(--transition);
}

.load-more-btn:hover {
  background: var(--bg-card);
}

/* ---- CATEGORY COUNT ---- */
.cat-count {
  margin-left: auto;
  margin-right: 6px;
  font-size: 10px;
  background: var(--bg-deep);
  color: var(--text-dim);
  padding: 1px 6px;
  border-radius: 99px;
  font-weight: 600;
}

.cat-name {
  flex: 1;
}

/* ---- LOADING MSG (placeholder) ---- */
#loading-msg {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  max-width: 260px;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 700px) {
  #app {
    grid-template-rows: 52px auto 1fr;
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "player"
      "sidebar";
  }

  #sidebar {
    border-right: none;
    border-top: 1px solid var(--border);
    max-height: 40vh;
  }

  #kbd-hints {
    display: none;
  }
}