/* ============================================================
   CUBE Intelligence Design System
   Typography: Sora (400, 500, 600, 700, 800)
   Primary: #FF6B35
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700;800&display=swap');

/* ---- Custom Properties ---- */
:root {
  /* Colors */
  --primary: #FF6B35;
  --primary-dark: #E55A2B;
  --primary-light: #FF8A5C;
  --gradient: linear-gradient(180deg, #ff8a00 0%, #ff6b35 100%);
  --gradient-text: linear-gradient(90deg, #ff8a00 0%, #ff6b35 100%);

  --text-primary: #111827;
  --text-secondary: #6C7278;
  --text-muted: #9CA3AF;

  --surface-page: #FAFAFA;
  --surface-card: #FFFFFF;
  --surface-hover: #F3F4F6;
  --surface-active: #FFF3ED;

  --border: #E5E7EB;
  --border-light: #F3F4F6;

  --success: #22C55E;
  --success-bg: #F0FDF4;
  --warning: #F59E0B;
  --warning-bg: #FFFBEB;
  --error: #EF4444;
  --error-bg: #FEF2F2;
  --info: #3B82F6;
  --info-bg: #EFF6FF;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);

  /* Party Colors */
  --partido-pt: #CC0000;
  --partido-pl: #003DA5;
  --partido-mdb: #FF8C00;
  --partido-psd: #1E90FF;
  --partido-pp: #4169E1;
  --partido-uniao: #2E8B57;
  --partido-psdb: #0047AB;
  --partido-republicanos: #00529B;
  --partido-pdt: #DC143C;
  --partido-psol: #FFD700;
  --partido-pode: #FF4500;
  --partido-novo: #FF6347;
  --partido-default: #9CA3AF;
}

/* ---- Base Reset & Typography ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-primary);
  background: var(--surface-page);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Typography scale */
.display { font-size: 42px; font-weight: 800; line-height: 1.1; }
h1, .h1 { font-size: 28px; font-weight: 800; line-height: 1.2; }
h2, .h2 { font-size: 18px; font-weight: 700; line-height: 1.3; }
h3, .h3 { font-size: 16px; font-weight: 700; }
.body-lg { font-size: 16px; }
.body { font-size: 14px; }
.small { font-size: 13px; }
.micro {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.gradient-text {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---- Layout ---- */
.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }

@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4, .grid-5, .grid-6 { grid-template-columns: 1fr; }
  .container { padding: 0 16px; }
  .display { font-size: 24px; }
  h1, .h1 { font-size: 22px; }
}
@media (min-width: 901px) and (max-width: 1100px) {
  .grid-4, .grid-5, .grid-6 { grid-template-columns: repeat(3, 1fr); }
}

/* ---- 1. Navigation Bar ---- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.navbar .logo { font-weight: 800; font-size: 18px; }
.nav-links { display: flex; gap: 4px; }
.nav-link {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
}
.nav-link:hover { background: var(--surface-hover); color: var(--text-primary); }
.nav-link.active { background: var(--surface-active); color: var(--primary); }

/* ---- 2. Filter Bar ---- */
.filter-bar {
  position: sticky;
  top: 56px;
  z-index: 90;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-light);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.filter-select {
  appearance: none;
  padding: 6px 32px 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Sora', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239CA3AF' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E") right 10px center/12px no-repeat;
  cursor: pointer;
  transition: border-color 0.15s;
  min-width: 120px;
}
.filter-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255,107,53,0.1);
}
.filter-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.filter-clear {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Sora', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.filter-clear:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--surface-active);
}

