/* PowerQual — Power Factor Correction Calculator
 * Modern, clean theme aligned to ELCO's white + gold + navy brand.
 * All selectors scoped under .pq-wrap so the plugin never touches the host theme.
 * NOTE: --rule, --cream, --accent/2/3 and --gold are referenced by the inline
 *       SVG diagram and the template — keep them defined.
 */
.pq-wrap {
  /* Neutrals */
  --ink:       #16202e;   /* near-black navy — headings & primary text */
  --ink-2:     #3a4456;   /* secondary text */
  --muted:     #8b94a3;   /* labels / tertiary */
  --line:      #e7e9ee;   /* hairline borders */
  --line-2:    #eef0f4;   /* lighter dividers */
  --paper:     #f3f5f8;   /* page background */
  --surface:   #ffffff;   /* cards */
  --surface-2: #f6f8fa;   /* inputs / diagram canvas / insets */
  --cream:     #f3f4f7;   /* legacy alias (used by inline refs) */
  --rule:      #d9dde4;   /* SVG legend stroke */

  /* Brand gold */
  --gold:      #b9881f;
  --gold-dk:   #9a6f12;
  --gold-tint: #faf3e1;
  --gold-line: rgba(185,134,31,0.28);

  /* Semantic colours — must match the diagram (do not retheme) */
  --accent:    #c0392b;   /* red   — "before" / warnings */
  --accent2:   #1a6b3c;   /* green — "after" / savings   */
  --accent3:   #1a4a7a;   /* blue  — active power        */

  --shadow:    rgba(22,32,46,0.10);
}

.pq-wrap * { box-sizing: border-box; margin: 0; padding: 0; }

.pq-wrap {
  background: transparent;
  color: var(--ink);
  font-family: 'DM Sans', system-ui, sans-serif;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Break out wider than the theme's content column, centred and capped to the
     viewport so it never triggers a horizontal scrollbar. */
  width: min(1500px, 94vw);
  margin-left: 50%;
  transform: translateX(-50%);
}

.pq-wrap .page {
  max-width: 1500px;
  margin: 0 auto;
  padding: 44px 32px 24px;
  position: relative;
  z-index: 1;
}

/* ── Section label ──────────────────────────────────────────────────── */
.pq-wrap .section-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.pq-wrap .section-label::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--gold);
  flex-shrink: 0;
}
.pq-wrap .section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ── Layout ─────────────────────────────────────────────────────────── */
.pq-wrap .layout {
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 24px;
  margin-bottom: 24px;
  align-items: start;
}

/* ── Panels / cards ─────────────────────────────────────────────────── */
.pq-wrap .panel,
.pq-wrap .results-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px;
  box-shadow: 0 1px 2px rgba(22,32,46,0.04),
              0 14px 34px -18px rgba(22,32,46,0.20);
}
.pq-wrap .panel-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 11px;
}
.pq-wrap .panel-title .icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--gold-tint);
  border: 1px solid var(--gold-line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.pq-wrap .panel-title .icon svg { color: var(--gold-dk); display: block; }

/* ── Fields ─────────────────────────────────────────────────────────── */
.pq-wrap .field-group { margin-bottom: 18px; }
.pq-wrap label {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  gap: 4px 10px;
}
.pq-wrap .label-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
}
.pq-wrap .label-unit {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.pq-wrap input[type="number"],
.pq-wrap select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface-2);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  appearance: textfield;
  -moz-appearance: textfield;
}
.pq-wrap input[type="number"]::-webkit-outer-spin-button,
.pq-wrap input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }
.pq-wrap input[type="number"]:hover,
.pq-wrap select:hover { border-color: #cfd4dc; }
.pq-wrap input[type="number"]:focus,
.pq-wrap select:focus {
  border-color: var(--gold);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(185,134,31,0.15);
}
.pq-wrap select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238b94a3' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* ── Segmented toggle (Load Type / PF Target Type) ──────────────────── */
.pq-wrap .phase-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
}
.pq-wrap .phase-btn {
  appearance: none;
  border: none;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  padding: 9px 8px;
  border-radius: 9px;
  cursor: pointer;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.pq-wrap .phase-btn svg { flex-shrink: 0; }
.pq-wrap .phase-btn:hover { color: var(--ink); }
.pq-wrap .phase-btn.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(22,32,46,0.10),
              0 3px 10px -5px rgba(22,32,46,0.30);
}

/* ── Slider ─────────────────────────────────────────────────────────── */
.pq-wrap .slider-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}
/* Slider track wrapper + unity marker (capacitive overcorrection UI) */
.pq-wrap .slider-track-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}
.pq-wrap .slider-track-wrap input[type="range"] { flex: 1; width: 100%; }
.pq-wrap .unity-marker {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.pq-wrap .unity-marker .unity-tick {
  width: 2px;
  height: 11px;
  background: var(--ink);
  opacity: 0.5;
  margin-top: -2px;
}
.pq-wrap .unity-marker .unity-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 9px;
  font-weight: 600;
  color: var(--ink);
  opacity: 0.55;
  margin-top: 3px;
  white-space: nowrap;
}
.pq-wrap input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}
.pq-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(22,32,46,0.25);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.pq-wrap input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(22,32,46,0.25);
  cursor: pointer;
}
.pq-wrap input[type="range"]::-moz-range-track {
  height: 6px; background: var(--line); border-radius: 999px;
}
.pq-wrap input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.12); }
.pq-wrap input[type="range"]:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(185,134,31,0.18);
}
.pq-wrap .range-val {
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--gold-dk);
  min-width: 46px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Calculate button ───────────────────────────────────────────────── */
