/**
 * Bahia Atual Eleições 2026 - Main Stylesheet
 * Journalistic, Modern, Mobile-First, Accessible
 */

:root {
  --bae-primary: #dc2626;
  --bae-primary-hover: #b91c1c;
  --bae-primary-light: rgba(220, 38, 38, 0.08);
  --bae-primary-rgb: 220, 38, 38;
  --bae-success: #16a34a;
  --bae-success-light: rgba(22, 163, 74, 0.1);
  --bae-warning: #d97706;
  --bae-warning-light: rgba(217, 119, 6, 0.1);
  --bae-bg: #f8fafc;
  --bae-card-bg: #ffffff;
  --bae-text-primary: #0f172a;
  --bae-text-secondary: #475569;
  --bae-text-muted: #64748b;
  --bae-border: #e2e8f0;
  --bae-border-light: #f1f5f9;
  --bae-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --bae-shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
  --bae-shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.12);
  --bae-radius: 12px;
  --bae-radius-sm: 8px;
  --bae-radius-pill: 9999px;
  --bae-font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --bae-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset / Scope */
.bae-election-wrapper {
  font-family: var(--bae-font);
  color: var(--bae-text-primary);
  background-color: var(--bae-bg);
  max-width: 1200px;
  margin: 20px auto 40px auto;
  padding: 16px;
  border-radius: var(--bae-radius);
  box-sizing: border-box;
}

.bae-election-wrapper *,
.bae-election-wrapper *::before,
.bae-election-wrapper *::after,
.bae-summary-widget * {
  box-sizing: border-box;
}

/* Header */
.bae-header {
  background: var(--bae-card-bg);
  border-radius: var(--bae-radius);
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--bae-border);
  box-shadow: var(--bae-shadow-sm);
}

.bae-header__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.bae-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bae-portal-tag {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #ffffff;
  background: var(--bae-text-primary);
  padding: 4px 10px;
  border-radius: var(--bae-radius-sm);
}

/* Badges */
.bae-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: var(--bae-radius-pill);
}

.bae-badge-live {
  background: rgba(220, 38, 38, 0.12);
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.3);
}

.bae-badge-final {
  background: rgba(15, 23, 42, 0.08);
  color: var(--bae-text-primary);
  border: 1px solid var(--bae-border);
}

.bae-pulse-dot {
  width: 8px;
  height: 8px;
  background-color: #dc2626;
  border-radius: 50%;
  position: relative;
  display: inline-block;
}

.bae-pulse-dot::after {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  background: rgba(220, 38, 38, 0.5);
  animation: bae-pulse 1.6s infinite ease-out;
}

@keyframes bae-pulse {
  0% { transform: scale(0.9); opacity: 0.9; }
  50% { transform: scale(2); opacity: 0.1; }
  100% { transform: scale(0.9); opacity: 0.9; }
}

.bae-badge-final .bae-pulse-dot {
  background-color: var(--bae-text-muted);
}
.bae-badge-final .bae-pulse-dot::after {
  display: none;
}

/* Refresh Button */
.bae-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid var(--bae-border);
  color: var(--bae-text-primary);
  padding: 8px 14px;
  border-radius: var(--bae-radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--bae-transition);
}

.bae-btn:hover:not(:disabled) {
  background: var(--bae-border-light);
  border-color: #cbd5e1;
}

.bae-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.bae-btn.is-spinning .bae-icon--spin-target {
  animation: bae-spin 1s linear infinite;
}

@keyframes bae-spin {
  100% { transform: rotate(360deg); }
}

.bae-title {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.25;
  margin: 0 0 8px 0;
  color: var(--bae-text-primary);
}

.bae-subtitle {
  font-size: 15px;
  color: var(--bae-text-secondary);
  margin: 0 0 16px 0;
  line-height: 1.5;
}

.bae-header__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--bae-border-light);
  font-size: 13px;
  color: var(--bae-text-muted);
}

.bae-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Share Buttons */
.bae-share {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bae-share__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--bae-text-muted);
}

.bae-share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--bae-border);
  background: #ffffff;
  color: var(--bae-text-secondary);
  cursor: pointer;
  transition: var(--bae-transition);
}

.bae-share-btn--whatsapp:hover {
  background: #25d366;
  color: #ffffff;
  border-color: #25d366;
}

.bae-share-btn--facebook:hover {
  background: #1877f2;
  color: #ffffff;
  border-color: #1877f2;
}

