/* ===========================
   BASE E RESET
=========================== */
body {
  font-family: Arial, sans-serif;
  background: #f4f6f8;
  margin: 0;
  color: #333;
}

/* ===========================
   TIPOGRAFIA E ELEMENTOS GERAIS
=========================== */
h1 {
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 1.8rem;
}

p {
  text-align: center;
  margin-bottom: 2rem;
  font-size: 1rem;
  color: #666;
}

a {
  display: block;
  margin-top: 1rem;
  text-align: center;
  color: #003366;
  text-decoration: none;
}

/* ===========================
   FORMULÁRIOS
=========================== */
.form-container,
.login-container,
.container {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  max-width: 500px;
  margin: 2rem auto;
}

form {
  display: flex;
  flex-direction: column;
}

label {
  display: block;
  margin-top: 1rem;
  font-weight: bold;
}

input {
  width: 100%;
  padding: 0.6rem;
  margin-top: 0.3rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
}

button {
  margin-top: 1.5rem;
  padding: 0.8rem;
  background-color: #003366;
  color: white;
  border: none;
  border-radius: 5px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

button:hover {
  background-color: #002244;
}

/* ===========================
   MENSAGENS DE STATUS
=========================== */
.erro {
  background: #ffe0e0;
  color: #a00;
  padding: 0.75rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.sucesso {
  background: #e0ffe0;
  color: #080;
  padding: 0.75rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

/* ===========================
   PAINEL E DASHBOARD
=========================== */
.topbar {
  background: #003366;
  color: white;
  padding: 0.2rem 1rem;
  height: 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Título da topbar (evita <a class="btn"> invisível sobre fundo escuro) */
.topbar h1 {
  margin: 0;
  font-size: 1rem;
  text-align: left;
}
.topbar-titulo {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  display: inline-block;
  margin: 0;
}
.topbar-titulo:hover { opacity: .85; }

.rep-nome {
  font-weight: bold;
  font-size: 0.8rem;
}

.dashboard {
  padding: 2rem;
}

.stats {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.card {
  background: white;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
  flex: 1;
  min-width: 200px;
  text-align: center;
}

.card h2 {
  margin-bottom: 0.5rem;
}

.actions {
  margin-top: 1.2rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn {
  background: #003366;
  color: white;
  padding: 0.75rem 1.5rem;
  text-decoration: none;
  border-radius: 5px;
  font-weight: bold;
}

.btn.small {
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
}

.btn.small.muted {
  background: #eee;
  color: #333;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* Estado ativo dos botões de navegação */
.btn.ativa {
  background: #ffcc00;
  color: #003366;
  border: 1px solid #ffcc00;
  box-shadow: 0 0 0 2px rgba(255, 204, 0, .35);
}
.btn.ativa:hover {
  background: #ffd633;
}

/* ===========================
   TABELAS
=========================== */
.table-wrap {
  overflow-x: auto;
  margin-top: 1rem;
}

.clientes-table,
.consorcios-table,
.grupos-table,
.agencias-table {
  font-family: Arial, Helvetica, sans-serif;
  border-collapse: collapse;
  width: 100%;
}

.clientes-table td,
.clientes-table th,
.consorcios-table td,
.consorcios-table th,
.grupos-table td,
.grupos-table th,
.agencias-table td,
.agencias-table th {
  border: 1px solid #ddd;
  padding: 8px;
}

.clientes-table tr:nth-child(even),
.consorcios-table tr:nth-child(even),
.grupos-table tr:nth-child(even),
.agencias-table tr:nth-child(even) {
  background-color: #f9fafb;
}

.clientes-table tr:hover,
.consorcios-table tr:hover,
.grupos-table tr:hover,
.agencias-table tr:hover {
  background-color: #eef2f6;
}

.clientes-table th,
.consorcios-table th,
.grupos-table th,
.agencias-table th {
  padding-top: 12px;
  padding-bottom: 12px;
  text-align: left;
  background-color: #003366;
  color: white;
}

/* Colunas numéricas alinhadas à direita */
.grupos-table th.num,
.grupos-table td.num {
  text-align: right;
}

/* ===========================
   FILTROS (grid genérico)
=========================== */
.filtros {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  align-items: end;
}

.filtros h3 {
  grid-column: 1 / -1;
  margin-bottom: 0.5rem;
}

/* ===========================
   FILTROS EM LINHA (legado)
=========================== */
.filtros-inline {
  display: flex;
  flex-wrap: nowrap;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 6px;
  border: 1px solid #e9ecef;
}

.filtro-grupo {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.filtro-grupo label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #495057;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filtro-grupo select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-size: 0.9rem;
  background: white;
  width: 100%;
  transition: border-color 0.15s ease-in-out;
}

.filtro-grupo select:focus {
  border-color: #003366;
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.1);
}

/* ===========================
   FILTROS AVANÇADOS (details recolhível)
=========================== */
.filtros-painel {
  background: #f8f9fb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0;
  margin-bottom: 16px;
  overflow: hidden;
}
.filtros-painel > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  background: #f3f4f6;
  transition: background .15s;
}
.filtros-painel > summary::-webkit-details-marker { display: none; }
.filtros-painel > summary:hover { background: #eef0f4; }
.filtros-painel > summary::before {
  content: "▸";
  font-size: 11px;
  color: #6b7280;
  transition: transform .15s;
}
.filtros-painel[open] > summary::before { transform: rotate(90deg); }

.filtros-painel .badge-filtros {
  background: #2563eb;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
  line-height: 1.5;
}

.filtros-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 16px;
  align-items: end;
  padding: 14px 16px 16px;
}

.filtros-grid .filtro-grupo {
  flex: initial;
  min-width: 0;
}

.filtros-grid .filtro-grupo label {
  font-size: 11px;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 0;
}

.filtros-grid .filtro-grupo input,
.filtros-grid .filtro-grupo select {
  height: 32px;
  padding: 0 8px;
  font-size: 13px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  background: #fff;
  box-sizing: border-box;
  width: 100%;
  margin-top: 0;
  transition: border-color .15s, box-shadow .15s;
}
.filtros-grid .filtro-grupo input:focus,
.filtros-grid .filtro-grupo select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, .15);
}

.filtro-range {
  display: flex;
  align-items: center;
  gap: 6px;
}
.filtro-range input { min-width: 0; }
.range-sep {
  color: #9ca3af;
  font-size: 12px;
  flex-shrink: 0;
}

.filtro-acoes { align-self: end; }
.acoes-botoes { display: flex; gap: 8px; }

.btn-aplicar,
.btn-limpar {
  height: 32px;
  padding: 0 14px;
  font-size: 13px;
  border-radius: 5px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-weight: 500;
  margin-top: 0;
}
.btn-aplicar { background: #2563eb; color: #fff; }
.btn-aplicar:hover { background: #1d4ed8; }
.btn-limpar {
  background: #fff;
  color: #374151;
  border-color: #d1d5db;
}
.btn-limpar:hover { background: #f3f4f6; }

@media (max-width: 640px) {
  .filtros-grid { grid-template-columns: 1fr; }
  .filtro-acoes { grid-column: 1 / -1; }
}

/* ===========================
   RESUMO / TOTAIS
=========================== */
.resumo {
  background: #eef2f6;
  padding: 0.75rem 1rem;
  border-radius: 5px;
  margin: 1rem 0;
  font-size: 0.95rem;
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  align-items: center;
}

.resumo strong { color: #003366; }

.resumo-totais {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding: 10px 2px;
  font-size: 13px;
  color: #444;
}
.resumo-totais strong { color: #111; }

/* ===========================
   SEÇÕES
=========================== */
.grupos-section,
.consorcios-section,
.clientes-section,
.agencias-section {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
  margin: 1.5rem auto;
  max-width: 1200px;
}

/* ===========================
   PAGINAÇÃO
=========================== */
.paginacao {
  text-align: center;
  margin-top: 0.75rem;
}

.paginacao span {
  display: inline-block;
  margin: 2px;
}

.paginacao a {
  display: inline-block;
  padding: 6px 12px;
  margin: 2px;
  background: #003366;
  color: white;
  border-radius: 4px;
  text-decoration: none;
}

.paginacao a.ativa {
  background: #ffcc00;
  color: #003366;
}

/* ===========================
   DROPDOWN E MENU
=========================== */
.user-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.dropdown {
  position: relative;
}

.menu-btn {
  background: #ffcc00;
  border: none;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  cursor: pointer;
  border-radius: 4px;
}

.dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  top: 110%;
  background-color: white;
  min-width: 150px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  z-index: 1;
  border-radius: 4px;
}

.dropdown-content a {
  color: #003366;
  padding: 0.75rem 1rem;
  text-decoration: none;
  display: block;
}

.dropdown-content a:hover {
  background-color: #f0f0f0;
}

.dropdown:hover .dropdown-content {
  display: block;
}

/* ===========================
   RODAPÉ
=========================== */
.rodape {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  text-align: center;
  padding: 1rem;
  background: #eaeaea;
  font-size: 0.9rem;
  color: #333;
  border-top: 1px solid #ccc;
  z-index: 1000;
}

/* ===========================
   ÍCONE DE LINK (edição)
=========================== */
.icon-link {
  display: inline-block;
  text-decoration: none;
  font-size: 1.2rem;
  margin: 0;
  padding: 0 4px;
}

/* ===========================
   BOTÕES DE CONTATO (tel/WhatsApp)
=========================== */
.btn-call {
  display: inline-block;
  color: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
  transition: opacity 0.2s;
}
.btn-call:hover {
  opacity: 0.8;
}

/* ===========================
   BARRA DE NAVEGAÇÃO — CADASTRO DE GRUPOS
   Layout: 5 colunas em uma linha
   (badge · busca · anterior · próximo · novo)
=========================== */
.grupo-nav {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  gap: 10px 12px;
  align-items: center;
  background: #f8f9fb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

/* --- Coluna 1: badge --- */
.grupo-nav .badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  background: #e5e7eb;
  color: #374151;
  white-space: nowrap;
}
.grupo-nav .badge.novo   { background: #dcfce7; color: #166534; }
.grupo-nav .badge.editar { background: #dbeafe; color: #1e40af; }

/* --- Coluna 2: formulário de busca --- */
.grupo-nav .nav-busca {
  display: flex;
  flex-direction: row;
  gap: 6px;
  margin: 0;
  min-width: 0;
}
.grupo-nav .nav-busca input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  font-size: 13px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  box-sizing: border-box;
  margin-top: 0;
}
.grupo-nav .nav-busca input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* Botão de busca — quadrado, apenas o ícone */
.grupo-nav .nav-busca button {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0;
  transition: background .15s, border-color .15s;
}
.grupo-nav .nav-busca button:hover {
  background: #f3f4f6;
}
.grupo-nav .nav-busca button:focus-visible {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* --- Colunas 3, 4 e 5: botões de navegação --- */
.grupo-nav .btn-nav {
  height: 34px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  margin-top: 0;
}
.grupo-nav .btn-nav:hover { background: #f3f4f6; }

.grupo-nav .btn-nav.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.grupo-nav .btn-nav.primary {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.grupo-nav .btn-nav.primary:hover { background: #1d4ed8; }

/* --- Responsivo: tablet (≤ 900px) — 3 colunas --- */
@media (max-width: 900px) {
  .grupo-nav {
    grid-template-columns: auto 1fr auto;
  }
  .grupo-nav .nav-busca  { grid-column: 2 / -1; }
  .grupo-nav .btn-nav    { width: 100%; }
}

/* --- Responsivo: mobile (≤ 560px) — 1 coluna --- */
@media (max-width: 560px) {
  .grupo-nav {
    grid-template-columns: 1fr;
  }
  .grupo-nav .nav-busca {
    flex-direction: column;
    grid-column: auto;
  }
  .grupo-nav .nav-busca input,
  .grupo-nav .nav-busca button {
    width: 100%;
  }
  .grupo-nav .badge { justify-self: start; }
}

/* ===========================
   MOBILE RESPONSIVO (global)
=========================== */
@media screen and (max-width: 768px) {
  body {
    font-size: 16px;
    margin: 0;
    padding: 0;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 10px;
    height: auto;
  }

  .topbar h1 {
    font-size: 1em;
    margin: 0;
    margin-bottom: 10px;
  }

  .user-menu {
    width: 100%;
    display: flex;
    justify-content: space-between;
  }

  .dashboard {
    padding: 10px;
  }

  .stats {
    flex-direction: column;
    gap: 10px;
  }

  .card {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
  }

  .actions {
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
  }

  .btn {
    font-size: 1em;
    padding: 10px;
    text-align: center;
  }

  .clientes-section,
  .consorcios-section,
  .grupos-section,
  .agencias-section {
    overflow-x: auto;
    padding: 1rem;
  }

  .filtros {
    flex-direction: column;
    align-items: stretch;
  }

  .filtros input,
  .filtros select,
  .filtros button,
  .filtros a {
    width: 100%;
    max-width: none;
  }

  .filtros-inline {
    flex-wrap: wrap;
  }

  .rodape {
    padding: 10px;
  }

  .resumo {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }

  /* Oculta elementos com classe .desktop-only */
  .desktop-only {
    display: none !important;
  }
}