/* Estrutura geral: shell, sidebar, topbar, formularios e tabelas. */

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--corpo);
  font-size: 15px;
  line-height: 1.5;
  color: var(--v8s-grafite);
  background: var(--v8s-cinza-claro);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--titulo);
  color: var(--v8s-grafite);
  margin: 0;
  line-height: 1.25;
}

a {
  color: var(--v8s-azul);
}

#app {
  min-height: 100%;
}

.carregando {
  display: grid;
  place-items: center;
  min-height: 100vh;
  color: var(--v8s-cinza-medio);
}

/* Shell -------------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: var(--largura-sidebar) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--v8s-grafite-profundo);
  color: rgba(255, 255, 255, 0.78);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__logo {
  display: block;
  width: 100%;
  max-width: 168px;
  margin: 4px auto 18px;
}

.sidebar__kicker {
  font-family: var(--titulo);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--v8s-azul-claro);
  padding: 0 10px 8px;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--raio-pequeno);
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar__link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--v8s-branco);
}

.sidebar__link.ativo {
  background: var(--v8s-azul);
  color: var(--v8s-branco);
}

.sidebar__rodape {
  margin-top: auto;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
  padding: 0 12px;
}

.area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--altura-topbar);
  background: var(--v8s-branco);
  border-bottom: 1px solid var(--v8s-borda);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar__titulo {
  font-family: var(--titulo);
  font-size: 17px;
  font-weight: 700;
}

.topbar__usuario {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar__nome {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__papel {
  font-size: 12px;
  color: var(--v8s-cinza-medio);
}

.conteudo {
  padding: 24px;
  max-width: 1180px;
  width: 100%;
}

.pagina__cabecalho {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.pagina__titulo {
  font-size: 22px;
  font-weight: 700;
}

.pagina__apoio {
  color: var(--v8s-cinza-medio);
  font-size: 14px;
  margin-top: 4px;
}

.acoes {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Formularios -------------------------------------------------------- */

.formulario {
  display: grid;
  gap: 16px;
}

.linha {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.campo {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.campo__rotulo {
  font-size: 13px;
  font-weight: 600;
  color: var(--v8s-grafite);
}

.campo__ajuda {
  font-size: 12px;
  color: var(--v8s-cinza-medio);
}

input,
select,
textarea {
  font-family: var(--corpo);
  font-size: 15px;
  color: var(--v8s-grafite);
  background: var(--v8s-branco);
  border: 1px solid var(--v8s-borda);
  border-radius: var(--raio-pequeno);
  padding: 10px 12px;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--v8s-azul);
  box-shadow: 0 0 0 3px rgba(0, 132, 177, 0.15);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--v8s-cinza-claro);
  color: var(--v8s-cinza-medio);
}

.botao {
  font-family: var(--corpo);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--raio-pequeno);
  padding: 10px 18px;
  cursor: pointer;
  background: var(--v8s-azul);
  color: var(--v8s-branco);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.botao:hover {
  background: var(--v8s-azul-escuro);
}

.botao:disabled {
  opacity: 0.6;
  cursor: progress;
}

.botao--secundario {
  background: var(--v8s-branco);
  color: var(--v8s-grafite);
  border-color: var(--v8s-borda);
}

.botao--secundario:hover {
  background: var(--v8s-cinza-claro);
  border-color: var(--v8s-cinza-medio);
}

.botao--discreto {
  background: transparent;
  color: var(--v8s-azul);
  padding: 8px 10px;
}

.botao--discreto:hover {
  background: rgba(0, 132, 177, 0.08);
}

.botao--perigo {
  background: var(--v8s-branco);
  color: var(--erro-texto);
  border-color: var(--erro-borda);
}

.botao--perigo:hover {
  background: var(--erro-fundo);
}

/* Tabelas ------------------------------------------------------------ */

.tabela-envolucro {
  overflow-x: auto;
  border: 1px solid var(--v8s-borda);
  border-radius: var(--raio);
  background: var(--v8s-branco);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  background: var(--v8s-grafite);
  color: var(--v8s-branco);
  font-family: var(--titulo);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: left;
  padding: 12px 14px;
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  border-top: 1px solid var(--v8s-borda);
  vertical-align: middle;
}

tbody tr:nth-child(even) {
  background: var(--v8s-cinza-claro);
}

/* Celular ------------------------------------------------------------ */

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    height: auto;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    gap: 4px;
    z-index: 10;
  }

  .sidebar__logo,
  .sidebar__kicker,
  .sidebar__rodape {
    display: none;
  }

  .sidebar__link {
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
    padding: 8px 10px;
    flex: 1;
    justify-content: center;
    text-align: center;
  }

  .topbar {
    padding: 0 16px;
  }

  .conteudo {
    padding: 16px 16px 96px;
  }

  .pagina__titulo {
    font-size: 20px;
  }
}
