/* Portaal-prototype. --accent is de kleur van de organisatie; het script zet
   hem op basis van de gegevens, zodat huisstijl data is en geen aparte pagina. */

:root {
  --accent: #2e7d32;
  --tekst: #1f2933;
  --zacht: #5f6b7a;
  --lijn: #d9dee5;
  --vlak: #ffffff;
  --achtergrond: #f4f6f8;
  --zee: #dbe8f3;
  --land: #edf1e4;
  --landrand: #a8b494;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 15px;
  color: var(--tekst);
  background: var(--achtergrond);
}

button,
select {
  font: inherit;
  color: inherit;
}

/* --- Kop ---------------------------------------------------------------- */

.kop {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--vlak);
  border-bottom: 3px solid #6cb33f;
}

/* Ematec-logo links, daarna de titel in dezelfde stijl als de beheerpagina (wens Jos 6-10). */
.ematec-logo {
  height: 48px;
  width: auto;
  flex-shrink: 0;
}

.merk {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 14px;
  border-left: 1px solid #dfe6d8;
  font-size: 18px;
  font-weight: 600;
  color: #4c8a2e;
  min-width: 0;
}

.merk img {
  width: 34px;
  height: 34px;
}

.prototype {
  margin-right: auto;
  padding: 3px 10px;
  border: 1px solid #e0b252;
  border-radius: 999px;
  background: #fff6dd;
  color: #6b4e00;
  font-size: 13px;
  white-space: nowrap;
}

.afmelden {
  padding: 6px 14px;
  border: 1px solid var(--lijn);
  border-radius: 6px;
  background: var(--vlak);
  color: var(--tekst);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.afmelden {
  text-decoration: none;
}

.afmelden:hover {
  border-color: #6cb33f;
}

/* --- Indeling ------------------------------------------------------------ */

main {
  flex: 1;
  display: flex;
  min-height: 0;
}

.zijbalk {
  width: 340px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 14px;
  background: var(--vlak);
  border-right: 1px solid var(--lijn);
}

.melding {
  margin: 0 0 12px;
  padding: 8px 10px;
  border: 1px solid #e5a3a3;
  border-radius: 6px;
  background: #fdecec;
  color: #8a1f1f;
}

.wie {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--lijn);
}

.wie p {
  margin: 0;
  color: var(--zacht);
}

.wie .email,
.wie .telling {
  color: var(--zacht);
  font-size: 13px;
}

.rollen {
  margin: 6px 0;
  padding-left: 18px;
  font-size: 13px;
}

.leeg {
  color: var(--zacht);
}

/* --- Lijst per organisatie ---------------------------------------------- */

.org {
  margin-bottom: 14px;
}

