/* ==========================================================================
   Groen Maps — Project-specifieke styles
   Alleen wat niet in het CSS framework zit.
   ========================================================================== */

/* Gebruikersnaam in de topbar: enkel op tablet+ tonen. */
.nav-user-name {
  display: none;
}

@media (min-width: 641px) {
  .nav-user-name {
    display: inline;
  }
}

/* Enkel licht thema (blok 2): ook native knoppen, invoer en schuifbalken licht,
   los van de donkere modus van het toestel. Kaartkleuren — gedeeld door de
   kaartlagen (map.js) en de legende. */
:root {
  color-scheme: light;
  --map-talk: #21ad5b;
  --map-not-home: #e8890c;
  --map-no-talk: #7d847d;
  --map-followup: #cc3d3d;
  --map-street-todo: #9ba19b;
  --map-street-busy: #77d199;
  --map-street-done: #146838;
  --map-street-selected: #072312;
  /* Routes (turf cutting): zelfde vaste palet als de data-tool (data/public/css/app.css) */
  --route-1: #2a78d6;
  --route-2: #eb6834;
  --route-3: #1baf7a;
  --route-4: #eda100;
  --route-5: #e87ba4;
  --route-6: #008300;
  --route-7: #4a3aa7;
  --route-8: #e34948;
}

/* Routenaam met kleurbolletje (Mijn campagne, campagnedetail) */
.route-name {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  font-weight: 600;
}

.route-dot {
  flex-shrink: 0;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: var(--radius-full);
  box-shadow: 0 0 0 1px var(--color-border-strong);
}

/* De kaart vult .app-content (onder de kop), niet het hele venster */
.app-content {
  position: relative;
}

/* Map container */
#map-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

/* Campagneknop op de kaart (opent het campagnepaneel) */
.map-campaign-filter {
  position: fixed;
  top: calc(var(--nav-top-height) + var(--safe-top) + var(--space-md));
  left: calc(var(--space-sm) + var(--safe-left));
  right: calc(var(--space-sm) + var(--safe-right) + 3.5rem);  /* ruimte voor kompas/locatie */
  z-index: var(--z-sticky);
  pointer-events: none;
}

.map-campaign-button {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  max-width: 100%;
  min-height: var(--tap-min);
  padding: 0 var(--space-sm) 0 var(--space-md);
  font: inherit;
  font-weight: 700;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  cursor: pointer;
}

.map-campaign-button > .material-icons:first-child {
  color: var(--color-primary-text);
}

.map-campaign-button:active {
  background: var(--color-surface-sunken);
}

/* Geen campagne: kaart blijft zichtbaar, uitleg onderaan */
.map-empty {
  position: fixed;
  left: calc(var(--space-sm) + var(--safe-left));
  right: calc(var(--space-sm) + var(--safe-right));
  bottom: calc(var(--nav-bottom-height) + var(--safe-bottom) + var(--space-sm));
  z-index: var(--z-sticky);
  display: flex;
  justify-content: center;
}

.map-empty-card {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-md);
  width: 100%;
  max-width: 28rem;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.map-empty-icon {
  color: var(--color-primary-text);
  font-size: 32px;
}

.map-empty-body {
  flex: 1 1 10rem;
  min-width: 0;
}

.map-empty-title {
  margin: 0;
  font-size: var(--text-base);
  color: var(--color-text);
}

.map-empty-text {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* Legende + eigen tellers linksonder */
.map-overlay-left {
  position: fixed;
  left: calc(var(--space-sm) + var(--safe-left));
  bottom: calc(var(--nav-bottom-height) + var(--safe-bottom) + var(--space-lg));
  z-index: var(--z-sticky);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-xs);
  max-width: calc(100vw - 6rem);
}

.map-stats-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
  padding: var(--space-xs) var(--space-md) var(--space-sm);
}

.map-stats-caption {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text-muted);
}

.map-stats-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.map-stats-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.map-stats-icon {
  font-size: 18px;
  color: var(--color-text-muted);
}

.map-stats-value {
  font-size: var(--text-base);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.map-stats-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.2;
}

.map-stats-divider {
  width: 1px;
  height: 24px;
  background: var(--color-border);
}

.map-stats-pending {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-warning-text);
}

.map-legend {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.map-legend-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  min-height: var(--control-height-sm);
  padding: 0 var(--space-md) 0 var(--space-sm);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  background: none;
  border: none;
  cursor: pointer;
}

