/* Shared Design System for Ēkufonds.lv - Liquid Glass Edition */
:root {
  /* Spacing */
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.25rem;  /* 20px */
  --space-6: 1.5rem;   /* 24px */
  --space-8: 2rem;     /* 32px */
  --space-10: 2.5rem;  /* 40px */
  --space-12: 3rem;    /* 48px */
  --space-16: 4rem;    /* 64px */
  --space-20: 5rem;    /* 80px */
  --space-24: 6rem;    /* 96px */
  --space-32: 8rem;    /* 128px */

  /* Typography */
  --text-xs: 0.75rem;  /* 12px */
  --text-sm: 0.875rem; /* 14px */
  --text-base: 1rem;   /* 16px */
  --text-lg: 1.125rem; /* 18px */
  --text-xl: 1.25rem;  /* 20px */
  --text-2xl: 1.5rem;  /* 24px */
  --text-3xl: 1.875rem;/* 30px */
  --text-4xl: 2.25rem; /* 36px */
  --text-5xl: 3rem;    /* 48px */
  --text-6xl: 3.75rem; /* 60px */

  /* Brand Colors */
  --brand-primary: #8b5cf6;
  --brand-secondary: #a855f7;
  --brand-accent: #c084fc;
  
  --success: #22c55e;
  --success-400: #4ade80;
  --success-500: #22c55e;
  --warning: #f59e0b;
  --warning-500: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;

  /* Primary color variants */
  --primary-400: #818cf8;
  --primary-500: #6366f1;
  --primary-600: #4f46e5;

  /* Neutral colors */
  --neutral-50: #f9fafb;
  --neutral-200: #e5e7eb;
  --neutral-300: #d1d5db;
  --neutral-400: #9ca3af;
  --neutral-800: #1f2937;
  --neutral-900: #111827;

  /* Border radius */
  --radius-md: 8px;
  --radius-lg: 12px;

  --gradient-brand: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  --gradient-text: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
  
  /* Liquid Glass Defaults (Light) */
  --bg-primary: #f0f2f5;
  --bg-secondary: #ffffff;
  --bg-tertiary: rgba(0, 0, 0, 0.03);
  --text-primary: #1d1d1f;
  --text-secondary: #86868b;
  --text-muted: #a1a1a6;
  --text-inverse: #ffffff;
  
  --glass-surface: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-highlight: rgba(255, 255, 255, 0.8);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
  --glass-blur: 20px;
  --glass-saturate: 180%;
  
  --border-subtle: rgba(0, 0, 0, 0.1);
  --border-muted: rgba(0, 0, 0, 0.2);
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.15);
}

/* Theme variants */
.theme-dark {
  --bg-primary: #000000;
  --bg-secondary: #1c1c1e;
  --bg-tertiary: rgba(255, 255, 255, 0.05);
  --text-primary: #f5f5f7;
  --text-secondary: #86868b;
  --text-muted: #6e6e73;
  
  --glass-surface: rgba(28, 28, 30, 0.65);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-highlight: rgba(255, 255, 255, 0.15);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
  
  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-muted: rgba(255, 255, 255, 0.2);
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.theme-light {
  /* Inherits root defaults */
  --bg-primary: #f0f2f5;
}

/* Base */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.5s ease, color 0.5s ease;
}

/* Liquid Glass Utility Class */
.liquid-glass {
  background: var(--glass-surface);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 24px;
  position: relative;
  overflow: hidden;
}

/* Add specular highlight */
.liquid-glass::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, var(--glass-highlight), transparent 60%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.5;
}

/* Header - Simplified Liquid Glass */
/* Header - Full width (replaces previous centered pill layout) */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 1000;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-bottom: 1px solid var(--border-subtle);
  /* Default to light-friendly glass; theme overrides below enforce final color */
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  animation: headerFadeIn 0.8s ease-out;
}

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

