/* Modern Design System for Oatfinder */
/* Uses Tailwind CSS via CDN with custom extensions */

/* ===== CSS Variables ===== */
:root {
  /* Primary Colors */
  --color-primary: #0F766E;
  --color-primary-hover: #12796F;
  --color-primary-light: #E6F7F6;
  
  /* Accent Colors */
  --color-accent: #F59E0B;
  --color-accent-light: #FEF3E2;
  
  /* Semantic Colors */
  --color-success: #22C55E;
  --color-warning: #F97316;
  --color-danger: #EF4444;
  
  /* Neutral Colors */
  --color-surface: #F7F8FB;
  --color-panel: #FFFFFF;
  --color-border: #E5E7EB;
  --color-text: #0F172A;
  --color-text-muted: #64748B;
  
  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  
  /* Spacing Scale (8px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  
  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
}

/* ===== Global Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-surface);
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-4) 0;
  font-weight: 600;
  line-height: 1.25;
  color: var(--color-text);
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
  margin: 0 0 var(--space-4) 0;
}

/* ===== Components ===== */

/* Stat Card */
.stat-card {
  background: var(--color-panel);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
  border: 1px solid var(--color-border);
}

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

.stat-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}

.stat-card-label {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  font-weight: 500;
  margin-bottom: var(--space-1);
}

.stat-card-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
}

.stat-card-delta {
  font-size: 0.875rem;
  font-weight: 500;
  margin-top: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.stat-card-delta.positive {
  color: var(--color-success);
}

.stat-card-delta.negative {
  color: var(--color-danger);
}

/* Section */
.section {
  background: var(--color-panel);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}

.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  line-height: 1;
}

.badge-primary {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.badge-success {
  background: #DCFCE7;
  color: #15803D;
}

.badge-warning {
  background: #FEF3C7;
  color: #A16207;
}

.badge-danger {
  background: #FEE2E2;
  color: #B91C1C;
}

.badge-neutral {
  background: var(--color-surface);
  color: var(--color-text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-4);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-lg);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  gap: var(--space-2);
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}

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

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: white;
}

/* Loading State */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-12);
  color: var(--color-text-muted);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: var(--space-12);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-4);
  color: var(--color-text-muted);
}

.empty-state-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.empty-state-text {
  color: var(--color-text-muted);
}

/* Map Clusters */
.cluster-marker {
  background: var(--color-primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  border: 3px solid white;
  transition: all var(--transition-fast);
}

.cluster-marker:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-lg);
}

.cluster-marker-small {
  width: 32px;
  height: 32px;
  font-size: 0.75rem;
}

.cluster-marker-medium {
  width: 40px;
  height: 40px;
  font-size: 0.875rem;
  background: var(--color-accent);
}

.cluster-marker-large {
  width: 48px;
  height: 48px;
  font-size: 1rem;
  background: var(--color-danger);
}

/* Animations */
.animate-fade-in {
  animation: fadeIn var(--transition-slow);
}

.animate-slide-up {
  animation: slideUp var(--transition-slow);
}

.animate-scale-in {
  animation: scaleIn var(--transition-base);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes scaleIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Focus States */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Responsive Utilities */
@media (max-width: 640px) {
  .hide-mobile { display: none; }
}

@media (min-width: 641px) {
  .hide-desktop { display: none; }
}

/* ===== Polish & Micro-interactions ===== */

/* Enhanced focus states */
.stat-card:focus-within {
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
  outline: none;
}

/* Button focus improvements */
.btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

/* Enhanced loading animations */
@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.loading-soft {
  animation: pulse-soft 1.5s ease-in-out infinite;
}

/* Stagger animations for cards */
.stat-card:nth-child(1) { animation-delay: 0ms; }
.stat-card:nth-child(2) { animation-delay: 100ms; }
.stat-card:nth-child(3) { animation-delay: 200ms; }
.stat-card:nth-child(4) { animation-delay: 300ms; }

/* Modern scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-surface);
}

::-webkit-scrollbar-thumb {
  background: var(--color-text-muted);
  border-radius: var(--radius-md);
}

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

/* Selection styling */
::selection {
  background: rgba(15, 118, 110, 0.2);
  color: var(--color-text);
}

/* Enhanced map container */
.map-container {
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
}

.map-container::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.map-container:hover {
  box-shadow: var(--shadow-lg);
}

/* Enhanced chart containers */
#countriesChart, #changesTimeline {
  transition: opacity var(--transition-base);
}

#countriesChart.loading, #changesTimeline.loading {
  opacity: 0.5;
  pointer-events: none;
}

/* Improved empty states */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--color-text-muted);
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-4);
  opacity: 0.5;
}