.map-legend-list {
  list-style: none;
  margin: 0;
  padding: 0 var(--space-md) var(--space-sm);
  display: grid;
  gap: var(--space-xs);
  font-size: var(--text-sm);
}

.map-legend-list li {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin: 0;
}

.map-dot {
  flex-shrink: 0;
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 50%;
  border: 2px solid var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-border-strong);
}

.map-dot-open     { background: var(--color-surface); border: 2px solid var(--map-no-talk); box-shadow: none; }
.map-dot-talk     { background: var(--map-talk); }
.map-dot-not-home { background: var(--map-not-home); }
.map-dot-no-talk  { background: var(--map-no-talk); }
.map-dot-followup { background: transparent; border: 2.5px solid var(--map-followup); box-shadow: none; }

.map-line {
  flex-shrink: 0;
  width: 1.25rem;
  height: 0.375rem;
  border-radius: var(--radius-full);
}

.map-line-todo { background: var(--map-street-todo); }
.map-line-busy { background: var(--map-street-busy); }
.map-line-done { background: var(--map-street-done); }

/* Campagne met routes: een straat zonder bezoeken heeft de kleur van haar route */
.map-legend-caption {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.map-legend-list .map-legend-sub {
  padding-inline-start: var(--space-sm);
}

.map-street-route {
  margin: var(--space-2xs) 0 0;
  font-size: var(--text-sm);
}

/* Straat getikt op de kaart */
.map-street-card {
  position: fixed;
  left: calc(var(--space-sm) + var(--safe-left));
  right: calc(var(--space-sm) + var(--safe-right));
  bottom: calc(var(--nav-bottom-height) + var(--safe-bottom) + var(--space-sm));
  z-index: var(--z-sticky);
  display: grid;
  gap: var(--space-sm);
  max-width: 28rem;
  margin-inline: auto;
  padding: var(--space-md) var(--space-lg) var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.map-street-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
}

.map-street-text {
  flex: 1;
  min-width: 0;
}

.map-street-title {
  margin: 0;
  font-size: var(--text-lg);
  color: var(--color-text);
  overflow-wrap: anywhere;
}

.map-street-meta {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

@media (min-width: 641px) {
  .map-street-card {
    left: var(--space-lg);
    right: auto;
    width: 24rem;
    bottom: var(--space-xl);
  }
}

/* Popup van een deur (MapLibre, className "map-popup") */
.map-popup .maplibregl-popup-content {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-body);
  color: var(--color-text);
}

.map-popup-title {
  font-weight: 700;
  font-size: var(--text-sm);
  padding-right: var(--space-lg);
}

.map-popup-status {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
}

.map-popup-meta {
  margin-top: var(--space-xs);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Wijzig gemeente: resultaten onder de zoeker (in het venster, geen zwevende lijst) */
.municipality-results {
  max-height: 18rem;
  overflow-y: auto;
  margin: 0;
}

.municipality-results .list-item {
  cursor: pointer;
}

.municipality-results .list-item.is-active {
  background: var(--color-primary-subtle);
}

/* "Bezoek loggen" onder een deur */
.map-popup-action {
  margin-top: var(--space-sm);
}

.map-popup .maplibregl-popup-close-button {
  width: 2rem;
  height: 2rem;
  font-size: 1.25rem;
  color: var(--color-text-secondary);
}

/* Startscherm zonder verbinding (bewust geen offline opstart) */
.boot-offline {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--space-xl) + var(--safe-top)) var(--space-lg) calc(var(--space-xl) + var(--safe-bottom));
  background: var(--color-surface);
}

.boot-offline-card {
  max-width: 24rem;
  text-align: center;
  display: grid;
  gap: var(--space-md);
  justify-items: center;
}

.boot-offline-icon {
  font-size: 56px;
  color: var(--color-text-muted);
}

.boot-offline-title {
  font-size: var(--text-2xl);
  margin: 0;
}

.boot-offline p {
  margin: 0;
  color: var(--color-text-secondary);
}

/* ─── Bezoekformulier (js/visit-form.js) ─── */
.visit-form,
.visit-form-body,
.visit-address,
.visit-reasons,
.visit-talk,
.visit-newsletter-fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.visit-address {
  gap: var(--space-sm);
}

.visit-form .form-group {
  margin-bottom: 0;
}

