/* ============================================================
   Divvy Analytics Dashboard - Premium Dark Theme
   ============================================================ */

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

:root {
  /* Palette - vibrant gradients on deep dark */
  --indigo: #6366f1;
  --cyan: #06b6d4;
  --violet: #8b5cf6;
  --rose: #f43f5e;
  --amber: #f59e0b;
  --emerald: #10b981;
  --sky: #38bdf8;

  /* Chart colors: colorblind-safe, high contrast */
  --c-member: #6366f1;
  --c-casual: #f59e0b;
  --c-electric: #d946ef;
  --c-classic: #f59e0b;
  --c-docked: #8b5cf6;

  /* Surfaces */
  --bg-base: #09090b;
  --bg-surface: #111114;
  --bg-card: rgba(17, 17, 20, 0.75);
  --bg-card-hover: rgba(24, 24, 30, 0.9);
  --bg-glass: rgba(255, 255, 255, 0.03);

  /* Borders & lines */
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --grid-line: rgba(255, 255, 255, 0.05);

  /* Text */
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;

  /* Spacing & shapes */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;

  /* Glow */
  --glow-indigo: 0 0 60px -12px rgba(99, 102, 241, 0.35);
  --glow-cyan: 0 0 60px -12px rgba(6, 182, 212, 0.3);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.15);
  --shadow-card-hover: 0 4px 12px rgba(0,0,0,0.4), 0 16px 48px rgba(0,0,0,0.25);

  /* Transition */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Base --- */
html {
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-width: 0;
}

/* Noise removed: feTurbulence SVG filter repainted the full viewport every frame */

/* --- Header --- */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(9, 9, 11, 0.92);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1.5rem;
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.header-brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  text-align: center;
}

.brand-link.header-company {
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--casual);
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.brand-link.header-company:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.header-project {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.01em;
}

.header-subtitle {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-light);
}

.header-divider {
  color: rgba(255, 255, 255, 0.15);
  font-weight: 900;
  font-size: 0.8rem;
}


.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 500;
  border-radius: 100px;
  background: rgba(16, 185, 129, 0.1);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.2);
  white-space: nowrap;
}

/* --- Main --- */
main {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
  min-width: 0;
}

/* --- KPI Row --- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: background-color 0.3s var(--ease), border-color 0.3s var(--ease), transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
  cursor: default;
}

.kpi-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.kpi-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.kpi-icon svg {
  width: 20px;
  height: 20px;
}

.kpi-icon-trips    { background: rgba(99, 102, 241, 0.12); color: var(--indigo); }
.kpi-icon-stations { background: rgba(6, 182, 212, 0.12);  color: var(--cyan); }
.kpi-icon-member   { background: rgba(139, 92, 246, 0.12); color: var(--violet); }
.kpi-icon-duration { background: rgba(245, 158, 11, 0.12); color: var(--amber); }
.kpi-icon-peak     { background: rgba(244, 63, 94, 0.12);  color: var(--rose); }

.kpi-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.kpi-value {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  white-space: nowrap;
}

.kpi-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* --- Chart Grid --- */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

/* --- Card --- */
.card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 1.25rem 1.35rem 1rem;
  min-width: 0;
  overflow: hidden;
  transition: border-color 0.35s var(--ease), transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}

