/* ============================================================
   detalhe.css — página de Detalhes da Licitação (redesign)
   Complementa modern.css (tema) — não duplicar variáveis globais.
   ============================================================ */

body.pagina-detalhe {
  background: var(--background-main, #f1f5f9);
  padding-bottom: 90px; /* espaço para a barra de salvar */
}

/* ── Hero ──────────────────────────────────────────────────── */
.det-hero {
  background: linear-gradient(135deg, #0f2732 0%, var(--tinta, #14333e) 60%, var(--tinta-clara, #1e4a5a) 100%);
  color: #fff;
  padding: 1.25rem 0 1.5rem;
}
.det-hero .hero-top {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}
.det-hero .hero-pncp {
  font-size: .78rem;
  color: #94a3b8;
  letter-spacing: .4px;
}
.det-hero .hero-orgao {
  font-size: .85rem;
  color: #cbd5e1;
}
.det-hero .hero-objeto {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.45;
  color: #f8fafc;
  margin: .35rem 0 .9rem;
}
.det-hero .hero-meta {
  display: flex;
  align-items: stretch;
  gap: .75rem;
  flex-wrap: wrap;
}
.hero-stat {
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 10px;
  padding: .5rem .9rem;
  min-width: 140px;
}
.hero-stat .stat-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: #94a3b8;
  margin-bottom: .1rem;
}
.hero-stat .stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}
/* Countdown de prazo — cores de urgência */
.hero-stat.countdown-danger  { background: rgba(239, 68, 68, .2);  border-color: rgba(239, 68, 68, .55); }
.hero-stat.countdown-danger .stat-value  { color: #fca5a5; }
.hero-stat.countdown-warning { background: rgba(245, 158, 11, .18); border-color: rgba(245, 158, 11, .5); }
.hero-stat.countdown-warning .stat-value { color: #fcd34d; }
.hero-stat.countdown-ok      { background: rgba(34, 197, 94, .15);  border-color: rgba(34, 197, 94, .45); }
.hero-stat.countdown-ok .stat-value      { color: #86efac; }
.hero-stat.countdown-closed  { background: rgba(148, 163, 184, .15); border-color: rgba(148, 163, 184, .35); }
.hero-stat.countdown-closed .stat-value  { color: #cbd5e1; }

/* Badge de status grande com dropdown */
#status-dropdown-btn.badge {
  font-size: .9rem;
  padding: .5rem .9rem;
  cursor: pointer;
  border: none;
}
#status-dropdown-btn .bi-chevron-down { font-size: .7rem; }

.hero-badges .badge {
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .15);
  color: #e2e8f0;
  font-weight: 500;
}

/* ── Stepper de fases ──────────────────────────────────────── */
.fases-stepper {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.25rem 1rem 1rem;
  margin-top: -1.25rem; /* sobrepõe levemente o hero */
  box-shadow: 0 4px 12px rgba(15, 23, 42, .06);
  position: relative;
  z-index: 2;
}
.stepper-track {
  display: flex;
  align-items: flex-start;
}
.stepper-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  cursor: pointer;
  user-select: none;
}
.stepper-step .step-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  background: #fff;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  transition: all .18s ease;
  position: relative;
  z-index: 2;
}
.stepper-step:hover .step-circle {
  border-color: #3b82f6;
  color: #3b82f6;
  transform: scale(1.06);
}
.stepper-step.done .step-circle {
  background: var(--selo, #1b7a43);
  border-color: var(--selo, #1b7a43);
  color: #fff;
}
/* linha conectora */
.stepper-step::before,
.stepper-step::after {
  content: '';
  position: absolute;
  top: 21px;
  height: 2px;
  background: #e2e8f0;
  width: 50%;
  z-index: 1;
}
.stepper-step::before { left: 0; }
.stepper-step::after  { right: 0; }
.stepper-step:first-child::before,
.stepper-step:last-child::after { display: none; }
.stepper-step.done::before { background: var(--selo, #1b7a43); }
.stepper-step.done + .stepper-step::before { background: var(--selo, #1b7a43); }

.stepper-step .step-label {
  font-size: .78rem;
  font-weight: 600;
  color: #475569;
  margin-top: .5rem;
}
.stepper-step.done .step-label { color: var(--selo, #1b7a43); }
.stepper-step .step-date {
  font-size: .7rem;
  color: #94a3b8;
  min-height: 1rem;
}
.stepper-step .step-date-input {
  font-size: .7rem;
  width: 128px;
  margin-top: .15rem;
  padding: .05rem .3rem;
}

/* ── Cards ─────────────────────────────────────────────────── */
.det-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin-bottom: 1rem;
  overflow: hidden;
}
.det-card-header {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: .6rem 1rem;
  font-weight: 600;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: #475569;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.det-card-body { padding: 1rem; }

.field-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: #94a3b8;
  margin-bottom: .15rem;
}
.field-value {
  font-size: .88rem;
  color: #1e293b;
  word-break: break-word;
}
.field-value.text-block {
  white-space: pre-line;
  max-height: 200px;
  overflow-y: auto;
}

/* ── Sidebar sticky ────────────────────────────────────────── */
.det-sidebar {
  position: sticky;
  top: 1rem;
}
.det-sidebar .accordion-button {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: #475569;
  padding: .65rem .9rem;
  background: #f8fafc;
}
.det-sidebar .accordion-button:not(.collapsed) {
  background: #eff6ff;
  color: #1d4ed8;
  box-shadow: none;
}
.det-sidebar .accordion-body { padding: .85rem .9rem; }
.det-sidebar .accordion-item { border-color: #e2e8f0; }

/* ── Análise IA / Chat ─────────────────────────────────────── */
.analise-pre {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: .82rem;
  background: #fafafa;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 1rem;
  max-height: 500px;
  overflow-y: auto;
}
.chat-mensagens {
  height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: .75rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.chat-bolha {
  max-width: 80%;
  padding: .5rem .75rem;
  border-radius: 12px;
  font-size: .85rem;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}
.chat-bolha.usuario { background: var(--protocolo, #0e5f7a); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-bolha.ia { background: #fff; color: #1e293b; border: 1px solid #e2e8f0; align-self: flex-start; border-bottom-left-radius: 4px; }
.chat-bolha.erro { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; align-self: flex-start; }
.chat-digitando {
  align-self: flex-start;
  padding: .4rem .75rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  color: #94a3b8;
  font-size: .78rem;
  font-style: italic;
}

/* ── Barra de salvar (dirty) ───────────────────────────────── */
.save-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1050;
  background: #0f2732;
  color: #fff;
  padding: .65rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  box-shadow: 0 -4px 16px rgba(15, 23, 42, .25);
  transform: translateY(110%);
  transition: transform .22s ease;
}
.save-bar.visible { transform: translateY(0); }
.save-bar .save-msg { font-size: .85rem; color: #cbd5e1; }

/* ── Toasts ────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 9999;
}

/* ── Botões de decisão (Participar / Descartar) ────────────── */
.btn-decisao {
  font-weight: 600;
  padding: .5rem 1.4rem;
  border-radius: var(--radius-md, 8px);
  border: 2px solid transparent;
  min-height: 44px;
}
.btn-decisao-participar {
  background: var(--selo, #1b7a43);
  color: #fff;
}
.btn-decisao-participar:hover { background: #15683a; color: #fff; }
.btn-decisao-participar.ativo { box-shadow: 0 0 0 3px rgba(27, 122, 67, .35); }
.btn-decisao-descartar {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, .5);
}
.btn-decisao-descartar:hover { background: var(--carimbo, #b42318); border-color: var(--carimbo, #b42318); color: #fff; }
.btn-decisao-descartar.ativo { background: var(--carimbo, #b42318); border-color: var(--carimbo, #b42318); }
.btn-decisao-proposta {
  background: #fff;
  color: var(--tinta, #14333e);
  border-color: #fff;
}
.btn-decisao-proposta:hover { background: #eaf3f5; color: var(--tinta, #14333e); border-color: #eaf3f5; }

/* ── Painel Go/No-Go ───────────────────────────────────────── */
.gonogo-panel {
  background: #fff;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-lg, 12px);
  padding: 1rem;
  margin-top: -1.25rem;
  box-shadow: 0 4px 12px rgba(15, 23, 42, .06);
  position: relative;
  z-index: 2;
}
.gonogo-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
}
.gonogo-tile {
  background: var(--papel, #f6f4ef);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-md, 8px);
  padding: .6rem .8rem;
  min-width: 0;
}
.gonogo-tile .tile-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--grafite-2, #5c6670);
  margin-bottom: .15rem;
}
.gonogo-tile .tile-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--tinta, #14333e);
  line-height: 1.15;
  word-break: break-word;
}
.gonogo-tile .tile-value-sm { font-size: .95rem; line-height: 1.3; }
.gonogo-tile .tile-sub { font-size: .72rem; color: var(--grafite-2, #5c6670); margin-top: .1rem; }
.gonogo-tile .tile-detalhe { margin-top: .3rem; font-size: .72rem; }
.gonogo-tile .tile-detalhe summary { cursor: pointer; color: var(--protocolo, #0e5f7a); }
.gonogo-tile .tile-detalhe ul { margin-top: .25rem; }
/* Countdown de prazo — cores de urgência (aplicadas ao tile) */
.gonogo-tile.countdown-danger  { background: var(--carimbo-bg, #fbe9e7); border-color: var(--carimbo, #b42318); }
.gonogo-tile.countdown-danger .tile-value  { color: var(--carimbo, #b42318); }
.gonogo-tile.countdown-warning { background: var(--lacre-bg, #fdf0d5); border-color: var(--lacre, #9a5b00); }
.gonogo-tile.countdown-warning .tile-value { color: var(--lacre, #9a5b00); }
.gonogo-tile.countdown-ok      { background: var(--selo-bg, #e3f2e8); border-color: var(--selo, #1b7a43); }
.gonogo-tile.countdown-ok .tile-value      { color: var(--selo, #1b7a43); }
.gonogo-tile.countdown-closed  { background: var(--arquivo-bg, #f1f0ec); border-color: var(--arquivo, #6b7280); }
.gonogo-tile.countdown-closed .tile-value  { color: var(--arquivo, #6b7280); font-size: .95rem; }

.gonogo-veredito {
  margin-top: .75rem;
  padding: .5rem .8rem;
  border-radius: var(--radius-md, 8px);
  font-size: .85rem;
  font-weight: 500;
}
.gonogo-veredito.veredito-bom    { background: var(--selo-bg, #e3f2e8); color: var(--selo, #1b7a43); }
.gonogo-veredito.veredito-alerta { background: var(--lacre-bg, #fdf0d5); color: var(--lacre, #9a5b00); }
.gonogo-veredito.veredito-neutro { background: var(--arquivo-bg, #f1f0ec); color: var(--grafite-2, #5c6670); }

/* ── Navegação em abas ─────────────────────────────────────── */
.det-tabs {
  display: flex;
  gap: .25rem;
  margin: 1.25rem 0 1rem;
  border-bottom: 2px solid var(--border-color, #e2e8f0);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.det-tabs::-webkit-scrollbar { display: none; }
.det-tab {
  flex-shrink: 0;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: .6rem 1rem;
  font-size: .85rem;
  font-weight: 600;
  color: var(--grafite-2, #5c6670);
  white-space: nowrap;
  margin-bottom: -2px;
  cursor: pointer;
}
.det-tab:hover { color: var(--tinta, #14333e); }
.det-tab.active {
  color: var(--protocolo, #0e5f7a);
  border-bottom-color: var(--protocolo, #0e5f7a);
}
.det-tab-pane { display: none; }
.det-tab-pane.active { display: block; animation: cardArrive .2s ease; }

/* ── Tabela de preços por item ─────────────────────────────── */
.tabela-precos .inp-preco-num { width: 100px; text-align: right; }
.badge-margem {
  display: inline-block;
  font-size: .8rem;
  font-weight: 600;
  padding: .1rem .4rem;
  border-radius: var(--radius-sm, 4px);
}
.badge-margem.margem-negativa { background: var(--carimbo-bg, #fbe9e7); color: var(--carimbo, #b42318); }
.badge-margem.margem-baixa    { background: var(--lacre-bg, #fdf0d5); color: var(--lacre, #9a5b00); }
.badge-margem.margem-ok       { background: var(--selo-bg, #e3f2e8); color: var(--selo, #1b7a43); }

.precos-resumo {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .5rem;
  margin-bottom: 1rem;
}
.precos-resumo-tile {
  background: var(--papel, #f6f4ef);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-md, 8px);
  padding: .5rem .7rem;
}
.precos-resumo-tile .tile-label { font-size: .62rem; text-transform: uppercase; letter-spacing: .4px; color: var(--grafite-2, #5c6670); }
.precos-resumo-tile .tile-value { font-size: 1rem; font-weight: 700; color: var(--tinta, #14333e); }

/* Cards de item (mobile) */
.preco-card {
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-md, 8px);
  padding: .75rem;
  margin-bottom: .6rem;
  background: #fff;
}
.preco-card-resultado {
  background: var(--selo-bg, #e3f2e8);
  border-radius: var(--radius-sm, 4px);
  padding: .35rem .5rem;
}

/* ── Checklist / validade ──────────────────────────────────── */
.badge-validade {
  font-size: .68rem;
  font-weight: 600;
  padding: .12rem .45rem;
  border-radius: 999px;
}
.badge-validade.validade-vigente     { background: var(--selo-bg, #e3f2e8); color: var(--selo, #1b7a43); }
.badge-validade.validade-vencendo    { background: var(--lacre-bg, #fdf0d5); color: var(--lacre, #9a5b00); }
.badge-validade.validade-vencido     { background: var(--carimbo-bg, #fbe9e7); color: var(--carimbo, #b42318); }
.badge-validade.validade-sem_validade { background: var(--arquivo-bg, #f1f0ec); color: var(--grafite-2, #5c6670); }

.seg-status .btn { padding: .1rem .5rem; font-size: .72rem; }
.seg-status .btn.ativo { color: #fff; border-color: transparent; }
.seg-status .btn.status-pendente { background: var(--lacre, #9a5b00); }
.seg-status .btn.status-ok        { background: var(--selo, #1b7a43); }
.seg-status .btn.status-nao_aplicavel { background: var(--arquivo, #6b7280); }
.seg-status .btn.status-problema  { background: var(--carimbo, #b42318); }

/* ── Timeline ──────────────────────────────────────────────── */
.timeline { position: relative; padding-left: .5rem; }
.timeline-item {
  position: relative;
  padding-left: 2rem;
  padding-bottom: 1rem;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 24px;
  bottom: 0;
  width: 2px;
  background: var(--border-color, #e2e8f0);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  position: absolute;
  left: 0;
  top: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  color: #fff;
  background: var(--grafite-2, #5c6670);
}
.timeline-item.evt-status .timeline-dot    { background: var(--protocolo, #0e5f7a); }
.timeline-item.evt-nota .timeline-dot      { background: var(--lacre, #9a5b00); }
.timeline-item.evt-documento .timeline-dot { background: var(--selo, #1b7a43); }
.timeline-item.evt-proposta .timeline-dot  { background: var(--disputa, #4f46a5); }
.timeline-data { font-size: .72rem; margin-top: .15rem; }
.timeline-desc { color: var(--grafite-2, #5c6670); white-space: pre-line; }

/* ── Barra de decisão fixa (mobile) ────────────────────────── */
.decisao-bar-mobile {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1040;
  display: flex;
  gap: .5rem;
  padding: .6rem .75rem;
  padding-bottom: calc(.6rem + env(safe-area-inset-bottom, 0));
  background: var(--tinta, #14333e);
  box-shadow: 0 -4px 16px rgba(15, 23, 42, .25);
}
.decisao-bar-mobile .btn-decisao { min-height: 48px; }

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .det-sidebar { position: static; }
  .gonogo-tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 575.98px) {
  body.pagina-detalhe { padding-bottom: 84px; } /* espaço p/ barra de decisão fixa */
  .det-hero .hero-objeto { font-size: 1rem; }
  .gonogo-tiles { grid-template-columns: repeat(2, 1fr); }
  .gonogo-tile .tile-value { font-size: 1.05rem; }
  .precos-resumo { grid-template-columns: repeat(2, 1fr); }
  .stepper-step .step-label { font-size: .68rem; }
  .stepper-step .step-circle { width: 34px; height: 34px; }
  .stepper-step::before, .stepper-step::after { top: 17px; }
  .stepper-step .step-date-input { width: 110px; }
  .save-bar { flex-wrap: wrap; bottom: 68px; } /* acima da barra de decisão */
  .save-bar .save-msg { flex-basis: 100%; }
}
