/* Reporte Cívico enhanced styles */
:root {
  --rc-primary: #14285A;
  --rc-secondary: #F58220;
  --rc-success: #28a745;
  --rc-error: #dc3545;
  --rc-border: #ddd;
  --rc-radius: 8px;
  --rc-spacing: 12px;
  --rc-transition: all 0.3s ease;
}

/* Use theme's active font stack */
.rc-form,
.rc-map-list,
.rc-field input,
.rc-field textarea,
.rc-field select,
.rc-btn,
.rc-stats,
.rc-legend,
.rc-list,
.rc-error,
.rc-help,
.rc-legal,
.rc-pager,
.leaflet-container,
.leaflet-control,
.leaflet-popup-content,
.marker-cluster div {
  font-family: inherit;
}

/* Ensure Leaflet layout is not broken by global theme CSS */
.leaflet-container {
  overflow: hidden; /* prevent tiles from overflowing */
  display: block;
  position: relative; /* ensure panes/tiles are positioned correctly */
}
.leaflet-container img,
.leaflet-container .leaflet-tile,
.leaflet-container .leaflet-marker-icon,
.leaflet-container .leaflet-marker-shadow {
  max-width: none !important;
  max-height: none !important;
}

/* Do not override width/height of tiles; Leaflet CSS defines correct values */

.rc-form, .rc-map-list { 
  max-width: 900px; 
  margin: 0 auto; 
  padding: var(--rc-spacing);
}

.rc-field { 
  margin-bottom: var(--rc-spacing); 
}

.rc-field label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  color: var(--rc-primary);
}

.rc-field input,
.rc-field textarea,
.rc-field select {
  width: 100%;
  padding: 8px 12px;
  border: 2px solid var(--rc-border);
  border-radius: var(--rc-radius);
  font-size: 14px;
  transition: var(--rc-transition);
}

