/* ============================================================
   results.css — Shell de resultados, cards, footer, modal, a11y
   ============================================================ */

/* ─── Shell ───────────────────────────────────────────────── */
.results {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  container-type: inline-size;
  container-name: results;
  background: var(--bg-results);
  min-height: 0;
}

/* ─── Header ──────────────────────────────────────────────── */
.results-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 var(--spacing-md);
  flex-shrink: 0;
  position: absolute;
  top: 0;
  width: 100%;
  border-bottom: 1px solid var(--border);
  background: var(--bg-header);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  z-index:1;
}
.results-header h1 { font-size: calc(15px * var(--font-scale, 1)); font-weight: 700; color: var(--text); }

.rh-counts {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}
.rh-cnt-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.rh-counts .facet-cnt {
  display: inline-flex;
  align-items: center;
  font-size: calc(14px * var(--font-scale, 1));
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  gap: 5px;
}
.rh-counts .facet-cnt svg { width: 14px; height: 14px; flex-shrink: 0; }

.rh-actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

/* Dropdown menus do header */
.dl-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 140px;
  padding: 4px;
  display: none;
}
.dl-menu.open { display: block; }
.dl-menu-bottom { top: auto; bottom: calc(100% + 4px); }

.dl-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 3px;
  font-size: calc(12px * var(--font-scale, 1));
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background .1s;
}
.dl-item:hover  { background: var(--primary-3); color: var(--primary); border-radius: var(--radius-sm); }
.dl-badge       { font-size: calc(11px * var(--font-scale, 1)); color: var(--text-light); }

/* ─── Results list ────────────────────────────────────────── */
.results-list {
  flex: 1;
  overflow-y: auto;
  padding: calc(52px + var(--spacing-md)) calc(var(--spacing-md) - 5px) calc(52px + var(--spacing-md)) var(--spacing-md);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  height: 100%;
  scrollbar-gutter:stable;
}
.results-list:has(.view-code--json),
.results-list:has(.view-code--xml),
.results-list:has(.view-code--csv),
.results-list:has(.view-table-wrap) { padding: 0; }

/* ─── Proc card ───────────────────────────────────────────── */
.proc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow:hidden;
  flex-shrink: 0;
}
.proc-header { padding: 12px 14px 10px; }

.proc-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.proc-id {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: calc(13px * var(--font-scale, 1));
  font-weight: 600;
  color: var(--primary);
}
.proc-id svg { flex-shrink: 0; }

