/* MoversSurvey design tokens — SINGLE SOURCE OF TRUTH for brand colour.
 *
 * Rules (see .ai/INSTRUCTIONS.md §8):
 *  - MovingLayers purple is the only brand hue. Lime (--ms-signal) is for
 *    SIGNALLING ONLY (status emphasis), never a button or large surface.
 *  - Keep the portal near-colourless so map styles carry the colour.
 *  - Never inline hex in addon components/CSS — read these custom properties.
 *  - OL canvas colours (RGBA arrays in style_v3.json) are the one documented
 *    exception: #511A3F == [81, 26, 63].
 */

/* Brand wordmark typeface — ABC Gravity (Dinamo, licensed by MovingLayers), the
 * same font the mobile-app login screen uses so the wordmark reads identically
 * across the field app and this WebGIS. One weight ships ("Normal" == 400). The
 * .otf lives in resources/fonts/ (copied into the served portal by `npm run
 * sync`); the src url is relative to this file at resources/styles/. */
@font-face {
  font-family: "ABC Gravity";
  src: url("../fonts/ABCGravity-Normal.otf") format("opentype");
  font-weight: 400;
  font-display: swap;
}

:root {
  /* Brand (from frontend/src/styles/variables.scss) */
  --ms-primary: #511A3F;
  --ms-primary-hover: #852565;
  --ms-primary-pressed: #5C0540;
  --ms-on-primary: #ffffff;
  /* Soft brand focus ring (primary at low alpha) */
  --ms-focus-ring: rgba(81, 26, 63, 0.18);

  /* Signalling only — never a button/background; reserved for status emphasis */
  --ms-signal: #C9F2CD;
  --ms-signal-strong: #A6F1AE;

  /* Neutral surfaces — kept near-colourless so map styles dominate */
  --ms-text: #2b2b2b;
  --ms-text-muted: #6b6b6b;
  --ms-bg: #ffffff;
  --ms-bg-muted: #f5f5f5;
  --ms-border: #e0e0e0;

  /* Semantic error (destructive/failed states) — not a brand hue */
  --ms-error: #b3261e;
  --ms-error-bg: #fbeae8;

  /* Status palette for DOM badges (OL canvas colours live in style_v3.json) */
  --ms-status-angelegt: #9e9e9e;
  --ms-status-geplant: #511A3F;
  --ms-status-in-durchfuehrung: #852565;
  --ms-status-abgeschlossen: #4a7a4a;
  --ms-status-freigegeben: #2b6e2b;
  --ms-status-archiviert: #bdbdbd;

  /* Spacing / radius / shadow — one calm shadow, gentle radii */
  --ms-space-xs: 4px;
  --ms-space-sm: 8px;
  --ms-space-md: 12px;
  --ms-space-lg: 16px;
  --ms-radius: 6px;
  --ms-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  --ms-transition: 0.3s ease;

  /* Brand wordmark font stack (see @font-face above); web-safe fallback matches
   * the login gate's default so the wordmark stays legible before the font loads. */
  --ms-font-brand: "ABC Gravity", -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ─── Brand accents driven only by the tokens above ─── */
#masterportal-root .mp-menu .title,
#masterportal-root .menu-navigation-content .title {
  color: var(--ms-primary);
}

.btn-primary,
#masterportal-root .btn-primary {
  background-color: var(--ms-primary);
  border-color: var(--ms-primary);
  color: var(--ms-on-primary);
  transition: background-color var(--ms-transition), border-color var(--ms-transition);
}

.btn-primary:hover,
#masterportal-root .btn-primary:hover {
  background-color: var(--ms-primary-hover);
  border-color: var(--ms-primary-hover);
}

.btn-primary:active,
#masterportal-root .btn-primary:active {
  background-color: var(--ms-primary-pressed);
  border-color: var(--ms-primary-pressed);
}

/* ─── Shared addon UI primitives (calm; one badge per item, semantic states) ─── */
.ms-panel {
  color: var(--ms-text);
  font-size: 14px;
}

.ms-card {
  background: var(--ms-bg);
  border: 1px solid var(--ms-border);
  border-radius: var(--ms-radius);
  padding: var(--ms-space-md);
  margin-bottom: var(--ms-space-sm);
  box-shadow: var(--ms-shadow);
  transition: border-color var(--ms-transition);
}

.ms-card.is-selected {
  border-color: var(--ms-primary);
}

.ms-card__title {
  font-weight: 600;
  color: var(--ms-primary);
}

.ms-card__meta {
  color: var(--ms-text-muted);
  font-size: 12px;
}

/* Status badge — a single neutral pill tinted by the status token. */
.ms-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px var(--ms-space-sm);
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--ms-on-primary);
  background: var(--ms-status-angelegt);
}
.ms-badge--ANGELEGT { background: var(--ms-status-angelegt); }
.ms-badge--GEPLANT { background: var(--ms-status-geplant); }
.ms-badge--IN_DURCHFUEHRUNG { background: var(--ms-status-in-durchfuehrung); }
.ms-badge--ABGESCHLOSSEN { background: var(--ms-status-abgeschlossen); }
.ms-badge--FREIGEGEBEN { background: var(--ms-status-freigegeben); }
.ms-badge--ARCHIVIERT { background: var(--ms-status-archiviert); }

