/**
 * FCD·Analytics WebGIS Prototyp - Globales Stylesheet
 * Farbschema: Primär #1A3C5E, Akzent #F4A300, Hintergrund #F5F7FA
 */

/* Google Material Symbols */
/* Icon-Schrift liegt lokal: Nach dem Deploy hinter
   WireGuard ist Google nicht erreichbar, und bis dahin
   soll die Oberflaeche nicht bei jedem Aufruf einen
   Dritten anfunken. Apache-2.0-Lizenz, Selbsthosten ist
   ausdruecklich erlaubt. */
@import url("../vendor/material-symbols.0213d42b7be2.css");

/* Icon helper class for Material Symbols */
.material-symbols-outlined {
  font-family: "Material Symbols Outlined";
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  vertical-align: middle;
}

/* ============================================================
   CSS VARIABLEN & RESET
   ============================================================ */
:root {
  --primary: #1a3c5e;
  --primary-light: #2a5080;
  --primary-dark: #0f2840;
  --accent: #f4a300;
  --accent-hover: #e09500;
  --bg-main: #f5f7fa;
  --bg-card: #ffffff;
  --bg-sidebar: #2c2c2c;
  --bg-topbar: #ffffff;
  --text-primary: #2c3e50;
  --text-secondary: #6b7c93;
  --text-light: #ffffff;
  --border-color: #e1e8ed;

  /* Ampelfarben */
  --green: #2ecc71;
  --yellow: #f39c12;
  --red: #e74c3c;
  --dark-red: #8b0000;

  /* Layout */
  --sidebar-width: 260px;
  --topbar-height: 60px;
  --timebar-height: 80px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    Cantarell, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-main);
}

/* ============================================================
   TYPOGRAFIE
   ============================================================ */
h1 {
  font-size: 2rem;
  font-weight: 700;
}
h2 {
  font-size: 1.5rem;
  font-weight: 600;
}
h3 {
  font-size: 1.25rem;
  font-weight: 600;
}
h4 {
  font-size: 1rem;
  font-weight: 600;
}

.text-accent {
  color: var(--accent);
}
.text-muted {
  color: var(--text-secondary);
}
.text-light {
  color: var(--text-light);
}

/* ============================================================
   LAYOUT - TOPBAR
   ============================================================ */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
}

.topbar-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.topbar-logo span {
  color: var(--accent);
}

.topbar-actions {
  display: flex;
  gap: 12px;
}

/* ============================================================
   LAYOUT - SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--topbar-height));
  background: var(--bg-sidebar);
  color: var(--text-light);
  overflow-y: auto;
  z-index: 900;
}

.sidebar-nav {
  padding: 16px 0;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.5);
  padding: 8px 20px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-light);
}

.nav-item.active {
  background: rgba(244, 163, 0, 0.2);
  border-left: 3px solid var(--accent);
  color: var(--text-light);
}

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

/* ============================================================
   LAYOUT - HAUPTBEREICH
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  min-height: calc(100vh - var(--topbar-height));
  padding: 24px;
}

.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

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

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

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

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-outline:hover {
  background: var(--bg-main);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* Active state for comparison button */
#btn-compare.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#btn-compare.active:hover {
  background: var(--accent-hover);
}

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
}

/* ============================================================
   CARDS & PANELS
   ============================================================ */
.card {
  background: var(--bg-card);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  padding: 20px;
}

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

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

/* ============================================================
   KPI KACHELN
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.kpi-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.kpi-unit {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-secondary);
}

/* ============================================================
   FORMULARE
   ============================================================ */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.form-input,
.form-select {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-primary);
  transition: border-color 0.2s ease;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

/* ============================================================
   TABLES
   ============================================================ */
.table-container {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.875rem;
  background: var(--bg-main);
}

.data-table tr:hover td {
  background: rgba(26, 60, 94, 0.03);
}

/* ============================================================
   TABS
   ============================================================ */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 24px;
}

.tab-btn {
  padding: 12px 24px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

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

.tab-btn.active {
  color: var(--primary);
}

.tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
}

.badge-low {
  background: rgba(46, 204, 113, 0.15);
  color: var(--green);
}
.badge-medium {
  background: rgba(243, 156, 18, 0.15);
  color: var(--yellow);
}
.badge-high {
  background: rgba(231, 76, 60, 0.15);
  color: var(--red);
}
.badge-congested {
  background: rgba(139, 0, 0, 0.15);
  color: var(--dark-red);
}

.badge-recommended {
  background: var(--accent);
  color: var(--primary-dark);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
}

.toast {
  background: var(--text-primary);
  color: var(--text-light);
  padding: 14px 20px;
  border-radius: 8px;
  margin-top: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast-success {
  background: var(--green);
}
.toast-error {
  background: var(--red);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal-overlay.show .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
}

/* ============================================================
   MAP PAGE SPECIFIC
   ============================================================ */
.map-container {
  position: fixed;
  top: var(--topbar-height);
  left: var(--sidebar-width);
  right: 0;
  bottom: var(--timebar-height);
}

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

/* Sidebar Panel für Map */
.sidebar-panel {
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.panel-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 12px;
}

/* Layer Control */
.layer-control {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.layer-control input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.layer-label {
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
}

/* Detail Panel */
.detail-panel {
  padding: 16px;
  background: rgba(0, 0, 0, 0.2);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.detail-label {
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
}

.detail-value {
  color: var(--text-light);
  font-weight: 500;
}

/* Zeitnavigation */
.time-bar {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--timebar-height);
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}

.time-display {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary);
  min-width: 280px;
}

.time-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.time-btn {
  min-width: 50px;
  padding: 6px 12px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.time-btn:hover {
  background: var(--bg-main);
}

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

/* Leaflet Legend */
.legend {
  background: rgba(255, 255, 255, 0.95);
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.legend-title {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  padding: 3px 0;
}

.legend-color {
  width: 20px;
  height: 4px;
  border-radius: 2px;
}

/* ============================================================
   LANDING PAGE
   ============================================================ */
.hero {
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-dark) 100%
  );
  color: white;
  padding: 80px 40px;
  text-align: center;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 16px;
}

.hero p {
  font-size: 1.125rem;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto 32px;
}

/* Features */
.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  padding: 48px 40px;
}