.pq-wrap .calc-btn {
  position: relative;
  overflow: hidden;
  width: 100%;
  padding: 15px;
  margin-top: 10px;
  background: linear-gradient(180deg, #1f2c44, var(--ink));
  color: #fff;
  border: none;
  border-radius: 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.12s ease;
}
/* Flat-gold wipe that slides in from the left on hover (a gradient->solid
   background can't be transitioned, so we animate an overlay instead). */
.pq-wrap .calc-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gold);
  transform: translateX(-101%);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 0;
}
.pq-wrap .calc-btn:hover::before { transform: translateX(0); }
.pq-wrap .calc-btn:active { transform: scale(0.99); }
.pq-wrap .calc-btn span { position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.pq-wrap .calc-btn svg { flex-shrink: 0; }

/* ── Results: KPI cards ─────────────────────────────────────────────── */
.pq-wrap .result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.pq-wrap .result-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 15px 16px 15px 18px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(22,32,46,0.04);
  transition: transform 0.2s, box-shadow 0.2s;
}
.pq-wrap .result-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px -12px rgba(22,32,46,0.25);
}
.pq-wrap .result-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: 4px 0 0 4px;
}
.pq-wrap .result-card.red::before    { background: var(--accent); }
.pq-wrap .result-card.green::before  { background: var(--accent2); }
.pq-wrap .result-card.blue::before   { background: var(--accent3); }
.pq-wrap .result-card.gold::before   { background: var(--gold); }
.pq-wrap .result-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.pq-wrap .result-value {
  font-family: 'DM Sans', sans-serif;
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 4px;
  transition: all 0.4s;
}
.pq-wrap .result-value.red   { color: var(--accent); }
.pq-wrap .result-value.green { color: var(--accent2); }
.pq-wrap .result-value.blue  { color: var(--accent3); }
.pq-wrap .result-value.gold  { color: var(--gold-dk); }
.pq-wrap .result-sub {
  font-size: 11px;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
}

/* ── Power triangle / 3D diagram canvas ─────────────────────────────── */
.pq-wrap .triangle-wrap {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 20px;
  text-align: center;
}
.pq-wrap .triangle-wrap svg { width: 100%; height: auto; display: block; }

/* ── Component sizing table ─────────────────────────────────────────── */
.pq-wrap .rec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-bottom: 8px;
}
.pq-wrap .rec-table th {
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.pq-wrap .rec-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}
.pq-wrap .rec-table tr:last-child td { border-bottom: none; }
.pq-wrap .rec-table tbody tr { transition: background 0.15s; }
.pq-wrap .rec-table tbody tr:hover td { background: var(--surface-2); }
.pq-wrap .rec-table .val {
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  color: var(--ink);
}

/* ── Component badges ───────────────────────────────────────────────── */
.pq-wrap .badge-comp {
  display: inline-block;
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  letter-spacing: 0.03em;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 500;
}
.pq-wrap .badge-cap { background: rgba(26,107,60,0.10);  color: var(--accent2); border: 1px solid rgba(26,107,60,0.22); }
.pq-wrap .badge-ind { background: rgba(26,74,122,0.10);  color: var(--accent3); border: 1px solid rgba(26,74,122,0.22); }
.pq-wrap .badge-con { background: rgba(185,134,31,0.12); color: var(--gold-dk); border: 1px solid var(--gold-line); }
.pq-wrap .badge-fus { background: rgba(192,57,43,0.10);  color: var(--accent);  border: 1px solid rgba(192,57,43,0.22); }

/* ── Notes / alerts ─────────────────────────────────────────────────── */
.pq-wrap .contact-note {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--gold-tint);
  border: 1px solid var(--gold-line);
  border-radius: 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.6;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.pq-wrap .contact-note svg { color: var(--gold-dk); flex-shrink: 0; margin-top: 2px; }
.pq-wrap .contact-link { color: var(--gold-dk); font-weight: 600; text-decoration: none; }
.pq-wrap .contact-link:hover { text-decoration: underline; }

.pq-wrap .warning-box {
  background: rgba(192,57,43,0.05);
  border: 1px solid rgba(192,57,43,0.20);
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 14px;
  color: var(--ink-2);
  margin-top: 16px;
  display: none;
  line-height: 1.55;
}
.pq-wrap .warning-box svg { vertical-align: -3px; margin-right: 5px; }
.pq-wrap .info-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 14px;
  color: var(--ink-2);
  margin-top: 16px;
  line-height: 1.6;
  font-family: 'DM Sans', sans-serif;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.pq-wrap .info-box svg { color: var(--gold-dk); flex-shrink: 0; margin-top: 1px; }

/* ── Placeholder (empty results state) ──────────────────────────────── */
.pq-wrap .placeholder {
  text-align: center;
  padding: 56px 24px;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  line-height: 1.7;
  display: block;
}
.pq-wrap .placeholder-ico {
  display: block;
  margin: 0 auto 14px;
  color: var(--muted);
  opacity: 0.4;
}

/* ── Misc ───────────────────────────────────────────────────────────── */
.pq-wrap .divider { height: 1px; background: var(--line); margin: 22px 0; }
.pq-wrap .footnote {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 24px;
  line-height: 1.8;
}
.pq-wrap .footnote strong { color: var(--ink); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.pq-wrap .animate-in { animation: fadeUp 0.4s ease both; }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .pq-wrap .layout { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .pq-wrap .page { padding: 28px 16px 16px; }
  .pq-wrap .panel,
  .pq-wrap .results-panel { padding: 20px; border-radius: 16px; }
}
