/* style.css (neu, komplett) */

/* Grundlayout */
*{
  box-sizing: border-box;
}

/*Tabelle*/
.innerWrap
{
  max-width: 0;              /* wichtig in Tabellenlayout */
}

.inner-table col.col-label
{
  width: 1%;
}

.inner-table td:first-child,
.inner-table th:first-child
{
  width: 1%;
  white-space: nowrap;
}
.inner-table
{
  width: 100%;
  max-width: 100%;
  table-layout: fixed;       /* Spaltenbreiten fest, kein “rausdrücken” */
  border-collapse: collapse;
}

.inner-table th,
.inner-table td
{
  max-width: 0;              /* verhindert dass Content die Zelle aufzieht */
  overflow: hidden;
  text-overflow: ellipsis;   /* ... statt rauslaufen */
  white-space: nowrap;       /* ODER entfernen und unten durch wrap ersetzen */
}
html, body{
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3f4f6;
  color: #111827;
}

body{
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* Container */
.container{
  width: 100%;
  max-width: 1200px;
  margin: 1.5rem;
  padding: 1.5rem;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.08);
}

h1{
  margin: 0 0 1rem 0;
  font-size: 1.8rem;
  font-weight: 600;
  text-align: center;
}

/* Slider */
#rangeSlider{
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 10px;
  border-radius: 5px;
  background: #dddddd;
  outline: none;
}

#rangeSlider::-webkit-slider-thumb{
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #555555;
  border: 2px solid #ffffff;
  box-shadow: 0 0 2px rgba(0,0,0,0.5);
  cursor: pointer;
}

#rangeSlider::-moz-range-thumb{
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #555555;
  border: 2px solid #ffffff;
  box-shadow: 0 0 2px rgba(0,0,0,0.5);
  cursor: pointer;
}

#rangeSlider::-moz-range-track{
  height: 10px;
  border-radius: 5px;
  background: #dddddd;
}

/* Popup */
#popup{
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.55);
  z-index: 1500;
}

#popupBox{
  position: fixed;
  left: 50%;
  top: 60px;
  resize: both;
  overflow: auto;
  min-width: 500px;
  min-height: 350px;
  max-width: min(900px, 95vw);
  max-height: 80vh;
  overflow: auto;
  background: #ffffff;
  border-radius: 10px;
  padding: 0; /* wichtig: oben kein padding, damit Titlebar bündig ist */
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

#popupTitlebar{
  position: sticky;
  top: 0;
  z-index: 10;
  height: 34px;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  user-select: none;
  cursor: move;
}

#popupControls{
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 0 8px;
}

#popupMin, #popupCloseX{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 24px;
  cursor: pointer;
  border-radius: 6px;
}

#popupContent{
  padding: 12px 14px;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
}

#popupClose{
  margin: 0 14px 14px 14px;
  padding: 0.4rem 1.2rem;
  border-radius: 6px;
  border: none;
  background: #2563eb;
  color: #ffffff;
  font-size: 0.95rem;
  cursor: pointer;
}

#popupClose:hover{
  background: #1d4ed8;
}

/* Layout oben */
.top-flex{
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.left-controls{
  flex: 1 1 100%;
}

/* Tabelle */
.energy-table{
  table-layout: fixed;
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.energy-table td:nth-child(1),
.energy-table th:nth-child(1){
  width: 250px;
  min-width: 200px;
  max-width: 300px;
  overflow: hidden;
}

.energy-table th,
.energy-table td{
  border: 1px solid #e5e7eb;
  padding: 0.35rem 0.5rem;
  text-align: center;
}

.energy-table th{
  background: #f3f4f6;
  font-weight: 600;
}

.energy-table .row-label{
  text-align: left;
  font-weight: 600;
  background: #f9fafb;
}

/* Inputs */
.factor-input{
  width: 100%;
  padding: 0.25rem 0.4rem;
  font-size: 0.9rem;
  border-radius: 6px;
  border: 1px solid #d1d5db;
}

.factor-input:focus{
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37,99,235,0.2);
}

/* Checkboxen + Ausgabefeld */
.checkbox-output-row{
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
  margin-top: 0.75rem;
}

.checkbox-column{
  flex: 1 1 260px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.checkbox-line{
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.checkbox-line input[type="checkbox"]{
  width: 16px;
  height: 16px;
}

.checkbox-column button{
  margin-top: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  border: none;
  background: #059669;
  color: #ffffff;
  font-size: 0.9rem;
  cursor: pointer;
  align-self: flex-start;
}

.checkbox-column button:hover{
  background: #047857;
}

.co2-line{
  margin-top: 0.4rem;
  display: flex;
  justify-content: space-between;
  background: #f3f4f6;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.85rem;
}

.right-output{
  flex: 0 0 220px;
  border: 1px solid #e5e7eb;
  padding: 0.75rem 0.9rem;
  background: #f9fafb;
  border-radius: 8px;
}

#outputText{
  font-weight: 600;
  font-size: 0.95rem;
}

.Ausgabe-column{
  display: flex;
  flex-direction: column;
  text-align: left;
  gap: 8px;
}

/* Info-Text */
#info{
  min-height: 1.2rem;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: #b91c1c;
}
.right-output{
  display: flex;
  flex-direction: column;
}
.right-output > div{
  margin-bottom: 4px;
}
/* Plot */
.plot-wrapper{
  margin-top: 0.5rem;
  height: 420px;                 /* bleibt wie vorher */
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
}
#labelAbgeregelt,
#labelGrauerH2{
  display: block;
}

/* Canvas bekommt den verfügbaren Restplatz */
.plot-canvas{
  flex: 1 1 auto;
  min-height: 0;                 /* wichtig, damit Flex sauber rechnet */
}

/* Canvas füllt plot-canvas */
.plot-canvas canvas{
  display: block;
  width: 100%;
  height: 100%;
}

/* Slider nimmt eigene Zeile ein */
.plot-slider{
  flex: 0 0 auto;
  margin-top: 6px;
  padding: 0 8px;
}

/* Responsiv */
@media (max-width: 900px){
  .container{
    margin: 0.75rem;
    padding: 1rem;
  }

  .right-output{
    flex: 1 1 100%;
  }

  .plot-wrapper{
    height: 360px;
  }
}

@media (max-width: 600px){
  h1{
    font-size: 1.4rem;
  }

  .plot-wrapper{
    height: 320px;
  }
}