.feature-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.feature-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.feature-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 8px;
}

/* Pricing */
.pricing {
  background: var(--bg-main);
  padding: 48px 40px;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  max-width: 1000px;
  margin: 32px auto 0;
}

.pricing-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  position: relative;
}

.pricing-card.recommended {
  border: 2px solid var(--accent);
  transform: scale(1.05);
}

.pricing-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.pricing-price {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
}

.pricing-features {
  list-style: none;
  text-align: left;
  margin-top: 20px;
}

.pricing-features li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
}

/* Footer */
.footer {
  background: var(--primary-dark);
  color: white;
  padding: 32px 40px;
  text-align: center;
}

.footer-partners {
  display: flex;
  justify-content: center;
  gap: 48px;
  margin-top: 16px;
  font-size: 14px;
  opacity: 0.8;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-container {
  min-height: calc(100vh - var(--topbar-height));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.login-card {
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 450px;
  padding: 40px;
}

.login-tabs {
  display: flex;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
}

.login-tab {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
}

.login-tab.active {
  color: var(--primary);
}

.login-tab.active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
}

.login-form,
.register-form {
  display: none;
}

.login-form.active,
.register-form.active {
  display: block;
}

.security-note {
  text-align: center;
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ============================================================
   ANALYSIS PAGE
   ============================================================ */
.filter-bar {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.chart-card {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.chart-container {
  position: relative;
  height: 280px;
}

/* ============================================================
   EXPORT PAGE
   ============================================================ */
.export-layout {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 24px;
}

.preview-panel {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.report-preview {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 24px;
}

.preview-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--primary);
}

.preview-logo {
  font-weight: 700;
  color: var(--primary);
}

.preview-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.preview-map-placeholder {
  background: #e8e8e8;
  height: 200px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.preview-kpi-table {
  width: 100%;
  margin: 16px 0;
}

.preview-footer {
  text-align: center;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  font-size: 12px;
  color: var(--text-secondary);
}

/* ============================================================
   ACCOUNT PAGE
   ============================================================ */
.account-section {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
}

.usage-bar {
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.usage-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.api-key-display {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-main);
  padding: 12px 16px;
  border-radius: 6px;
  font-family: monospace;
}

/* ============================================================
   USE CASE CARDS (Dashboard)
   ============================================================ */
.usecase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.usecase-card {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.usecase-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.usecase-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.usecase-name {
  font-weight: 500;
}

/* ============================================================
   RESPONSIVE (Desktop First - nur für kleinere Bildschirme)
   ============================================================ */
@media (max-width: 1400px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }

  .export-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1200px) {
  .features,
  .pricing-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.flex {
  display: flex;
}
.flex-col {
  flex-direction: column;
}
.items-center {
  align-items: center;
}
.justify-between {
  justify-content: space-between;
}
.gap-8 {
  gap: 8px;
}
.gap-16 {
  gap: 16px;
}
.mt-16 {
  margin-top: 16px;
}
.mb-16 {
  margin-bottom: 16px;
}
.p-16 {
  padding: 16px;
}
.w-full {
  width: 100%;
}

/* Satzspiegelbreite fuer den Druck.
   A4 hoch sind 210 mm, abzueglich der Seitenraender aus @page bleiben
   188 mm — bei 96 dpi rund 710 px.

   Die Regel steht bewusst **ausserhalb** von `@media print`: Gesetzt
   wird die Klasse von `druckAufraeumen()` am `beforeprint`, und zu dem
   Zeitpunkt gilt noch das Bildschirm-Layout. Stuende sie im Druckblock,
   maessen Chart.js und MapLibre beim anschliessenden Neuzeichnen wieder
   die Bildschirmbreite — und genau das schnitt Karte und Diagramme im
   PDF rechts ab. `afterprint` nimmt die Klasse wieder zurueck. */
.druckbreite {
  width: 700px !important;
  max-width: 700px !important;
  overflow: hidden;
}

/* ---------------------------------------------------------------- Druck
   Ein Report soll die Auswertung zeigen, nicht die Anwendung. Ohne
   diese Regeln standen Seitenleiste und Kopfleiste auf jedem Blatt des
   PDF und nahmen ein Drittel der Breite; der Inhalt rutschte um die
   Seitenleistenbreite nach rechts aus dem Satzspiegel.

   Die Klasse `.no-print` wird auf mehreren Seiten fuer Bedienelemente
   vergeben — sie gehoert hierher, damit sie ueberall wirkt und nicht
   je Vorlage neu erklaert werden muss. */
@media print {
  .topbar,
  .sidebar,
  #toast-container,
  .no-print {
    display: none !important;
  }

  .main-content {
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
  }

  /* Zoomknoepfe und Kompass sind Bedienelemente einer Karte, die auf
     Papier niemand bedienen kann. */
  .maplibregl-ctrl,
  .maplibregl-ctrl-group {
    display: none !important;
  }

  /* Fangnetz, falls doch etwas breiter bleibt — lieber verkleinert als
     abgeschnitten. */
  canvas,
  img,
  .chart-container,
  #ana-map {
    max-width: 100% !important;
  }
}
