/* =============================================================
   consultas.css — estilo compartilhado das telas de Consulta
   (NCM, Bancos, Feriados, FIPE). Paleta e contraste seguindo a
   skill padrao-telas-protheus (pares texto/fundo medidos >= 4,5:1;
   bordas de campo >= 3:1; vermelho só em erro).
   ============================================================= */

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

:root {
  --azul:     #1a6fd4;
  --azul-dk:  #0f4fa0;
  --azul-lt:  #e8f1fc;
  --azul-mid: #2d7fe3;
  --verde:    #0d7a56;
  --verde-lt: #e6f7f2;
  --red:      #c0392b;
  --red-lt:   #fdeaea;
  --amber:    #b45309;
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-400: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --borda-campo: #7794B8;
  --radius:   14px;
  --shadow:   0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg:0 8px 32px rgba(0,0,0,.10);
}

body {
  background: var(--gray-50);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--gray-900);
  min-height: 100vh;
}

/* ── TOPBAR ── */
.topbar {
  background: #fff; border-bottom: 1px solid var(--gray-200);
  padding: 0 1.5rem; min-height: 56px;
  display: flex; align-items: center; gap: 10px;
  position: sticky; top: 0; z-index: 100; flex-wrap: wrap;
}
.topbar-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--azul) 0%, var(--azul-mid) 100%);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px;
}
.topbar-title { font-size: 15px; font-weight: 600; color: var(--gray-900); }
.topbar-sub   { font-size: 12px; color: var(--gray-400); margin-left: 2px; }
.topbar-nav   { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.topbar-nav a {
  font-size: .8rem; font-weight: 600; color: var(--gray-600);
  text-decoration: none; padding: 6px 12px; border-radius: 8px;
  transition: background .15s, color .15s;
}
.topbar-nav a:hover { background: var(--gray-100); color: var(--gray-900); }
.topbar-nav a.ativo { background: var(--azul-lt); color: var(--azul-dk); }
.topbar-nav a:focus-visible { outline: 2px solid var(--azul); outline-offset: 2px; }

/* ── LAYOUT ── */
.page { max-width: 880px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }

/* ── SEARCH HERO ── */
.search-hero {
  background: linear-gradient(135deg, var(--azul-dk) 0%, var(--azul) 100%);
  border-radius: var(--radius); padding: 2rem 2rem 1.75rem;
  margin-bottom: 1.75rem; box-shadow: var(--shadow-lg);
  position: relative; overflow: hidden;
}
.search-hero::before {
  content: ''; position: absolute; top: -40px; right: -40px;
  width: 200px; height: 200px; background: rgba(255,255,255,.05); border-radius: 50%;
}
.search-hero h2 { font-size: 1.2rem; font-weight: 700; color: #fff; margin-bottom: .25rem; }
.search-hero p  { font-size: .82rem; color: #fff; margin-bottom: 1.25rem; opacity: .96; }
.search-row { display: flex; gap: 10px; position: relative; z-index: 1; }
.search-input {
  flex: 1; height: 48px; border: none; border-radius: 10px; padding: 0 16px;
  font-size: 1rem; background: #fff; color: var(--gray-900); outline: none;
  box-shadow: 0 2px 8px rgba(0,0,0,.15); transition: box-shadow .2s;
}
.search-input.mono { font-family: 'Courier New', monospace; letter-spacing: .03em; }
.search-input:focus { box-shadow: 0 0 0 3px rgba(255,255,255,.55), 0 2px 8px rgba(0,0,0,.15); }
.btn-buscar {
  height: 48px; padding: 0 22px; background: #fff; color: var(--azul-dk);
  border: none; border-radius: 10px; font-size: .9rem; font-weight: 700;
  cursor: pointer; white-space: nowrap; display: flex; align-items: center; gap: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15); transition: transform .1s, box-shadow .1s;
}
.btn-buscar:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.btn-buscar:active:not(:disabled) { transform: translateY(0); }
.btn-buscar:disabled { opacity: .6; cursor: not-allowed; }
.btn-buscar:focus-visible { outline: 3px solid rgba(255,255,255,.7); outline-offset: 2px; }
.spin {
  width: 16px; height: 16px; border: 2px solid rgba(26,111,212,.3);
  border-top-color: var(--azul); border-radius: 50%;
  animation: rot .7s linear infinite; display: none;
}
@keyframes rot { to { transform: rotate(360deg); } }

.dica-hero { font-size: .74rem; color: #fff; margin-top: .75rem; position: relative; z-index: 1; }

.error-msg {
  margin-top: 1rem; padding: 10px 14px; background: rgba(0,0,0,.30);
  border: 1px solid rgba(255,255,255,.45); border-radius: 8px; color: #fff;
  font-size: .85rem; display: none;
}

/* ── COMBOS (FIPE) ── */
.filtro-card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.25rem; margin-bottom: 1.25rem;
}
.filtro-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 1rem; }
.filtro-item { display: flex; flex-direction: column; gap: 5px; }
.filtro-item label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-600); font-weight: 700; }
select {
  border: 1.5px solid var(--borda-campo); border-radius: 10px; padding: 12px 15px;
  font-size: .92rem; color: var(--gray-900); background: #fff; outline: none; width: 100%;
  transition: border-color .18s, box-shadow .18s; cursor: pointer;
}
select:hover:not(:disabled) { border-color: #5C7EA6; }
select:focus { border-color: #0066CC; border-width: 2px; padding: 11.5px 14.5px; box-shadow: 0 0 0 3px rgba(0,102,204,.16); }
select:disabled { background: var(--gray-100); color: var(--gray-400); cursor: not-allowed; }

/* ── CARDS ── */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1rem; overflow: hidden; }
.card-header { display: flex; align-items: center; gap: 10px; padding: .9rem 1.25rem; border-bottom: 1px solid var(--gray-100); }
.card-header-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; background: var(--azul-lt); }
.card-header-title { font-size: .85rem; font-weight: 700; color: var(--gray-700); text-transform: uppercase; letter-spacing: .06em; }
.card-body { padding: 1.25rem; }