/* ---- 3. Card ---- */
.card {
  background: var(--surface-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 16px; font-weight: 700; }
.card-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* ---- 4. KPI Card ---- */
.kpi-card {
  background: var(--surface-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kpi-card.active { border-color: var(--primary); background: var(--surface-active); }
.kpi-value {
  font-size: 32px;
  font-weight: 800;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}
.kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-top: 6px;
}
.kpi-detail { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ---- 5. Data Table ---- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.data-table th:hover { color: var(--primary); }
.data-table th.sorted { color: var(--primary); }
.data-table th.sorted::after { content: ' \25BC'; font-size: 9px; }
.data-table th.sorted.asc::after { content: ' \25B2'; }
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.data-table tr:nth-child(even) { background: var(--surface-page); }
.data-table tr:hover { background: var(--surface-active); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .winner { font-weight: 700; color: var(--primary); }

/* ---- 6. Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: var(--surface-hover); color: var(--text-secondary); }
.badge-partido {
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 700;
  color: white;
}

/* ---- 7. Highlight Box ---- */
.highlight-box {
  background: #FFF8F3;
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 18px;
  margin: 12px 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
}
.highlight-box strong { color: var(--primary); font-weight: 700; }
.insight-list { list-style: none; padding: 0; }
.insight-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}
.insight-list li:last-child { border-bottom: none; }
.insight-list li::before { content: '\2192 '; color: var(--primary); font-weight: 700; }

/* ---- 8. Score Badge ---- */
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 32px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 800;
  color: white;
  padding: 0 12px;
}
.score-low { background: var(--success); }
.score-medium { background: var(--warning); }
.score-high { background: var(--error); }

/* ---- 9. Persona Card ---- */
.persona-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--surface-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.persona-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  font-weight: 800;
  flex-shrink: 0;
}
.persona-info h3 { font-size: 16px; font-weight: 700; }
.persona-info .partido { font-size: 13px; color: var(--text-secondary); }
.persona-stats { display: flex; gap: 16px; margin-top: 6px; }
.persona-stat { font-size: 12px; color: var(--text-muted); }
.persona-stat strong { color: var(--text-primary); font-weight: 700; }

/* ---- 10. Chart Containers ---- */
.chart-container { position: relative; width: 100%; }
.chart-container canvas { width: 100% !important; }
.chart-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.chart-subtitle { font-size: 12px; color: var(--text-secondary); margin-top: -8px; margin-bottom: 12px; }

/* ---- 11. Map Container ---- */
.map-container {
  width: 100%;
  height: 500px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-page);
}
.map-container .leaflet-popup-content-wrapper {
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-family: 'Sora', sans-serif;
}
.map-container .leaflet-popup-content { font-size: 13px; }
@media (max-width: 900px) { .map-container { height: 350px; } }

/* ---- 12. Section Dividers & Spacing ---- */
.section { margin-bottom: 32px; }
.section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::before {
  content: '';
  width: 4px;
  height: 20px;
  background: var(--gradient);
  border-radius: 2px;
}
.divider { height: 1px; background: var(--border); margin: 24px 0; }

/* ---- 13. Loading & Empty States ---- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--text-muted);
}
.loading::after {
  content: '';
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---- 14. Tabs & Toggles ---- */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.tab {
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
}
.tab.active { background: white; color: var(--text-primary); box-shadow: var(--shadow); }
.toggle-group {
  display: inline-flex;
  gap: 2px;
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.toggle-btn {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
}
.toggle-btn.active { background: white; color: var(--primary); box-shadow: var(--shadow); }

/* ---- 15. Coalizao Bar ---- */
.coalizao-bar {
  display: flex;
  height: 40px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: 8px 0;
}
.coalizao-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  transition: all 0.2s;
  cursor: pointer;
}
.coalizao-segment:hover { opacity: 0.85; }
.coalizao-meta {
  height: 40px;
  position: absolute;
  border-left: 2px dashed var(--error);
  z-index: 2;
}
.coalizao-label {
  font-size: 11px;
  color: var(--error);
  font-weight: 700;
  position: absolute;
  top: -16px;
}

/* ---- 16. Search Input ---- */
.search-input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Sora', sans-serif;
  font-size: 15px;
  transition: all 0.15s;
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239CA3AF' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E") 14px center/20px no-repeat;
}
.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255,107,53,0.1);
}
.search-input::placeholder { color: var(--text-muted); }

/* ---- 17. Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- 18. Utility Classes ---- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 24px; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
