/* ============================================================
   ASFALTO LISO 3 - Design System & Custom Styles
   ============================================================ */

/* ---------- CSS Variables (Design Tokens) ---------- */
:root {
  /* Primary Palette */
  --color-primary: #1E40AF;
  --color-primary-light: #0EA5E9;
  --color-accent: #F59E0B;
  --color-accent-dim: rgba(190, 242, 100, 0.2);
  --color-accent-glow: rgba(190, 242, 100, 0.3);

  /* Status Colors */
  --status-nao-iniciada: #6B7280;
  --status-em-licitacao: #3B82F6;
  --status-em-andamento: #F59E0B;
  --status-concluida: #10B981;
  --status-pausada: #EF4444;
  --status-em-fiscalizacao: #8B5CF6;

  /* Dark Theme */
  --bg-black: #0a0a0a;
  --bg-dark: #121212;
  --bg-card: #1a1a1a;
  --bg-elevated: #262626;
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-light: rgba(255, 255, 255, 0.1);
  --text-primary: #f5f5f5;
  --text-secondary: #a3a3a3;
  --text-muted: #525252;

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Spacing */
  --radius-sm: 0.5rem;
  --radius-md: 1rem;
  --radius-lg: 1.5rem;
  --radius-xl: 2rem;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;
}

/* ---------- Glassmorphism ---------- */
.glass-card {
  background: rgba(26, 26, 26, 0.65);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
}

.glass-card-light {
  background: rgba(38, 38, 38, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
}

/* ---------- Neon Glow Effects ---------- */
.neon-glow {
  box-shadow: 0 0 15px var(--color-accent-glow);
}

.neon-glow-strong {
  box-shadow: 0 0 25px var(--color-accent-glow), 0 0 50px rgba(190, 242, 100, 0.1);
}

.neon-text {
  text-shadow: 0 0 10px var(--color-accent-glow);
}

/* ---------- Map Overlay Gradient ---------- */
.map-overlay-gradient {
  background: linear-gradient(to bottom,
      rgba(10, 10, 10, 0.85) 0%,
      rgba(10, 10, 10, 0) 18%,
      rgba(10, 10, 10, 0) 75%,
      rgba(10, 10, 10, 1) 100%);
}

/* ---------- Custom Scrollbar ---------- */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-accent);
}

/* ---------- Status Badge Styles ---------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.status-nao-iniciada {
  background: rgba(107, 114, 128, 0.15);
  color: #9CA3AF;
  border: 1px solid rgba(107, 114, 128, 0.25);
}

.status-em-licitacao {
  background: rgba(59, 130, 246, 0.15);
  color: #60A5FA;
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.status-em-andamento {
  background: rgba(245, 158, 11, 0.15);
  color: #FBBF24;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.status-concluida {
  background: rgba(16, 185, 129, 0.15);
  color: #34D399;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.status-pausada {
  background: rgba(239, 68, 68, 0.15);
  color: #F87171;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.status-em-fiscalizacao {
  background: rgba(139, 92, 246, 0.15);
  color: #A78BFA;
  border: 1px solid rgba(139, 92, 246, 0.25);
}

/* ---------- Progress Bar ---------- */
.progress-bar {
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width var(--transition-slow);
}

/* ---------- Pulse Animation (for active pins) ---------- */
@keyframes pulse-ring {
  0% {
    transform: scale(0.8);
    opacity: 1;
  }

  100% {
    transform: scale(2.2);
    opacity: 0;
  }
}

.pulse-dot::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid currentColor;
  animation: pulse-ring 2s ease-out infinite;
}

/* ---------- Counter Animation ---------- */
@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-count {
  animation: countUp 0.6s ease-out forwards;
}

/* ---------- Stagger List Animation ---------- */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-stagger>* {
  opacity: 0;
  animation: slideInUp 0.4s ease-out forwards;
}

.animate-stagger>*:nth-child(1) {
  animation-delay: 0.05s;
}

.animate-stagger>*:nth-child(2) {
  animation-delay: 0.10s;
}

.animate-stagger>*:nth-child(3) {
  animation-delay: 0.15s;
}

.animate-stagger>*:nth-child(4) {
  animation-delay: 0.20s;
}

.animate-stagger>*:nth-child(5) {
  animation-delay: 0.25s;
}