/* ── STATS / FIELDS / BADGES ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat-card { background: #fff; border-radius: 12px; padding: 1rem 1.1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--gray-400); font-weight: 700; }
.stat-value { font-size: 1.05rem; font-weight: 700; color: var(--gray-900); }
.stat-value.big { font-size: 1.5rem; color: var(--verde); }

.fields-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px,1fr)); gap: 1rem; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--gray-400); font-weight: 700; }
.field-value { font-size: .92rem; color: var(--gray-900); word-break: break-word; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .75rem; font-weight: 700; }
.badge-ok  { background: var(--verde-lt); color: var(--verde); }
.badge-bad { background: var(--red-lt);   color: var(--red); }
.badge-blue{ background: var(--azul-lt);  color: var(--azul-dk); }
.badge-gray{ background: var(--gray-100); color: var(--gray-600); }
.badge-amber{ background: #fef3c7; color: var(--amber); }

/* ── LISTA DE RESULTADOS (NCM, Bancos) ── */
.res-list { display: flex; flex-direction: column; }
.res-row {
  display: flex; align-items: flex-start; gap: .85rem;
  padding: .8rem .5rem; border-bottom: 1px solid var(--gray-100);
}
.res-row:last-child { border-bottom: none; }
.res-cod {
  font-family: 'Courier New', monospace; font-size: .82rem; font-weight: 700;
  color: var(--azul-dk); background: var(--azul-lt); border-radius: 6px;
  padding: 4px 9px; white-space: nowrap; flex-shrink: 0; min-width: 62px; text-align: center;
}
.res-info { flex: 1; min-width: 0; }
.res-desc { font-size: .9rem; color: var(--gray-900); line-height: 1.35; }
.res-sub  { font-size: .74rem; color: var(--gray-400); margin-top: 3px; }
.res-count { margin-left: auto; }

