/**
 * public/css/layout.css — Layout da aplicação (sidebar, main, responsivo).
 *
 * Estrutura da página admin:
 *   <div class="app-layout">
 *     <aside class="sidebar">...</aside>
 *     <div class="main-content">
 *       <header class="topbar">...</header>
 *       <main class="pagina">...</main>
 *     </div>
 *   </div>
 *
 * Em mobile (< 768px):
 *   - Sidebar vira um menu hambúrguer no topo
 *   - O topbar exibe o botão de abrir/fechar sidebar
 */

/* ============================================================
 * LAYOUT PRINCIPAL (sidebar + conteúdo)
 * ============================================================ */

.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
 * SIDEBAR (menu lateral — desktop)
 * ============================================================ */

.sidebar {
  width: var(--largura-sidebar);
  background: var(--cor-fundo-sidebar);
  color: var(--cor-texto-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  transition: transform 0.3s ease;
  z-index: 100;
}

/* Logo / nome da empresa no topo da sidebar */
.sidebar-logo {
  padding: var(--espaco-lg) var(--espaco-md);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: var(--espaco-sm);
}

.sidebar-logo-texto {
  font-size: 18px;
  font-weight: 700;
  color: var(--cor-primaria);
  letter-spacing: 0.5px;
}

.sidebar-logo-versao {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  margin-top: 2px;
}

/* Lista de itens de navegação */
.sidebar-nav {
  flex: 1;
  padding: var(--espaco-md) 0;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--espaco-sm);
  padding: var(--espaco-sm) var(--espaco-md);
  color: var(--cor-texto-sidebar);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  border-left: 3px solid transparent;
  font-size: 14px;
  user-select: none;
  /* justify-content pode ser sobrescrito inline para itens com badge (ex: Chamados) */
}

/* Item com badge de notificação (preenche toda a largura) */
.sidebar-nav-item.com-badge {
  justify-content: space-between;
}

/* Garante que o span de label dentro do item fique alinhado */
.sidebar-nav-item .nav-label {
  display: flex;
  align-items: center;
  gap: var(--espaco-sm);
  flex: 1;
}

.sidebar-nav-item:hover {
  background: var(--cor-fundo-sidebar-hover);
  color: #fff;
}

.sidebar-nav-item.ativo {
  background: var(--cor-fundo-sidebar-hover);
  color: var(--cor-texto-sidebar-ativo);
  border-left-color: var(--cor-primaria);
  font-weight: 600;
}

.sidebar-nav-item .icone {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

/* Rodapé da sidebar (usuário logado + logout) */
.sidebar-rodape {
  padding: var(--espaco-md);
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
  color: rgba(255,255,255,0.5);
}

.sidebar-rodape .usuario {
  margin-bottom: var(--espaco-sm);
  font-weight: 600;
  color: rgba(255,255,255,0.8);
}

/* ============================================================
 * CONTEÚDO PRINCIPAL
 * ============================================================ */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0; /* Previne overflow em flex */
}

/* Barra de topo */
.topbar {
  height: 56px;
  background: var(--cor-fundo-card);
  border-bottom: 1px solid var(--cor-borda);
  display: flex;
  align-items: center;
  padding: 0 var(--espaco-lg);
  gap: var(--espaco-md);
  flex-shrink: 0;
}

.topbar-titulo {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}

.topbar-acoes {
  display: flex;
  align-items: center;
  gap: var(--espaco-sm);
}

/* Área da página (scrollável) */
.pagina {
  flex: 1;
  overflow-y: auto;
  padding: var(--espaco-lg);
}

/* ============================================================
 * GRID DE ESTATÍSTICAS (cards de resumo)
 * ============================================================ */

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--espaco-md);
  margin-bottom: var(--espaco-lg);
}

.stat-card {
  background: var(--cor-fundo-card);
  border: 1px solid var(--cor-borda);
  border-radius: var(--raio-lg);
  padding: var(--espaco-md);
  display: flex;
  flex-direction: column;
  gap: var(--espaco-xs);
}

.stat-card .valor {
  font-size: 28px;
  font-weight: 700;
  color: var(--cor-primaria);
}

.stat-card .rotulo {
  font-size: 12px;
  color: var(--cor-texto-secundario);
}

/* ============================================================
 * CABEÇALHO DE SEÇÃO (título + botão de ação)
 * ============================================================ */

.secao-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--espaco-md);
  flex-wrap: wrap;
  gap: var(--espaco-sm);
}

.secao-titulo {
  font-size: 18px;
  font-weight: 700;
}

/* ============================================================
 * PORTAL DO CLIENTE — layout simples centralizado
 * ============================================================ */

.portal-layout {
  min-height: 100vh;
  background: var(--cor-fundo);
  display: flex;
  flex-direction: column;
}

.portal-header {
  background: var(--cor-fundo-sidebar);
  color: #fff;
  padding: var(--espaco-md) var(--espaco-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.portal-header .logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--cor-primaria);
}

.portal-conteudo {
  flex: 1;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: var(--espaco-xl) var(--espaco-md);
}

/* Caixa de login do portal */
.portal-login {
  max-width: 400px;
  margin: var(--espaco-xxl) auto;
}

/* ============================================================
 * PÁGINA DE LOGIN (admin)
 * ============================================================ */

.login-layout {
  min-height: 100vh;
  background: var(--cor-fundo-sidebar);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--espaco-md);
}

.login-card {
  background: var(--cor-fundo-card);
  border-radius: var(--raio-lg);
  padding: var(--espaco-xl);
  width: 100%;
  max-width: 380px;
  box-shadow: var(--sombra-modal);
}

.login-logo {
  text-align: center;
  margin-bottom: var(--espaco-xl);
}

.login-logo-nome {
  font-size: 24px;
  font-weight: 700;
  color: var(--cor-primaria);
}

.login-logo-sub {
  font-size: 13px;
  color: var(--cor-texto-secundario);
}

/* ============================================================
 * RESPONSIVO — MOBILE (< 768px)
 * ============================================================ */

@media (max-width: 767px) {
  /* Sidebar vira menu hamburguer */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 200;
    box-shadow: var(--sombra-modal);
  }

  .sidebar.aberta {
    transform: translateX(0);
  }

  /* Overlay escuro quando sidebar está aberta */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
  }

  .sidebar-overlay.ativo {
    display: block;
  }

  /* Topbar exibe botão hamburguer */
  .btn-hamburger {
    display: flex !important;
  }

  /* Reduz padding em mobile */
  .pagina {
    padding: var(--espaco-md);
  }

  /* Tabela: esconde colunas menos importantes */
  .tabela .ocultar-mobile {
    display: none;
  }

  /* Modal ocupa tela inteira em mobile */
  .modal {
    max-width: 100%;
    max-height: 95vh;
    border-radius: var(--raio-lg) var(--raio-lg) 0 0;
    align-self: flex-end;
  }

  .modal-overlay {
    align-items: flex-end;
  }

  /* Grid de stats em 2 colunas */
  .grid-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Botão hamburguer — oculto em desktop */
.btn-hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
}