.animate-stagger>*:nth-child(6) {
  animation-delay: 0.30s;
}

.animate-stagger>*:nth-child(7) {
  animation-delay: 0.35s;
}

.animate-stagger>*:nth-child(8) {
  animation-delay: 0.40s;
}

.animate-stagger>*:nth-child(9) {
  animation-delay: 0.45s;
}

.animate-stagger>*:nth-child(10) {
  animation-delay: 0.50s;
}

/* ---------- Fade In ---------- */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.animate-fade-in {
  animation: fadeIn 0.5s ease-out forwards;
}

/* ---------- Skeleton Loading ---------- */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* ---------- Tooltip ---------- */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-fast);
  border: 1px solid var(--border-subtle);
  z-index: 100;
}

.tooltip:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ---------- Mapbox Popup Override ---------- */
.mapboxgl-popup-content {
  background: rgba(26, 26, 26, 0.95) !important;
  backdrop-filter: blur(12px) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: var(--radius-lg) !important;
  color: var(--text-primary) !important;
  padding: 1rem !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4) !important;
}

.mapboxgl-popup-tip {
  border-top-color: rgba(26, 26, 26, 0.95) !important;
}

.mapboxgl-popup-close-button {
  color: var(--text-secondary) !important;
  font-size: 1.25rem !important;
}

/* ---------- Responsive Helpers ---------- */
@media (max-width: 640px) {
  .glass-card {
    border-radius: var(--radius-lg);
  }
}

/* Mobile: limit roads table to ~25 visible rows with scroll */
@media (max-width: 768px) {
  #roads-container {
    max-height: 1050px;
    overflow-y: auto;
  }
}

/* ---------- Header Search Bar ---------- */
.header-search-wrapper {
  position: relative;
  flex: 1;
  max-width: 520px;
  z-index: 9999;
}

.header-search-input {
  width: 100%;
  background: rgba(38, 38, 38, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  font-size: 0.8125rem;
  font-family: var(--font-sans);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-base);
}

.header-search-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
  font-weight: 400;
}

.header-search-input:focus {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(38, 38, 38, 0.9);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.08), 0 4px 20px rgba(0, 0, 0, 0.3);
}

.header-search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  color: rgba(255, 255, 255, 0.3);
  pointer-events: none;
  transition: color var(--transition-base);
}

.header-search-input:focus ~ .header-search-icon {
  color: var(--color-accent);
}

.header-search-clear {
  position: absolute;
  right: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.25rem;
  height: 1.25rem;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  padding: 0;
  transition: all var(--transition-fast);
}

.header-search-clear:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.header-search-clear.visible {
  display: flex;
}

/* Search Results Dropdown */
.header-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: rgba(26, 26, 26, 0.97);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  max-height: 380px;
  overflow-y: auto;
  z-index: 9999;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.header-search-results.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover,
.search-result-item.active {
  background: rgba(245, 158, 11, 0.08);
}

.search-result-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.search-result-info {
  flex: 1;
  min-width: 0;
}

.search-result-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-name mark {
  background: transparent;
  color: var(--color-accent);
  font-weight: 700;
}

.search-result-meta {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

.search-result-status {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  flex-shrink: 0;
  white-space: nowrap;
}

.search-no-results {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.search-no-results svg {
  display: block;
  margin: 0 auto 0.5rem;
  opacity: 0.3;
}

.search-hint {
  padding: 0.5rem 1rem;
  font-size: 0.6875rem;
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-hint kbd {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.625rem;
  font-family: var(--font-sans);
}

@media (max-width: 768px) {
  .header-search-wrapper {
    max-width: none;
    flex: none;
    order: 3;
  }
  .header-search-results {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
  }
}

/* Search Section Headers */
.search-section-header {
  padding: 0.5rem 1rem 0.375rem;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.02);
}

.search-section-header:first-child {
  border-top: none;
}

/* Temporary Map Marker Animation */
@keyframes markerBounce {
  0% {
    transform: rotate(-45deg) translateY(-20px);
    opacity: 0;
  }
  60% {
    transform: rotate(-45deg) translateY(4px);
    opacity: 1;
  }
  100% {
    transform: rotate(-45deg) translateY(0);
  }
}

.mapbox-search-marker {
  cursor: pointer;
  transition: transform 0.2s ease;
}

.mapbox-search-marker:hover {
  transform: scale(1.15);
}