.rc-field input:focus,
.rc-field textarea:focus,
.rc-field select:focus {
  border-color: var(--rc-secondary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(245, 130, 32, 0.1);
}

.rc-grid { 
  display: grid; 
  grid-template-columns: 1fr 1fr; 
  gap: var(--rc-spacing); 
}

.rc-checkbox { 
  margin: 8px 0; 
}

.rc-checkbox input {
  width: auto;
  margin-right: 8px;
}

.rc-btn { 
  background: var(--rc-primary); 
  color: #fff; 
  border: 0; 
  padding: 12px 24px; 
  border-radius: var(--rc-radius); 
  cursor: pointer;
  font-weight: 600;
  transition: var(--rc-transition);
  min-width: 120px;
}

.rc-btn:hover {
  background: var(--rc-secondary);
  transform: translateY(-1px);
}

.rc-btn:disabled { 
  opacity: 0.6; 
  cursor: not-allowed;
  transform: none;
}

.rc-message { 
  margin-top: 10px; 
  padding: 8px 12px;
  border-radius: var(--rc-radius);
  font-weight: 500;
}

.rc-message[style*="green"] {
  background: rgba(40, 167, 69, 0.1);
  color: var(--rc-success);
  border: 1px solid var(--rc-success);
}

.rc-message[style*="red"] {
  background: rgba(220, 53, 69, 0.1);
  color: var(--rc-error);
  border: 1px solid var(--rc-error);
}

.rc-map {
  width: 100%;
  height: 420px;
  border-radius: var(--rc-radius);
  border: 2px solid var(--rc-border);
  transition: var(--rc-transition);
}

/* Instruções com ícones no formulário */
.rc-instructions {
  background: #f8f9fa;
  border-left: 3px solid var(--rc-secondary);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.rc-instructions-list {
  list-style: none;
  padding: 0; margin: 0;
  display: flex; flex-wrap: wrap; gap: 12px 20px;
}
.rc-instructions-list li {
  display: flex; align-items: center; gap: 8px; color: #343a40;
}
.rc-instructions-list svg { color: var(--rc-secondary); }

/* Notas de ajuda e privacidade/legais */
.rc-help,
.rc-legal,
.rc-privacy-note {
  margin-top: 6px;
  color: #495057;
  line-height: 1.5;
}
.rc-legal {
  font-size: 0.9rem;
  color: #6c757d;
}
.rc-privacy-note {
  background: #f8f9fa;
  padding: 8px 12px;
  border-left: 3px solid var(--rc-primary);
  border-radius: 6px;
  margin-bottom: 8px;
}
.rc-legal a,
.rc-privacy-note a {
  color: var(--rc-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.rc-legal a:hover,
.rc-privacy-note a:hover {
  color: var(--rc-secondary);
}

.rc-map:focus-within {
  border-color: var(--rc-secondary);
}

.rc-list { 
  list-style: none; 
  padding: 0; 
  margin: var(--rc-spacing) 0 0; 
  display: grid; 
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); 
  gap: var(--rc-spacing); 
}

.rc-list li { 
  border: 1px solid var(--rc-border); 
  border-radius: var(--rc-radius); 
  padding: 20px; 
  background: #fff;
  transition: var(--rc-transition);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.rc-list li:hover {
  box-shadow: 0 8px 18px rgba(0,0,0,0.12);
  transform: translateY(-3px);
}

/* Card layout for occurrences list */
.rc-card-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  align-items: start;
}
.rc-card-grid--no-thumb {
  grid-template-columns: 1fr;
}

.rc-card-thumb {
  display: block;
}
.rc-card-thumb img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--rc-radius);
}

/* Pré‑visualização de fotos na submissão */
.rc-photo-count { font-weight: 600; color: #495057; margin-left: 6px; }
.rc-photo-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.rc-preview-item { position: relative; width: 120px; height: 120px; border: 1px solid var(--rc-border); border-radius: 6px; overflow: hidden; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.rc-preview-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rc-preview-item.dragging { opacity: .75; }
.rc-preview-item.dragover { outline: 2px dashed var(--rc-secondary); outline-offset: -4px; }
.rc-preview-item--small { border-color: var(--rc-secondary); box-shadow: inset 0 0 0 2px rgba(245,130,32,.25); }
.rc-preview-remove { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; display: grid; place-items: center; line-height: 1; font-weight: 700; }
.rc-preview-remove:hover, .rc-preview-remove:focus-visible { background: rgba(0,0,0,.8); outline: 2px solid var(--rc-secondary); outline-offset: 2px; }

.rc-card-thumb--placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 120px; /* ensure consistent height when images are missing */
  background: #f1f3f5;
  color: #6c757d;
  border-radius: var(--rc-radius);
}
.rc-placeholder-label { font-size: 12px; }

.rc-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rc-card-excerpt {
  margin: 0;
  color: #2b2b2b;
}

.rc-map-list-address {
  margin: 0 0 6px 0;
  color: #666;
}

/* Leaflet popup thumbnails */
.leaflet-popup-content .rc-popup-thumb {
  display: block;
  max-width: 160px;
  width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 0 0 8px 0;
  object-fit: cover;
}
.leaflet-popup-content .rc-popup-thumb--placeholder {
  width: 160px;
  aspect-ratio: 4 / 3;
  background: #f1f3f5;
  color: #6c757d;
  display: grid;
  place-items: center;
  border-radius: 6px;
  margin: 0 0 8px 0;
}

.rc-list h4 { 
  margin: 0 0 8px 0; 
  font-size: 1.15rem;
  color: var(--rc-primary);
}

.rc-list h4 a {
  color: inherit;
  text-decoration: none;
}

.rc-list h4 a:hover {
  color: var(--rc-secondary);
}

/* Badge de fotos extra nos cards */
.rc-card-thumb { position: relative; display: inline-block; }
.rc-thumb-badge {
  position: absolute; right: 8px; bottom: 8px;
  background: var(--rc-secondary); color: #fff;
  font-size: 12px; line-height: 1; padding: 4px 6px; border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.rc-filters { 
  display: flex; 
  gap: var(--rc-spacing); 
  align-items: center; 
  margin: 12px 0; 
  padding: var(--rc-spacing);
  background: #f8f9fa;
  border-radius: var(--rc-radius);
}
.rc-filters input[type="date"],
.rc-filters select { height: 36px; }
.rc-filter-inline { display: inline-flex; align-items: center; gap: 6px; color: #343a40; }

/* Estatísticas na listagem */
.rc-stats { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.rc-stat { font-size: 0.95rem; }
.rc-stat--resolvido { color: #2e7d32; }
.rc-stat--em-resolucao { color: #e67700; }
.rc-stat--novo { color: #0b7285; }

/* Barra de erro */
.rc-error { background: #fdecec; color: #842029; border: 1px solid #f5c2c7; padding: 8px 12px; border-radius: 6px; margin: 8px 0; }

/* Estado loading na listagem */
.rc-map-list.loading { opacity: .6; cursor: progress; }

/* Estilos dos clusters do Leaflet (override do tema) */
.marker-cluster div {
  background: var(--rc-primary);
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.marker-cluster-small div { background: var(--rc-secondary); }
.marker-cluster-medium div { background: #1f3d7a; }
.marker-cluster-large div { background: #0d1f45; }
.marker-cluster span { color: #fff; font-weight: 700; }

/* Paginação */
.rc-pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 14px 0; }
.rc-page-info { color: #495057; }

/* Mensagem de vazio */
.rc-empty { list-style: none; padding: 16px; text-align: center; color: #6c757d; background: #f8f9fa; border: 1px dashed #dee2e6; border-radius: 8px; }

/* Live region (não visível mas ocupando espaço mínimo) */
.rc-live { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Legenda de estados */
.rc-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 8px 0; }
.rc-legend-item { display: inline-flex; align-items: center; gap: 6px; color: #343a40; font-size: .95rem; }
.rc-legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.rc-status--novo { background: #0b7285; }
.rc-status--em-validacao { background: #5e35b1; }
.rc-status--em-resolucao { background: #e67700; }
.rc-status--resolvido { background: #2e7d32; }
.rc-status--rejeitado { background: #c92a2a; }
.rc-status--default { background: #6c757d; }

.rc-filters select {
  padding: 6px 12px;
  border: 1px solid var(--rc-border);
  border-radius: var(--rc-radius);
  background: white;
}

/* Garantir que filtros e lista ficam acima do mapa e são clicáveis */
.rc-filters, .rc-list { position: relative; z-index: 2; }
.rc-list li { pointer-events: auto; }
.rc-map-list .leaflet-container { position: relative; z-index: 1; }

/* Botão secundário usado nos filtros */
.rc-btn-secondary {
  background: #e9ecef;
  color: var(--rc-primary);
  border: 1px solid var(--rc-border);
  padding: 8px 14px;
  border-radius: var(--rc-radius);
  cursor: pointer;
  font-weight: 600;
  transition: var(--rc-transition);
}
.rc-btn-secondary:hover { background: #dee2e6; }
.rc-btn-secondary:disabled { opacity: .6; cursor: not-allowed; }

/* Responsive design */
@media (max-width: 640px) { 
  .rc-grid { 
    grid-template-columns: 1fr; 
  }
  .rc-filters { flex-wrap: wrap; }
  .rc-filters > * { flex: 1 1 100%; }
  .rc-filters .rc-btn-secondary { width: 100%; }
  
  .rc-form, .rc-map-list {
    padding: 8px;
  }
  
  .rc-list {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .rc-card-grid {
    grid-template-columns: 1fr;
  }
  
  .rc-filters {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  .rc-btn,
  .rc-list li,
  .rc-field input,
  .rc-field textarea {
    transition: none;
  }
}

/* Loading state */
.rc-form.loading .rc-btn::after {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-left: 8px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: rc-spin 1s linear infinite;
}

@keyframes rc-spin {
  to { transform: rotate(360deg); }
}