.bae-share-btn--copy:hover {
  background: var(--bae-text-primary);
  color: #ffffff;
  border-color: var(--bae-text-primary);
}

/* Tabs Navigation */
.bae-tabs-nav {
  margin-bottom: 20px;
}

.bae-tabs-scroller {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.bae-tabs-scroller::-webkit-scrollbar {
  height: 4px;
}
.bae-tabs-scroller::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.bae-tab {
  flex: 1 0 auto;
  min-width: 140px;
  background: var(--bae-card-bg);
  border: 1px solid var(--bae-border);
  border-radius: var(--bae-radius);
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  transition: var(--bae-transition);
}

.bae-tab span {
  font-size: 15px;
  font-weight: 700;
  color: var(--bae-text-primary);
}

.bae-tab small {
  font-size: 12px;
  color: var(--bae-text-muted);
  margin-top: 2px;
}

.bae-tab:hover {
  background: #ffffff;
  border-color: #94a3b8;
}

.bae-tab.active {
  background: #ffffff;
  border-color: var(--bae-primary);
  box-shadow: 0 0 0 2px var(--bae-primary-light), var(--bae-shadow-sm);
}

.bae-tab.active span {
  color: var(--bae-primary);
}

/* Toast Notifications */
.bae-notification {
  background: #0f172a;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: var(--bae-radius-sm);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--bae-shadow-md);
  animation: bae-slide-down 0.25s ease-out;
}

@keyframes bae-slide-down {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.bae-notification--error {
  background: #991b1b;
}

/* Content Panels */
.bae-panel {
  display: none;
}
.bae-panel.active {
  display: block;
}

/* Progress Box */
.bae-progress-card {
  background: var(--bae-card-bg);
  border-radius: var(--bae-radius);
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--bae-border);
  box-shadow: var(--bae-shadow-sm);
}

.bae-progress-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.bae-progress-title-wrap h2 {
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 4px 0;
  color: var(--bae-text-primary);
}

.bae-progress-subtitle {
  font-size: 13px;
  color: var(--bae-text-muted);
}

.bae-status-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--bae-radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bae-status-pill--counting {
  background: var(--bae-warning-light);
  color: var(--bae-warning);
}

.bae-status-pill--completed {
  background: var(--bae-success-light);
  color: var(--bae-success);
}

.bae-status-pill--not_started {
  background: var(--bae-border-light);
  color: var(--bae-text-muted);
}

/* Visual Progress Bar */
.bae-progress-visual {
  margin-bottom: 16px;
}

.bae-progress-visual__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.bae-progress-pct {
  font-size: 32px;
  font-weight: 900;
  color: var(--bae-primary);
  line-height: 1;
}

.bae-progress-detail {
  font-size: 13px;
  color: var(--bae-text-muted);
  font-weight: 500;
}

.bae-progress-bar {
  width: 100%;
  height: 12px;
  background: #e2e8f0;
  border-radius: var(--bae-radius-pill);
  overflow: hidden;
  position: relative;
}

.bae-progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--bae-primary) 0%, #ef4444 100%);
  border-radius: var(--bae-radius-pill);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.bae-sections-meta {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--bae-text-muted);
  padding-top: 12px;
  border-top: 1px solid var(--bae-border-light);
}

/* Fallback Notice */
.bae-fallback-alert {
  background: #fef2f2;
  border-left: 4px solid var(--bae-primary);
  padding: 10px 16px;
  border-radius: var(--bae-radius-sm);
  font-size: 13px;
  color: #991b1b;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Candidate Cards List */
.bae-candidates-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.bae-cand-card {
  background: var(--bae-card-bg);
  border-radius: var(--bae-radius);
  padding: 16px 20px;
  border: 1px solid var(--bae-border);
  box-shadow: var(--bae-shadow-sm);
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 16px;
  position: relative;
  transition: var(--bae-transition);
}

.bae-cand-card:hover {
  box-shadow: var(--bae-shadow-md);
  border-color: #cbd5e1;
}

.bae-cand-card.is-leader {
  border-color: rgba(220, 38, 38, 0.4);
  background: linear-gradient(180deg, #ffffff 0%, #fff8f8 100%);
}

.bae-cand-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bae-border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px var(--bae-border);
  flex-shrink: 0;
}

.bae-cand-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bae-avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #475569 0%, #1e293b 100%);
  color: #ffffff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.05em;
  user-select: none;
}

