/* ==========================================================================
   LKTV — SHELL (menu lateral + barra superior)
   Depende de theme.css. Carregado depois dele.
   ========================================================================== */

#dashboardScreen.active {
  background: var(--surface-0);
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
  width: 258px;
  /* Item flex: sem min-width:0 o conteúdo interno vira piso e a largura
     não obedece. Usamos as propriedades separadas (e não o atalho `flex`)
     para que a largura da versão encolhida consiga sobrescrever. */
  flex-grow: 0;
  flex-shrink: 0;
  flex-basis: 258px;
  min-width: 0;
  background: var(--surface-1);
  border-right: 1px solid var(--line);
  transition: flex-basis var(--t-med), width var(--t-med);
  position: relative;
  z-index: 40;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: 18px 16px 18px 20px;
  border-bottom: 1px solid var(--line-soft);
  min-height: 64px;
}

.sidebar-header h2 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.sidebar-collapse-btn {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  color: var(--tx-3);
  cursor: pointer;
  font-size: 11px;
  transition: color var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}

.sidebar-collapse-btn:hover {
  color: var(--tx-1);
  background: var(--surface-3);
  border-color: var(--line-strong);
}

.sidebar-nav {
  flex: 1;
  padding: 10px 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ── Item de menu ── */
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 11px;
  border-radius: var(--r-sm);
  border-left: 0;
  color: var(--tx-2);
  font-size: 13.5px;
  font-weight: 550;
  text-decoration: none;
  position: relative;
  transition: background var(--t-fast), color var(--t-fast);
}

.nav-item i {
  width: 17px;
  margin-right: 0;
  font-size: 13.5px;
  text-align: center;
  flex-shrink: 0;
  opacity: .82;
}

.nav-item > span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--tx-1);
}

.nav-item:hover i { opacity: 1; }

.nav-item.active {
  background: var(--brand-soft);
  color: #DDD3FF;
  border-left-color: transparent;
  font-weight: 650;
}

.nav-item.active i { color: var(--purple-primary); opacity: 1; }

/* Marca vertical do item ativo */
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--purple-primary), var(--pink-primary));
}

.nav-solo { margin-bottom: 6px; }

/* Alvos ocultos (páginas que viraram sub-abas) */
.nav-hidden-target {
  display: none !important;
}

/* ── Grupo colapsável ── */
.nav-group {
  display: flex;
  flex-direction: column;
  margin-top: 3px;
}

.nav-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 11px;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--tx-3);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .075em;
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast);
}

.nav-group-head:hover { color: var(--tx-1); background: var(--surface-2); }

.nav-group-icon { width: 17px; font-size: 12px; text-align: center; flex-shrink: 0; }

.nav-group-title {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-group-caret {
  font-size: 9px;
  transition: transform var(--t-med);
  opacity: .6;
}

.nav-group.open .nav-group-caret { transform: rotate(180deg); }

.nav-group-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: var(--r-full);
  background: var(--bad);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}

/* Corpo do grupo: animação de abrir/fechar */
.nav-group-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--t-med);
  padding-left: 12px;
  margin-left: 8px;
  border-left: 1px solid var(--line-soft);
}

.nav-group-body > * { overflow: hidden; }

.nav-group.open .nav-group-body { grid-template-rows: 1fr; }

.nav-group-body {
  overflow: hidden;
}

.nav-group.open .nav-group-body {
  overflow: visible;
}