/* ── TABELA (Feriados) ── */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--gray-400); font-weight: 700; padding: .55rem .8rem; text-align: left;
  border-bottom: 1px solid var(--gray-100);
}
.tbl td { font-size: .88rem; padding: .65rem .8rem; border-bottom: 1px solid var(--gray-100); color: var(--gray-700); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--gray-50); }
.tbl .data { font-weight: 700; color: var(--gray-900); white-space: nowrap; }
.tbl .dow  { color: var(--gray-600); }

/* ── UTIL / JSON ── */
.util-bar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.btn-util {
  height: 34px; padding: 0 14px; background: #fff; border: 1px solid var(--gray-200);
  border-radius: 8px; font-size: .82rem; color: var(--gray-700); cursor: pointer;
  display: flex; align-items: center; gap: 6px; box-shadow: 0 1px 2px rgba(0,0,0,.05);
  transition: background .15s, border-color .15s;
}
.btn-util:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-util:focus-visible { outline: 2px solid var(--azul); outline-offset: 1px; }
.json-box {
  background: #0f172a; color: #cbd5e1; border-radius: 10px; padding: 1rem;
  font-family: 'Courier New', monospace; font-size: .75rem; max-height: 320px;
  overflow-y: auto; white-space: pre-wrap; word-break: break-all; display: none; margin-bottom: 1rem;
}

/* ── EXEMPLO DE USO DA API (botão + modal) ── */
.howto-bar { display: flex; justify-content: center; margin-bottom: 1.5rem; }
.btn-exemplo {
  background: #fff; border: 1px solid var(--gray-200); border-radius: 10px;
  padding: 8px 16px; font-size: .82rem; font-weight: 600; color: var(--azul-dk);
  cursor: pointer; display: flex; align-items: center; gap: 6px; box-shadow: 0 1px 2px rgba(0,0,0,.05);
  transition: background .15s, border-color .15s;
}
.btn-exemplo:hover { background: var(--azul-lt); border-color: var(--azul); }
.btn-exemplo:focus-visible { outline: 2px solid var(--azul); outline-offset: 1px; }
.modal-overlay { display: none; position: fixed; inset: 0; z-index: 1000; background: rgba(15,23,42,.55); align-items: center; justify-content: center; padding: 1.5rem; }
.modal-overlay.aberto { display: flex; }
.modal-box { background: #fff; border-radius: var(--radius); max-width: 640px; width: 100%; max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--gray-100); position: sticky; top: 0; background: #fff; border-radius: var(--radius) var(--radius) 0 0; }
.modal-header h3 { font-size: .95rem; font-weight: 700; color: var(--gray-900); }
.modal-close { background: var(--gray-100); border: none; border-radius: 8px; width: 28px; height: 28px; cursor: pointer; font-size: .85rem; color: var(--gray-600); }
.modal-close:hover { background: var(--gray-200); }
.modal-close:focus-visible { outline: 2px solid var(--azul); outline-offset: 1px; }
.modal-body { padding: 1.1rem 1.25rem 1.5rem; }
.modal-body p { font-size: .85rem; color: var(--gray-700); line-height: 1.5; margin-bottom: .5rem; }
.modal-body h4 { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-400); font-weight: 700; margin: 1rem 0 .4rem; }
.modal-body h4:first-child { margin-top: 0; }
.code-block { background: #0f172a; color: #cbd5e1; border-radius: 10px; padding: .85rem 1rem; font-family: 'Courier New', monospace; font-size: .76rem; white-space: pre-wrap; word-break: break-all; line-height: 1.5; }

/* ── RESPONSIVO / MOTION ── */
@media (max-width: 600px) {
  .page { padding: 1rem .75rem 3rem; }
  .search-hero { padding: 1.4rem 1.1rem 1.25rem; }
  .search-row { flex-direction: column; }
  .btn-buscar { width: 100%; justify-content: center; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .fields-grid { grid-template-columns: 1fr; }
  .filtro-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .spin { animation: none; }
  .btn-buscar { transition: none; }
}