.bae-cand-card.is-leader .bae-avatar-fallback {
  background: linear-gradient(135deg, var(--bae-primary) 0%, #991b1b 100%);
}

.bae-cand-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bae-cand-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bae-cand-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--bae-text-primary);
}

.bae-cand-party {
  font-size: 12px;
  font-weight: 600;
  color: var(--bae-text-muted);
  background: var(--bae-border-light);
  padding: 2px 8px;
  border-radius: var(--bae-radius-sm);
}

.bae-cand-number {
  font-size: 12px;
  font-weight: 700;
  color: var(--bae-text-secondary);
}

.bae-status-tag {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--bae-radius-sm);
}

.bae-status-tag--elected {
  background: var(--bae-success-light);
  color: var(--bae-success);
  border: 1px solid rgba(22, 163, 74, 0.3);
}

.bae-status-tag--second_round {
  background: var(--bae-warning-light);
  color: var(--bae-warning);
  border: 1px solid rgba(217, 119, 6, 0.3);
}

/* Candidate Progress Bar */
.bae-cand-bar-wrap {
  margin-top: 6px;
  width: 100%;
}

.bae-cand-bar {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: var(--bae-radius-pill);
  overflow: hidden;
}

.bae-cand-bar__fill {
  height: 100%;
  background: var(--bae-text-muted);
  border-radius: var(--bae-radius-pill);
  transition: width 0.5s ease-out;
}

.bae-cand-card.is-leader .bae-cand-bar__fill {
  background: var(--bae-primary);
}

/* Candidate Right Column (Numbers) */
.bae-cand-numbers {
  text-align: right;
  min-width: 110px;
}

.bae-cand-pct {
  font-size: 22px;
  font-weight: 900;
  color: var(--bae-text-primary);
  line-height: 1.1;
}

.bae-cand-card.is-leader .bae-cand-pct {
  color: var(--bae-primary);
}

.bae-cand-votes {
  font-size: 12px;
  color: var(--bae-text-muted);
  margin-top: 2px;
  display: block;
}

/* Summary Metrics Cards (Votos Válidos, Nulos, Brancos, etc.) */
.bae-summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.bae-metric-card {
  background: var(--bae-card-bg);
  border-radius: var(--bae-radius);
  padding: 14px 16px;
  border: 1px solid var(--bae-border);
  box-shadow: var(--bae-shadow-sm);
}

.bae-metric-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--bae-text-muted);
  margin-bottom: 4px;
  display: block;
}

.bae-metric-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--bae-text-primary);
}

/* Empty State */
.bae-empty-state {
  background: var(--bae-card-bg);
  border: 2px dashed var(--bae-border);
  border-radius: var(--bae-radius);
  padding: 40px 20px;
  text-align: center;
  color: var(--bae-text-muted);
  margin-bottom: 20px;
}

.bae-empty-state h3 {
  font-size: 18px;
  color: var(--bae-text-primary);
  margin: 12px 0 6px 0;
}

.bae-empty-icon {
  font-size: 36px;
}

/* Municipalities Search & Interface */
.bae-mun-search-box {
  background: var(--bae-card-bg);
  border-radius: var(--bae-radius);
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid var(--bae-border);
  box-shadow: var(--bae-shadow-sm);
  position: relative;
}

.bae-mun-label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--bae-text-primary);
}

.bae-mun-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.bae-mun-search-icon {
  position: absolute;
  left: 14px;
  color: var(--bae-text-muted);
  pointer-events: none;
}

.bae-mun-input {
  width: 100%;
  padding: 12px 40px 12px 42px;
  font-size: 15px;
  border: 1px solid var(--bae-border);
  border-radius: var(--bae-radius-sm);
  outline: none;
  background: #ffffff;
  transition: var(--bae-transition);
}

.bae-mun-input:focus {
  border-color: var(--bae-primary);
  box-shadow: 0 0 0 3px var(--bae-primary-light);
}

.bae-mun-clear {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--bae-text-muted);
  cursor: pointer;
}

/* Autocomplete Dropdown */
.bae-mun-dropdown {
  position: absolute;
  top: calc(100% - 10px);
  left: 20px;
  right: 20px;
  background: #ffffff;
  border: 1px solid var(--bae-border);
  border-radius: var(--bae-radius-sm);
  box-shadow: var(--bae-shadow-lg);
  max-height: 240px;
  overflow-y: auto;
  z-index: 100;
}

.bae-mun-option {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--bae-border-light);
}