/* Unified Liquid Glass Effect */
/* Optional liquid-glass variant retains subtle translucency */
.header.liquid-glass {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow:
    0 8px 32px rgba(31, 38, 135, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    inset 0 -1px 0 rgba(255, 255, 255, 0.2);
}

/* Explicit theme overrides with high specificity to beat inline .header */
.theme-light .header {
  background: rgba(255, 255, 255, 0.85) !important;
  border-bottom: 1px solid rgba(139, 92, 246, 0.10) !important;
  backdrop-filter: blur(20px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
}

.theme-dark .header {
  background: rgba(10, 10, 10, 0.80) !important;
  border-bottom: 1px solid var(--border-subtle) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
}

.theme-dark .header.liquid-glass {
  background: rgba(20, 20, 22, 0.7);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

/* Glass layers - hidden */
.glass-filter,
.glass-overlay,
.glass-specular {
  display: none;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.logo { 
  display: flex; 
  align-items: center; 
  gap: var(--space-3); 
  text-decoration: none; 
  color: var(--text-primary); 
  font-weight: 700; 
  font-size: var(--text-lg);
  transition: transform 0.3s ease;
}

.logo:hover {
  transform: scale(1.02);
}

.logo-icon { 
  width: 44px; 
  height: 44px; 
  background: linear-gradient(
    135deg,
    rgba(139, 92, 246, 1) 0%,
    rgba(168, 85, 247, 1) 100%
  );
  border-radius: 14px; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  font-size: 22px; 
  box-shadow: 
    0 8px 24px rgba(139, 92, 246, 0.35),
    0 4px 12px rgba(139, 92, 246, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.logo-icon::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255, 255, 255, 0.2) 50%,
    transparent 70%
  );
  transform: rotate(45deg);
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
  100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.logo:hover .logo-icon {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 
    0 12px 32px rgba(139, 92, 246, 0.45),
    0 6px 16px rgba(139, 92, 246, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

.nav { 
  display: flex; 
  align-items: center; 
  gap: var(--space-6); 
}

.nav-links { 
  display: flex; 
  align-items: center; 
  gap: var(--space-2); 
  list-style: none; 
}

.nav-link { 
  color: var(--text-secondary); 
  text-decoration: none; 
  font-weight: 500; 
  font-size: var(--text-sm); 
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); 
  padding: 0.5rem 1.25rem;
  border-radius: 50px;
  position: relative;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.nav-link::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50px;
  background: rgba(255, 255, 255, 0.1);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
}

.nav-link:hover::before {
  opacity: 1;
}

.nav-link:hover { 
  color: var(--text-primary); 
  transform: translateY(-2px);
  box-shadow: 
    0 4px 12px rgba(139, 92, 246, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.nav-link.active { 
  color: var(--text-primary);
  background: linear-gradient(
    135deg,
    rgba(139, 92, 246, 0.6) 0%,
    rgba(168, 85, 247, 0.5) 100%
  );
  box-shadow: 
    0 4px 16px rgba(139, 92, 246, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 0 20px rgba(255, 255, 255, 0.1);
  font-weight: 600;
}

.theme-dark .nav-link {
  color: var(--text-secondary);
}

.theme-dark .nav-link::before {
  background: rgba(255, 255, 255, 0.05);
}

.theme-dark .nav-link:hover {
  color: var(--text-primary);
  box-shadow: 
    0 4px 12px rgba(124, 58, 237, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.theme-dark .nav-link.active {
  background: linear-gradient(
    135deg,
    rgba(124, 58, 237, 0.6) 0%,
    rgba(139, 92, 246, 0.5) 100%
  );
  box-shadow: 
    0 4px 16px rgba(124, 58, 237, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 0 20px rgba(255, 255, 255, 0.05);
}

/* Theme Switcher (Apple Liquid Style) */
.theme-switcher-wrapper {
  position: relative;
  display: flex;
  background: rgba(0,0,0,0.05);
  border-radius: 100px;
  padding: 4px;
  gap: 4px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}
.theme-dark .theme-switcher-wrapper {
  background: rgba(255,255,255,0.1);
}

.theme-btn {
  all: unset;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: var(--text-secondary);
}

.theme-btn.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transform: scale(1.1);
}

/* Auth Container */
.auth-container {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.auth-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2);
}

.auth-loading .spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(139, 92, 246, 0.2);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Buttons */
.btn { 
  display:inline-flex; 
  align-items:center; 
  gap: var(--space-2); 
  padding: 0.75rem 1.5rem; 
  background: var(--gradient-brand); 
  color: var(--text-inverse); 
  border:none; 
  border-radius: 100px; 
  font-size: var(--text-sm); 
  font-weight:600; 
  cursor:pointer; 
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); 
  text-decoration:none; 
  box-shadow: 
    0 4px 16px rgba(139, 92, 246, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s;
}

.btn:hover::before {
  left: 100%;
}

.btn:hover { 
  transform: translateY(-2px) scale(1.02); 
  box-shadow: 
    0 8px 24px rgba(139, 92, 246, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn-secondary { 
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary); 
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover { 
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(139, 92, 246, 0.3);
  box-shadow: 
    0 4px 12px rgba(139, 92, 246, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.theme-dark .btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.theme-dark .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(124, 58, 237, 0.4);
}

/* Utilities */
.hidden { display:none; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
*:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }

/* Leaflet dark theme tweaks */
.leaflet-container { background: var(--bg-secondary); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--bg-secondary); color: var(--text-primary); border: 1px solid var(--border-subtle); }
.leaflet-control-zoom a { background: var(--bg-secondary); color: var(--text-primary); border: 1px solid var(--border-subtle); }
.leaflet-control-zoom a:hover { background: var(--bg-primary); }

/* Status bar */
.status-bar { display:flex; align-items:center; justify-content: space-between; padding: var(--space-3) var(--space-6); background: var(--bg-secondary); border-top: 1px solid var(--border-subtle); font-size: var(--text-xs); color: var(--text-muted); }
.status-info { display:flex; align-items:center; gap: var(--space-2); }
.status-actions { display:flex; gap: var(--space-3); }

