/* meters.css — settings + editor page for the two LESCO meters. */

header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; gap: 24px; }

.pill-muted {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--card-edge);
  border-radius: 999px;
  padding: 3px 10px;
  letter-spacing: 0.02em;
}

.card { margin-bottom: 16px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-desc {
  margin: 2px 0 16px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.55;
}

/* ---------- Collapsible Billing Settings (native <details>) ---------- */
.settings-details { padding: 0; }
.settings-details > *:not(summary) { padding-left: 24px; padding-right: 24px; }
.settings-details > *:not(summary):last-child { padding-bottom: 24px; }
.settings-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 24px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  outline: none;
}
.settings-summary::-webkit-details-marker { display: none; }
.settings-summary-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  flex-shrink: 0;
}
.settings-summary-values {
  flex: 1;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.settings-summary-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-dim);
  transition: transform .2s ease;
  flex-shrink: 0;
}
.settings-details[open] .settings-summary-chevron { transform: rotate(180deg); }
.settings-details[open] .settings-summary {
  border-bottom: 1px solid var(--card-edge);
  padding-bottom: 16px;
  margin-bottom: 16px;
}
.settings-summary:hover .settings-summary-title,
.settings-summary:hover .settings-summary-chevron { color: var(--text); }

/* ---------- Meter card ---------- */
.meter-card { position: relative; }
.meter-card .meter-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}
.meter-active-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.35);
  margin-right: 8px;
  vertical-align: middle;
  transition: background .2s, box-shadow .2s;
}
.meter-card.active .meter-active-dot {
  background: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}
.meter-card.active .meter-card-title { color: #7dd3fc; }

.meter-state-pill.active {
  background: rgba(52, 211, 153, 0.12);
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.3);
}
.meter-state-pill.inactive {
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-dim);
}

/* Cluster of pills (protected status + active/standby) shown together
   in the card head. The .pill-muted classes the JS removes on render
   would otherwise leave the gap awkward — flex with a small gap fixes it. */
.meter-pills { display: inline-flex; gap: 6px; align-items: center; }

/* Protected/Unprotected — derived from current-period units vs NEPRA
   200u cap. Visual weight matches severity: green for safe, red for lost. */
.meter-protected-pill.protected {
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.30);
}
.meter-protected-pill.unprotected {
  background: rgba(248, 113, 113, 0.14);
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.35);
  font-weight: 700;
}

.meter-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 14px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--card-edge);
  border-radius: 10px;
  margin: 14px 0 18px;
}
.meter-stats .stat { display: flex; flex-direction: column; gap: 4px; }
.meter-stats .stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 500;
}
.meter-stats .stat-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ---------- Form fields (shared with billing settings + meter cards) ---------- */
.field { margin-bottom: 18px; }
.field:last-of-type { margin-bottom: 10px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.field input[type="text"],
.field input[type="number"] {
  flex: 1;
  min-width: 0;
  background: rgba(20, 26, 42, 0.7);
  border: 1px solid var(--card-edge);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-family: "Inter", sans-serif;
  font-size: 14px;
  letter-spacing: 0.01em;
  transition: border-color .15s, background .15s;
}
.field input.mono {
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  letter-spacing: 0;
}
.field input:focus {
  outline: none;
  border-color: var(--batt-soft);
  background: rgba(20, 26, 42, 0.9);
}
.field input[type="number"] { max-width: 120px; }
.field-suffix {
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}
.field-hint {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.55;
}

/* ---------- Copy-row ---------- */
.copy-row input { flex: 1; }
.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #7dd3fc;
  border-radius: 8px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.btn-copy svg { width: 14px; height: 14px; }
.btn-copy:hover { background: rgba(56, 189, 248, 0.18); }
.btn-copy.copied { background: rgba(52, 211, 153, 0.18); border-color: rgba(52, 211, 153, 0.35); color: #34d399; }
.btn-copy.copied .btn-copy-label { color: #34d399; }
.btn-copy:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Form actions ---------- */
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.btn-primary, .btn-secondary {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background .15s, transform .08s;
}
.btn-primary {
  background: var(--batt-soft);
  color: #0b1220;
}
.btn-primary:hover { background: #7dd3fc; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--card-edge);
}
.btn-secondary:hover { background: rgba(255,255,255,0.04); }
.btn-secondary:disabled { opacity: 0.35; cursor: not-allowed; }

.save-msg {
  font-size: 12px;
  color: var(--text-dim);
  transition: opacity .2s;
}
.save-msg.ok { color: #34d399; }
.save-msg.err { color: #f87171; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  header { gap: 12px; margin-bottom: 14px; align-items: center; }
  .meter-stats { grid-template-columns: 1fr; }
  .field-row { flex-wrap: wrap; }
  .btn-copy { width: 100%; justify-content: center; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions .btn-primary,
  .form-actions .btn-secondary { width: 100%; }
}
