/**
 * SunMonitor — Customer Inverters page (Sprint K redesign)
 *
 * Card-per-omvormer layout vervangt 4-section oude design.
 * Mobile: 1-koloms · Desktop: auto-fill grid met min 360px per card.
 */

#customerScreen .cust-inv-page {
  padding: var(--space-2, 8px) 0;
}

#customerScreen .cust-inv-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4, 16px);
  margin-bottom: var(--space-5, 20px);
  flex-wrap: wrap;
}

#customerScreen .cust-inv-title {
  margin: 0;
  font-size: var(--fs-18, 18px);
  font-weight: var(--fw-bold, 700);
  color: var(--text-primary, #111827);
  letter-spacing: -0.01em;
}

#customerScreen .cust-inv-sub {
  margin: 4px 0 0;
  font-size: var(--fs-12, 12px);
  color: var(--text-muted, #6b7280);
}

#customerScreen .cust-inv-actions {
  display: flex;
  gap: var(--space-2, 8px);
  align-items: center;
}

#customerScreen .cust-inv-actions .form-inp {
  min-width: 220px;
  padding: 6px 12px;
}

#customerScreen .cust-inv-actions .btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Cards grid */
#customerScreen .cust-inv-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: var(--space-4, 16px);
}

#customerScreen .cust-inv-card {
  background: var(--surface-card, #fff);
  border: 1px solid var(--color-gray-200, #e2e8f0);
  border-left-width: 4px;
  border-radius: var(--radius-lg, 14px);
  padding: var(--space-4, 16px) var(--space-5, 18px);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(15, 23, 42, 0.05));
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
#customerScreen .cust-inv-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md, 0 4px 12px rgba(15, 23, 42, 0.10));
}

#customerScreen .cust-inv-card-online  { border-left-color: var(--color-success-active, #047857); }
#customerScreen .cust-inv-card-stale   { border-left-color: var(--color-warning-active, #d97706); }
#customerScreen .cust-inv-card-offline { border-left-color: var(--color-danger-active, #b91c1c); }

#customerScreen .cust-inv-card-hd {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3, 12px);
  margin-bottom: var(--space-4, 14px);
  padding-bottom: var(--space-3, 12px);
  border-bottom: 1px solid var(--color-gray-100, #f3f4f6);
}

#customerScreen .cust-inv-card-name {
  margin: 0 0 2px;
  font-size: var(--fs-15, 15px);
  font-weight: var(--fw-bold, 700);
  color: var(--text-primary, #111827);
}

#customerScreen .cust-inv-card-sub {
  font-size: var(--fs-11, 11px);
  color: var(--text-muted, #6b7280);
}

#customerScreen .cust-inv-card-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-11, 11px);
  font-weight: var(--fw-semibold, 600);
  padding: 4px 10px;
  border-radius: var(--radius-full, 999px);
  background: var(--color-gray-100, #f3f4f6);
}
#customerScreen .cust-inv-card-online .cust-inv-card-status {
  background: rgba(16, 185, 129, 0.10);
  color: var(--color-success-active, #047857);
}
#customerScreen .cust-inv-card-stale .cust-inv-card-status {
  background: rgba(217, 119, 6, 0.10);
  color: var(--color-warning-active, #92400e);
}
#customerScreen .cust-inv-card-offline .cust-inv-card-status {
  background: rgba(185, 28, 28, 0.10);
  color: var(--color-danger-active, #b91c1c);
}

/* KPI's */
#customerScreen .cust-inv-card-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3, 12px);
  margin-bottom: var(--space-4, 14px);
}
#customerScreen .cust-inv-card-kpis > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3, 10px);
  background: var(--color-gray-50, #f9fafb);
  border-radius: var(--radius-md, 8px);
}
#customerScreen .cust-inv-card-kpis span {
  font-size: var(--fs-10, 10px);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted, #6b7280);
  font-weight: var(--fw-semibold, 600);
}
#customerScreen .cust-inv-card-kpis strong {
  font-size: var(--fs-15, 15px);
  color: var(--text-primary, #111827);
  font-weight: var(--fw-bold, 700);
}