/* Badge numérico do item (não lidas, feedbacks) */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 19px;
  padding: 0 6px;
  border-radius: var(--r-full);
  background: var(--bad);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Rodapé do menu ── */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--line-soft);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 6px 4px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--purple-primary), var(--pink-primary));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.user-meta #userName {
  font-size: 13px;
  font-weight: 600;
  color: var(--tx-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role {
  font-size: 11px;
  color: var(--tx-3);
}

.btn-logout {
  width: 100%;
  padding: 8px;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid var(--line);
  color: var(--tx-2);
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.btn-logout:hover {
  background: var(--bad-soft);
  border-color: rgba(239, 68, 68, .34);
  color: #FCA5A5;
}

/* ==========================================================================
   SIDEBAR ENCOLHIDA (só ícones)
   ========================================================================== */
.sidebar.is-collapsed {
  width: 66px;
  flex-basis: 66px;
  overflow-x: hidden;
}

.sidebar.is-collapsed .sidebar-header { justify-content: center; padding-left: 12px; padding-right: 12px; }
.sidebar.is-collapsed .sidebar-header h2 { display: none; }
.sidebar.is-collapsed .sidebar-collapse-btn i { transform: rotate(180deg); }

.sidebar.is-collapsed .nav-group-title,
.sidebar.is-collapsed .nav-group-caret,
.sidebar.is-collapsed .nav-item > span,
.sidebar.is-collapsed .user-meta,
.sidebar.is-collapsed .btn-logout span { display: none; }

.sidebar.is-collapsed .nav-item,
.sidebar.is-collapsed .nav-group-head {
  justify-content: center;
  padding-left: 8px;
  padding-right: 8px;
}

.sidebar.is-collapsed .nav-group-body {
  grid-template-rows: 1fr;
  padding-left: 0;
  margin-left: 0;
  border-left: 0;
  overflow: visible;
}

.sidebar.is-collapsed .nav-group-head {
  pointer-events: none;
  opacity: .5;
  padding-top: 10px;
}

.sidebar.is-collapsed .nav-item.active::before { left: -4px; }
.sidebar.is-collapsed .user-info { justify-content: center; }

.sidebar.is-collapsed .nav-badge,
.sidebar.is-collapsed .nav-group-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 15px;
  height: 15px;
  font-size: 9px;
  padding: 0 3px;
}

/* Tooltip ao passar o mouse quando encolhida */
.sidebar.is-collapsed .nav-item::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 10px;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--tx-1);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--sh-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast);
  z-index: 200;
}

.sidebar.is-collapsed .nav-item:hover::after { opacity: 1; }

/* ==========================================================================
   BARRA SUPERIOR
   ========================================================================== */
.top-header {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  height: 64px;
  padding: 0 var(--sp-5);
  background: var(--surface-1);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 60;
}

/* ── Caminho de navegação ── */
.topbar-crumb {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex-shrink: 0;
}

.crumb-group {
  font-size: 13px;
  font-weight: 550;
  color: var(--tx-3);
  white-space: nowrap;
}

.crumb-sep { font-size: 8px; color: var(--tx-3); opacity: .55; }

.top-header h1#pageTitle {
  font-size: 16.5px;
  font-weight: 650;
  color: var(--tx-1);
  letter-spacing: -0.022em;
  white-space: nowrap;
  margin: 0;
}

/* ── Busca global ── */
.topbar-search {
  position: relative;
  flex: 1;
  max-width: 460px;
  margin: 0 auto;
}

.topbar-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12.5px;
  color: var(--tx-3);
  pointer-events: none;
}

#globalSearchInput {
  width: 100%;
  padding: 8px 40px 8px 34px;
  background: var(--surface-0);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--tx-1);
}

#globalSearchInput:focus {
  background: var(--surface-2);
  border-color: var(--purple-primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, .14);
}

.topbar-search-kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  padding: 1px 6px;
  border-radius: var(--r-xs);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--tx-3);
  font-size: 10.5px;
  font-family: inherit;
  font-weight: 600;
  pointer-events: none;
}

.topbar-search:focus-within .topbar-search-kbd { opacity: 0; }

/* ── Resultados da busca global ── */
.global-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 66vh;
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  padding: 6px;
  z-index: 300;
}

.gs-section-label {
  padding: 8px 10px 5px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .075em;
  color: var(--tx-3);
}

.gs-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast);
}

.gs-item:hover,
.gs-item.is-cursor { background: var(--surface-3); }

.gs-item-icon {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: var(--r-xs);
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--tx-2);
  font-size: 12px;
}

.gs-item-body { min-width: 0; flex: 1; }

.gs-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--tx-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gs-item-sub {
  font-size: 11.5px;
  color: var(--tx-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gs-empty {
  padding: 26px 14px;
  text-align: center;
  color: var(--tx-3);
  font-size: 13px;
}

/* ── Ações da barra ── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

.header-actions-divider {
  width: 1px;
  height: 22px;
  background: var(--line);
  margin: 0 4px;
}

.btn-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--tx-2);
  font-size: 13.5px;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.btn-icon:hover {
  background: var(--surface-3);
  border-color: var(--line);
  color: var(--tx-1);
}

.btn-restart:hover { background: var(--bad-soft); color: #FCA5A5; border-color: rgba(239, 68, 68, .3); }
.btn-quick-test:hover { background: var(--warn-soft); color: #FCD34D; border-color: rgba(245, 158, 11, .3); }

/* ── Sino de notificações ── */
.topbar-bell-wrap { position: relative; }

.topbar-bell-dot {
  position: absolute;
  top: 5px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bad);
  border: 2px solid var(--surface-1);
}

.notif-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 350px;
  max-height: 460px;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  z-index: 300;
  overflow: hidden;
}