/* Signalling highlight (lime) — subtle background only, never text/buttons. */
.ms-signal {
  background: var(--ms-signal);
  border-radius: var(--ms-radius);
  padding: var(--ms-space-xs) var(--ms-space-sm);
}

/* Lime "unseen change" dot — the live-update signal next to a list title / detail
 * tab title (SIGNALLING ONLY — §8). The stronger lime keeps a small dot legible;
 * a left gap sits it just after the text it annotates. */
.ms-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--ms-signal-strong);
  margin-left: var(--ms-space-xs);
  vertical-align: middle;
}

.ms-muted { color: var(--ms-text-muted); }
.ms-error { color: var(--ms-error); }

/* Map hover tooltip (ol/Overlay above an Immobilien marker) — created in JS, so
 * styled here by class. Non-interactive so it never eats map pointer events. */
.ms-map-tooltip {
  background: var(--ms-primary);
  color: var(--ms-on-primary);
  padding: 2px var(--ms-space-sm);
  border-radius: var(--ms-radius);
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  box-shadow: var(--ms-shadow);
  pointer-events: none;
}

/* Map click popup (ol/Overlay above a selected Immobilien marker) — created in JS,
 * so styled here by class. Interactive (holds the close button), calm surface: one
 * soft shadow, brand-hued title, no micro-animations. Wider than the hover tooltip
 * and pinned by a small caret-free offset. */
.ms-map-popup {
  position: relative;
  min-width: 160px;
  max-width: 260px;
  padding: var(--ms-space-sm) var(--ms-space-md, 12px);
  background: var(--ms-bg, #fff);
  color: var(--ms-text, #2b2b2b);
  border: 1px solid var(--ms-border, #e0e0e0);
  border-radius: var(--ms-radius);
  box-shadow: var(--ms-shadow);
  font-size: 12px;
  line-height: 1.5;
}
.ms-map-popup__close {
  position: absolute;
  top: 2px;
  right: 4px;
  padding: 0;
  border: none;
  background: none;
  color: var(--ms-text-muted, #6b6b6b);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: color var(--ms-transition, 0.3s ease);
}
.ms-map-popup__close:hover {
  color: var(--ms-primary, #511A3F);
}
.ms-map-popup__title {
  font-weight: 600;
  color: var(--ms-primary, #511A3F);
  padding-right: var(--ms-space-md, 12px);
}
.ms-map-popup__meta {
  color: var(--ms-text-muted, #6b6b6b);
}
.ms-map-popup__status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.ms-map-popup__dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ms-text-muted, #6b6b6b);
}
/* Attribute popup of the pmtiles tree layers: key/value table, scrolls when a feature has many fields. */
/* OP#2048: "n Erhebungen anzeigen" — opens the object's surveys in the detail panel. */
.ms-map-popup__link {
  display: block;
  margin-top: 6px;
  padding: 0;
  border: none;
  background: none;
  color: var(--ms-primary, #511A3F);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}
.ms-map-popup--attributes {
  max-width: 340px;
  max-height: 260px;
  overflow: auto;
}
.ms-map-popup__pager {
  display: flex;
  align-items: center;
  gap: var(--ms-space-sm);
  color: var(--ms-text-muted, #6b6b6b);
}
.ms-map-popup__pager button {
  padding: 0 4px;
  border: none;
  background: none;
  color: var(--ms-primary, #511A3F);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.ms-map-popup__attributes {
  margin-top: var(--ms-space-sm);
  border-collapse: collapse;
}
.ms-map-popup__attributes th {
  padding: 1px var(--ms-space-sm) 1px 0;
  text-align: left;
  font-weight: 600;
  color: var(--ms-text-muted, #6b6b6b);
  vertical-align: top;
}
.ms-map-popup__attributes td {
  padding: 1px 0;
  word-break: break-word;
}

/* Modern select — brand-hued, calm. A wrapper draws the chevron so we can keep
 * appearance:none (removes the OS control) without inlining a coloured SVG. */
.ms-select-wrapper {
  position: relative;
  display: block;
}
.ms-select-wrapper::after {
  content: "";
  position: absolute;
  top: 50%;
  right: var(--ms-space-md);
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--ms-primary);
  border-bottom: 2px solid var(--ms-primary);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
  transition: border-color var(--ms-transition);
}
.ms-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 100%;
  padding: var(--ms-space-sm) calc(var(--ms-space-lg) + var(--ms-space-md)) var(--ms-space-sm) var(--ms-space-md);
  font-size: 14px;
  color: var(--ms-text);
  background: var(--ms-bg);
  border: 1px solid var(--ms-border);
  border-radius: var(--ms-radius);
  box-shadow: var(--ms-shadow);
  cursor: pointer;
  transition: border-color var(--ms-transition), box-shadow var(--ms-transition);
}
.ms-select:hover {
  border-color: var(--ms-primary-hover);
}
.ms-select:focus {
  outline: none;
  border-color: var(--ms-primary);
  box-shadow: 0 0 0 3px var(--ms-focus-ring);
}

.ms-section {
  margin-top: var(--ms-space-lg);
  margin-bottom: var(--ms-space-lg);
}
.ms-section__title {
  font-weight: 600;
  color: var(--ms-text);
  margin-bottom: var(--ms-space-sm);
}