/* Campagne: knop om te wisselen */
.visit-campaign-switch {
  align-self: flex-start;
  max-width: 100%;
  margin-left: calc(-1 * var(--space-md));
  color: var(--color-text-secondary);
  font-weight: 600;
}

/* Campagnestraten in de zoeklijst zijn knoppen (toetsenbord) */
.visit-form .autocomplete-item {
  width: 100%;
  font: inherit;
  color: var(--color-text);
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--color-border);
}

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

.visit-street-head {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.visit-street-head strong {
  flex: 1 1 auto;
  min-width: 0;
}

.visit-street-count {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* Huisnummer, bus en stap op één rij; wrapt op een smalle gsm */
.visit-door {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-sm) var(--space-md);
}

.visit-bus {
  flex: 1 1 5rem;
  min-width: 5rem;
  max-width: 9rem;
}

.visit-step .segmented-item {
  padding-inline: var(--space-sm);
}

/* Adresgeschiedenis: één regel, klapt open */
.visit-history-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  min-height: var(--tap-min);
  padding: 0;
  font: inherit;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
}

.visit-history-toggle:disabled {
  color: var(--color-text-muted);
  cursor: default;
}

.visit-history-list .list-item {
  padding-inline: 0;
}

/* Resultaat = actie: drie gelijke knoppen */
.visit-results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-sm);
}

.visit-results .btn {
  padding-inline: var(--space-xs);
  line-height: 1.15;
  white-space: normal;
}

/* Groen-gezind: vijf labels naast elkaar, op twee regels indien nodig */
.visit-scale {
  border-radius: var(--radius-lg);
}

.visit-scale .segmented-item {
  padding-inline: var(--space-2xs);
  font-size: var(--text-xs);
  line-height: 1.15;
  text-align: center;
  white-space: normal;
  border-radius: var(--radius-md);
}

/* Kleur op resultaat en groen-gezind: .tone + één .tone-*.
   Oranje = opnieuw proberen (zoals "niet thuis" op de kaart), rood = geen gesprek / zeker niet.
   --tone: rand en tint · --tone-text: tekst op de tint · --tone-fill/--tone-on: gekozen */
.tone-red        { --tone: var(--color-error);       --tone-text: var(--color-error-fill);   --tone-fill: var(--color-error-fill);   --tone-on: var(--color-on-error); }
.tone-orange     { --tone: var(--map-not-home);      --tone-text: var(--color-warning-text); --tone-fill: var(--map-not-home);       --tone-on: var(--color-text); }
.tone-grey       { --tone: var(--color-neutral-600);--tone-text: var(--color-text);         --tone-fill: var(--color-neutral-600);  --tone-on: var(--color-text-inverse); }
.tone-lightgreen { --tone: var(--color-primary-300); --tone-text: var(--color-text);         --tone-fill: var(--color-primary-400);  --tone-on: var(--color-text); }
.tone-green      { --tone: var(--color-primary);     --tone-text: var(--color-primary-text); --tone-fill: var(--color-primary-fill); --tone-on: var(--color-on-primary); }

/* Score als bolletje in de adresgeschiedenis (in plaats van "· Eerder wel") */
.tone-dot {
  display: inline-block;
  width: 0.75em;
  height: 0.75em;
  margin-inline-start: var(--space-2xs);
  vertical-align: -0.05em;
  background: var(--tone-fill);
  border-radius: var(--radius-full);
  box-shadow: 0 0 0 1px var(--color-border-strong);
}

.btn.tone {
  color: var(--tone-text);
  background: color-mix(in srgb, var(--tone) 14%, var(--color-surface));
  border-color: var(--tone);
}

.btn.tone:active {
  background: color-mix(in srgb, var(--tone) 30%, var(--color-surface));
}

.btn.tone.active {
  color: var(--tone-on);
  background: var(--tone-fill);
  border-color: var(--tone-fill);
}

@media (hover: hover) {
  .btn.tone:hover:not(.active) {
    background: color-mix(in srgb, var(--tone) 24%, var(--color-surface));
  }
}

.segmented-item.tone {
  color: var(--color-text);
  background: color-mix(in srgb, var(--tone) 18%, var(--color-surface));
}

.segmented-item.tone:has(input:checked) {
  color: var(--tone-on);
  background: var(--tone-fill);
}

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

.visit-name {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: var(--space-sm);
}

.visit-consent {
  margin: 0;
}

