/* ============================================================
   PORTAL ESCOLAS DO BRASIL - DESIGN SYSTEM & ESTILOS
   ============================================================ */

:root {
  --primary: #1e40af;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --accent: #059669;
  --accent-light: #ecfdf5;
  --estadual: #7c3aed;
  --estadual-light: #f5f3ff;
  --municipal: #0284c7;
  --municipal-light: #f0f9ff;
  --privada: #d97706;
  --privada-light: #fffbeb;
  --dark: #0f172a;
  --dark-surface: #1e293b;
  --gray-900: #0f172a;
  --gray-800: #1e293b;
  --gray-700: #334155;
  --gray-600: #475569;
  --gray-500: #64748b;
  --gray-400: #94a3b8;
  --gray-300: #cbd5e1;
  --gray-200: #e2e8f0;
  --gray-100: #f1f5f9;
  --gray-50: #f8fafc;
  --white: #ffffff;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #f8fafc;
  color: var(--gray-800);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Base Layout */
.container {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header & Navigation */
.navbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(8px);
  background-color: rgba(255, 255, 255, 0.95);
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 72px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 22px;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.brand-name {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -0.02em;
}

.brand-name span {
  color: #2563eb;
}

.brand-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  background: #dbeafe;
  color: #1d4ed8;
  border-radius: var(--radius-full);
  margin-left: 6px;
  vertical-align: middle;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.city-selector-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  transition: var(--transition);
}

.city-selector-badge:hover {
  background: var(--gray-200);
  border-color: var(--gray-300);
}

.city-selector-badge i {
  color: #2563eb;
}

.btn-compare-trigger {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #2563eb;
  color: var(--white);
  border: none;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-compare-trigger:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.compare-badge-count {
  background: #ef4444;
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Hero Section */
.hero-section {
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  padding: 48px 0 32px 0;
  border-bottom: 1px solid var(--gray-200);
}

.hero-title-wrap {
  text-align: center;
  max-width: 820px;
  margin: 0 auto 32px auto;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: #dbeafe;
  color: #1e40af;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

.hero-title {
  font-size: 2.75rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 14px;
}

.hero-title .highlight {
  background: linear-gradient(135deg, #1d4ed8, #059669);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 1.125rem;
  color: var(--gray-600);
  max-width: 680px;
  margin: 0 auto;
}

/* Search Bar in Hero */
.search-container {
  max-width: 860px;
  margin: 0 auto 36px auto;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--white);
  border: 2px solid var(--gray-200);
  border-radius: 16px;
  padding: 8px 12px 8px 20px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.06);
  transition: var(--transition);
}

.search-box:focus-within {
  border-color: #2563eb;
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.15);
}

.search-icon {
  color: var(--gray-400);
  font-size: 1.25rem;
  margin-right: 12px;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1.05rem;
  font-family: inherit;
  color: var(--gray-900);
}

.search-input::placeholder {
  color: var(--gray-400);
}

.search-clear-btn {
  background: none;
  border: none;
  color: var(--gray-400);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  display: none;
}

.search-clear-btn:hover {
  color: var(--gray-600);
}

/* Stats Counter Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
}

.stat-icon.blue { background: #dbeafe; color: #1d4ed8; }
.stat-icon.purple { background: #f3e8ff; color: #7e22ce; }
.stat-icon.emerald { background: #d1fae5; color: #047857; }
.stat-icon.amber { background: #fef3c7; color: #b45309; }

.stat-info .stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1;
}

.stat-info .stat-label {
  font-size: 0.8125rem;
  color: var(--gray-500);
  font-weight: 600;
  margin-top: 4px;
}

/* Main Content Area */
.main-content {
  padding: 36px 0 80px 0;
}

/* Layout Grid (Filters + School List) */
.portal-grid {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 28px;
  align-items: start;
}

/* Sidebar Filters */
.filters-sidebar {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 92px;
}

.filters-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-200);
}

.filters-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-reset-filters {
  background: none;
  border: none;
  color: #2563eb;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
}

.btn-reset-filters:hover {
  text-decoration: underline;
}

.filter-group {
  margin-bottom: 22px;
}

.filter-label {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 10px;
  display: block;
}

.filter-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  color: var(--gray-600);
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}

.filter-checkbox-label:hover {
  color: var(--gray-900);
}

.filter-checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #2563eb;
  border-radius: 4px;
  cursor: pointer;
}

.filter-count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--gray-400);
  font-weight: 600;
}

/* Toolbar (View Mode, Sorting, Counter) */
.results-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
  background: var(--white);
  padding: 14px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
}

.results-count-text {
  font-size: 0.9375rem;
  color: var(--gray-600);
}

.results-count-text strong {
  color: var(--gray-900);
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sort-select {
  padding: 8px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--gray-700);
  cursor: pointer;
  outline: none;
}

.sort-select:focus {
  border-color: #2563eb;
}

.view-toggle {
  display: flex;
  background: var(--gray-100);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
}

.view-toggle-btn {
  background: none;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--gray-600);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.view-toggle-btn.active {
  background: var(--white);
  color: #2563eb;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

/* Map View Container */
#map-view-container {
  display: none;
  margin-bottom: 24px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-md);
}

#leaflet-map {
  width: 100%;
  height: 480px;
  background: #e2e8f0;
}

/* Schools Grid */
.schools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 20px;
}

/* School Card */
.school-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
}

