/* PoliSim 1.0 - Redesigned with Lightcyphers/Tibi aesthetic */

:root {
  /* Color Palette - Sophisticated minimalism */
  --black: #1a1a1a;
  --charcoal: #2d2d2d;
  --dark-gray: #4a4a4a;
  --medium-gray: #6b6b6b;
  --light-gray: #9a9a9a;
  --silver: #d4d4d4;
  --off-white: #f5f5f5;
  --white: #ffffff;

  /* Accent colors - muted, elegant */
  --taupe: #8b7355;
  --warm-gray: #a39383;
  --success: #4a7c59;
  --success-light: rgba(74, 124, 89, 0.1);
  --danger: #8b4049;
  --danger-light: rgba(139, 64, 73, 0.1);

  /* EU colors */
  --eu-blue: #003399;
  --eu-gold: #ffcc00;

  /* Functional */
  --text: var(--black);
  --text-muted: var(--medium-gray);
  --text-light: var(--light-gray);
  --border: var(--silver);
  --border-light: #e8e8e8;
  --bg: var(--off-white);
  --panel: var(--white);

  /* Sizing */
  --footer-h: 64px;
  --sidebar-w: 400px;
  --panel-handle-h: 56px;
}

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

/* Typography */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* DESKTOP LAYOUT */
.layout {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
  height: calc(100vh - var(--footer-h));
}

/* SIDEBAR */
.sidebar {
  background: var(--panel);
  border-left: 1px solid var(--border-light);
  overflow-y: auto;
  padding: 32px 28px;
  order: 2;
}

.panel-handle {
  display: none;
}

.panel-content {
  display: contents;
}

.sidebar-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-header h1 {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 8px;
}

.sidebar-header .subtitle {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.5;
}

.sidebar-header .header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s ease;
  border: 1px solid var(--border-light);
}

.btn-logout:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

/* CARDS */
.card {
  background: var(--panel);
  border: none;
  border-radius: 0;
  padding: 0;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-light);
}

.card:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
}

.card h2 {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 16px;
}

.card .hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  margin-bottom: 20px;
  margin-top: -8px;
}

.card .hint a {
  color: var(--taupe);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.card .hint a:hover {
  border-bottom-color: var(--taupe);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.stat {
  background: transparent;
  padding: 0;
}

.stat-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 20px;
  font-weight: 300;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* Result rows */
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.result-row:last-child {
  border-bottom: none;
}

.result-label {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
}

.result-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.result-highlight {
  background: var(--off-white);
  margin: 16px -28px -24px;
  padding: 20px 28px;
  border-bottom: none;
}

.result-highlight .result-label {
  font-weight: 500;
  color: var(--text);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.1em;
}

.result-highlight .result-value {
  font-size: 18px;
  font-weight: 400;
  color: var(--black);
}

/* Trend Indicators */
.trend-value {
  font-weight: 500;
  transition: color 0.2s ease;
}

.trend-value.trend-up,
.result-highlight .trend-up {
  color: var(--success) !important;
}

.trend-value.trend-down,
.result-highlight .trend-down {
  color: var(--danger) !important;
}

.trend-value.trend-neutral,
.result-highlight .trend-neutral {
  color: var(--medium-gray) !important;
}

/* Validation Status */
.validation-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--off-white);
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

.validation-icon {
  font-size: 14px;
  width: 20px;
  text-align: center;
}

.validation-status.valid {
  background: var(--success-light);
  color: var(--success);
}

.validation-status.invalid {
  background: var(--danger-light);
  color: var(--danger);
}

.validation-status.valid .validation-icon {
  color: var(--success);
}

.validation-status.invalid .validation-icon {
  color: var(--danger);
}

/* Combined Bar */
.combined-bar {
  display: flex;
  height: 8px;
  overflow: hidden;
  margin: 12px 0 0;
}

.combined-bar[hidden] {
  display: none;
}

.bar-da {
  background: var(--eu-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  transition: width 0.4s ease;
}

.bar-nu {
  background: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  transition: width 0.4s ease;
}

/* Result combined highlight */
.result-combined {
  margin-bottom: 0;
  padding-bottom: 12px;
}

/* BUTTONS */
.btn {
  padding: 12px 24px;
  border-radius: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid var(--black);
  background: var(--panel);
  color: var(--text);
  transition: all 0.2s ease;
}

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

/* MAP CONTAINER */
.map-container {
  position: relative;
  height: 100%;
  order: 1;
}

#map {
  height: 100%;
  width: 100%;
}

/* MAP CONTROLS */
.map-control {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--border-light);
  border-radius: 0;
  padding: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  z-index: 1000;
}

/* Reset Button */
.reset-control {
  bottom: 24px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 12px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  overflow: hidden;
  width: 42px;
  height: 42px;
}

.reset-control:hover {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
  width: auto;
  padding: 12px 16px;
  gap: 8px;
}

.reset-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.reset-text {
  white-space: nowrap;
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: opacity 0.2s ease, width 0.2s ease;
  text-transform: uppercase;
}

