/* Census App Unified UI Styles */

/* ========================================
   Animations
   ======================================== */

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

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

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

/* Animation utility classes */
.animate-fadeIn {
  animation: fadeIn 0.3s ease-out forwards;
}

.animate-fadeInUp {
  animation: fadeInUp 0.4s ease-out forwards;
}

.animate-slideInRight {
  animation: slideInRight 0.3s ease-out forwards;
}

.animate-slideInLeft {
  animation: slideInLeft 0.3s ease-out forwards;
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ========================================
   Tab Navigation
   ======================================== */

/* Hide scrollbar for tab navigation */
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

/* Tab button hover effects */
.tab-button {
  transition: all 0.2s ease;
}

.tab-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.tab-button:active:not(:disabled) {
  transform: translateY(0);
}

/* Active tab indicator animation */
.tab-active-indicator {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-focus) 100%);
  border-radius: 3px 3px 0 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Content Panel Transitions
   ======================================== */

.content-panel {
  position: relative;
  overflow: hidden;
}

.content-panel-enter {
  opacity: 0;
  transform: translateX(30px);
}

.content-panel-enter-active {
  opacity: 1;
  transform: translateX(0);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.content-panel-exit {
  opacity: 1;
  transform: translateX(0);
}

.content-panel-exit-active {
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Page transition effect */
.page-transition {
  transition: opacity 0.15s ease-in-out;
}

.page-transition-enter {
  opacity: 0;
}

.page-transition-enter-active {
  opacity: 1;
}

/* ========================================
   Compare Mode Styles
   ======================================== */

.compare-area-a {
  --area-color: var(--primary, #2563eb);
  border-color: var(--area-color);
}

.compare-area-b {
  --area-color: #f59e0b;
  border-color: var(--area-color);
}

.compare-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
}

.compare-badge-a {
  background-color: rgba(37, 99, 235, 0.1);
  color: #2563eb;
}

.dark .compare-badge-a {
  background-color: rgba(96, 165, 250, 0.2);
  color: #60a5fa;
}

.compare-badge-b {
  background-color: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
}

.dark .compare-badge-b {
  background-color: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
}

/* ========================================
   Card Hover Effects
   ======================================== */

.card-interactive {
  transition: all 0.2s ease;
  cursor: pointer;
}

.card-interactive:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

.dark .card-interactive:hover {
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
}

.card-interactive:active {
  transform: translateY(0);
}

/* ========================================
   AI Agent Cards
   ======================================== */

.ai-agent-card {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.ai-agent-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--agent-gradient, linear-gradient(90deg, #f59e0b, #f97316));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}

.ai-agent-card:hover::before {
  transform: scaleX(1);
}

.ai-agent-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.15);
}

/* ========================================
   Map Container
   ======================================== */

.map-container {
  position: relative;
  border-radius: 0.75rem;
  overflow: hidden;
}

.map-container .leaflet-container {
  border-radius: inherit;
}

.map-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.dark .map-loading-overlay {
  background: rgba(17, 24, 39, 0.8);
}

/* ========================================
   Chart Styles
   ======================================== */

.chart-container {
  transition: all 0.3s ease;
  /* Enable container queries for responsive charts */
  container-type: inline-size;
  container-name: chart;
}

.chart-container:hover {
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.dark .chart-container:hover {
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* Chart wrapper for container query targeting */
.chart-wrapper {
  container-type: inline-size;
  container-name: chart-wrapper;
  width: 100%;
}

/* Container queries for responsive chart sizing */
@container chart (max-width: 300px) {
  canvas {
    max-height: 150px !important;
  }
}

@container chart (max-width: 400px) {
  canvas {
    max-height: 180px !important;
  }
}

@container chart-wrapper (max-width: 300px) {
  canvas {
    max-height: 150px !important;
  }
}

@container chart-wrapper (max-width: 400px) {
  canvas {
    max-height: 180px !important;
  }
}

/* Recharts tooltip customization */
.recharts-tooltip-wrapper {
  z-index: 1000 !important;
}

/* ========================================
   Loading States
   ======================================== */

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.06) 25%,
    rgba(0, 0, 0, 0.1) 50%,
    rgba(0, 0, 0, 0.06) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.dark .skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.06) 25%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.06) 75%
  );
  background-size: 200% 100%;
}

/* ========================================
   Responsive Adjustments
   ======================================== */

/* Extra small phones (< 480px) */
@media (max-width: 480px) {
  .content-panel {
    padding: 0.5rem;
  }
  
  .chart-container {
    min-height: 140px;
    max-height: 200px;
  }
  
  .chart-wrapper {
    min-height: 140px;
  }
  
  /* Reduce chart canvas padding on extra small screens */
  .chart-container canvas {
    padding: 4px !important;
  }
  
  /* Compact legend on small screens */
  .chart-legend {
    font-size: 9px;
  }
}

/* Large phones (481px - 640px) */
@media (min-width: 481px) and (max-width: 640px) {
  .content-panel {
    padding: 0.75rem;
  }
  
  .chart-container {
    min-height: 160px;
    max-height: 240px;
  }
  
  .chart-wrapper {
    min-height: 160px;
  }
}

/* Small tablets (641px - 768px) */
@media (min-width: 641px) and (max-width: 768px) {
  .content-panel {
    padding: 0.875rem;
  }
  
  .chart-container {
    min-height: 180px;
    max-height: 280px;
  }
  
  .chart-wrapper {
    min-height: 180px;
  }
  
  /* Make tabs full width on tablets */
  .tab-button {
    flex: 1;
    min-width: auto;
    padding: 0.5rem 0.75rem;
  }
  
  /* Stack compare inputs vertically */
  .compare-inputs {
    flex-direction: column;
  }
}

/* Large tablets (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .content-panel {
    padding: 1rem;
  }
  
  .chart-container {
    min-height: 220px;
    max-height: 320px;
  }
  
  .chart-wrapper {
    min-height: 220px;
  }
}

/* Small desktops (1025px - 1280px) */
@media (min-width: 1025px) and (max-width: 1280px) {
  .chart-container {
    min-height: 260px;
    max-height: 360px;
  }
  
  .chart-wrapper {
    min-height: 260px;
  }
}

/* Large desktops (> 1280px) */
@media (min-width: 1281px) {
  .chart-container {
    min-height: 300px;
    max-height: 400px;
  }
  
  .chart-wrapper {
    min-height: 300px;
  }
}

/* ========================================
   Focus States for Accessibility
   ======================================== */

.focus-ring:focus {
  outline: none;
  ring: 2px;
  ring-color: var(--primary);
  ring-offset: 2px;
}

.focus-visible:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ========================================
   Utility Classes
   ======================================== */

.truncate-2-lines {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.truncate-3-lines {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Gradient text */
.gradient-text {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Smooth scroll */
.smooth-scroll {
  scroll-behavior: smooth;
}

/* No scroll */
.no-scroll {
  overflow: hidden;
}