.bae-mun-option:hover,
.bae-mun-option.is-selected {
  background: var(--bae-primary-light);
  color: var(--bae-primary);
  font-weight: 600;
}

/* Quick Filter Chips */
.bae-mun-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.bae-mun-chips-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--bae-text-muted);
}

.bae-chip {
  background: var(--bae-border-light);
  border: 1px solid var(--bae-border);
  color: var(--bae-text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--bae-radius-pill);
  cursor: pointer;
  transition: var(--bae-transition);
}

.bae-chip:hover {
  background: var(--bae-primary-light);
  border-color: var(--bae-primary);
  color: var(--bae-primary);
}

/* Skeleton Loaders */
.bae-skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: bae-shimmer 1.5s infinite;
  border-radius: var(--bae-radius);
  margin-bottom: 12px;
}

.bae-skeleton--progress {
  height: 140px;
}

.bae-skeleton--card {
  height: 76px;
}

@keyframes bae-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Footer Notice */
.bae-footer {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--bae-border);
  text-align: center;
  font-size: 13px;
  color: var(--bae-text-muted);
}

.bae-footer__brand strong {
  color: var(--bae-text-primary);
}

.bae-footer__source {
  margin: 6px 0 4px 0;
  font-weight: 600;
  color: var(--bae-text-secondary);
}

.bae-footer__disclaimer {
  margin: 0;
  font-size: 12px;
  color: var(--bae-text-muted);
}

/* Summary Widget Standalone Styles */
.bae-summary-widget {
  background: #ffffff;
  border: 1px solid var(--bae-border);
  border-radius: var(--bae-radius);
  padding: 16px;
  box-shadow: var(--bae-shadow-sm);
  margin: 16px 0;
  font-family: var(--bae-font);
}

.bae-widget-header {
  margin-bottom: 12px;
}

.bae-widget-title-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.bae-widget-tag {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--bae-text-muted);
}

.bae-widget-office {
  font-size: 16px;
  font-weight: 800;
  margin: 0;
  color: var(--bae-text-primary);
}

.bae-widget-progress {
  margin-bottom: 14px;
}

.bae-widget-progress-text {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 4px;
  color: var(--bae-text-muted);
}

.bae-widget-progress-text strong {
  color: var(--bae-primary);
}

.bae-widget-candidates {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.bae-widget-cand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  background: var(--bae-border-light);
  border-radius: var(--bae-radius-sm);
}

.bae-widget-cand-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.bae-widget-cand-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bae-widget-cand-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: 1;
}

.bae-widget-cand-name {
  font-size: 14px;
  display: block;
}

.bae-widget-cand-party {
  font-size: 11px;
  color: var(--bae-text-muted);
}

.bae-widget-cand-stats {
  text-align: right;
}

.bae-widget-cand-pct {
  font-size: 15px;
  font-weight: 800;
  color: var(--bae-primary);
  display: block;
}

.bae-widget-cand-votes {
  font-size: 11px;
  color: var(--bae-text-muted);
  display: block;
}

.bae-widget-cta {
  text-align: center;
}

.bae-widget-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px 14px;
  background: var(--bae-text-primary);
  color: #ffffff !important;
  text-decoration: none !important;
  font-size: 13px;
  font-weight: 700;
  border-radius: var(--bae-radius-sm);
  transition: var(--bae-transition);
}

.bae-widget-btn:hover {
  background: var(--bae-primary);
}

/* Responsive Breakpoints (Mobile First) */
@media (max-width: 640px) {
  .bae-header {
    padding: 16px;
  }

  .bae-title {
    font-size: 20px;
  }

  .bae-header__top {
    flex-direction: column;
    align-items: flex-start;
  }

  .bae-actions {
    width: 100%;
  }

  .bae-btn--refresh {
    width: 100%;
    justify-content: center;
  }

  .bae-cand-card {
    grid-template-columns: 44px 1fr;
    gap: 12px;
    padding: 14px;
  }

  .bae-cand-avatar {
    width: 44px;
    height: 44px;
  }

  .bae-cand-numbers {
    grid-column: 2 / 3;
    text-align: left;
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-top: 4px;
  }

  .bae-cand-pct {
    font-size: 18px;
  }

  .bae-progress-pct {
    font-size: 26px;
  }

  .bae-tab {
    min-width: 120px;
    padding: 10px 12px;
  }

  .bae-tab span {
    font-size: 14px;
  }
}
