/*
 * layout.css — Estrutura e Posicionamento da Aplicação
 *
 * Define a estrutura principal da UI:
 * - Sidebar lateral com menu de navegação
 * - Main wrapper com topbar e área de conteúdo
 *
 * O layout principal usa Flexbox:
 *   [sidebar][main-wrapper]
 *                ↕
 *           [topbar]
 *           [content-area]
 */

/* ============================================================
   SIDEBAR
   ============================================================ */

/* Container da navegação lateral */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-ink-black);
  color: var(--text-white);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: all 0.3s ease;
  z-index: 100;
}

/* Área da marca/logo no topo da sidebar */
.brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--secondary-green);
  border-bottom: 1px solid var(--border-translucent);
  gap: 0.75rem;
}

/* Logo da marca */
.brand img {
  width: 40px;
  height: 40px;
}

/* Área de navegação — ocupa o espaço restante da sidebar */
.nav-menu {
  flex: 1;
  padding: 1.5rem 0;
  overflow-y: auto;
}

/* Item de menu — cada link de navegação */
.nav-item {
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-white);
  text-decoration: none;
  transition: background 0.2s;
  cursor: pointer;
  opacity: 0.8;
}

/* Estado hover e ativo — borda verde à esquerda indica seleção */
.nav-item:hover,
.nav-item.active {
  background-color: var(--hover-bg);
  opacity: 1;
  border-left: 4px solid var(--secondary-green);
}

/* Ícone do menu */
.nav-item i {
  font-size: 1.25rem;
}

/* Rodapé da sidebar — informações da equipe */
.team-ft--sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 2rem;
  text-align: center;
  margin-bottom: 2rem;
}

.team-content {
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.team-content p.year-info {
  font-size: 0.8rem;
}

.designed h4 a {
  color: var(--secondary-green);
  text-decoration: none;
  font-weight: 600;
}

/* ============================================================
   MAIN WRAPPER — área direita da aplicação
   ============================================================ */

/* Container principal: topbar + content-area empilhados */
.main-wrapper {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ============================================================
   TOPBAR — cabeçalho do conteúdo principal
   ============================================================ */

.topbar {
  height: var(--header-height);
  background-color: var(--bg-white);
  border-bottom: 1px solid rgba(9, 16, 22, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding: 0 2rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  z-index: 10;
  position: sticky;
  top: 0;
}

/* Título da página atual */
.page-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-black);
  line-height: 1.2;
}

/* Agrupamento dos elementos à direita da topbar */
.topbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
}

/* Badge verde "Módulos Sincronizados" */
.sys-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  background: #e1f0c4;
  color: #3f5e00;
  padding: 0.5rem 1rem;
  border-radius: 20px;
}

/* Ponto pulsante do indicador de sistema ativo */
.pulse {
  width: 8px;
  height: 8px;
  background-color: var(--secondary-green);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(152, 206, 0, 0.7);
  animation: pulsing 1.5s infinite;
}

/* Botão de ícone (sino de notificações) */
.btn-icon {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-metal);
  cursor: pointer;
  position: relative;
}

/* Bolinha vermelha de contagem de notificações */
.badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background-color: var(--primary-pink);
  color: var(--text-white);
  font-size: 0.65rem;
  font-weight: bold;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

/* Avatar do operador */
.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-ink-black);
  color: var(--text-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.9rem;
}

/* ============================================================
   CONTENT AREA — área rolável do conteúdo
   ============================================================ */

/* Área principal de conteúdo — rola verticalmente */
.content-area {
  flex: 1;
  min-height: 0;
  padding: 2rem;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Seções de view — cada aba tem sua própria section */
.view-section {
  display: none;                  /* oculto por padrão */
  max-width: var(--max-width);
  margin: 0 auto;
}

/* Seção ativa — mostra com animação */
.view-section.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

/* ============================================================
   RESPONSIVIDADE
   ============================================================ */

/* Tablet: reduz padding */
@media (max-width: 992px) {
  .topbar {
    padding: 0 1.25rem;
  }

  .page-title {
    font-size: 1.1rem;
  }

  .content-area {
    padding: 1.5rem;
  }
}

/* Mobile: sidebar vira topo compacto com grade de navegação */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .brand {
    width: 100%;
    height: auto;
    min-height: 72px;
    justify-content: center;
    padding: 1rem 1.25rem;
    border-right: none;
  }

  .nav-menu {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.4rem;
    padding: 0.5rem 0.5rem 0.75rem;
    overflow: visible;
  }

  .nav-item {
    min-width: 0;
    min-height: 72px;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    gap: 0.35rem;
    padding: 0.85rem 0.4rem;
    border-radius: 10px;
    border-left: none !important;
    border-bottom: none !important;
  }

  .nav-item:hover,
  .nav-item.active {
    border-left: none !important;
    border-bottom: none !important;
    box-shadow: inset 0 -3px 0 var(--secondary-green);
  }

  .nav-item span {
    display: block;
    font-size: 0.7rem;
    line-height: 1.2;
  }

  .team-ft--sidebar {
    display: none;
  }

  .topbar {
    height: auto;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.875rem;
    padding: 1rem;
  }

  .page-title {
    width: 100%;
    font-size: 1rem;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
    gap: 0.75rem;
  }

  .sys-status {
    flex: 1 1 180px;
    justify-content: center;
  }

  .content-area {
    padding: 1rem 0.9rem calc(1rem + env(safe-area-inset-bottom));
  }
}

@media (max-width: 560px) {
  .nav-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar-actions {
    align-items: stretch;
  }

  .sys-status {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .brand {
    min-height: 68px;
    padding: 0.9rem 1rem;
    font-size: 1.05rem;
  }

  .brand img {
    width: 34px;
    height: 34px;
  }

  .nav-item {
    min-height: 64px;
    padding: 0.75rem 0.3rem;
  }

  .nav-item i {
    font-size: 1.1rem;
  }

  .nav-item span {
    font-size: 0.66rem;
  }

  .topbar {
    padding: 0.9rem 0.75rem;
  }

  .page-title {
    font-size: 0.95rem;
  }
}
