/* ============================================================
   Heizlast-Rechner – Styles
   Kompatibel mit Enfold / WordPress, nutzt CSS Custom Properties.
   ============================================================ */

/* ─── Basis-Reset im Plugin-Scope ─── */
.hlr-app *,
.hlr-app *::before,
.hlr-app *::after {
  box-sizing: border-box;
}

/* ─── Layout ─── */
.hlr-app {
  font-family: inherit;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ─── Card ─── */
.hlr-card {
  background: #fff;
  border: 1px solid #e2e5e9;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

.hlr-section-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1a1a2e;
  margin: 0 0 1.5rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}

.hlr-step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #1e6ebe;
  color: #fff;
  font-size: .85rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ─── Felder ─── */
.hlr-field-group {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  margin-bottom: 1.25rem;
  flex: 1;
}

.hlr-field-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.hlr-field-row .hlr-field-group {
  min-width: 200px;
}

.hlr-label {
  font-size: .875rem;
  font-weight: 600;
  color: #374151;
}

.hlr-label abbr {
  color: #e05a2b;
  text-decoration: none;
  margin-left: 2px;
}

.hlr-input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}

.hlr-input-wrap:focus-within {
  border-color: #1e6ebe;
  box-shadow: 0 0 0 3px rgba(30,110,190,.15);
}

.hlr-input {
  border: none;
  padding: .6rem .75rem;
  font-size: 1rem;
  width: 100%;
  outline: none;
  background: transparent;
  color: #111;
}

/* Standalone inputs (Adresse) */
.hlr-autocomplete-wrap .hlr-input {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: .65rem .85rem;
  transition: border-color .15s, box-shadow .15s;
}

.hlr-autocomplete-wrap .hlr-input:focus {
  border-color: #1e6ebe;
  box-shadow: 0 0 0 3px rgba(30,110,190,.15);
  outline: none;
}

.hlr-unit {
  padding: .6rem .75rem;
  background: #f3f4f6;
  color: #6b7280;
  font-size: .85rem;
  white-space: nowrap;
  border-left: 1px solid #e5e7eb;
}

.hlr-help {
  font-size: .8rem;
  color: #6b7280;
  margin: 0;
}

/* ─── Autocomplete Dropdown ─── */
.hlr-autocomplete-wrap {
  position: relative;
}

.hlr-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  list-style: none;
  padding: .25rem 0;
  margin: 0;
  z-index: 9999;
  max-height: 260px;
  overflow-y: auto;
  display: none;
}

.hlr-suggestion-item {
  padding: .55rem 1rem;
  cursor: pointer;
  font-size: .9rem;
  color: #1f2937;
  transition: background .1s;
}

.hlr-suggestion-item:hover,
.hlr-suggestion-item--active {
  background: #eff6ff;
  color: #1e6ebe;
}

/* ─── Karte ─── */
.hlr-map {
  height: 240px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e2e5e9;
  margin-bottom: 1rem;
}

/* ─── Bestätigungsbanner ─── */
.hlr-confirm-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  border-radius: 8px;
  padding: .65rem 1rem;
  font-size: .9rem;
  color: #065f46;
  margin-bottom: 1.25rem;
  gap: 1rem;
}

/* ─── Advanced / Accordion ─── */
.hlr-advanced {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 1.25rem;
}