.school-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--gray-300);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.badges-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-estadual { background: var(--estadual-light); color: var(--estadual); }
.badge-municipal { background: var(--municipal-light); color: var(--municipal); }
.badge-privada { background: var(--privada-light); color: var(--privada); }
.badge-urbana { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.badge-rural { background: #fefce8; color: #ca8a04; border: 1px solid #fef08a; }

.btn-card-compare {
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-full);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  cursor: pointer;
  transition: var(--transition);
}

.btn-card-compare:hover, .btn-card-compare.active {
  background: #eff6ff;
  border-color: #2563eb;
  color: #2563eb;
}

.card-school-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1.3;
  margin-bottom: 6px;
}

.card-inep {
  font-size: 0.775rem;
  color: var(--gray-400);
  font-weight: 600;
  margin-bottom: 12px;
}

.card-address {
  font-size: 0.8125rem;
  color: var(--gray-600);
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 14px;
  line-height: 1.4;
}

.card-address i {
  color: #ef4444;
  font-size: 0.95rem;
  margin-top: 2px;
}

.card-etapas-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 16px;
}

.etapa-pill {
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--gray-100);
  color: var(--gray-700);
  padding: 2px 8px;
  border-radius: 4px;
}

.card-metrics-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--gray-100);
  border-bottom: 1px solid var(--gray-100);
  margin-bottom: 16px;
  text-align: center;
}

.metric-item .m-val {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--gray-900);
}

.metric-item .m-lbl {
  font-size: 0.7rem;
  color: var(--gray-500);
  font-weight: 600;
}

.card-footer {
  margin-top: auto;
  display: flex;
  gap: 10px;
}

.btn-details {
  flex: 1;
  background: #2563eb;
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}

.btn-details:hover {
  background: #1d4ed8;
}

.btn-locate-map {
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-700);
  cursor: pointer;
  transition: var(--transition);
}

.btn-locate-map:hover {
  background: var(--gray-200);
  color: #2563eb;
}

/* Empty State */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--gray-300);
}

.empty-state-icon {
  font-size: 3rem;
  color: var(--gray-400);
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 6px;
}

.empty-state p {
  color: var(--gray-500);
  max-width: 420px;
  margin: 0 auto 20px auto;
}

/* Details Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.modal-backdrop.active {
  display: flex;
  opacity: 1;
}

.modal-dialog {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 780px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: translateY(20px);
  transition: transform 0.25s ease;
  position: relative;
}

.modal-backdrop.active .modal-dialog {
  transform: translateY(0);
}

.modal-header {
  padding: 24px 28px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 10;
}

.modal-close-btn {
  background: var(--gray-100);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--gray-600);
  cursor: pointer;
  transition: var(--transition);
}

.modal-close-btn:hover {
  background: var(--gray-200);
  color: var(--gray-900);
}

.modal-body {
  padding: 28px;
}

.modal-section {
  margin-bottom: 28px;
}

.modal-section-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.info-item {
  background: var(--gray-50);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
}

.info-item-label {
  font-size: 0.75rem;
  color: var(--gray-500);
  font-weight: 600;
  text-transform: uppercase;
}

.info-item-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-top: 2px;
}

/* Infrastructure Checklist */
.infra-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.infra-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--gray-50);
}

.infra-item.has {
  color: #065f46;
  background: #ecfdf5;
}

.infra-item.has i {
  color: #10b981;
}

.infra-item.lacks {
  color: #991b1b;
  background: #fef2f2;
}

.infra-item.lacks i {
  color: #ef4444;
}

/* Compare Drawer */
.compare-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--white);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.15);
  border-top: 2px solid #2563eb;
  z-index: 1500;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 16px 0;
}

.compare-drawer.active {
  transform: translateY(0);
}

.compare-drawer-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.compare-chips-list {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.compare-chip {
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 8px;
}

.compare-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-500);
  font-size: 0.875rem;
}

.compare-chip-remove:hover {
  color: #ef4444;
}

.compare-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Compare Modal Dialog */
.compare-modal-dialog {
  max-width: 1100px;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

.compare-table th, .compare-table td {
  padding: 12px 16px;
  border: 1px solid var(--gray-200);
  text-align: left;
  font-size: 0.875rem;
}

.compare-table th {
  background: var(--gray-100);
  font-weight: 800;
  color: var(--gray-900);
}

.compare-table tr:nth-child(even) td {
  background: var(--gray-50);
}

/* Footer */
.portal-footer {
  background: var(--dark);
  color: var(--gray-400);
  padding: 48px 0 24px 0;
  border-top: 1px solid var(--dark-surface);
}

.footer-top {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
}

.footer-brand h4 {
  color: var(--white);
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.footer-brand p {
  font-size: 0.875rem;
  line-height: 1.6;
  max-width: 380px;
}

.footer-col h5 {
  color: var(--white);
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-links a {
  color: var(--gray-400);
  text-decoration: none;
  font-size: 0.875rem;
  transition: var(--transition);
}

.footer-links a:hover {
  color: var(--white);
}

.footer-bottom {
  text-align: center;
  padding-top: 24px;
  border-top: 1px solid var(--dark-surface);
  font-size: 0.8125rem;
}

/* Responsive Breakpoints */
@media (max-width: 992px) {
  .portal-grid {
    grid-template-columns: 1fr;
  }
  
  .filters-sidebar {
    position: static;
  }
  
  .footer-top {
    grid-template-columns: 1fr;
    gap: 28px;
  }
}

@media (max-width: 768px) {
  .hero-title {
    font-size: 2rem;
  }
  
  .schools-grid {
    grid-template-columns: 1fr;
  }
  
  .modal-grid-2 {
    grid-template-columns: 1fr;
  }
}
