/* ============================================================
   FUNDAPAM — Sistema de Gestão de Projetos
   CSS Principal (estrutura adaptada de referência visual, paleta e
   dados próprios da Fundapam — ver _contexto/fundapam_contexto_design_system.md)
   ============================================================ */

:root {
  --primary: #624895;
  --primary-light: #f3eff9;
  --primary-hover: #513c7d;
  --sidebar-width: 252px;
  --sidebar-collapsed: 64px;
  --text: #1a1a2e;
  --muted: #8b8fa8;
  --border: #e8e8f0;
  --bg: #f7f7fb;
  --white: #ffffff;

  /* Cores de status — fixas por definição (não usam var(--primary)) */
  --status-em-andamento-cor: #1565c0;   --status-em-andamento-bg: #eff5fd;
  --status-suspenso-cor: #c27e0a;       --status-suspenso-bg: #fff8eb;
  --status-cancelado-cor: #8b8fa8;      --status-cancelado-bg: #f2f2f6;
  --status-concluido-cor: #2fb36e;      --status-concluido-bg: #edfaf3;
  --status-previsto-cor: #8b8fa8;       --status-previsto-bg: #f2f2f6;
  --status-recebido-cor: #2fb36e;       --status-recebido-bg: #edfaf3;
  --status-atrasado-cor: #c53030;       --status-atrasado-bg: #fff0f0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ===== AVISO DE MANUTENÇÃO (banner global) ===== */
.aviso-manutencao {
  background: #fff8eb;
  border-bottom: 1px solid #fde68a;
  color: #92400e;
  font-size: 13px;
  line-height: 1.5;
  padding: 12px 48px 12px 20px;
  text-align: center;
  position: relative;
}
.aviso-manutencao.aviso-normal { background: #eff5fd; border-bottom-color: #bfdbfe; color: #1565c0; }
.aviso-manutencao.aviso-alta   { background: #fff0f0; border-bottom-color: #feb2b2; color: #c53030; }
.aviso-fechar {
  border: none; background: none; cursor: pointer;
  color: inherit; font-size: 18px; line-height: 1;
  padding: 0 4px; position: absolute; right: 14px; top: 10px;
}
.aviso-fechar:hover { opacity: 0.7; }

/* ===== PORTAL (shell autenticado) ===== */
.portal { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: width 0.25s ease;
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-header {
  display: flex; align-items: center;
  padding: 0 14px; height: 68px;
  border-bottom: 1px solid var(--border);
  gap: 8px; flex-shrink: 0;
}
.logo-wrap { flex: 1; overflow: hidden; display: flex; align-items: center; min-width: 0; }
.logo-full { height: 34px; width: auto; display: block; object-fit: contain; object-position: left center; max-width: 160px; }
.logo-icon { height: 34px; width: 34px; display: none; object-fit: contain; flex-shrink: 0; cursor: pointer; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 0; }
.sidebar.collapsed .logo-wrap { flex: none; justify-content: center; }
.sidebar.collapsed .logo-full { display: none; }
.sidebar.collapsed .logo-icon { display: block; }
.sidebar.collapsed .toggle-btn { display: none; }

.toggle-btn {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px; border: none; background: none;
  cursor: pointer; color: var(--muted); transition: all 0.15s; flex-shrink: 0;
}
.toggle-btn:hover { background: var(--primary-light); color: var(--primary); }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; overflow-x: hidden; }
.nav-section {
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
  padding: 0 8px; margin: 12px 0 4px;
  white-space: nowrap; transition: opacity 0.2s;
}
.sidebar.collapsed .nav-section { opacity: 0; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  font-size: 13.5px; font-weight: 400;
  color: var(--muted); cursor: pointer; text-decoration: none;
  transition: all 0.15s; white-space: nowrap; margin-bottom: 2px; position: relative;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 500; }
.nav-item svg { flex-shrink: 0; }
.nav-label { transition: opacity 0.15s; }
.sidebar.collapsed .nav-label { opacity: 0; width: 0; overflow: hidden; }

.nav-tooltip {
  position: fixed; left: calc(var(--sidebar-collapsed) + 10px);
  background: var(--text); color: #fff;
  font-size: 12px; padding: 5px 10px; border-radius: 6px;
  white-space: nowrap; pointer-events: none; opacity: 0; z-index: 999;
  transition: opacity 0.15s;
}
.sidebar.collapsed .nav-item:hover .nav-tooltip { opacity: 1; }

.sidebar-footer { padding: 10px 10px 14px; border-top: 1px solid var(--border); flex-shrink: 0; }
.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  margin-bottom: 4px; overflow: hidden;
  text-decoration: none; transition: background 0.15s;
}
.user-row:hover { background: var(--bg); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-details { overflow: hidden; transition: opacity 0.15s; }
.user-name { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; }
.user-role { font-size: 11px; color: var(--muted); }
.sidebar.collapsed .user-details { opacity: 0; width: 0; }

.logout-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  border: none; background: none; cursor: pointer;
  color: var(--muted); font-size: 13px; font-family: 'DM Sans', sans-serif;
  width: 100%; text-align: left; transition: all 0.15s; white-space: nowrap; text-decoration: none;
}
.logout-btn:hover { background: #fff0f0; color: #e53e3e; }
.sidebar.collapsed .logout-label { opacity: 0; width: 0; overflow: hidden; }

/* ===== MAIN ===== */
.main { flex: 1; margin-left: var(--sidebar-width); transition: margin-left 0.25s ease; min-height: 100vh; display: flex; flex-direction: column; }
.main.collapsed { margin-left: var(--sidebar-collapsed); }

.topbar {
  height: 68px; background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 28px; position: sticky; top: 0; z-index: 50;
}
.topbar-info { flex: 1; }
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

.page { padding: 28px; flex: 1; }

/* ===== CARDS ===== */
.card { background: var(--white); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 18px; }
.card-head { padding: 16px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-size: 14px; font-weight: 600; }
.card-body { padding: 22px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 8px; }
.stat-value { font-size: 26px; font-weight: 600; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ===== BADGES ===== */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.badge-success { background: #edfaf3; color: #2fb36e; }
.badge-warning { background: #fff8eb; color: #c27e0a; }
.badge-error   { background: #fff0f0; color: #c53030; }
.badge-neutral { background: var(--bg); color: var(--muted); }
.badge-primary { background: var(--primary-light); color: var(--primary); }

/* Status de projeto */
.badge-em-andamento { background: var(--status-em-andamento-bg); color: var(--status-em-andamento-cor); }
.badge-suspenso     { background: var(--status-suspenso-bg); color: var(--status-suspenso-cor); }
.badge-cancelado    { background: var(--status-cancelado-bg); color: var(--status-cancelado-cor); }
.badge-concluido    { background: var(--status-concluido-bg); color: var(--status-concluido-cor); }

/* Status de etapa de recebimento / lançamento */
.badge-previsto { background: var(--status-previsto-bg); color: var(--status-previsto-cor); }
.badge-recebido { background: var(--status-recebido-bg); color: var(--status-recebido-cor); }
.badge-atrasado { background: var(--status-atrasado-bg); color: var(--status-atrasado-cor); }

/* ===== TAG (metadado neutro: categoria, tipo) ===== */
.tag { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 6px; font-size: 11px; font-weight: 500; background: var(--bg); color: var(--text); white-space: nowrap; }

/* ===== BOTÕES DE AÇÃO EM TABELA ===== */
.btn-acao { display: inline-flex; align-items: center; gap: 4px; padding: 5px 11px; border-radius: 7px; border: 1.5px solid var(--border); background: var(--white); color: var(--text); font-size: 12px; font-weight: 500; font-family: 'DM Sans', sans-serif; cursor: pointer; transition: all 0.15s; white-space: nowrap; text-decoration: none; }
.btn-acao:hover { border-color: var(--primary); color: var(--primary); }
.btn-acao.apagar:hover { border-color: #e53e3e; color: #e53e3e; }
.btn-acao.confirmar:hover { border-color: #2fb36e; color: #2fb36e; }

/* ===== BOTÃO VOLTAR ===== */
.back-btn { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; border: none; background: none; font-family: 'DM Sans', sans-serif; padding: 0; margin-bottom: 20px; transition: color 0.15s; text-decoration: none; }
.back-btn:hover { color: var(--primary); }

/* ===== TABELA AGRUPADA POR STATUS (expansível) ===== */
.grupo-bloco { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 14px; }
.grupo-cabecalho {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px; cursor: pointer; user-select: none;
  background: var(--status-bg, var(--bg));
  border-left: 3px solid var(--status-cor, var(--border));
}
.grupo-cabecalho .chevron { transition: transform 0.15s; color: var(--status-cor, var(--muted)); flex-shrink: 0; }
.grupo-cabecalho.aberto .chevron { transform: rotate(180deg); }
.grupo-label { font-size: 13.5px; font-weight: 600; color: var(--status-cor, var(--text)); flex: 1; }
.grupo-contagem { font-size: 12px; color: var(--status-cor, var(--muted)); background: var(--white); padding: 2px 9px; border-radius: 999px; }
.grupo-corpo { display: none; }
.grupo-corpo.aberto { display: block; }
.linha-status { border-left: 3px solid var(--status-cor, transparent); }

/* ===== TIMELINE (anotações) ===== */
.timeline { list-style: none; position: relative; padding-left: 22px; margin: 0; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 0; width: 2px; background: var(--border); }
.tl-item { position: relative; margin-bottom: 24px; }
.tl-dot { position: absolute; left: -22px; top: 4px; width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--border); background: var(--white); z-index: 1; }
.tl-dot.done { background: var(--primary); border-color: var(--primary); }
.tl-header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; justify-content: space-between; }
.tl-title { font-size: 13.5px; font-weight: 500; }
.msg-text { font-size: 13px; color: var(--text); line-height: 1.55; }

/* ===== ARQUIVOS ===== */
.file-item { display: flex; align-items: center; gap: 14px; padding: 14px 18px; background: var(--white); border: 1px solid var(--border); border-radius: 10px; transition: border-color 0.15s; margin-bottom: 10px; }
.file-item:hover { border-color: var(--primary); }
.file-icon { width: 38px; height: 38px; border-radius: 8px; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.file-name { font-size: 13.5px; font-weight: 500; }
.file-date { font-size: 12px; color: var(--muted); margin-top: 2px; }
.btn-dl { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 7px; border: 1.5px solid var(--border); background: var(--white); color: var(--text); font-size: 12px; font-weight: 500; font-family: 'DM Sans', sans-serif; cursor: pointer; transition: all 0.15s; white-space: nowrap; text-decoration: none; }
.btn-dl:hover { border-color: var(--primary); color: var(--primary); }

/* ===== ABAS (detalhe do projeto) ===== */
.doc-tabs { display: flex; gap: 3px; margin-bottom: 18px; background: var(--bg); padding: 4px; border-radius: 10px; width: fit-content; flex-wrap: wrap; }
.doc-tab { padding: 7px 15px; border-radius: 7px; font-size: 13px; color: var(--muted); cursor: pointer; border: none; background: none; transition: all 0.15s; font-family: 'DM Sans', sans-serif; text-decoration: none; }
.doc-tab.active { background: var(--white); color: var(--text); font-weight: 500; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

/* ===== TABELAS ===== */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }

/* ===== PROGRESSO ===== */
.progress-wrap { background: var(--border); border-radius: 999px; height: 5px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: var(--primary); }
.progress-fill.gasto { background: #c53030; }
.pct-destaque { color: var(--primary); font-weight: 600; }

/* Cores semânticas pros valores em destaque dos dashboards (tipo extrato bancário) */
.stat-positivo { color: #2fb36e; }
.stat-negativo { color: #c53030; }
.stat-azul     { color: #1565c0; }

/* ===== ALERTAS ===== */
.alert-warn    { background: #fff8eb; border: 1px solid #fde68a; border-radius: 10px; padding: 12px 16px; font-size: 13px; color: #92400e; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.alert-success { background: #edfaf3; border: 1px solid #9ae6b4; border-radius: 8px; padding: 10px 14px; font-size: 13px; color: #2f855a; margin-bottom: 16px; }
.alert-error   { background: #fff0f0; border: 1px solid #feb2b2; border-radius: 8px; padding: 10px 14px; font-size: 13px; color: #c53030; margin-bottom: 16px; }
.alert-persistente { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.alert-fechar  { border: none; background: none; cursor: pointer; color: inherit; font-size: 12px; font-weight: 600; text-decoration: underline; padding: 0; flex-shrink: 0; white-space: nowrap; }

/* ===== INFO (label: valor, leitura simples) ===== */
.info-row { font-size: 13.5px; margin-bottom: 10px; }
.info-row:last-child { margin-bottom: 0; }
.info-row-label { font-weight: 500; color: var(--muted); }

/* ===== FORMULÁRIOS ===== */
.field-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.field-input, select.field-input, textarea.field-input {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 8px;
  font-family: 'DM Sans', sans-serif; font-size: 14px; color: var(--text);
  background: #fff; outline: none; transition: border-color 0.2s; margin-bottom: 16px;
}
.field-input:focus { border-color: var(--primary); }
.field-hint { font-size: 12px; color: var(--muted); margin-top: -10px; margin-bottom: 14px; }

.btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; background: var(--primary); color: #fff; border: none; border-radius: 8px; font-family: 'DM Sans', sans-serif; font-size: 14px; font-weight: 500; cursor: pointer; transition: background 0.2s; text-decoration: none; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary:disabled:hover { background: var(--primary); }
.btn-secundario { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; background: var(--white); color: var(--text); border: 1.5px solid var(--border); border-radius: 8px; font-family: 'DM Sans', sans-serif; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s; text-decoration: none; }
.btn-secundario:hover { border-color: var(--primary); color: var(--primary); }

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 300;
  background: rgba(26,26,46,0.45);
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.aberto { display: flex; }
.modal-box {
  background: var(--white); border-radius: 12px;
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-head {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--white);
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close {
  border: none; background: none; cursor: pointer; color: var(--muted);
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: 7px; transition: all 0.15s; font-size: 18px; line-height: 1;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 22px; }

/* ===== LOGIN ===== */
.login-page { display: flex; min-height: 100vh; }
.login-left { flex: 1; background: var(--primary); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 48px; position: relative; overflow: hidden; }
.login-left::before { content: ''; position: absolute; width: 420px; height: 420px; border-radius: 50%; border: 64px solid rgba(255,255,255,0.06); top: -120px; left: -120px; }
.login-left::after { content: ''; position: absolute; width: 320px; height: 320px; border-radius: 50%; border: 48px solid rgba(255,255,255,0.05); bottom: -80px; right: -80px; }
.login-left-content { position: relative; z-index: 1; text-align: center; color: #fff; }
.login-left-content img { width: 72px; margin-bottom: 28px; filter: brightness(0) invert(1); }
.login-left-content h2 { font-size: 24px; font-weight: 600; margin-bottom: 10px; }
.login-left-content p { font-size: 14px; opacity: 0.72; line-height: 1.65; }
.login-right { flex: 1; display: flex; align-items: center; justify-content: center; background: #fff; padding: 60px; }
.login-box { width: 100%; max-width: 360px; }
.login-box h1 { font-size: 24px; font-weight: 600; margin-bottom: 4px; }
.login-subtitle { color: var(--muted); font-size: 14px; margin-bottom: 32px; }
.login-footer { text-align: center; margin-top: 32px; font-size: 12px; color: var(--muted); }
.login-links { display: flex; justify-content: space-between; margin-top: -8px; margin-bottom: 20px; font-size: 12.5px; }
.login-links a { color: var(--muted); text-decoration: none; }
.login-links a:hover { color: var(--primary); }

@media (max-width: 768px) {
  .login-left { display: none; }
}