.hlr-advanced-toggle {
  list-style: none;
  cursor: pointer;
  padding: .75rem 1rem;
  font-size: .9rem;
  font-weight: 600;
  color: #374151;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.hlr-advanced-toggle::-webkit-details-marker { display: none; }

.hlr-advanced[open] .hlr-chevron {
  transform: rotate(180deg);
}

.hlr-chevron {
  transition: transform .2s;
  flex-shrink: 0;
}

.hlr-advanced-body {
  padding: 0 1rem 1rem;
}

/* ─── Radio Group ─── */
.hlr-radio-group {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

.hlr-radio-label {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  font-size: .9rem;
  cursor: pointer;
  padding: .6rem .8rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  transition: border-color .15s, background .15s;
}

.hlr-radio-label:has(input:checked) {
  border-color: #1e6ebe;
  background: #eff6ff;
}

.hlr-radio-label input[type="radio"] {
  margin-top: .2rem;
  flex-shrink: 0;
  accent-color: #1e6ebe;
}

.hlr-radio-label span {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.hlr-radio-label strong {
  color: #1a1a2e;
  font-weight: 600;
}

.hlr-radio-label small {
  font-size: .78rem;
  color: #6b7280;
}

/* ─── Buttons ─── */
.hlr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .7rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, box-shadow .15s, opacity .15s;
  border: none;
  text-decoration: none;
}

.hlr-btn--primary {
  background: #1e6ebe;
  color: #fff;
  margin-top: .5rem;
}

.hlr-btn--primary:hover:not(:disabled) {
  background: #155da1;
  box-shadow: 0 4px 12px rgba(30,110,190,.3);
}

.hlr-btn--primary:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.hlr-btn--ghost {
  background: transparent;
  color: #374151;
  border: 1px solid #d1d5db;
}

.hlr-btn--ghost:hover {
  background: #f3f4f6;
}

.hlr-btn--sm {
  padding: .3rem .8rem;
  font-size: .85rem;
}

/* ─── Ladeindikator ─── */
.hlr-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem;
  color: #6b7280;
}

.hlr-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e5e7eb;
  border-top-color: #1e6ebe;
  border-radius: 50%;
  animation: hlr-spin .8s linear infinite;
}

@keyframes hlr-spin {
  to { transform: rotate(360deg); }
}

/* ─── Fehler ─── */
.hlr-error-banner {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  color: #991b1b;
  padding: 1rem 1.25rem;
  font-size: .9rem;
}

/* ─── Ergebnis Hero ─── */
.hlr-result-hero {
  text-align: center;
  background: linear-gradient(135deg, #1e6ebe 0%, #0e4a8a 100%);
  color: #fff;
  border-radius: 10px;
  padding: 2rem 1rem;
  margin-bottom: 1.5rem;
}

.hlr-hero-label {
  font-size: .9rem;
  opacity: .85;
  margin-bottom: .25rem;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.hlr-hero-value {
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1.1;
}

.hlr-hero-unit {
  font-size: 1.5rem;
  font-weight: 400;
  opacity: .8;
  margin-left: .25rem;
}

.hlr-hero-quantile {
  font-size: .78rem;
  opacity: .75;
  margin-top: .25rem;
  letter-spacing: .03em;
}

.hlr-hero-meta {
  font-size: .8rem;
  opacity: .7;
  margin-top: .5rem;
}

/* ─── KPI-Zeile ─── */
.hlr-kpi-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.hlr-kpi {
  flex: 1;
  min-width: 140px;
  background: #f8fafc;
  border: 1px solid #e2e5e9;
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

.hlr-kpi-label {
  font-size: .78rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .25rem;
}

.hlr-kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1a1a2e;
}

/* ─── Chart ─── */
.hlr-chart-wrap {
  margin-bottom: 1.5rem;
  max-height: 320px;
}

/* ─── Tabellen ─── */
.hlr-table-wrap {
  overflow-x: auto;
  padding: 0 1rem 1rem;
}

.hlr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.hlr-table th,
.hlr-table td {
  padding: .5rem .75rem;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

.hlr-table th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
}

.hlr-table tr:last-child td {
  border-bottom: none;
}

.hlr-table tr:hover td {
  background: #f0f7ff;
}

/* ─── Responsive ─── */
@media (max-width: 600px) {
  .hlr-card { padding: 1.25rem; }
  .hlr-field-row { flex-direction: column; gap: .75rem; }
  .hlr-hero-value { font-size: 2.5rem; }
  .hlr-kpi-row { gap: .75rem; }
}

.hlr-radio-label--compare {
  border-style: dashed;
  border-color: #d1d5db;
  background: #fafafa;
}

.hlr-radio-label--compare:has(input:checked) {
  border-color: #6b7280;
  border-style: dashed;
  background: #f3f4f6;
}

.hlr-radio-label--compare strong {
  color: #374151;
}

.hlr-radio-label--compare::after {
  content: 'Vergleich';
  font-size: .7rem;
  font-weight: 600;
  color: #6b7280;
  background: #e5e7eb;
  padding: .1rem .4rem;
  border-radius: 4px;
  margin-left: auto;
  white-space: nowrap;
  align-self: center;
}
.hlr-kpi--highlight {
  border-color: #1e6ebe;
  background: #eff6ff;
}

.hlr-kpi--highlight .hlr-kpi-label {
  color: #1e6ebe;
}

.hlr-kpi-note {
  font-size: .72rem;
  color: #6b7280;
  margin-top: .2rem;
}

.hlr-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.hlr-results-header .hlr-section-title {
  margin: 0;
}

.hlr-btn--icon {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}

/* ─── CSV-Export-Buttons in Summary ─── */
.hlr-summary-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
}

.hlr-export-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .6rem;
  font-size: .78rem;
  font-weight: 600;
  color: #1e6ebe;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}

.hlr-export-btn:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

/* ─── Aktionszeile unten ─── */
.hlr-action-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid #e5e7eb;
  align-items: center;
}

