/* =====================================================
   VALAIS SEINET — Design System
   Premium Dark Mode Real Estate Dashboard
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* --- CSS Custom Properties --- */
:root {
  /* Primary palette */
  --navy-900: #0a0e1a;
  --navy-800: #0f1629;
  --navy-700: #151d38;
  --navy-600: #1a2547;
  --navy-500: #243058;
  --navy-400: #2e3d6b;
  --navy-300: #4a5a8a;
  --navy-200: #6b7db0;
  --navy-100: #94a3d4;

  /* Gold accent */
  --gold-500: #d4a853;
  --gold-400: #e0ba6a;
  --gold-300: #ecd08a;
  --gold-200: #f5e2b0;
  --gold-600: #b8923f;
  --gold-700: #9a7a30;

  /* Semantic colors */
  --success: #34d399;
  --success-dim: rgba(52, 211, 153, 0.15);
  --danger: #f87171;
  --danger-dim: rgba(248, 113, 113, 0.15);
  --warning: #fbbf24;
  --warning-dim: rgba(251, 191, 36, 0.15);
  --info: #60a5fa;
  --info-dim: rgba(96, 165, 250, 0.15);

  /* Choropleth scale */
  --price-1: #1a4d2e;
  --price-2: #2d7a4a;
  --price-3: #5aad6e;
  --price-4: #9fd48c;
  --price-5: #e8e870;
  --price-6: #f0c040;
  --price-7: #e88830;
  --price-8: #d84020;
  --price-9: #a01010;

  /* Glass effect */
  --glass-bg: rgba(15, 22, 41, 0.7);
  --glass-border: rgba(212, 168, 83, 0.15);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --glass-blur: blur(20px);

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-gold: var(--gold-400);

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;

  /* Sidebar */
  --sidebar-width: 260px;
  --header-height: 64px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--navy-900);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--gold-400); text-decoration: none; transition: color var(--duration-fast) var(--ease-out); }
a:hover { color: var(--gold-300); }

img { max-width: 100%; height: auto; display: block; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--navy-800); }
::-webkit-scrollbar-thumb { background: var(--navy-400); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--gold-600); }

/* --- Layout Shell --- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--navy-800);
  border-right: 1px solid var(--glass-border);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform var(--duration-normal) var(--ease-out);
}

.sidebar-logo {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.sidebar-logo img {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
}

.sidebar-logo h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.sidebar-logo span {
  font-size: 0.7rem;
  color: var(--gold-400);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-md) 0;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  padding: var(--space-lg) var(--space-lg) var(--space-sm);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-lg);
  margin: 2px var(--space-sm);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--duration-fast) var(--ease-out);
  cursor: pointer;
}

.nav-link:hover {
  background: var(--navy-600);
  color: var(--text-primary);
}

.nav-link.active {
  background: linear-gradient(135deg, rgba(212, 168, 83, 0.15), rgba(212, 168, 83, 0.05));
  color: var(--gold-400);
  border-left: 3px solid var(--gold-500);
}

.nav-link .icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding: var(--space-lg);
  border-top: 1px solid var(--glass-border);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* Main content */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
}

.page-header {
  padding: var(--space-lg) var(--space-2xl);
  border-bottom: 1px solid var(--glass-border);
  background: var(--navy-800);
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.page-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.page-header .breadcrumb {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.page-body {
  padding: var(--space-2xl);
}

/* --- Glass Card --- */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  transition: all var(--duration-normal) var(--ease-out);
}

.glass-card:hover {
  border-color: rgba(212, 168, 83, 0.3);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.card-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.card-body {
  padding: var(--space-lg);
}

/* --- KPI Cards --- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg);
}

.kpi-card {
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold-500), var(--gold-300));
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
}

.kpi-card:hover::before {
  opacity: 1;
}

.kpi-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.kpi-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: var(--space-xs);
}

.kpi-value.gold { color: var(--gold-400); }

.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.kpi-trend.up {
  color: var(--success);
  background: var(--success-dim);
}

.kpi-trend.down {
  color: var(--danger);
  background: var(--danger-dim);
}

.kpi-trend.neutral {
  color: var(--warning);
  background: var(--warning-dim);
}

.kpi-icon {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  font-size: 2rem;
  opacity: 0.15;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-500), var(--gold-600));
  color: var(--navy-900);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--gold-400), var(--gold-500));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(212, 168, 83, 0.3);
}

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

.btn-ghost:hover {
  background: var(--navy-600);
  color: var(--text-primary);
}

.btn-sm { padding: 4px 10px; font-size: 0.75rem; }

/* --- Tags / Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-gold { background: rgba(212, 168, 83, 0.2); color: var(--gold-400); }
.badge-success { background: var(--success-dim); color: var(--success); }
.badge-danger { background: var(--danger-dim); color: var(--danger); }
.badge-info { background: var(--info-dim); color: var(--info); }

/* --- Tables --- */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.data-table th {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--glass-border);
}

.data-table td {
  padding: var(--space-sm) var(--space-md);
  font-size: 0.875rem;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--duration-fast) var(--ease-out);
}

.data-table tbody tr:hover {
  background: rgba(212, 168, 83, 0.05);
}

/* --- Hero Banner --- */
.hero {
  position: relative;
  height: 320px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-2xl);
}

.hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(10, 14, 26, 0.85) 0%, rgba(10, 14, 26, 0.4) 60%, transparent 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--space-2xl);
}

.hero-title {
  font-size: 2.2rem;
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: var(--space-sm);
}

.hero-title .gold { color: var(--gold-400); }

.hero-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 500px;
}

/* --- Ticker --- */
.ticker-wrap {
  overflow: hidden;
  background: var(--navy-800);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) 0;
  margin-bottom: var(--space-2xl);
}

.ticker {
  display: flex;
  animation: ticker-scroll 40s linear infinite;
  white-space: nowrap;
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0 var(--space-xl);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.ticker-item .commune { color: var(--text-primary); font-weight: 600; }
.ticker-item .price { color: var(--gold-400); font-weight: 700; }
.ticker-item .trend-up { color: var(--success); }
.ticker-item .trend-down { color: var(--danger); }

@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* --- Filters Panel --- */
.filters-panel {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--navy-800);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-2xl);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.filter-group label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.filter-group select,
.filter-group input {
  background: var(--navy-700);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-out);
  min-width: 160px;
}

.filter-group select:focus,
.filter-group input:focus {
  border-color: var(--gold-500);
}

.filter-group select option {
  background: var(--navy-700);
}

/* --- Chart Container --- */
.chart-container {
  position: relative;
  width: 100%;
  padding: var(--space-md);
}

.chart-container canvas {
  width: 100% !important;
}

/* --- Grid Layouts --- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-lg);
}

/* --- Map --- */
.map-container {
  width: 100%;
  height: calc(100vh - var(--header-height) - 2 * var(--space-2xl));
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--glass-border);
}

.map-sidebar {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  z-index: 1000;
  width: 280px;
  max-height: calc(100% - 2 * var(--space-md));
  overflow-y: auto;
}

.layer-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  transition: background var(--duration-fast);
  border-radius: var(--radius-sm);
}

.layer-toggle:hover {
  background: var(--navy-600);
}

.layer-toggle input[type="checkbox"] {
  accent-color: var(--gold-500);
  width: 16px;
  height: 16px;
}

.legend-bar {
  display: flex;
  height: 12px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: var(--space-sm) 0;
}

.legend-bar div {
  flex: 1;
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* --- LinkedIn Feed --- */
.linkedin-feed {
  max-width: 680px;
  margin: 0 auto;
}

.linkedin-post {
  margin-bottom: var(--space-lg);
  animation: fadeInUp 0.5s var(--ease-out) forwards;
  opacity: 0;
}

.linkedin-post.visible {
  opacity: 1;
}

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

.post-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  padding-bottom: 0;
}

.post-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--gold-500), var(--gold-700));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--navy-900);
  flex-shrink: 0;
}

.post-meta .post-author {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.post-meta .post-role {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.post-meta .post-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.post-content {
  padding: var(--space-md) var(--space-lg);
  font-size: 0.9rem;
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--text-secondary);
}

.post-hashtags {
  padding: 0 var(--space-lg);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.post-hashtags span {
  color: var(--info);
  font-size: 0.8rem;
  font-weight: 500;
}

.post-actions {
  display: flex;
  gap: var(--space-xl);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--glass-border);
  margin-top: var(--space-md);
}

.post-action {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--duration-fast);
}

.post-action:hover { color: var(--gold-400); }

/* --- Animations --- */
@keyframes pulse-gold {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 168, 83, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(212, 168, 83, 0); }
}

.pulse { animation: pulse-gold 2s ease-in-out infinite; }

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

.count-up { animation: countUp 0.6s var(--ease-out) forwards; }

/* --- Responsive --- */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-sm);
}

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .menu-toggle {
    display: block;
  }

  .page-body {
    padding: var(--space-lg);
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }

  .hero { height: 220px; }
  .hero-title { font-size: 1.5rem; }

  .filters-panel {
    flex-direction: column;
  }

  .filter-group select,
  .filter-group input {
    min-width: 100%;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .kpi-value {
    font-size: 1.5rem;
  }
}

/* --- Print --- */
@media print {
  .sidebar, .page-header, .menu-toggle { display: none !important; }
  .main-content { margin-left: 0; }
  body { background: white; color: black; }
  .glass-card { background: white; border: 1px solid #ddd; box-shadow: none; }
}

/* --- Utilities --- */
.text-gold { color: var(--gold-400); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.mt-1 { margin-top: var(--space-md); }
.mt-2 { margin-top: var(--space-xl); }
.mb-1 { margin-top: var(--space-md); }
.mb-2 { margin-bottom: var(--space-xl); }
.gap-1 { gap: var(--space-md); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none; }

/* Leaflet overrides for dark mode */
.leaflet-control-zoom a {
  background: var(--navy-700) !important;
  color: var(--text-primary) !important;
  border-color: var(--glass-border) !important;
}

.leaflet-popup-content-wrapper {
  background: var(--navy-700) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-md) !important;
  border: 1px solid var(--glass-border) !important;
  box-shadow: var(--glass-shadow) !important;
}

.leaflet-popup-tip {
  background: var(--navy-700) !important;
}

.leaflet-control-attribution {
  background: rgba(10, 14, 26, 0.8) !important;
  color: var(--text-muted) !important;
}

.leaflet-control-attribution a {
  color: var(--text-muted) !important;
}