.proc-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.badge { font-size: calc(11px * var(--font-scale, 1)); font-weight: 600; padding: 2px 8px; border-radius: var(--radius-sm); }
.badge-juntado { background: #e0f2fe; color: #0369a1; }
.badge-tipo    { background: #fff7ed; color: #c2410c; }
.badge-val     { background: #f8fafc; color: #475569; border: 1px solid var(--border); }

.badge-em-análise,
.badge-em-an-lise { background: #fef9c3; color: #92400e; }
.badge-arquivado  { background: #f1f5f9; color: var(--text-light); }
.badge-julgado    { background: #f5f3ff; color: #6d28d9; }
.badge-doc-tipo   { background: #fdf4ff; color: #a21caf; }
.badge-grp        { background: #f5f3ff; color: #7c3aed; }
.badge-sit        { background: #fef3c7; color: #92400e; }
.badge-sub        { background: #fff1f2; color: #be123c; }

.proc-contrib {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-size: calc(12px * var(--font-scale, 1));
  color: var(--text-light);
  margin-bottom: 5px;
}
.proc-contrib strong { color: var(--text); font-weight: 600; }
.sep { color: #d1d5db; }

.proc-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.proc-meta-item { display: flex; align-items: center; gap: 4px; font-size: calc(11px * var(--font-scale, 1)); color: var(--text-light); }

/* Snippet de highlight */
.proc-snippet {
  font-size: calc(11px * var(--font-scale, 1));
  color: var(--text-light);
  line-height: 1.5;
  padding: 6px 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-top: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}
.proc-snippet mark { background: #fef9c3; color: #78350f; border-radius: 2px; padding: 0 2px; }

/* ─── Docs toggle ─────────────────────────────────────────── */
.docs-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border: none;
  border-top: 1px solid #f1f5f9;
  background: var(--primary-2);
  border-radius:0;
  cursor: pointer;
  font-family: inherit;
  font-size: calc(12px * var(--font-scale, 1));
  color: var(--text-light);
  transition: background .15s;
}
.docs-toggle:hover { background: var(--primary-3); }
.docs-toggle:active {transform:scale(1);background: var(--primary-4);}
.docs-toggle-left  { display: flex; align-items: center; gap: 6px; }

.chevron-icon { width: 14px; height: 14px; transition: transform .2s; }
.docs-toggle.open .chevron-icon { transform: rotate(180deg); }

.docs-list      { display: none; }
.docs-list.open { display: flex;
    padding: var(--spacing-sm);
    gap: var(--spacing-sm);
    flex-direction: column;
  background:var(--primary-2) }

/* ─── Doc row ─────────────────────────────────────────────── */
.doc-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* gap: 10px; */
  border: 1px solid var(--border);
  transition: background .1s;
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
  background:var(--lightest);
}
.doc-row:hover { z-index:1;box-shadow:var(--shadow-md-flat) }

.doc-card { border-radius: var(--radius);overflow:hidden;flex-shrink:0; }

.dc-body { padding: 10px 14px; width: 100%; }
.dc-top  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.dc-title { font-size: calc(12px * var(--font-scale, 1)); font-weight: 600; color: var(--text); flex: 1; min-width: 0; }
.dc-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.dc-sec { margin-top: 6px; }
.dc-mtags { display: flex; flex-wrap: wrap; gap: 6px; }
.dc-mtag  { display: flex; align-items: center; gap: 3px; font-size: calc(11px * var(--font-scale, 1)); color: var(--text-light); }

.dc-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 12px; }
.dc-f      { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dc-f-lbl  { font-size: calc(9px * var(--font-scale, 1)); font-weight: 800; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.3px; }
.dc-f-val  { font-size: calc(12px * var(--font-scale, 1)); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.dc-proc { padding: 8px 14px; background: var(--primary-2); border-bottom: 1px solid var(--border); width: 100%; }
.dc-proc-id {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: calc(12px * var(--font-scale, 1));
  font-weight: 600;
  color: var(--primary);
}
.dc-proc-contrib { display: flex; align-items: center; gap: 4px; font-size: calc(12px * var(--font-scale, 1)); color: var(--text-light); }
.dc-proc-badges  { display: flex; flex-wrap: wrap; gap: 5px; }

.score      { font-size: calc(12px * var(--font-scale, 1)); font-weight: 700; color: var(--text-light); min-width: 30px; text-align: right; }
.score.high { color: #16a34a; }
.score.med  { color: #d97706; }

.doc-open-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: calc(11px * var(--font-scale, 1));
  font-weight: 600;
  color: var(--text-light);
  text-decoration: none;
  transition: background .15s;
}
.doc-open-btn svg { width: 11px; height: 11px; }
.doc-open-btn:hover { background: var(--primary-3); color: var(--primary); }

/* ─── Section title ───────────────────────────────────────── */
.section-title {
  font-size: calc(12px * var(--font-scale, 1));
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ─── Footer ──────────────────────────────────────────────── */
.results-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  flex-wrap: wrap;
  padding: 0 var(--spacing-md);
  height: var(--header-height);
  position: absolute;
  width: 100%;
  bottom: 0;
  border-top: 1px solid var(--border);
  background: var(--bg-header);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
}

.rf-info    { display: flex; flex-direction: column; gap: 2px; }
.rf-page    { font-size: calc(11px * var(--font-scale, 1)); color: var(--text-hint); }
.rf-showing { font-size: calc(12px * var(--font-scale, 1)); color: var(--text-light); }
.rf-right   { display: flex; align-items: center; gap: var(--spacing-lg); }

/* ─── Paginação ───────────────────────────────────────────── */
.pagination { display: flex; align-items: center; }

.pg-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border-radius: 0;
  background: rgba(255,255,255,.75);
  font-size: calc(12px * var(--font-scale, 1));
  font-weight: 600;
  color: var(--text);
  line-height: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, border-color .15s, color .15s;
}
.pg-btn + .pg-btn { border-right: 1px solid var(--surface); }

.pagination .pg-btn:first-of-type  { margin-right: 8px; border-radius: var(--radius-full); }
.pagination .pg-btn:last-of-type   { margin-left: 8px;  border-radius: var(--radius-full); }
.pagination .pg-btn:nth-of-type(2) { border-radius: var(--radius) 0 0 var(--radius); }
.pagination .pg-btn:nth-last-of-type(2) { border-radius: 0 var(--radius) var(--radius) 0; }

.pg-btn:hover    { background: var(--primary-3); }
.pg-btn.active   { background: var(--primary); border-color: var(--primary); color: #fff; }
.pg-btn.disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
.pg-btn svg      { width: 13px; height: 13px; }

.pg-ellipsis { font-size: calc(24px * var(--font-scale, 1)); color: var(--text-hint); padding: 0 4px; line-height: 10px; }

.rh-per-page { display: flex; align-items: center; gap: 6px; font-size: calc(12px * var(--font-scale, 1)); color: var(--text-light); }

/* ─── Cursor limit ────────────────────────────────────────── */
.cursor-limit-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  font-size: calc(12px * var(--font-scale, 1));
  color: #92400e;
  margin-top: 4px;
}
.cursor-limit-msg svg    { flex-shrink: 0; color: #d97706; }
.cursor-limit-msg strong { font-weight: 700; }
.cursor-limit-btn {
  margin-left: auto;
  height: 28px;
  padding: 0 12px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  color: #92400e;
  font-size: calc(11px * var(--font-scale, 1));
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
  white-space: nowrap;
}
.cursor-limit-btn:hover { background: #fde68a; }

/* ─── Modal distribuição ──────────────────────────────────── */
.modal-overlay       { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.35); display: none; align-items: center; justify-content: center; }
.modal-overlay.open  { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 960px;
  max-width: 95vw;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: calc(14px * var(--font-scale, 1)); font-weight: 700; color: var(--text); }
.modal-close {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  cursor: pointer;
  font-size: calc(18px * var(--font-scale, 1));
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--primary-3); }
.modal-body { padding: 18px; overflow-y: auto; }
.dist-empty { color: var(--text-light); text-align: center; padding: 24px; margin: 0; }

.dist-section-title {
  font-size: calc(11px * var(--font-scale, 1));
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.dist-bar-row   { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.dist-bar-label { font-size: calc(12px * var(--font-scale, 1)); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.dist-bar-wrap  { flex: 1; background: var(--primary-3); border-radius: var(--radius-sm); height: 7px; overflow: hidden; }
.dist-bar-fill  { height: 100%; border-radius: var(--radius-sm); background: var(--primary); }
.dist-bar-fill.teal { background: #0f6e56; }
.dist-bar-counts { display: flex; gap: 4px; flex-shrink: 0; }
.dist-cnt   { font-size: calc(10px * var(--font-scale, 1)); font-weight: 600; padding: 1px 5px; border-radius: var(--radius-sm); }
.dist-cnt-p { background: var(--primary-4); color: var(--primary); }
.dist-cnt-d { background: #f0fdf4; color: #15803d; }

/* ─── A11y menu ───────────────────────────────────────────── */
.a11y-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  max-height: min(80vh, 560px);
  overflow-y: auto;
  padding: 4px;
  display: none;
}
.a11y-menu.open { display: block; }

.a11y-section-title {
  font-size: calc(10px * var(--font-scale, 1));
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 10px 3px;
}
.a11y-divider { height: 1px; background: var(--border); margin: 4px 0; }

.a11y-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  font-size: calc(12px * var(--font-scale, 1));
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: background .1s;
  width: 100%;
  text-align: left;
  height: auto;
  gap: 2px;
}
.a11y-item:hover  { background: var(--primary-3); color: var(--primary); border-radius: var(--radius-sm); }
.a11y-item.active { color: var(--primary); }
.a11y-item.active::after { content: "✓"; font-size: calc(11px * var(--font-scale, 1)); }

.a11y-font-scale { display: flex; gap: 3px; padding: 4px 6px 6px; }
.a11y-font-btn {
  flex: 1;
  justify-content: center;
  padding: 5px 2px !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  font-size: calc(11px * var(--font-scale, 1)) !important;
}
.a11y-font-btn:hover  { background: var(--primary-3) !important; color: var(--primary) !important; }
.a11y-font-btn.active { background: var(--primary) !important; color: #fff !important; border-color: var(--primary) !important; }
.dc-all-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px 16px;
  margin-top: 6px;
}

/* dc-mtag e dc-f ficam inline sem separação por seção */
.dc-all-fields .dc-mtag { font-size: calc(11px * var(--font-scale, 1)); }

.proc-id    { white-space: nowrap; flex-shrink: 0; }
.proc-contrib { flex-wrap: nowrap; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-snippet {
  font-size: calc(11px * var(--font-scale, 1));
  color: var(--text-light);
  line-height: 1.5;
  padding: 6px 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-top: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}
.doc-snippet mark { background: #fef9c3; color: #78350f; border-radius: 2px; padding: 0 2px; }