/* Curve per string (vandaag) */
#customerScreen .cust-inv-curve-wrap {
  margin-bottom: var(--space-4, 14px);
  padding: var(--space-3, 12px);
  background: var(--color-gray-50, #f9fafb);
  border-radius: var(--radius-md, 10px);
}

#customerScreen .cust-inv-curve-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2, 8px);
}

#customerScreen .cust-inv-curve-title {
  font-size: var(--fs-11, 11px);
  font-weight: var(--fw-semibold, 600);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted, #6b7280);
}

#customerScreen .cust-inv-curve-loading {
  font-size: var(--fs-10, 10px);
  color: var(--text-muted, #6b7280);
  font-style: italic;
}

#customerScreen .cust-inv-curve-zoom {
  background: transparent;
  border: 0;
  padding: 2px 6px;
  cursor: pointer;
  color: var(--text-muted, #6b7280);
  border-radius: 4px;
  margin-left: auto;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  transition: background .15s ease, color .15s ease;
}
#customerScreen .cust-inv-curve-zoom:hover {
  background: var(--color-gray-100, #f3f4f6);
  color: var(--text-primary, #111827);
}

/* Vergroot-modal overlay */
.cust-inv-curve-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4, 16px);
  animation: cust-inv-fade-in .15s ease;
}
@keyframes cust-inv-fade-in { from { opacity: 0; } to { opacity: 1; } }

