/* Reset e base */
:root { 
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Arial, sans-serif;
  --primary-color: #0055cc;
  --secondary-color: #f7f7f7;
  --text-color: #222;
  --text-muted: #666;
  --text-light: #555;
  --border-color: #e0e0e0;
  --shadow: 0 2px 12px rgba(0,0,0,.06);
  --shadow-hover: 0 4px 20px rgba(0,0,0,.12);
  --badge-bg: #eef4ff;
  --badge-border: #cfe0ff;
}

/* Variáveis para modo dark */
[data-theme="dark"] {
  --primary-color: #4a9eff;
  --secondary-color: #1a1a1a;
  --text-color: #e0e0e0;
  --text-muted: #a0a0a0;
  --text-light: #b0b0b0;
  --border-color: #333;
  --shadow: 0 2px 12px rgba(0,0,0,.3);
  --shadow-hover: 0 4px 20px rgba(0,0,0,.5);
  --badge-bg: #1e3a5f;
  --badge-border: #2a4a6f;
}

/* Estilos do toggle de tema */
.theme-toggle-container {
  position: absolute;
  bottom: 16px;
  right: 24px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  background: transparent;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
  z-index: 1000;
}

.theme-toggle-label {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-right: 3px;
}

.theme-options {
  display: flex;
  gap: 3px;
}

.theme-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 2px 5px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.6rem;
  cursor: pointer;
  transition: all .2s ease;
  white-space: nowrap;
  opacity: 0.6;
}

.theme-option:hover {
  opacity: 1;
  border-color: var(--primary-color);
  background: var(--badge-bg);
}

.theme-option.active {
  opacity: 1;
  border-color: var(--primary-color);
  background: var(--primary-color);
  color: white;
  font-weight: 500;
}

.theme-option input[type="radio"] {
  display: none;
}

.theme-icon {
  font-size: 0.7rem;
}

* { box-sizing: border-box; }

body { 
  margin: 0; 
  color: var(--text-color); 
  background: var(--secondary-color);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Layout principal */
.container { 
  max-width: 980px; 
  margin: 0 auto; 
  padding: 20px 48px;
}

/* Header */
header {
  position: relative;
  text-align: center;
  margin-bottom: 48px;
  padding: 32px 0;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

[data-theme="dark"] header {
  background: #252525;
}

h1 { 
  margin: 0 0 8px 0;
  font-size: 2.1rem;
  font-weight: 600;
  color: var(--primary-color);
  transition: color 0.3s ease;
}

.subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 1.05rem;
  transition: color 0.3s ease;
}

/* Seções brancas "cartão" */
section {
  background: white;
  margin-bottom: 40px;
  padding: 32px 40px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

[data-theme="dark"] section {
  background: #252525;
}

/* ======= Agrupamento por órgão/origem ======= */
.org-group { padding-top: 28px; }
.org-header { margin-bottom: 18px; }
.org-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.org-title h2 { 
  margin: 0; 
  font-size: 1.4rem; 
  font-weight: 600; 
  color: var(--text-color);
  transition: color 0.3s ease;
}
.org-scope {
  display: inline-block;
  font-size: 0.85rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--badge-bg);
  border: 1px solid var(--badge-border);
  color: var(--primary-color);
  transition: all 0.3s ease;
}
.org-note { 
  margin: 6px 0 0 0; 
  font-size: 0.95rem; 
  color: var(--text-light);
  transition: color 0.3s ease;
}

/* Corpo com linhas (minimalista, sem "caixotes" excessivos) */
.org-body { display: grid; gap: 18px; }

/* Subgrupos dentro do TJPR (Órgão Especial, Foro, etc.) */
.suborg { margin-top: 6px; }
.suborg-title {
  margin: 12px 0 6px 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--primary-color);
  transition: color 0.3s ease;
}

/* Cada ato em linha */
.ato-line {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px 16px;
  background: #fafafa;
  transition: box-shadow .2s ease, transform .2s ease, background-color 0.3s ease, border-color 0.3s ease;
}