.org-kop {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-left: 4px solid var(--accent);
  border-radius: 4px;
  background: var(--achtergrond);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.org-kop:hover {
  background: #e9edf1;
}

.org-kop .logo {
  width: 24px;
  height: 24px;
}

.org-naam {
  flex: 1;
  min-width: 0;
}

.org-aantal {
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-size: 12px;
  line-height: 20px;
}

.locaties {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.loc {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 6px 8px 6px 12px;
  border: 0;
  border-left: 4px solid transparent;
  border-radius: 4px;
  background: none;
  text-align: left;
  cursor: pointer;
}

.loc:hover {
  background: var(--achtergrond);
}

.loc.actief {
  border-left-color: var(--accent);
  background: var(--achtergrond);
}

.loc-detail {
  color: var(--zacht);
  font-size: 12px;
}

/* --- Kaart (Leaflet) ------------------------------------------------------ */

.kaart {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  background: var(--zee);
  isolation: isolate; /* de z-indexen van Leaflet blijven binnen de kaart */
}

.kaart.leaflet-container {
  font: inherit;
}

/* Leaflet zet de houder op de juiste plek; de knop erin is de zichtbare marker. */
.marker-houder {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.marker {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

.marker img {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  pointer-events: none;
}

.marker:hover,
.marker:focus-visible {
  box-shadow: 0 0 0 3px #ffffff, 0 0 0 5px var(--accent);
  outline: none;
}

.marker.actief {
  width: 46px;
  height: 46px;
  box-shadow: 0 0 0 3px #ffffff, 0 0 0 6px var(--accent), 0 2px 8px rgba(0, 0, 0, 0.35);
}

.marker.actief img {
  width: 30px;
  height: 30px;
}

.marker.bundel {
  background: var(--accent);
  border-color: #ffffff;
  color: #ffffff;
  font-size: 14px;
}

/* --- Ballon bij de gekozen locatie (inhoud van de Leaflet-popup) --------- */

.ballon {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 6px;
  border-top: 4px solid var(--accent);
  font-size: 14px;
}

.ballon-org {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.ballon-adres {
  color: var(--zacht);
  font-size: 13px;
}

.ballon-kop {
  margin-top: 6px;
  color: var(--zacht);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ballon-controllers {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.ballon-controllers li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
}

.ballon-controllers .type {
  color: var(--zacht);
  white-space: nowrap;
}

.ballon-controllers li:has(.kenmerken) {
  flex-wrap: wrap;
}

.ballon-controllers .kenmerken {
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  font-size: 0.85em;
  color: var(--zacht);
}

.ballon-controllers .mac {
  font-family: Consolas, 'Courier New', monospace;
  user-select: all;
}

/* --- Niet online: rode ! ------------------------------------------------- */

.marker {
  position: relative;
}

.marker > .storing {
  position: absolute;
  top: -6px;
  right: -6px;
}

.storing {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #c62828;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.ballon-keuze {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.ballon-kies {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 4px;
  border: 0;
  border-bottom: 1px solid var(--lijn);
  background: none;
  color: inherit;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.ballon-kies:hover,
.ballon-kies:focus-visible {
  background: var(--achtergrond);
  outline: none;
}

.ballon-kies .naam {
  flex: 1;
}

.ballon-kies .type {
  color: var(--zacht);
  white-space: nowrap;
}

.ballon-terug {
  align-self: flex-start;
  margin-bottom: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.kenmerk.niet-online {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #c62828;
  font-weight: 600;
}

.kenmerk.online {
  color: var(--accent);
  font-weight: 600;
}

/* --- Bediening ------------------------------------------------------------ */

.kaart-alles button {
  display: block;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: #ffffff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.kaart-alles button:hover {
  background: #f4f4f4;
}

@media (max-width: 760px) {
  main {
    flex-direction: column-reverse;
  }

  .zijbalk {
    width: auto;
    max-height: 42%;
    border-right: 0;
    border-top: 1px solid var(--lijn);
  }

  .kop {
    flex-wrap: wrap;
  }
}

/* Meetdata onder de lijst: keuzes, status intern/klant en een staafgrafiek. */
.meetdata {
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--lijn);
}
.md-kop { margin: 0 0 8px; font-size: 1.05rem; }
.md-controller { margin: 8px 0 6px; font-size: 0.95rem; color: var(--zacht); }
.md-keuzes { display: grid; gap: 6px; }
.md-keuze { display: grid; gap: 2px; font-size: 0.8rem; color: var(--zacht); }
.md-keuze select { font: inherit; color: var(--tekst); padding: 3px; }
.md-status { margin: 8px 0 4px; font-size: 0.8rem; color: var(--accent); }
.md-status.md-intern { color: #8a5a00; }
.md-grafiek { width: 100%; height: auto; display: block; background: var(--achtergrond); border-radius: 4px; }
.md-staaf { fill: var(--accent); }
.md-staaf:hover { fill: var(--tekst); }
.md-as { stroke: var(--zacht); stroke-width: 1; }
.md-label { font-size: 13px; fill: var(--zacht); }
.md-samenvatting { margin: 4px 0 0; font-size: 0.78rem; color: var(--zacht); }

/* Actuele spanning (wens Jos 6-10-2026). */
.md-spanning { margin: 6px 0 10px; }
.md-spanning-kop { margin: 0 0 6px; font-size: 0.8rem; color: #5f6b62; }
.md-tegels { display: flex; flex-wrap: wrap; gap: 6px; }
.md-tegel { display: flex; flex-direction: column; min-width: 78px; padding: 6px 10px; border-radius: 8px; background: #eef5e6; }
.md-tegel-naam { font-size: 0.72rem; color: #5f6b62; }
.md-tegel-waarde { font-size: 0.95rem; font-weight: 600; }

/* Kleiner logo op smalle schermen. */
@media (max-width: 760px) {
  .ematec-logo { height: 34px; }
  .merk { font-size: 16px; padding-left: 10px; }
}

/* Logo is een link naar het totaaloverzicht (wens Jos 6-10). */
.logo-link { display: flex; flex-shrink: 0; line-height: 0; }

/* Link naar het dashboard in de ballon (wens William 6-10). */
.ballon-dashboard { display: inline-block; margin-top: 10px; padding: 6px 12px; border-radius: 6px; background: #6cb33f; color: #fff; font-weight: 600; font-size: 13px; text-decoration: none; }
.ballon-dashboard:hover { background: #4c8a2e; }
.ballon-dashboard + .ballon-dashboard { margin-left: 6px; }
.leaflet-container a.ballon-dashboard { color: #fff; }

/* Dashboard als pop-up boven de kaart (wens Jos 6-10). */
.dash-dialoog { width: min(1120px, 80vw); height: 80vh; max-height: 80vh; padding: 0; border: 0; border-radius: 14px; overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); background: #f6f8f4; }
.dash-dialoog::backdrop { background: rgba(31, 41, 51, 0.45); }
.dash-dialoog iframe { width: 100%; height: 100%; border: 0; display: block; }
.dash-sluit { position: absolute; top: 10px; right: 26px; z-index: 2; width: 36px; height: 36px; border-radius: 50%; border: 1px solid #d9dee5; background: #fff; font-size: 22px; line-height: 1; cursor: pointer; color: #1f2933; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12); }
.dash-sluit:hover { border-color: #6cb33f; color: #4c8a2e; }
@media (max-width: 640px) { .dash-dialoog { width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; } }

/* Open systeem (EMATEC-26): tweede knop naast "Dashboard openen", en dezelfde pop-up met een
   smalle titelbalk boven het afgeschermde iframe. */
.ballon-systeem { display: inline-block; margin: 10px 0 0 6px; padding: 6px 12px; border-radius: 6px; border: 1px solid #6cb33f; background: #fff; color: #4c8a2e; font-weight: 600; font-size: 13px; cursor: pointer; }
.ballon-systeem:hover { background: #eef6e8; }
.sys-dialoog { display: none; flex-direction: column; }
.sys-dialoog[open] { display: flex; }
.sys-balk { display: flex; gap: 12px; align-items: baseline; padding: 14px 72px 10px 18px; border-bottom: 1px solid #d9dee5; background: #fff; font-weight: 600; color: #1f2933; }
.sys-uitleg { font-weight: 400; font-size: 12px; color: #616e7c; }
.sys-dialoog iframe { flex: 1; height: auto; min-height: 0; background: #fff; }

/* Meetfout in de bron: energiewaarden niet te vertrouwen (mail William 19-10-2026). */
.onbetrouwbaar, td.onbetrouwbaar { color: #b45309; }