/* ─── Modal Overlay ─── */
.hlr-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 999999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  /* padding-top wird per JS auf gemessene Header-Höhe + 16px gesetzt */
  padding: var(--hlr-modal-top, 100px) 1rem 2rem;
  overflow-y: auto;
  box-sizing: border-box;
}

/* ─── Modal Box ─── */
.hlr-modal {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%;
  max-width: 680px;
  /* Kein max-height mehr nötig – das Overlay selbst scrollt */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 1rem;  /* Abstand zum unteren Rand beim Scrollen */
}

.hlr-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.hlr-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a1a2e;
  margin: 0;
}

.hlr-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #6b7280;
  padding: .25rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color .15s, background .15s;
}

.hlr-modal-close:hover {
  color: #111;
  background: #f3f4f6;
}

.hlr-modal-body {
  padding: 1.5rem;
}

.hlr-modal-intro {
  color: #374151;
  line-height: 1.6;
  margin-bottom: 1.5rem;
  padding: .9rem 1rem;
  background: #f0f7ff;
  border-left: 3px solid #1e6ebe;
  border-radius: 0 6px 6px 0;
}

.hlr-modal-body h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #1a1a2e;
  margin: 1.5rem 0 .6rem;
  padding-top: 1rem;
  border-top: 1px solid #f3f4f6;
}

.hlr-modal-body h3:first-of-type {
  border-top: none;
  margin-top: .5rem;
}

.hlr-modal-body p {
  color: #374151;
  line-height: 1.6;
  margin-bottom: .5rem;
  font-size: .9rem;
}

/* ─── Formel-Box ─── */
.hlr-formula-box {
  background: #1a1a2e;
  color: #e0e7ff;
  font-family: 'Courier New', monospace;
  font-size: .95rem;
  padding: .75rem 1.25rem;
  border-radius: 8px;
  margin: .6rem 0 .8rem;
  letter-spacing: .02em;
  line-height: 1.7;
}

.hlr-formula-box--result {
  background: #1e3a6e;
  border: 2px solid #3b82f6;
  color: #fff;
  font-size: 1rem;
}

.hlr-formula-note {
  font-size: .82rem !important;
  color: #6b7280 !important;
  font-style: italic;
  margin-top: -.25rem !important;
}

/* ─── Formel-Legende ─── */
.hlr-formula-legend {
  list-style: none;
  padding: 0;
  margin: .25rem 0 .75rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.hlr-formula-legend li {
  font-size: .85rem;
  color: #374151;
  padding-left: 1.1rem;
  position: relative;
}

.hlr-formula-legend li::before {
  content: '·';
  position: absolute;
  left: .25rem;
  color: #9ca3af;
}

/* ─── Hinweis-Box im Modal ─── */
.hlr-modal-note {
  margin-top: 1.5rem;
  padding: .9rem 1rem;
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  border-radius: 0 6px 6px 0;
  font-size: .85rem;
  color: #374151;
  line-height: 1.6;
}

/* ─── Responsive Modal ─── */
@media (max-width: 600px) {
  .hlr-modal { border-radius: 10px; max-height: 95vh; }
  .hlr-modal-body { padding: 1rem; }
  .hlr-formula-box { font-size: .82rem; }
  .hlr-action-row { flex-direction: column; }
  .hlr-results-header { flex-wrap: wrap; gap: .5rem; }
}
