/* V2026.05.13 - 13/05/26 BRT */
:root {
  --bg: #f3f5fb;
  --card: #ffffff;
  --text: #16131d;
  --muted: #6d6b73;
  --brand: #1f2b53;
  --cta: #8b1e3f;
  --ok: #0c7c59;
  --warn: #c46210;
  --line: #d8dde8;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, Arial, sans-serif; font-size: 16px; line-height: 1.6; background: var(--bg); color: var(--text); overflow-x: hidden; }
a { color: inherit; text-decoration: none; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.admin-sidebar {
  background: var(--brand);
  color: #fff;
  padding: 1.4rem 1.1rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Cabeçalho — logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding-bottom: 1.1rem;
  margin-bottom: 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  flex-shrink: 0;
}
.logo-icone {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.15);
  border-radius: 7px;
  font-size: 0.95rem;
}
.logo-titulo {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
}

/* Menu */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  color: #c8c6cc;
  font-size: 0.95rem;
  transition: background 0.15s, color 0.15s;
}
.sidebar-nav a i { width: 1.1em; text-align: center; flex-shrink: 0; }
.sidebar-nav a:hover,
.sidebar-nav a.ativo { background: rgba(255,255,255,0.12); color: #fff; }

/* Rodapé — usuário */
.sidebar-rodape {
  padding-top: 1rem;
  margin-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.15);
  flex-shrink: 0;
}
.sidebar-rodape p {
  margin: 0 0 0.25rem;
  font-weight: 600;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: #fff;
}
.sidebar-rodape small {
  color: #c8c6cc;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.admin-main { padding: 1rem 1.25rem; min-width: 0; }
.admin-header { margin-bottom: 1rem; }
.admin-header h2 { margin: 0; color: var(--brand); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; margin-bottom: 1rem; }
/* Cards (Auto-fit mín 280px no Desktop) */
.grid { 
  display: grid; 
  gap: 1rem; 
  margin-bottom: 1rem; 
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); 
}
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-5 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* Grid específica para KPIs */
.grid-kpis {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
  grid-template-columns: 1fr; /* Mobile: 1 coluna empilhado */
}

@media (min-width: 768px) {
  .grid-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .grid-kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
.btn-toggle-kpis {
  display: none;
  width: 100%;
  margin-bottom: 1rem;
  background: #edf1fb;
  color: var(--brand);
  border: 1px solid var(--line);
  font-weight: 600;
  border-radius: 8px;
}

.grid > .card, .grid-kpis > .card { margin-bottom: 0; }

.kpi { border-left: 4px solid var(--brand); min-height: 88px; display: flex; flex-direction: column; justify-content: center; }
.kpi h3 { margin: 0 0 0.25rem; font-size: 0.92rem; color: var(--muted); }
.kpi p { margin: 0; font-size: 1.6rem; font-weight: 700; }

table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 0.6rem 0.5rem; text-align: left; vertical-align: top; }
th { font-size: 0.84rem; color: var(--muted); }

form { display: grid; gap: 0.75rem; }
label { display: grid; gap: 0.3rem; font-weight: 500; font-size: 0.92rem; }
input, textarea, select {
  width: 100%;
  border: 1px solid #cbd2e1;
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font: inherit;
}
textarea { min-height: 120px; resize: vertical; }

.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; align-items: start; }
.row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; align-items: start; }

.btn {
  background: var(--brand);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 0.62rem 0.9rem;
  cursor: pointer;
}
.btn:hover { opacity: 0.94; }
.btn-cta { background: var(--cta); }
.btn-ok { background: var(--ok); }
.btn-warn { background: var(--warn); }