.visit-extra {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

/* "Opslaan · nr X" plakt onderaan, over de volle breedte van de container */
.visit-form .action-bar {
  margin-inline: calc(-1 * var(--space-lg));
}

.visit-today .list-item {
  padding-inline: var(--space-lg) var(--space-sm);
}

/* "＋ thema": open knop naast de thema's (geen keuze, een actie) */
.visit-theme-add {
  border-style: dashed;
  color: var(--color-primary-text);
}

/* Themakiezer (js/themes.js) */
.theme-picker {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.theme-picker .chip-group {
  max-height: 50vh;
  overflow-y: auto;
}

/* Campagne bewerken: wat er aan de deur gevraagd wordt */
.door-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin: 0 0 var(--space-lg);
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.door-options legend {
  padding-inline: var(--space-xs);
}

.door-option > div {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  padding-bottom: var(--space-xs);
}

/* Campagnedetail: totalen "Aan de deur" */
.door-results {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

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

.door-result-title {
  font-size: var(--text-base);
  font-weight: 600;
  margin: 0;
}

/* Municipality modal centered icon */
.modal-body.text-center .material-icons {
  display: block;
  margin: 0 auto;
}

/* Tablet+ adjustments */
@media (min-width: 641px) {
  .map-campaign-filter {
    left: var(--space-lg);
    right: auto;
    max-width: 24rem;
    top: calc(var(--nav-top-height) + var(--safe-top) + var(--space-lg));
  }

  .map-overlay-left,
  .map-empty {
    bottom: var(--space-xl);
    left: var(--space-lg);
  }
}

/* Desktop: wider visit form */
@media (min-width: 1025px) {
  #visit-container,
  #campaigns-container,
  #campaign-detail-container {
    max-width: 640px;
    margin: 0 auto;
  }
}

/* ─── DARK MODE ───
   Geactiveerd via data-theme="dark" op <html> (beheerd door ThemeModule). */

/* MapLibre controls (zoom, compass) */
[data-theme="dark"] .maplibregl-ctrl-group {
  background: var(--color-surface-raised) !important;
}

[data-theme="dark"] .maplibregl-ctrl-group button + button {
  border-top-color: var(--color-border) !important;
}

/* MapLibre control icons — SVG's met hardcoded donkere kleuren */
[data-theme="dark"] .maplibregl-ctrl button .maplibregl-ctrl-icon {
  filter: invert(1);
}

/* MapLibre popup dark mode */
[data-theme="dark"] .maplibregl-popup-content {
  background: var(--color-surface-raised);
  color: var(--color-text);
}

[data-theme="dark"] .maplibregl-popup-tip {
  border-top-color: var(--color-surface-raised);
}

[data-theme="dark"] .maplibregl-popup-close-button {
  color: var(--color-text-muted);
}

/* Login pagina */
.auth-container {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

.auth-content {
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.auth-logo img {
  height: 48px;
  width: auto;
}

.auth-card {
  width: 100%;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-lg) 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* Compacte stat-cards in het campagnedetail (in de framework-.stats-grid) */
.stat-card-compact {
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
}

.stat-card-compact .stat-label {
  letter-spacing: 0.02em;
}

.stat-card-compact .stat-value {
  font-size: var(--text-lg);
}

.stat-card-compact .stat-label {
  margin-top: var(--space-2xs);
}

.stat-card-compact .stat-icon {
  width: 2.25rem;
  height: 2.25rem;
}

/* Confirm- en opvolgingsdialogen: native <dialog class="modal"> (framework v4). */

/* Lijstrij met een eigen hoofdknop naast een knop rechts (opvolgingen): de knop
   neemt de ruimte van .list-item-content in, zonder knopopmaak. */
.list-item-button {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.list-item-button:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* Sessie verlopen — .banner (framework v4), hier zwevend onder de navigatie
   en boven de kaart-overlays i.p.v. in de flow */
.session-banner {
  position: fixed;
  top: calc(var(--nav-top-height) + var(--safe-top) + var(--space-xs));
  left: calc(var(--space-sm) + var(--safe-left));
  right: calc(var(--space-sm) + var(--safe-right));
  z-index: var(--z-overlay);
  border: 1px solid var(--color-warning-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

/* Sync spin animation */
.spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Alpine.js cloak — voorkomt FOUC, !important nodig */
[x-cloak] {
  display: none !important;
}