.notif-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  font-weight: 650;
  color: var(--tx-1);
}

.notif-panel-body { overflow-y: auto; padding: 6px; }

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast);
}

.notif-item:hover { background: var(--surface-3); }

.notif-item-icon {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: var(--r-xs);
  display: grid;
  place-items: center;
  font-size: 12px;
}

.notif-item-icon.bad { background: var(--bad-soft); color: #FCA5A5; }
.notif-item-icon.warn { background: var(--warn-soft); color: #FCD34D; }
.notif-item-icon.info { background: var(--info-soft); color: #7DD3FC; }
.notif-item-icon.brand { background: var(--brand-soft); color: #C4B5FD; }

.notif-item-title { font-size: 13px; font-weight: 600; color: var(--tx-1); }
.notif-item-sub { font-size: 11.5px; color: var(--tx-3); margin-top: 1px; line-height: 1.4; }

/* ==========================================================================
   ÁREA DE CONTEÚDO
   ========================================================================== */
.main-content {
  background: var(--surface-0);
  min-width: 0;
}

.content-area {
  padding: var(--sp-5) var(--sp-6);
}

/* ==========================================================================
   RESPONSIVO
   ========================================================================== */
@media (max-width: 1180px) {
  .topbar-search { max-width: 300px; }
}

@media (max-width: 980px) {
  .topbar-search-kbd { display: none; }
  .crumb-group, .crumb-sep { display: none; }
}

@media (max-width: 768px) {
  .top-header {
    gap: var(--sp-2);
    padding: 0 var(--sp-3);
    height: 58px;
  }

  .topbar-search {
    position: static;
    max-width: none;
    margin: 0;
  }

  /* No celular a busca vira um botão que expande sobre a barra */
  .topbar-search:not(.is-open) #globalSearchInput,
  .topbar-search:not(.is-open) .topbar-search-icon { }

  .global-search-results {
    left: var(--sp-3);
    right: var(--sp-3);
  }

  .header-actions-divider { display: none; }

  .content-area { padding: var(--sp-4) var(--sp-3); }

  /* No celular o menu é gaveta: encolher não faz sentido */
  /* No celular o menu é gaveta deslizante (comportamento de style.css).
     Precisa ser redeclarado aqui porque esta folha é carregada depois. */
  .sidebar,
  .sidebar.is-collapsed {
    position: fixed;
    left: -290px;
    top: 0;
    height: 100vh;
    width: 280px;
    flex-basis: 280px;
    z-index: 1000;
    transition: left var(--t-med);
  }

  .sidebar.mobile-open,
  .sidebar.is-collapsed.mobile-open {
    left: 0;
    box-shadow: 4px 0 30px rgba(0, 0, 0, .55);
  }

  /* Encolhido não faz sentido em gaveta: mostra tudo */
  .sidebar.is-collapsed .nav-group-title,
  .sidebar.is-collapsed .nav-group-caret,
  .sidebar.is-collapsed .nav-item > span,
  .sidebar.is-collapsed .user-meta,
  .sidebar.is-collapsed .btn-logout span,
  .sidebar.is-collapsed .sidebar-header h2 { display: revert; }

  .sidebar.is-collapsed .nav-item,
  .sidebar.is-collapsed .nav-group-head {
    justify-content: flex-start;
    padding-left: 11px;
    padding-right: 11px;
  }

  .sidebar.is-collapsed .nav-group-head { pointer-events: auto; opacity: 1; }
  .sidebar.is-collapsed .nav-item::after { content: none; }
  .sidebar-collapse-btn { display: none; }

  .notif-panel {
    position: fixed;
    top: 62px;
    left: var(--sp-3);
    right: var(--sp-3);
    width: auto;
  }
}

@media (max-width: 560px) {
  .topbar-crumb { display: none; }
}