.flash { padding: 0.7rem 0.8rem; border-radius: 8px; margin-bottom: 1rem; }
.flash.ok { background: #e8f7f0; border: 1px solid #9dd9bf; color: #18593f; }
.flash.err { background: #fdeceb; border: 1px solid #efb6b2; color: #8d2720; }

.top-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.pill { display: inline-block; padding: 0.18rem 0.48rem; border-radius: 999px; background: #edf1fb; color: #23315c; font-size: 0.78rem; }
.pill-capa { background: #d4edda; color: #155724; font-weight: 600; }
.pill-novo       { background: #dbeafe; color: #1e40af; }
.pill-contato    { background: #fef3c7; color: #92400e; }
.pill-qualificado{ background: #d1fae5; color: #065f46; }
.pill-convertido { background: #dcfce7; color: #14532d; }
.pill-descartado { background: #fee2e2; color: #991b1b; }
.pill-rascunho   { background: #ffedd5; color: #c2410c; font-weight: 600; }
.pill-publicado  { background: #d1fae5; color: #065f46; font-weight: 600; }
.pill-arquivado  { background: #f3f4f6; color: #4b5563; font-weight: 600; }

.acoes-td { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }

.fotos-contador { display: inline-block; margin-left: 0.4rem; padding: 0.1rem 0.45rem; border-radius: 999px; background: #edf1fb; color: #23315c; font-size: 0.78rem; font-weight: 600; vertical-align: middle; }
.fotos-limite { background: #fdeceb; color: #8d2720; }
.foto-arquivo { font-size: 0.8rem; color: var(--muted); word-break: break-all; max-width: 340px; }
.campo-ajuda { display: block; margin-top: 0.25rem; font-size: 0.82rem; color: var(--muted); font-weight: 400; }
.campo-aviso { display: block; margin-top: 0.25rem; font-size: 0.82rem; color: var(--cta); font-weight: 600; }

/* Auth pages: login / valida_otp */
.auth-page-main { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: min(100%, 460px); }
.auth-title { margin-top: 0; color: var(--brand); }
.auth-subtitle { margin-top: 0; color: var(--muted); }

/* Inline action forms e helpers de layout */
.form-inline { display: inline-grid; }
.form-inline-action { display: inline-grid; margin-top: 0.35rem; }
.form-action-mt { margin-top: 0.35rem; }
.filter-submit { display: flex; align-self: center; } /* legado — não usar em novos forms */
.filter-form > * { height: 2.5rem; box-sizing: border-box; }
.form-select-action { display: flex; gap: 0.4rem; align-items: center; }
.form-select-action select { flex: 1; width: auto; }

/* Utilitários CSS (Substitutos de Inline Style) */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mt-1-5 { margin-top: 1.5rem; }
.my-1-5 { margin-top: 1.5rem; margin-bottom: 1.5rem; }
.pt-1 { padding-top: 1rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.max-w-800 { max-width: 800px; width: 100%; }
.bg-disabled { background-color: #f5f5f5; }
.border-t-light { border-top: 1px solid #eee; }
.border-0 { border: 0; }
.p-1-5 { padding: 1.5rem; }
.font-1-1 { font-size: 1.1rem; }
.d-contents { display: contents; }
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline-block { display: inline-block; }
.input-readonly { background: #f0f2f8; color: var(--muted); cursor: default; }
.text-warning { color: #e5a000; }
.text-muted { color: #ccc; }
.text-archived { color: #999; font-size: 0.85rem; }
.empty-table-msg { text-align: center; color: #999; padding: 1.5rem; }
.mb-0-25 { margin-bottom: 0.25rem; }

.mt-1 { margin-top: 1rem; }
.mt-1-5 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 1rem; }
.v-align-middle { vertical-align: middle; }
.avatar-sm { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.avatar-sm-icon { font-size: 30px; color: var(--muted); }
.form-actions { margin-top: 1.5rem; justify-content: flex-end; display: flex; gap: 1rem; border-top: 1px solid #eee; padding-top: 1rem; }
.w-25 { width: 25%; }
.w-15 { width: 15%; }
.w-10 { width: 10%; }

/* Paginação */
.paginacao { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 1rem; align-items: center; }
.paginacao a, .paginacao span { display: inline-flex; align-items: center; justify-content: center; min-width: 2rem; height: 2rem; padding: 0 0.5rem; border-radius: 6px; border: 1px solid var(--line); font-size: 0.88rem; text-decoration: none; color: var(--brand); background: #fff; }
.paginacao .ativa { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 700; }
.paginacao .desabilitado { color: var(--muted); pointer-events: none; }

/* Checkbox com label visivel */
.label-check {
  display: flex !important;
  align-items: center;
  gap: 0.65rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0.55rem 0.8rem;
  background: #f8f9fc;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: fit-content;
}
.label-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--brand);
  margin: 0;
}


/* Hamburger — oculto no desktop */
.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--brand);
}

/* Overlay — oculto por padrão */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 199;
}
.sidebar-overlay.visivel { display: block; }

/* Scroll to Top */
.scroll-top {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--brand);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(31, 43, 83, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease, transform 200ms ease;
}
.scroll-top.visivel { opacity: 1; pointer-events: auto; }
.scroll-top:hover { transform: translateY(-3px); filter: brightness(1.15); }

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

  /* Sidebar desliza da esquerda */
  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    width: 260px;
    min-height: 100dvh;
    transform: translateX(-260px);
    transition: transform 0.26s ease;
    z-index: 200;
  }
  .admin-sidebar.aberta { transform: translateX(0); }

  /* Hamburger visível */
  .hamburger { display: flex; }

  /* Header com botão + título em linha */
  .admin-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0 0.75rem;
  }
  .admin-header h2 { margin: 0; }

  .admin-main { padding: 20px; }
  .grid, .grid-2, .grid-3, .grid-5, .row, .row-3 { grid-template-columns: 1fr; }
  .scroll-top { width: 44px; height: 44px; }
}

@media (max-width: 480px) {
  .admin-main { padding: 15px; }
  .grid-kpis.kpis-oculto { display: none; }
  .btn-toggle-kpis { display: block; padding: 0.8rem; }
  .scroll-top { width: 40px; height: 40px; bottom: 16px; right: 16px; }
}

/* Modais e Layout */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 9999; padding: 2rem 1rem; overflow-y: auto; align-items: flex-start; justify-content: center; }
.modal-overlay.ativo, .modal-overlay.is-active { display: flex; }
.modal-content { background: #fff; border-radius: 8px; width: 100%; max-width: 750px; margin: auto; padding: 2rem; position: relative; box-shadow: 0 10px 25px rgba(0,0,0,0.2); }
.modal-close { position: absolute; top: 1rem; right: 1rem; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #666; transition: color 0.2s; }
.modal-close:hover, .modal-close:focus { color: #000; outline: 2px solid var(--brand); border-radius: 4px; }
.tabs { display: flex; gap: 1rem; margin-bottom: 1.5rem; border-bottom: 1px solid #ddd; padding-bottom: 0.5rem; flex-wrap: wrap; }
.tab-btn { background: none; border: none; padding: 0.5rem 1rem; cursor: pointer; font-weight: bold; color: #777; border-bottom: 2px solid transparent; transition: all 0.2s; }
.tab-btn.ativo, .tab-btn.is-active { color: var(--brand); border-bottom: 2px solid var(--brand); }
.tab-btn:hover, .tab-btn:focus { color: #000; }
.tab-pane { display: none; }
.tab-pane.ativo, .tab-pane.is-active { display: block; }
.avatar-preview { width: 90px; height: 90px; border-radius: 50%; object-fit: cover; background: #eee; display: block; margin-bottom: 1rem; border: 1px solid #ddd; }
.acoes-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border-radius: 4px; }

/* Acessibilidade: Focus e Tabela Responsiva */
input:focus, textarea:focus, select:focus, button:focus { outline: 2px solid var(--brand); outline-offset: 2px; }
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 1.5rem; }
.table-responsive table { margin-top: 0; min-width: 800px; }
.admin-main-container { max-width: 1200px; margin: 0 auto; width: 100%; }

/* ==== Modal de Confirmação Personalizado ==== */
.custom-modal-backdrop {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(2px);
  z-index: 9999; display: flex; align-items: center; justify-content: center;
  opacity: 1; visibility: visible; transition: opacity 0.2s, visibility 0.2s;
}
.custom-modal-backdrop[hidden] {
  opacity: 0; visibility: hidden; pointer-events: none;
}
.custom-modal-box {
  background: var(--card); width: 90%; max-width: 400px; border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2); padding: 1.5rem; text-align: center;
  transform: translateY(0); transition: transform 0.2s;
}
.custom-modal-backdrop[hidden] .custom-modal-box {
  transform: translateY(-20px);
}
.custom-modal-header { margin-bottom: 1rem; }
.custom-modal-icon { font-size: 2.5rem; color: var(--warn); margin-bottom: 0.5rem; }
.custom-modal-icon.icon-danger { color: #dc3545; }
.custom-modal-title { margin: 0; font-size: 1.25rem; color: var(--text); }
.custom-modal-msg { color: var(--muted); margin-bottom: 1.5rem; font-size: 0.95rem; }
.custom-modal-actions { display: flex; gap: 0.75rem; justify-content: center; }
.custom-modal-actions .btn { min-width: 100px; }
.btn-danger { background: #dc3545; color: #fff; border: 1px solid #dc3545; }
.btn-danger:hover { background: #bb2d3b; border-color: #b02a37; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn-outline:hover { background: var(--bg); }