.reset-control:hover .reset-text {
  opacity: 1;
  width: auto;
}

/* Measure Control */
.measure-control {
  bottom: 74px;
  left: 12px;
  display: none;
  align-items: center;
  gap: 0;
  padding: 12px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  overflow: hidden;
  width: 42px;
  height: 42px;
}

.measure-control:hover {
  width: auto;
  padding: 12px 16px;
  gap: 8px;
}

.measure-control.measuring {
  width: auto;
  height: auto;
  padding: 12px 16px;
  gap: 10px;
  flex-direction: column;
  align-items: stretch;
}

.measure-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: inherit;
  cursor: pointer;
  padding: 0;
}

.measure-control:hover,
.measure-control.measuring {
  color: var(--danger);
}

.measure-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.measure-label {
  white-space: nowrap;
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: opacity 0.2s ease, width 0.2s ease;
  text-transform: uppercase;
}

.measure-control:hover .measure-label,
.measure-control.measuring .measure-label {
  opacity: 1;
  width: auto;
}

.measure-result {
  display: none;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}

.measure-control.measuring .measure-result {
  display: flex;
}

.measure-distance {
  font-size: 14px;
  font-weight: 500;
  color: var(--danger);
  flex: 1;
}

.measure-clear {
  background: transparent;
  border: none;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
}

.measure-clear:hover {
  color: var(--danger);
}

.measure-marker {
  width: 20px;
  height: 20px;
  background: var(--danger);
  color: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  border: 2px solid var(--white);
}

/* Search Control */
.search-control {
  top: 12px;
  left: 60px;
  width: 280px;
  padding: 14px 16px;
}

.search-label {
  display: block;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 10px;
}

.search-control input {
  width: 100%;
  padding: 10px 0;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  font-size: 14px;
  font-weight: 400;
  background: transparent;
  color: var(--text);
  transition: border-color 0.2s;
}

.search-control input:focus {
  outline: none;
  border-bottom-color: var(--black);
}

.search-control input::placeholder {
  color: var(--text-light);
}

.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--border-light);
  margin-top: 4px;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.suggestion-item {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 400;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s;
}

.suggestion-item:hover,
.suggestion-item.selected {
  background: var(--black);
  color: var(--white);
}

.suggestion-item:last-child {
  border-bottom: none;
}

/* Legend */
.legend-control.legend-desktop {
  display: none;
}

.legend-title {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text);
  margin-top: 8px;
}

.swatch {
  width: 16px;
  height: 16px;
  border-radius: 0;
  border: none;
}

/* Mini Legend */
.legend-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: var(--panel);
  border: 1px solid var(--border-light);
  padding: 10px 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  cursor: pointer;
}

.legend-mini-dots {
  display: flex;
  gap: 6px;
}

.mini-dot {
  width: 12px;
  height: 12px;
  border-radius: 0;
  border: none;
}

.legend-mini-expand {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  transition: color 0.2s;
}

.legend-mini-expand:hover {
  color: var(--text);
}

/* Legend Overlay */
.legend-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.legend-overlay:not([hidden]) {
  display: flex;
}

.legend-overlay-content {
  background: var(--panel);
  padding: 28px;
  width: 100%;
  max-width: 280px;
  animation: fadeIn 0.2s ease;
}

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

.legend-overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.legend-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}

.legend-close:hover {
  color: var(--text);
}

/* Info Button (for Media voturi, Tendință) */
.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  vertical-align: middle;
  transition: all 0.2s ease;
}

.info-btn:hover {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
}

/* Info Overlay (Modal) */
.info-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.info-overlay:not([hidden]) {
  display: flex;
}

.info-overlay-content {
  background: var(--panel);
  padding: 28px;
  width: 100%;
  max-width: 360px;
  animation: fadeIn 0.2s ease;
}

.info-overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.info-title {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text);
}

.info-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}

.info-close:hover {
  color: var(--text);
}

.info-body {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}

.info-body p {
  margin-bottom: 12px;
}

.info-body p:last-child {
  margin-bottom: 0;
}

.info-formula {
  margin-top: 16px;
  margin-bottom: 8px !important;
}

.info-formula-code {
  background: var(--off-white);
  padding: 12px 16px;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  font-size: 12px;
  color: var(--charcoal);
  border-left: 3px solid var(--taupe);
}

.info-note {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--off-white);
  font-size: 12px;
  color: var(--text-muted);
}

.info-note .trend-up {
  color: var(--success);
  font-weight: 500;
}

.info-note .trend-down {
  color: var(--danger);
  font-weight: 500;
}

.info-note .trend-neutral {
  color: var(--medium-gray);
  font-weight: 500;
}

/* Panel Footer */
.panel-footer {
  display: none;
}

/* FOOTER (Desktop) */
.footer {
  background: var(--black);
  color: var(--white);
  padding: 20px 32px;
  min-height: var(--footer-h);
  display: flex;
  align-items: center;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
}

.disclaimer {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.6;
  opacity: 0.7;
}

.disclaimer strong {
  font-weight: 500;
}

