.app-pv-planer,
.app-pv-planer * {
  box-sizing: border-box;
}

.app-pv-planer {
  position: relative;
  isolation: isolate;
  z-index: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: max(520px, 80vh);
  max-height: 80vh;
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
  overflow: hidden;
  background: #fff;
}

/* Auf größeren Bildschirmen rund 15 % breiter als der normale Inhaltsbereich,
   ohne über den sichtbaren Browserbereich hinauszuragen. */
@media (min-width: 900px) {
  .app-pv-planer {
    width: min(115%, calc(100vw - 24px));
    max-width: none;
    margin-left: 50%;
    transform: translateX(-50%);
  }
}

.app-pv-planer #topbar {
  background: #060d3a;
  color: #fff;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 14px !important;
  position: relative;
  flex: 0 0 auto;
  z-index: 5;
}

/* Beide Bedienzeilen dürfen umbrechen. Dadurch sind alle Eingaben und Buttons
   direkt sichtbar; es ist kein horizontales Scrollen mehr erforderlich. */
.app-pv-planer #topbar > div:first-child,
.app-pv-planer #topbar > div:last-child {
  display: flex;
  align-items: center;
  align-content: center;
  gap: 6px;
  flex-wrap: wrap;
  overflow: visible;
  width: 100%;
}

.app-pv-planer #topbar > div:last-child {
  gap: 5px;
}

/* Beschriftung und zugehöriges Eingabefeld bilden immer eine untrennbare
   Einheit. Nur komplette Einheiten werden bei Platzmangel in die nächste
   Zeile verschoben. */
.app-pv-planer #topbar .app-pv-planer__field {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 5px;
  min-width: max-content;
  white-space: nowrap;
}

.app-pv-planer #topbar .app-pv-planer__field--address {
  flex: 1 1 330px;
  min-width: min(100%, 290px);
}

.app-pv-planer #topbar label {
  color: #fff;
  white-space: nowrap;
  margin: 0;
  font-weight: 400;
}

.app-pv-planer #topbar input,
.app-pv-planer #topbar select,
.app-pv-planer #topbar button {
  font-family: Arial, sans-serif;
  border-radius: 2px;
}

.app-pv-planer #topbar input#address {
  flex: 1 1 220px;
  min-width: 180px;
  max-width: 340px;
  height: 28px;
  font-size: 14px;
}

.app-pv-planer #topbar input:not(#address) {
  width: 52px !important;
  min-width: 52px;
  height: 26px;
  font-size: 12px;
}

.app-pv-planer #topbar #skewDeg {
  width: 58px !important;
  min-width: 58px;
}

.app-pv-planer #topbar select {
  width: 92px !important;
  min-width: 92px;
  height: 28px !important;
  font-size: 13px !important;
  padding: 2px 4px;
}

.app-pv-planer #topbar button {
  min-height: 28px;
  height: auto;
  font-size: 14px;
  line-height: 1.25;
  padding: 4px 7px;
  white-space: normal;
  flex: 0 1 auto;
  cursor: pointer;
}

.app-pv-planer .app-pv-planer__map-stage {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.app-pv-planer #map {
  position: relative !important;
  flex: 1 1 auto;
  width: 100% !important;
  min-height: 0;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  z-index: 1 !important;
}

.app-pv-planer #drawRoof,
.app-pv-planer #screenshotButton {
  position: absolute;
  top: 8px;
  z-index: 6;
  font-size: 14px;
  padding: 8px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  font-weight: bold;
}

.app-pv-planer #drawRoof {
  left: 72px;
  background: #ffcc00;
  color: #111;
}

.app-pv-planer #drawRoof.is-drawing {
  background: #ff8a00;
  color: #111;
}

.app-pv-planer #screenshotButton {
  left: 272px;
  background: #ff6b6b;
  color: #fff;
}

.app-pv-planer #templateImage {
  position: absolute;
  cursor: move;
  display: none;
  width: 200px;
  height: auto;
  border: 2px solid #fff;
  border-radius: 8px;
  box-shadow: 0 4px 4px rgba(255,255,255,0);
  pointer-events: auto;
  z-index: 7 !important;
}

.app-pv-planer #pvPlannerStatus {
  display: none;
  position: absolute;
  top: 52px;
  left: 12px;
  z-index: 8;
  max-width: min(520px, calc(100% - 24px));
  padding: 9px 12px;
  border-radius: 4px;
  background: rgba(6,13,58,.94);
  color: #fff;
  box-shadow: 0 3px 12px rgba(0,0,0,.35);
  font-size: 13px;
}

.app-pv-planer #pvPlannerStatus.is-visible { display: block; }
.app-pv-planer #pvPlannerStatus.is-error { background: rgba(145,20,20,.96); }

.app-pv-planer__configuration-error {
  padding: 24px;
  border: 2px solid #b32d2e;
  background: #fff4f4;
  color: #3c434a;
}

@media (max-width: 899px) {
  .app-pv-planer {
    width: 100%;
    margin-left: 0;
    transform: none;
  }
}

@media (max-width: 780px) {
  .app-pv-planer {
    height: max(500px, 80svh);
    min-height: 500px;
    max-height: 80svh;
  }

  .app-pv-planer #topbar {
    padding: 8px;
    gap: 6px;
    font-size: 13px !important;
  }

  .app-pv-planer #topbar > div:first-child,
  .app-pv-planer #topbar > div:last-child {
    gap: 5px;
  }

  .app-pv-planer #topbar .app-pv-planer__field--address {
    flex: 1 1 100%;
    min-width: 100%;
  }

  .app-pv-planer #topbar input#address {
    flex: 1 1 auto;
    min-width: 120px;
    max-width: none;
  }

  .app-pv-planer #topbar button {
    font-size: 12px;
    padding: 4px 6px;
  }

  .app-pv-planer #drawRoof,
  .app-pv-planer #screenshotButton {
    top: 8px;
    padding: 7px 9px;
    font-size: 12px;
  }

  .app-pv-planer #drawRoof { left: 56px; }
  .app-pv-planer #screenshotButton { left: 222px; }
  .app-pv-planer #pvPlannerStatus { top: 48px; left: 8px; }
}

@media (max-width: 430px) {
  .app-pv-planer #screenshotButton {
    left: auto;
    right: 12px;
  }
}
