/* ============================================================
   Reset e base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #f4f6f9;
  color: #1a1a2e;
  min-height: 100vh;
}

#app { min-height: 100vh; }

/* ============================================================
   Utilitários
   ============================================================ */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.erro-404, .erro { text-align: center; padding: 4rem; color: #e74c3c; }

/* ============================================================
   Formulários
   ============================================================ */
.form-grupo { margin-bottom: 1.2rem; }
.form-grupo label { display: block; font-weight: 600; margin-bottom: .4rem; font-size: .9rem; }

/* .campo — classe reutilizável para qualquer input/select/textarea */
.campo,
.form-grupo input,
.form-grupo select,
.form-grupo textarea {
  width: 100%;
  padding: .65rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: .95rem;
  color: #111827;
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
  box-sizing: border-box;
}
.campo:focus,
.form-grupo input:focus,
.form-grupo select:focus,
.form-grupo textarea:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.campo::placeholder { color: #9ca3af; }

/* ============================================================
   Botões
   ============================================================ */
.btn {
display: inline-flex;
align-items: center;
gap: .5rem;
padding: .65rem 1.5rem;
border: none;
border-radius: 8px;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: opacity .2s, transform .1s;
justify-content: center;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primario { background: #6366f1; color: #fff; }
.btn-primario:hover:not(:disabled) { background: #4f46e5; }
.btn-perigo { background: #ef4444; color: #fff; }
.btn-perigo:hover:not(:disabled) { background: #dc2626; }
.btn-secundario { background: #e5e7eb; color: #374151; }
.btn-secundario:hover:not(:disabled) { background: #d1d5db; }
.btn-bloco { width: 100%; justify-content: center; }

/* Aliases inglês (usados nas páginas JS) */
.btn-primary   { background: #3b82f6; color: #fff; }
.btn-primary:hover:not(:disabled)   { background: #2563eb; }
.btn-secondary { background: #e5e7eb; color: #374151; }
.btn-secondary:hover:not(:disabled) { background: #d1d5db; }
.btn-danger    { background: #ef4444; color: #fff; }
.btn-danger:hover:not(:disabled)    { background: #dc2626; }
.btn-success   { background: #22c55e; color: #fff; }
.btn-success:hover:not(:disabled)   { background: #16a34a; }
.btn-sm { padding: .35rem .85rem; font-size: .8rem; border-radius: 6px; }

/* ============================================================
   Cartões
   ============================================================ */
.cartao {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

/* ============================================================
   Tela de Login
   ============================================================ */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef2ff 0%, #f4f6f9 100%);
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 2.5rem;
}

.login-logo { text-align: center; margin-bottom: 1rem; }

.login-titulo {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: .25rem;
}

.login-subtitulo {
  text-align: center;
  color: #6b7280;
  margin-bottom: 2rem;
  font-size: .95rem;
}

.input-senha-wrapper { position: relative; }
.input-senha-wrapper input { padding-right: 3rem; }
.btn-icone {
  position: absolute;
  right: .75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

/* ============================================================
   Layout Dashboard
   ============================================================ */
.dashboard-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: #1e1e2e;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 2rem;
  color: #fff;
}

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: .25rem; }

.nav-item {
  display: block;
  padding: .6rem .9rem;
  border-radius: 8px;
  color: #94a3b8;
  text-decoration: none;
  font-size: .95rem;
  transition: background .15s, color .15s;
}
.nav-item:hover, .nav-item.ativo {
  background: #6366f1;
  color: #fff;
}

.sidebar-footer { border-top: 1px solid #2d2d3d; padding-top: 1rem; }
.sidebar-usuario { font-weight: 600; font-size: .95rem; }
.sidebar-role { font-size: .8rem; color: #94a3b8; text-transform: capitalize; margin-bottom: .5rem; }

.conteudo-principal { flex: 1; display: flex; flex-direction: column; overflow: auto; min-width: 0; }

.topbar {
  padding: 1rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.topbar h2 { font-size: 1.25rem; font-weight: 700; }

/* Botão hamburguer — escondido no desktop */
.btn-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: .25rem;
  flex-shrink: 0;
}
.btn-hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: #374151;
  border-radius: 2px;
  transition: background .2s;
}

/* Overlay da sidebar em mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 49;
}
.sidebar-overlay.overlay-visivel { display: block; }

/* ============================================================
   Responsivo — Mobile
   ============================================================ */
@media (max-width: 768px) {
  .btn-hamburger { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .25s ease;
    width: 260px;
  }
  .sidebar.sidebar-aberta { transform: translateX(0); }

  .topbar { padding: .85rem 1rem; }
  .topbar h2 { font-size: 1.1rem; }

  #pagina-conteudo { padding: 1rem; }

  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: .75rem;
    padding: 1rem;
  }

  .tabela thead { display: none; }
  .tabela tbody tr {
    display: flex;
    flex-direction: column;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: .75rem;
    padding: .75rem;
    background: #fff;
  }
  .tabela tbody td {
    border: none;
    padding: .2rem 0;
    font-size: .88rem;
  }
  .tabela tbody td[style*="display:flex"] {
    padding-top: .5rem;
    border-top: 1px solid #f3f4f6;
    margin-top: .25rem;
  }

  .modal-caixa {
    max-width: 100%;
    margin: 0 .5rem;
    padding: 1.5rem;
  }
}

/* ============================================================
   Dashboard — cards de estatísticas
   ============================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  padding: 2rem;
}

.stat-card { text-align: center; }
.stat-label { font-size: .85rem; color: #6b7280; margin-bottom: .5rem; }
.stat-valor { font-size: 2rem; font-weight: 700; color: #6366f1; }

/* ============================================================
   Conteúdo interno das páginas
   ============================================================ */
#pagina-conteudo { padding: 2rem; flex: 1; }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal-caixa {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

/* ============================================================
   Formulários — grupos
   ============================================================ */
.form-grupo { margin-bottom: 1rem; }
.form-grupo label { display: block; font-size: .85rem; font-weight: 600; color: #374151; margin-bottom: .35rem; }

/* ============================================================
   Tabelas
   ============================================================ */
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  overflow: hidden;
}

.tabela {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.tabela thead th {
  background: #f3f4f6;
  padding: .75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: #374151;
  border-bottom: 1px solid #e5e7eb;
}
.tabela tbody td {
  padding: .75rem 1rem;
  border-bottom: 1px solid #f3f4f6;
  color: #111827;
  vertical-align: middle;
}
.tabela tbody tr:last-child td { border-bottom: none; }
.tabela tbody tr:hover { background: #f9fafb; }

/* ============================================================
   Dialog customizado (substitui alert/confirm do navegador)
   ============================================================ */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 1rem;
  transition: background .2s ease;
}
.dialog-overlay.dialog-visivel {
  background: rgba(0, 0, 0, .5);
}
.dialog-caixa {
  background: #fff;
  border-radius: 1rem;
  padding: 2rem 2rem 1.5rem;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  transform: translateY(16px) scale(.97);
  opacity: 0;
  transition: transform .22s ease, opacity .22s ease;
}
.dialog-overlay.dialog-visivel .dialog-caixa {
  transform: translateY(0) scale(1);
  opacity: 1;
}
.dialog-icone { margin-bottom: 1rem; }
.dialog-titulo {
  font-size: 1.1rem;
  font-weight: 700;
  color: #111827;
  margin: 0 0 .5rem;
}
.dialog-mensagem {
  font-size: .95rem;
  color: #4b5563;
  margin: 0 0 1.5rem;
  line-height: 1.5;
}
.dialog-acoes {
  display: flex;
  gap: .75rem;
  justify-content: center;
}
.dialog-acoes .btn { min-width: 100px; }