[data-theme="dark"] .ato-line {
  background: #2a2a2a;
}

.ato-line:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }

/* Título do ato e badge JSON */
.ato-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 6px 0;
  font-size: 1.06rem;
  font-weight: 600;
}
.ato-title > a:first-child {
  color: var(--primary-color);
  text-decoration: none;
  transition: color 0.3s ease;
}
.ato-title > a:first-child:hover { text-decoration: underline; }

.badge-json {
  display: inline-block;
  font-size: 0.82rem;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--badge-bg);
  border: 1px solid var(--badge-border);
  color: var(--primary-color);
  text-decoration: none;
  transition: all 0.3s ease;
}
.badge-json:hover { text-decoration: underline; }

.badge-txt {
  display: inline-block;
  font-size: 0.82rem;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--badge-bg);
  border: 1px solid var(--badge-border);
  color: var(--primary-color);
  text-decoration: none;
  transition: all 0.3s ease;
}
.badge-txt:hover { text-decoration: underline; }

.badge-raw {
  display: inline-block;
  font-size: 0.82rem;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--badge-bg);
  border: 1px solid var(--badge-border);
  color: var(--primary-color);
  text-decoration: none;
  transition: all 0.3s ease;
}
.badge-raw:hover { text-decoration: underline; }

/* Descrição e fonte */
.ato-description { 
  margin: 0 0 6px 0; 
  color: var(--text-light); 
  font-size: 0.98rem;
  text-align: justify;
  transition: color 0.3s ease;
}
.ato-source { 
  margin: 0; 
  font-size: 0.9rem; 
  color: var(--text-muted);
  transition: color 0.3s ease;
}

/* Seção de informações */
.info ul { padding-left: 20px; }
.info li { margin-bottom: 8px; }
.info code {
  background: #f0f4f8;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  transition: background-color 0.3s ease;
}

[data-theme="dark"] .info code {
  background: #333;
  color: #e0e0e0;
}

/* Footer */
footer {
  background: white;
  padding: 24px 32px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  text-align: center;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

[data-theme="dark"] footer {
  background: #252525;
}

.disclaimer {
  background-color: #fff3cd;
  border: 1px solid #ffeaa7;
  padding: 15px;
  border-radius: 5px;
  font-size: 1.2em;
  color: #856404;
  text-align: justify;
  margin: 0;
  line-height: 1.5;
  transition: all 0.3s ease;
}

[data-theme="dark"] .disclaimer {
  background-color: #3d3416;
  border-color: #5a4a1f;
  color: #f4d06f;
}

.disclaimer strong {
  color: #856404;
}

[data-theme="dark"] .disclaimer strong {
  color: #f4d06f;
}

.disclaimer a {
  color: #856404;
  text-decoration: underline;
}

[data-theme="dark"] .disclaimer a {
  color: #f4d06f;
}

/* Links gerais */
a { 
  color: var(--primary-color); 
  text-decoration: none;
  transition: color 0.3s ease;
}
a:hover { text-decoration: underline; }

/* Responsividade */
@media (max-width: 768px) {
  .container { padding: 16px 22px; }
  section { padding: 24px; margin-bottom: 28px; }
  .org-title h2 { font-size: 1.2rem; }
  .ato-title { font-size: 1rem; }
  .badge-json { padding: 5px 7px; font-size: 0.8rem; }
  
  .theme-toggle-container {
    position: static;
    justify-content: center;
    margin-top: 12px;
  }
  
  .theme-toggle-label {
    font-size: 0.7rem;
  }
  
  .theme-option {
    padding: 3px 6px;
    font-size: 0.65rem;
  }
  
  .theme-icon {
    font-size: 0.75rem;
  }
}

/* ======= CONTROLES DE BUSCA E FILTROS (HARMONIZADO) ======= */

/* Container principal dos controles - estilo cartão como as seções */
.controls-container {
  position: sticky;
  top: 0;
  z-index: 100;
  background: white;
  padding: 28px 40px;
  margin-bottom: 40px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

[data-theme="dark"] .controls-container {
  background: #252525;
}

.search-box {
  margin-bottom: 20px;
}

/* Input de busca - bordas arredondadas e estilo minimalista */
#searchInput {
  width: 100%;
  padding: 16px 20px;
  font-size: 1rem;
  border: 2px solid var(--primary-color);
  border-radius: 12px;
  background: white;
  color: var(--text-color);
  transition: all .2s ease;
  font-family: inherit;
}

[data-theme="dark"] #searchInput {
  background: #2a2a2a;
}