.disclaimer a {
  color: var(--white);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  transition: border-color 0.2s;
}

.disclaimer a:hover {
  border-bottom-color: var(--white);
}

/* HOVER POPUP */
.hover-popup .maplibregl-popup-content {
  background: var(--panel);
  border: 1px solid var(--border-light);
  border-radius: 0;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 400;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  color: var(--text);
}

.hover-popup .maplibregl-popup-tip {
  border-top-color: var(--panel);
}

/* MapLibre Controls Override */
.maplibregl-ctrl-group {
  background: var(--panel);
  border: 1px solid var(--border-light);
  border-radius: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.maplibregl-ctrl-group button {
  width: 36px;
  height: 36px;
}

.maplibregl-ctrl-group button + button {
  border-top: 1px solid var(--border-light);
}

/* MOBILE RESPONSIVE */
@media (max-width: 900px) {
  :root {
    --footer-h: 0px;
  }

  body {
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
  }

  .layout {
    display: block;
    height: 100vh;
    height: 100dvh;
    position: relative;
  }

  .map-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    height: 100dvh;
    z-index: 1;
  }

  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 85vh;
    max-height: calc(100vh - 80px);
    z-index: 100;
    border-left: none;
    border-top: 1px solid var(--border-light);
    padding: 0;
    overflow: hidden;
    transform: translateY(calc(100% - var(--panel-handle-h)));
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
  }

  .sidebar.panel-half {
    transform: translateY(50%);
  }

  .sidebar.panel-full {
    transform: translateY(0);
  }

  .sidebar.dragging {
    transition: none;
  }

  .panel-handle {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 20px 10px;
    cursor: grab;
    background: var(--panel);
    touch-action: none;
  }

  .panel-handle:active {
    cursor: grabbing;
  }

  .handle-bar {
    width: 36px;
    height: 3px;
    background: var(--border);
    margin-bottom: 10px;
  }

  .handle-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text);
  }

  .badge-arrow {
    transition: transform 0.3s;
    font-size: 10px;
  }

  .sidebar.panel-full .badge-arrow {
    transform: rotate(180deg);
  }

  .badge-count {
    background: var(--black);
    color: var(--white);
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 500;
  }

  .badge-count:empty {
    display: none;
  }

  .panel-content {
    display: block;
    height: calc(100% - var(--panel-handle-h));
    overflow-y: auto;
    padding: 0 20px 24px;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar-header {
    padding-top: 8px;
  }

  .sidebar-header h1 {
    font-size: 10px;
  }

  .card {
    margin-bottom: 24px;
    padding-bottom: 20px;
  }

  .stat-value {
    font-size: 18px;
  }

  .panel-footer {
    display: block;
    padding: 20px 0;
    margin-top: 20px;
    border-top: 1px solid var(--border-light);
  }

  .panel-footer .disclaimer {
    font-size: 11px;
    color: var(--text-muted);
  }

  .panel-footer .disclaimer a {
    color: var(--text);
  }

  .footer-desktop {
    display: none;
  }

  /* Mobile Map Controls */
  .reset-control {
    top: auto;
    bottom: calc(var(--panel-handle-h) + 16px);
    left: 12px;
    width: 42px;
    height: 42px;
    padding: 12px;
  }

  .reset-control:hover {
    width: 42px;
    padding: 12px;
    gap: 0;
    background: var(--panel);
    color: var(--text);
    border-color: var(--border-light);
  }

  .reset-control:active {
    background: var(--black);
    color: var(--white);
    border-color: var(--black);
  }

  .reset-text {
    display: none;
  }

  .search-control {
    top: 12px;
    left: 60px;
    right: 12px;
    width: auto;
    padding: 10px 14px;
  }

  .search-label {
    display: none;
  }

  .search-control input {
    padding: 12px 0;
    font-size: 16px;
  }

  .maplibregl-ctrl-top-left {
    top: 12px;
    left: 12px;
  }

  .maplibregl-ctrl-top-left .maplibregl-ctrl {
    margin: 0;
  }

  .legend-mini {
    position: fixed;
    bottom: calc(var(--panel-handle-h) + 16px);
  }

  .legend-overlay {
    align-items: flex-end;
    padding: 20px;
  }

  .legend-overlay-content {
    max-width: 320px;
    animation: slideUp 0.3s ease;
  }

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

  /* Info overlay mobile */
  .info-overlay {
    align-items: flex-end;
    padding: 20px;
  }

  .info-overlay-content {
    max-width: 100%;
    animation: slideUp 0.3s ease;
  }

  .sidebar.panel-half ~ .map-container .legend-mini,
  .sidebar.panel-full ~ .map-container .legend-mini {
    bottom: calc(50vh + 16px);
  }

  .sidebar.panel-half ~ .map-container .reset-control,
  .sidebar.panel-full ~ .map-container .reset-control {
    bottom: calc(50vh + 16px);
  }
}

@media (max-width: 400px) {
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stat-value {
    font-size: 18px;
  }

  .search-control {
    left: 56px;
    right: 8px;
  }
}
