/*
 * Localização no projeto:
 * /public/assets/css/principal.css
 *
 * Descrição:
 * CSS do layout interno do SIE — telas após login.
 * Visual fiel ao PEN-SIE/UFSM: barra superior azul escura,
 * linha laranja, menu lateral, área de conteúdo.
 * Responsivo: menu lateral colapsa em drawer no mobile.
 *
 * Versão:
 * v1.0.0
 *
 * Histórico de versões:
 * v1.0.0 - Criação inicial fiel ao PEN-SIE com responsividade mobile.
 *
 * Observações:
 * Não alterar a localização sem atualizar este cabeçalho.
 * Não remover este bloco de controle.
 * Carregar APÓS sie.css e o CSS de tema.
 */

/* ============================================================
   RESET DO BODY PARA LAYOUT INTERNO
   ============================================================ */
body.layout-principal {
  margin: 0;
  padding: 0;
  background: #f0f2f5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ============================================================
   BARRA SUPERIOR — azul escura, fiel ao PEN-SIE
   ============================================================ */
/* Barra entidade — fina, #155f9b */
.barra-entidade-interna {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1001;
  background-color: #155f9b;
  color: #d6e8f7;
  font-size: 11px;
  font-family: Arial, sans-serif;
  padding: 3px 16px;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  height: 22px;
  display: flex;
  align-items: center;
}

/* Barra topo — azul #0494c7 */
.barra-topo {
  position: fixed;
  top: 22px;
  left: 0;
  right: 0;
  z-index: 1000;
  background-color: #0494c7;
  color: #ffffff;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.20);
}

/* Sem linha laranja — removida por decisão de design */
.barra-laranja { display: none; }

/* Esquerda da barra */
.barra-topo-esquerda {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 0;
  min-width: 0;
  flex: 1;
}

/* Botao toggler — visivel em TODOS os tamanhos de tela */
.btn-menu-mobile {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 14px;
  height: 48px;
  min-width: 48px;
}

.btn-menu-mobile span {
  display: block;
  width: 20px;
  height: 2px;
  background: #ffffff;
  border-radius: 1px;
  transition: all 0.2s;
}

/* Título na barra */
.barra-topo-titulo {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #ffffff;
  text-decoration: none;
  font-size: 16px;
  font-weight: 500;
  font-family: Arial, sans-serif;
  padding: 0 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.barra-topo-titulo:hover {
  color: #ffffff;
  text-decoration: none;
}

.barra-topo-separador {
  color: rgba(255,255,255,0.5);
  margin: 0 4px;
}

.barra-topo-tela {
  color: rgba(255,255,255,0.85);
  font-weight: 400;
}

/* Direita da barra */
.barra-topo-direita {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

/* Contador de sessão */
.barra-sessao {
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.barra-sessao strong {
  font-size: 13px;
  color: #ffffff;
  font-family: monospace;
  letter-spacing: 1px;
}

.btn-renovar-sessao {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  font-size: 16px;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}

.btn-renovar-sessao:hover {
  color: #ffffff;
}

/* Botão/dropdown do usuário */
.barra-usuario {
  position: relative;
}

.btn-usuario {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: #ffffff;
  cursor: pointer;
  font-size: 13px;
  font-family: Arial, sans-serif;
  padding: 6px 8px;
  border-radius: 3px;
  white-space: nowrap;
  transition: background-color 0.15s;
}

.btn-usuario:hover {
  background-color: rgba(255,255,255,0.1);
}

.seta-dropdown {
  opacity: 0.7;
}

/* Dropdown do usuário */
.usuario-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  background: #ffffff;
  border: 1px solid #dde3ea;
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 1100;
  overflow: hidden;
}

.dropdown-cabecalho {
  padding: 12px 14px 10px;
  border-bottom: 1px solid #eef0f3;
  background: #f8f9fb;
}

.dropdown-login {
  font-size: 11px;
  color: #888;
  margin-bottom: 3px;
}

.dropdown-nome {
  font-size: 14px;
  font-weight: bold;
  color: #155f9b;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 13px;
  color: #333;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.12s;
}

.dropdown-item:hover {
  background-color: #f0f4f8;
  text-decoration: none;
  color: #1e3a5f;
}

.dropdown-email {
  font-size: 12px;
  color: #555;
  cursor: default;
}

.dropdown-email:hover {
  background: none;
  color: #555;
}

.dropdown-divisor {
  height: 1px;
  background: #eef0f3;
  margin: 2px 0;
}

.dropdown-sair {
  color: #c0392b;
}

.dropdown-sair:hover {
  background-color: #fdf5f5;
  color: #c0392b;
}

/* ============================================================
   LAYOUT CORPO: sidebar + conteúdo
   ============================================================ */
.layout-corpo {
  display: flex;
  margin-top: 70px; /* barra entidade (22px) + barra sistema (48px) */
  min-height: calc(100vh - 70px);
}

/* ============================================================
   MENU LATERAL — fiel ao PEN-SIE
   ============================================================ */
.menu-lateral {
  width: 260px;
  min-width: 260px;
  background: #ffffff;
  border-right: 1px solid #dde3ea;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 70px);
  position: fixed;
  top: 70px;
  left: 0;
  z-index: 900;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.25s ease;
}

/* Botão Criar Novo */
.btn-criar-novo {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #4a5568;
  color: #ffffff;
  text-decoration: none;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: Arial, sans-serif;
  margin: 8px 8px 6px;
  border-radius: 3px;
  transition: background-color 0.15s;
  flex-shrink: 0;
}

.btn-criar-novo:hover {
  background: #2d3748;
  color: #ffffff;
  text-decoration: none;
}

.btn-criar-novo-icone {
  font-size: 16px;
  font-weight: bold;
  line-height: 1;
}

/* Itens do menu */
.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  font-size: 13px;
  color: #2d3748;
  text-decoration: none;
  font-family: Arial, sans-serif;
  transition: background-color 0.12s;
  position: relative;
  border-radius: 0;
}

.menu-item:hover {
  background-color: #f0f4f8;
  color: #1e3a5f;
  text-decoration: none;
}

/* Item ativo — #155f9b, texto branco, como no SEI */
.menu-item-ativo {
  background-color: #155f9b !important;
  color: #ffffff !important;
}

.menu-item-ativo:hover {
  background-color: #124f85 !important;
  color: #ffffff !important;
}

.menu-item-ativo .menu-icone {
  stroke: #ffffff;
}

.menu-item-ativo .menu-contador {
  background: #e8a000;
  color: #000;
}

/* Ícones do menu */
.menu-icone {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: #4a5568;
}

.menu-item-ativo .menu-icone {
  stroke: #ffffff;
}

/* Texto do menu */
.menu-texto {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Contador (badge amarelo) */
.menu-contador {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  background: #e8b000;
  color: #000000;
  border-radius: 10px;
  font-size: 11px;
  font-weight: bold;
  flex-shrink: 0;
}

.menu-contador-zero {
  background: #dde3ea;
  color: #666;
}

/* Subitem "Geral" abaixo de Caixa de Entrada */
.menu-subitem-geral {
  display: block;
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  padding: 1px 14px 4px 40px;
  background-color: #1e3a5f;
}

/* Item secundário (Controle de Processos) */
.menu-item-secundario {
  color: #4a5568;
  font-size: 12px;
}

/* Divisor */
.menu-divisor {
  height: 1px;
  background: #eef0f3;
  margin: 4px 0;
}

/* Seção de marcadores */
.menu-secao-marcadores {
  padding-bottom: 8px;
}

.menu-marcadores-cabecalho {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px 4px;
}

.menu-marcadores-titulo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: bold;
  color: #4a5568;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.menu-icone-pequeno {
  width: 13px;
  height: 13px;
  stroke: #4a5568;
}

.btn-marcadores-menu {
  background: none;
  border: none;
  cursor: pointer;
  color: #888;
  font-size: 16px;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 3px;
}

.btn-marcadores-menu:hover {
  background: #eef0f3;
  color: #333;
}

/* Dropdown de opções dos marcadores */
.marcadores-menu-dropdown {
  position: absolute;
  background: #fff;
  border: 1px solid #dde3ea;
  border-radius: 4px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.12);
  z-index: 500;
  min-width: 150px;
  right: 8px;
}

.marcadores-opcao {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  color: #333;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}

.marcadores-opcao:hover {
  background: #f0f4f8;
}

/* Lista de marcadores */
.menu-marcadores-lista {
  padding: 0;
}

.menu-marcadores-vazio {
  display: block;
  padding: 4px 14px;
  font-size: 12px;
  color: #aaa;
  font-style: italic;
}

.menu-marcador-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  text-decoration: none;
  font-size: 12px;
  color: #333;
  transition: background 0.1s;
}

.menu-marcador-item:hover {
  background: #f5f7fa;
  text-decoration: none;
}

.menu-marcador-icone {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.menu-marcador-nome {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-marcador-cont {
  font-size: 11px;
  color: #888;
  background: #eef0f3;
  border-radius: 8px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

.menu-marcador-config {
  background: none;
  border: none;
  cursor: pointer;
  color: #aaa;
  font-size: 12px;
  padding: 1px 2px;
  opacity: 0;
  transition: opacity 0.1s;
}

.menu-marcador-item:hover .menu-marcador-config {
  opacity: 1;
}

/* Rodapé do menu */
.menu-rodape {
  margin-top: auto;
  padding: 8px 14px;
  font-size: 11px;
  color: #aaa;
  border-top: 1px solid #eef0f3;
}

/* ============================================================
   ÁREA DE CONTEÚDO PRINCIPAL
   ============================================================ */
.conteudo-principal {
  flex: 1;
  margin-left: 260px;
  padding: 0;
  min-width: 0;
  background: #f0f2f5;
}

/* Flash no conteúdo principal */
.alerta-principal {
  margin: 12px 16px 0;
}

/* ============================================================
   MODAIS
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px 20px;
  overflow-y: auto;
}

.modal-caixa {
  background: #ffffff;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
}

.modal-cabecalho {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #eef0f3;
}

.modal-titulo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: bold;
  color: #1e3a5f;
  margin: 0;
}

.modal-fechar {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #888;
  line-height: 1;
  padding: 0 4px;
  border-radius: 3px;
}

.modal-fechar:hover {
  color: #333;
  background: #f0f0f0;
}

.modal-corpo {
  padding: 20px;
  overflow-y: auto;
}

.modal-rodape {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid #eef0f3;
  background: #f8f9fb;
}

/* Busca avançada */
.modal-busca-caixa {
  max-width: 780px;
}

.busca-avancada-form {}

.busca-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.campo-grupo-full {
  grid-column: 1 / -1;
}

/* Marcador */
.modal-marcador-caixa {
  max-width: 680px;
}

.marcador-form {}

.marcador-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 14px;
}

.marcador-descricao-grupo {
  grid-column: 2 / 3;
  grid-row: 1;
}

.campo-cor {
  height: 38px;
  padding: 2px 4px;
  cursor: pointer;
  width: 100%;
}

.marcador-preview-bloco {
  grid-column: 1 / -1;
  border-top: 1px solid #eef0f3;
  padding-top: 14px;
  margin-top: 6px;
}

.marcador-preview-titulo {
  font-size: 13px;
  font-weight: bold;
  color: #333;
  margin-bottom: 10px;
}

.marcador-preview-grid {
  display: flex;
  gap: 30px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.marcador-preview-label {
  font-size: 11px;
  color: #888;
  margin-bottom: 6px;
}

.marcador-preview-doc {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 3px;
  font-size: 13px;
  font-weight: bold;
}

.marcador-preview-menu {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #333;
}

.marcador-preview-cont {
  font-size: 11px;
  color: #888;
  background: #eef0f3;
  border-radius: 8px;
  padding: 1px 6px;
}

.marcador-contraste {
  margin-top: 8px;
  font-size: 11px;
  color: #888;
}

/* ============================================================
   OVERLAY MOBILE
   ============================================================ */
.menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 850;
}

/* ============================================================
   RESPONSIVO — MOBILE
   ============================================================ */
@media (max-width: 768px) {

  /* Mostrar hamburguer */
  .btn-menu-mobile {
    display: flex;
  }

  /* Ocultar título longo, mostrar apenas sigla */
  .barra-topo-tela {
    display: none;
  }

  /* Barra menor */
  .barra-topo-titulo {
    font-size: 14px;
    padding: 0 8px;
  }

  /* Ocultar sessão no mobile */
  .barra-sessao {
    display: none;
  }

  /* Menu lateral: drawer fora da tela por padrão */
  .menu-lateral {
    transform: translateX(-100%);
    box-shadow: none;
    z-index: 900;
  }

  /* Menu lateral aberto */
  .menu-lateral.menu-aberto {
    transform: translateX(0);
    box-shadow: 3px 0 16px rgba(0,0,0,0.2);
  }

  /* Overlay visível quando menu aberto */
  .menu-overlay.visivel {
    display: block;
  }

  /* Conteúdo ocupa tudo */
  .conteudo-principal {
    margin-left: 0;
  }

  /* Modal em tela cheia no mobile */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal-caixa {
    max-width: 100%;
    border-radius: 12px 12px 0 0;
  }

  /* Grid de busca: 1 coluna no mobile */
  .busca-grid {
    grid-template-columns: 1fr;
  }

  .campo-grupo-full {
    grid-column: 1;
  }

  /* Grid de marcador: 1 coluna no mobile */
  .marcador-grid {
    grid-template-columns: 1fr;
  }

  .marcador-descricao-grupo {
    grid-column: 1;
    grid-row: auto;
  }

  /* Dropdown usuário adaptado */
  .usuario-dropdown {
    right: -8px;
    min-width: 200px;
  }

  /* Ocultar nome no mobile, só ícone */
  .btn-usuario span:not(.seta-dropdown) {
    display: none;
  }
}

@media (max-width: 480px) {
  .barra-topo-separador {
    display: none;
  }

  .marcador-preview-grid {
    flex-direction: column;
    gap: 12px;
  }
}

/* ============================================================
   MENU COLAPSAVEL NO DESKTOP
   ============================================================ */
.menu-lateral.menu-colapsado {
  width: 0;
  min-width: 0;
  overflow: hidden;
  border-right: none;
}

.conteudo-principal.conteudo-expandido {
  margin-left: 0;
}

/* Transicao suave */
.menu-lateral {
  transition: width 0.25s ease, min-width 0.25s ease, transform 0.25s ease;
}

.conteudo-principal {
  transition: margin-left 0.25s ease;
}

/* ============================================================
   MODAIS - garantir display correto
   ============================================================ */
.modal-overlay {
  display: none;
}

.modal-overlay:not([hidden]) {
  display: flex !important;
}

/* ============================================================
   MENU DE ADMINISTRAÇÃO
   ============================================================ */
.menu-secao-adm {
  border-top: 1px solid #eef0f3;
  margin-top: 4px;
}

.menu-adm-titulo {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: bold;
  color: #4a5568;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
  transition: background .12s;
}

.menu-adm-titulo:hover { background: #f5f7fa; }

.menu-adm-seta {
  margin-left: auto;
  transition: transform .2s;
}

.menu-adm-seta.rotacionado { transform: rotate(180deg); }

.menu-adm-submenu { padding-bottom: 6px; }

.menu-adm-grupo {
  font-size: 10px;
  font-weight: bold;
  color: #0494c7;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 8px 14px 3px 14px;
}

.menu-adm-item {
  display: block;
  padding: 5px 14px 5px 22px;
  font-size: 12px;
  color: #2d3748;
  text-decoration: none;
  transition: background .1s;
}

.menu-adm-item:hover {
  background: #f0f4f8;
  color: #155f9b;
  text-decoration: none;
}

.menu-adm-ativo {
  color: #155f9b;
  font-weight: bold;
  background: #edf3fb;
}

.menu-adm-ativo:hover { background: #e3ecf8; }