#searchInput:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(0, 85, 204, 0.1);
}

[data-theme="dark"] #searchInput:focus {
  box-shadow: 0 0 0 4px rgba(74, 158, 255, 0.2);
}

#searchInput::placeholder {
  color: var(--text-muted);
}

/* Linha de filtros */
.filters-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

/* Selects de filtro - estilo minimalista harmonizado */
.filter-select {
  flex: 1;
  min-width: 180px;
  padding: 12px 16px;
  font-size: 0.95rem;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: white;
  color: var(--text-color);
  cursor: pointer;
  transition: all .2s ease;
  font-family: inherit;
}

[data-theme="dark"] .filter-select {
  background: #2a2a2a;
}

.filter-select:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow);
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 85, 204, 0.1);
}

[data-theme="dark"] .filter-select:focus {
  box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.2);
}

/* Botão limpar filtros - estilo badge harmonizado */
.reset-btn {
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  border: 2px solid var(--primary-color);
  border-radius: 10px;
  background: white;
  color: var(--primary-color);
  cursor: pointer;
  transition: all .2s ease;
  font-family: inherit;
  white-space: nowrap;
}

[data-theme="dark"] .reset-btn {
  background: #2a2a2a;
}

.reset-btn:hover {
  background: var(--primary-color);
  color: white;
  box-shadow: var(--shadow-hover);
}

.reset-btn:active {
  transform: scale(0.98);
}

/* Informação de resultados */
.result-info {
  text-align: center;
  margin-top: 4px;
}

#resultCount {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.3s ease;
}

.result-count-filtered {
  color: var(--primary-color) !important;
  font-weight: 600;
}

.result-count-all {
  color: var(--text-muted) !important;
}

/* Animação suave para itens filtrados */
.ato-line {
  transition: opacity .2s ease, transform .2s ease;
}

.ato-line.hidden-by-filter {
  opacity: 0;
  transform: scale(0.98);
}

/* Ajustes para mobile */
@media (max-width: 768px) {
  .controls-container {
    padding: 20px 24px;
    margin-bottom: 28px;
  }
  
  .filters-row {
    flex-direction: column;
    gap: 12px;
  }
  
  .filter-select {
    width: 100%;
    min-width: auto;
  }
  
  .reset-btn {
    width: 100%;
  }
  
  #searchInput {
    padding: 14px 18px;
    font-size: 0.95rem;
  }
}

/* Ajuste do header para não conflitar com sticky */
header {
  position: relative;
  z-index: 50;
}

/* Melhorias visuais para seções vazias */
.org-group[style*="display: none"] {
  margin: 0;
  padding: 0;
}



/* [fix] Evita espaçamento residual quando a sub-seção estiver vazia */
.suborg > br { display: none; }

/* Estilo harmonizado para o botão Busca Avançada */
.btn-outline,
#pf-trigger {
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  border: 2px solid var(--primary-color);
  border-radius: 10px;
  background: transparent;
  color: var(--primary-color);
  cursor: pointer;
  transition: all .2s ease;
  font-family: inherit;
  white-space: nowrap;
}

[data-theme="dark"] .btn-outline,
[data-theme="dark"] #pf-trigger {
  background: transparent;
}

.btn-outline:hover,
#pf-trigger:hover {
  background: var(--primary-color);
  color: white;
  box-shadow: var(--shadow-hover);
}

.btn-outline:active,
#pf-trigger:active {
  transform: scale(0.98);
}