.card:hover {
  border-color: var(--indigo);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.card-wide {
  grid-column: 1 / -1;
}

/* Vertical and Tall layout for top stations and map side-by-side */
.card-vertical-layout {
  height: 600px;
  display: flex;
  flex-direction: column;
}

.card-vertical-layout .chart-wrap {
  height: 500px;
}

.card-vertical-layout #map, .card-vertical-layout #map-extreme {
  height: 500px;
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  z-index: 1;
  background: #0c0c0f;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.card h2 {
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.card-desc {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  line-height: 1.4;
}

.card-insight {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.5rem;
  width: fit-content;
}

.chart-wrap {
  position: relative;
  height: 260px;
  width: 100%;
  min-width: 0;
}

.chart-wrap > canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.growth-bar-tooltip {
  display: none;
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  background: rgba(17, 17, 20, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.45;
  color: #e4e4e7;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.growth-bar-tooltip .growth-tip-title {
  font-weight: 600;
  font-size: 12px;
  color: #fafafa;
  margin-bottom: 2px;
}

.growth-bar-tooltip .growth-tip-value {
  color: #a1a1aa;
}

/* --- Station growth tables --- */
.growth-tables {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.growth-table-wrap {
  min-width: 0;
}

.growth-table-title {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 0.5rem;
}

.growth-table-title-up { color: #10b981; }
.growth-table-title-down { color: #f43f5e; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.74rem;
}

.data-table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 0.5rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  vertical-align: top;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: rgba(99, 102, 241, 0.05);
}

.data-table .col-rank {
  width: 2rem;
  color: var(--text-muted);
}

.data-table .col-station {
  color: var(--text-primary);
  font-weight: 500;
  line-height: 1.35;
}

.data-table .col-pct {
  font-weight: 600;
  white-space: nowrap;
}

.data-table .col-pct.positive { color: #10b981; }
.data-table .col-pct.negative { color: #f43f5e; }

.data-table .col-num {
  white-space: nowrap;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .growth-tables {
    grid-template-columns: 1fr;
  }
}

.station-select {
  flex-shrink: 0;
  max-width: 280px;
  width: 100%;
  padding: 0.45rem 0.65rem;
  font-size: 0.74rem;
  font-family: inherit;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  outline: none;
}

.station-select:hover,
.station-select:focus {
  border-color: var(--indigo);
}

@media (max-width: 768px) {
  .card-header {
    flex-wrap: wrap;
  }

  .station-select {
    max-width: 100%;
  }
}

.chart-wrap-lg {
  height: 300px;
}

.chart-wrap-tall {
  height: 420px;
}

/* --- Map --- */
#map, #map-extreme {
  height: 480px;
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  z-index: 1;
  background: #0c0c0f;
}

.map-legend-inline {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.8rem;
  flex-shrink: 0;
  width: 220px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-bubble {
  border-radius: 50%;
  border: 1.5px solid var(--border-hover);
  background: transparent;
  display: inline-block;
  flex-shrink: 0;
}

.legend-label-text {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Leaflet popup override */
.leaflet-popup-content-wrapper {
  background: rgba(17, 17, 20, 0.98);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.leaflet-popup-tip {
  background: rgba(17, 17, 20, 0.95);
}

.leaflet-popup-content {
  margin: 10px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  line-height: 1.5;
}

.leaflet-popup-content strong {
  color: var(--cyan);
  font-weight: 600;
}

/* --- Scroll animation --- */
.animate-in {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

.animate-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Footer --- */
footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  padding: 1.5rem 1.5rem 2rem;
}

.footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  text-align: center;
}

footer p {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.footer-sub {
  margin-top: 0.25rem;
  opacity: 0.6;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
  .kpi-row {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .chart-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.85rem;
  }

  .card-wide {
    grid-column: 1;
  }

  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
    margin-bottom: 1rem;
  }

  .kpi-card {
    padding: 0.75rem 0.85rem;
  }

  .kpi-icon {
    width: 34px;
    height: 34px;
  }

  .kpi-icon svg {
    width: 16px;
    height: 16px;
  }

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

  header, main, footer {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }

  h1 {
    font-size: 1rem;
  }

  .subtitle {
    font-size: 0.72rem;
  }

  .header-badge {
    display: none;
  }

  .card {
    padding: 1rem 1rem 0.85rem;
  }

  .chart-wrap {
    height: 230px;
  }

  .chart-wrap-lg {
    height: 260px;
  }

  .chart-wrap-tall {
    height: 360px;
  }

  #map, #map-extreme {
    height: 340px;
  }

  .map-legend-inline {
    display: none;
  }
}

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

  header, main {
    padding-left: 0.65rem;
    padding-right: 0.65rem;
  }

  .chart-wrap {
    height: 200px;
  }

  .chart-wrap-lg {
    height: 230px;
  }

  .chart-wrap-tall {
    height: 300px;
  }

  #map, #map-extreme {
    height: 280px;
  }

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

/* --- Map Controls Overlay Panel --- */
.map-controls {
  position: absolute;
  bottom: 20px;
  left: 20px;
  z-index: 1000;
  background: rgba(12, 12, 15, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  width: 270px;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  pointer-events: auto;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.control-group label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-light);
  display: flex;
  justify-content: space-between;
}

.control-group label span {
  color: var(--indigo);
  font-weight: 700;
}

.control-group input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  margin: 4px 0;
}

.control-group input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--indigo);
  cursor: pointer;
  transition: transform 0.1s, background-color 0.1s;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  background-color: var(--cyan);
}

/* --- Pill Selector --- */
.pill-selector {
  display: flex;
  background: #18181b;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px;
  gap: 2px;
}

.pill-btn {
  background: transparent;
  border: none;
  border-radius: 18px;
  padding: 4px 12px;
  color: var(--text-light);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pill-btn:hover {
  color: var(--text);
}

.pill-btn.active {
  background: var(--indigo);
  color: #fff;
}