.cust-inv-curve-modal {
  background: var(--surface-card, #fff);
  border-radius: var(--radius-lg, 14px);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.30);
  width: min(1100px, 95vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cust-inv-curve-modal-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-gray-100, #f3f4f6);
  flex-wrap: wrap;
}
.cust-inv-curve-modal-titles { min-width: 0; }
.cust-inv-curve-modal-hd h3 {
  margin: 0;
  font-size: var(--fs-16, 16px);
  font-weight: var(--fw-bold, 700);
  color: var(--text-primary, #111827);
}
.cust-inv-curve-modal-sub {
  font-size: var(--fs-12, 12px);
  color: var(--text-muted, #6b7280);
  margin-top: 2px;
  text-transform: capitalize;
}

.cust-inv-curve-modal-tools {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cust-inv-curve-day-btn {
  background: var(--color-gray-50, #f9fafb);
  border: 1px solid var(--color-gray-200, #e2e8f0);
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
  color: var(--text-secondary, #4b5563);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
}
.cust-inv-curve-day-btn:hover {
  background: var(--color-gray-100, #f3f4f6);
  color: var(--text-primary, #111827);
}
.cust-inv-curve-day-input {
  border: 1px solid var(--color-gray-200, #e2e8f0);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: var(--fs-13, 13px);
  color: var(--text-primary, #111827);
  background: #fff;
}
.cust-inv-curve-day-today {
  background: var(--color-gray-50, #f9fafb);
  border: 1px solid var(--color-gray-200, #e2e8f0);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: var(--fs-12, 12px);
  font-weight: var(--fw-semibold, 600);
  color: var(--text-secondary, #4b5563);
}
.cust-inv-curve-day-today:hover {
  background: var(--color-gray-100, #f3f4f6);
  color: var(--text-primary, #111827);
}
.cust-inv-curve-modal-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.7);
  font-size: var(--fs-13, 13px);
  color: var(--text-muted, #6b7280);
  font-style: italic;
  z-index: 2;
}
.cust-inv-curve-modal-close {
  background: transparent;
  border: 0;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 6px;
  font-size: 18px;
  color: var(--text-muted, #6b7280);
  display: inline-flex;
  align-items: center;
}
.cust-inv-curve-modal-close:hover {
  background: var(--color-gray-100, #f3f4f6);
  color: var(--text-primary, #111827);
}

.cust-inv-curve-modal-bd {
  flex: 1;
  min-height: 0;
  padding: 16px 20px 8px;
  position: relative;
  height: 60vh;
}
.cust-inv-curve-modal-bd canvas {
  width: 100% !important;
  height: 100% !important;
}

.cust-inv-curve-overlay .cust-inv-curve-legend {
  padding: 12px 20px 18px;
  font-size: var(--fs-14, 14px);
  gap: 18px;
  border-top: 1px solid var(--color-gray-100, #f3f4f6);
  background: var(--color-gray-50, #f9fafb);
  flex-wrap: wrap;
}
.cust-inv-curve-overlay .cust-inv-curve-legend-item {
  font-size: var(--fs-13, 13px);
  font-weight: var(--fw-semibold, 600);
  color: var(--text-primary, #111827);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: #fff;
  border: 1px solid var(--color-gray-200, #e2e8f0);
  border-radius: 999px;
}
.cust-inv-curve-overlay .cust-inv-curve-legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .cust-inv-curve-modal { width: 100vw; max-height: 100vh; border-radius: 0; }
  .cust-inv-curve-modal-bd { height: 55vh; }
  /* Header verticaal stacken zodat de date-tools een eigen rij krijgen */
  .cust-inv-curve-modal-hd {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }
  .cust-inv-curve-modal-hd h3 { font-size: 14px; }
  .cust-inv-curve-modal-sub { font-size: 11px; }
  .cust-inv-curve-modal-tools {
    flex-wrap: wrap;
    gap: 4px;
  }
  .cust-inv-curve-day-input {
    flex: 1 1 auto;
    min-width: 120px;
    font-size: 12px;
  }
  .cust-inv-curve-day-today { font-size: 10px; padding: 5px 8px; }
  .cust-inv-curve-modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
  }
  /* Legend chips kleiner */
  .cust-inv-curve-overlay .cust-inv-curve-legend {
    padding: 10px 14px 14px;
    gap: 8px;
  }
  .cust-inv-curve-overlay .cust-inv-curve-legend-item {
    font-size: 11px;
    padding: 3px 8px;
  }
}

/* ─── I-V curve sectie in detail-modal ─── */
.cust-inv-iv-wrap { margin-top: 8px; }
.cust-inv-iv-hint {
  font-size: 12px; color: #64748b; line-height: 1.4;
  padding: 8px 12px; background: #f9fafb;
  border-left: 3px solid #cbd5e1; border-radius: 4px; margin-bottom: 12px;
}
.cust-inv-iv-loading, .cust-inv-iv-empty {
  text-align: center; padding: 24px; color: #6b7280; font-size: 13px;
}
.cust-inv-iv-meta {
  display: flex; gap: 18px; padding: 8px 12px; margin-bottom: 10px;
  background: #f3f4f6; border-radius: 6px; font-size: 12px;
}
.cust-inv-iv-meta strong { color: #111827; font-family: var(--font-mono, monospace); }
.cust-inv-iv-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
.cust-inv-iv-card {
  border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px;
  background: #fff;
}
.cust-inv-iv-card-hd {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; margin-bottom: 8px;
}
.cust-inv-iv-card-name { font-weight: 700; font-size: 13px; color: #111827; }
.cust-inv-iv-diag-badge {
  font-size: 11px; font-weight: 600; padding: 3px 8px;
  border-radius: 999px; white-space: nowrap;
}
.cust-inv-iv-canvas-wrap { height: 220px; position: relative; }
.cust-inv-iv-reason {
  font-size: 11px; color: #475569; margin-top: 6px; font-style: italic;
}
.cust-inv-iv-features {
  display: flex; gap: 10px; font-size: 11px; color: #64748b;
  margin-top: 8px; font-family: var(--font-mono, monospace);
}
.cust-inv-iv-kinks { color: #d97706; font-weight: 600; }

/* Admin inverter-edit form (gebruikt hetzelfde .cust-inv-curve-modal frame) */
.adm-form .adm-form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.adm-form .adm-form-row > span {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}
.adm-form .form-inp {
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}
.adm-form .form-inp:focus {
  outline: none;
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}
@media (max-width: 540px) {
  #invEditForm { grid-template-columns: 1fr !important; }
}

#customerScreen .cust-inv-curve-canvas-wrap {
  position: relative;
  height: 140px;
  margin-bottom: var(--space-2, 8px);
}

#customerScreen .cust-inv-curve-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3, 10px);
  font-size: var(--fs-11, 11px);
  color: var(--text-secondary, #4b5563);
}

#customerScreen .cust-inv-curve-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: var(--fw-semibold, 600);
}

#customerScreen .cust-inv-curve-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* Strings */
#customerScreen .cust-inv-strings {
  margin-bottom: var(--space-3, 12px);
}
#customerScreen .cust-inv-strings-hd {
  font-size: var(--fs-11, 11px);
  font-weight: var(--fw-semibold, 600);
  color: var(--text-muted, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-2, 8px);
}
#customerScreen .cust-inv-string {
  display: grid;
  grid-template-columns: 70px 1fr 70px auto;
  align-items: center;
  gap: var(--space-2, 8px);
  padding: 4px 0;
}
#customerScreen .cust-inv-string-label {
  font-size: var(--fs-11, 11px);
  font-weight: var(--fw-semibold, 600);
  color: var(--text-secondary, #4b5563);
}
#customerScreen .cust-inv-string-bar {
  height: 8px;
  background: var(--color-gray-100, #f3f4f6);
  border-radius: 4px;
  overflow: hidden;
}
#customerScreen .cust-inv-string-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .3s ease;
}
#customerScreen .cust-inv-string-bar-fill.is-ok    { background: linear-gradient(90deg, #34d399, #10b981); }
#customerScreen .cust-inv-string-bar-fill.is-amber { background: linear-gradient(90deg, #fbbf24, #d97706); }
#customerScreen .cust-inv-string-bar-fill.is-warn  { background: linear-gradient(90deg, #f87171, #b91c1c); }

#customerScreen .cust-inv-string-value {
  font-size: var(--fs-11, 11px);
  font-family: var(--font-mono, monospace);
  font-weight: var(--fw-semibold, 600);
  color: var(--text-primary, #111827);
  text-align: right;
}
#customerScreen .cust-inv-string-note {
  font-size: var(--fs-10, 10px);
  font-weight: var(--fw-bold, 700);
  color: var(--color-warning-active, #d97706);
  padding: 2px 6px;
  background: rgba(217, 119, 6, 0.10);
  border-radius: 4px;
  white-space: nowrap;
}

/* Aandachtspunten */
#customerScreen .cust-inv-attention {
  padding: var(--space-3, 12px);
  background: rgba(14, 165, 233, 0.06);
  border-left: 3px solid var(--color-info-active, #0284c7);
  border-radius: var(--radius-md, 8px);
}
#customerScreen .cust-inv-attention-hd {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-11, 11px);
  font-weight: var(--fw-bold, 700);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-info-active, #0284c7);
  margin-bottom: var(--space-2, 8px);
}
#customerScreen .cust-inv-attention-hd i { font-size: 14px; }
#customerScreen .cust-inv-attention ul {
  margin: 0;
  padding-left: 18px;
  list-style: disc;
}
#customerScreen .cust-inv-attention li {
  font-size: var(--fs-12, 12px);
  color: var(--text-secondary, #4b5563);
  line-height: 1.5;
  padding: 2px 0;
}

/* Mobile */
@media (max-width: 640px) {
  #customerScreen .cust-inv-cards {
    grid-template-columns: 1fr;
  }
  #customerScreen .cust-inv-actions {
    width: 100%;
  }
  #customerScreen .cust-inv-actions .form-inp {
    flex: 1;
    min-width: 0;
  }
  #customerScreen .cust-inv-card-kpis {
    grid-template-columns: 1fr;
    gap: var(--space-2, 6px);
  }
  #customerScreen .cust-inv-card-kpis > div {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}
