/* ==========================================================================
   Talynex Estimator UX V97 – User-friendliness layer
   Goals: clearer steps, larger targets, less cognitive load, better mobile
   ========================================================================== */

/* ---- Clearer step hierarchy ---- */
.solar-estimator-workspace .step-heading {
  margin-bottom: 18px;
}
.solar-estimator-workspace .step-heading h2 {
  font-size: clamp(1.25rem, 2.5vw, 1.45rem);
  margin-bottom: 4px;
}
.solar-estimator-workspace .step-heading p {
  font-size: 0.9rem;
  line-height: 1.55;
  max-width: 42em;
}

/* ---- Location / property fields: less cramped ---- */
.estimator-customer-grid.compact.location-grid,
.estimator-customer-grid {
  gap: 12px 14px;
}
.estimator-customer-grid label {
  font-size: 0.8rem;
}
.estimator-customer-grid select,
.estimator-customer-grid input {
  min-height: 44px;
  padding: 11px 12px;
  font-size: 0.92rem;
}

/* ---- Presets: more obvious as "quick start" ---- */
.load-presets {
  gap: 10px;
  margin: 8px 0 18px;
}
.load-presets button {
  min-height: 40px;
  padding: 9px 16px;
  font-size: 0.8rem;
  border-radius: 999px;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
}
.load-presets button:hover {
  transform: translateY(-1px);
}
.load-presets button[data-preset="clear"] {
  border-style: dashed;
  opacity: 0.85;
}

/* ---- Appliance cards: larger tap targets, clearer active state ---- */
.appliance-grid {
  gap: 12px;
}
.appliance-card {
  padding: 14px;
  border-radius: 16px;
  min-height: 52px;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.appliance-card.is-active {
  border-color: #5ec9a8;
  background: #f3fbf8;
  box-shadow: 0 8px 22px rgba(20, 130, 100, 0.08);
}
.appliance-toggle {
  min-height: 40px;
}
.appliance-name {
  font-size: 0.9rem;
  line-height: 1.3;
}
.appliance-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
}
.appliance-fields {
  margin-top: 10px;
  gap: 8px;
}
.appliance-fields input,
.appliance-fields select {
  min-height: 38px;
  font-size: 0.84rem;
}

/* ---- Live result panel: stronger hierarchy ---- */
.instant-result-panel {
  position: sticky;
  top: 96px;
}
.result-header .eyebrow {
  letter-spacing: 0.12em;
  font-size: 0.72rem;
}
.result-header h2 {
  font-size: 1.35rem;
  margin: 2px 0 0;
}
.result-subtitle {
  font-size: 0.88rem;
  line-height: 1.5;
  margin: 8px 0 16px;
  color: #5a6d82;
}
.result-hero strong,
.result-card .result-value-visible {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.result-card {
  padding: 14px 14px 12px;
  border-radius: 16px;
}
.result-card .result-explain {
  font-size: 0.78rem;
  line-height: 1.45;
  margin-top: 6px;
  opacity: 0.9;
}

/* ---- Email card: clearer, less cramped ---- */
.result-email-card {
  margin-top: 18px;
  padding: 16px;
  border-radius: 16px;
}
.result-email-card h3 {
  font-size: 1.05rem;
}
.result-email-form {
  grid-template-columns: 1fr;
  gap: 10px;
}
.result-email-form input {
  min-height: 44px;
  font-size: 0.9rem;
}
.btn-email-estimate {
  width: 100%;
  min-height: 48px;
  justify-content: center;
  font-size: 0.95rem;
  margin-top: 4px;
}
.estimator-security-check {
  margin: 10px 0 6px;
}
.security-check-label {
  font-size: 0.86rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.4;
  cursor: pointer;
}
.security-check-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex-shrink: 0;
}

/* ---- Primary next-step CTAs ---- */
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.result-actions .btn {
  width: 100%;
  min-height: 48px;
  justify-content: center;
}

/* ---- Add appliance button ---- */
[data-add-custom] {
  min-height: 44px;
  margin-top: 8px;
}

/* ---- Mobile: stack cleanly, sticky result summary ---- */
@media (max-width: 980px) {
  .estimator-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .instant-result-panel {
    position: relative;
    top: auto;
    order: -1; /* Show live estimate first on mobile so users see value immediately */
  }
  .estimator-input-panel {
    order: 0;
  }
}

@media (max-width: 700px) {
  .solar-estimator-workspace {
    padding-top: 28px;
  }
  .estimator-input-panel,
  .instant-result-panel {
    padding: 18px 16px;
    border-radius: 18px;
  }
  .appliance-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .estimator-customer-grid {
    grid-template-columns: 1fr;
  }
  .load-presets button {
    flex: 1 1 auto;
    text-align: center;
  }
  .result-hero strong,
  .result-card .result-value-visible {
    font-size: 1.22rem;
  }
  .result-subtitle {
    font-size: 0.84rem;
  }
  /* Keep floating WhatsApp from covering the email button */
  .result-email-card {
    margin-bottom: 12px;
  }
}

/* ---- Focus visibility for keyboard / accessibility ---- */
.appliance-card:focus-within,
.load-presets button:focus-visible,
.btn-email-estimate:focus-visible,
[data-system-request]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(32, 185, 140, 0.35);
}

/* ---- Empty state clarity ---- */
.instant-result-panel .result-hero strong:empty::after,
[data-result-inverter]:empty {
  content: none;
}

/* ---- Progress steps ---- */
.estimator-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 0 0 28px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid #e2eaf1;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(10, 35, 65, 0.05);
}
.estimator-progress-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
}
.estimator-progress-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 800;
  background: #e8eef4;
  color: #5a6d82;
}
.estimator-progress-step.is-active .estimator-progress-num,
.estimator-progress-step.is-done .estimator-progress-num {
  background: #20b98c;
  color: #fff;
}
.estimator-progress-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #5a6d82;
}
.estimator-progress-step.is-active .estimator-progress-label {
  color: #0b1d38;
}
.estimator-progress-line {
  width: 36px;
  height: 2px;
  background: #d5e0ea;
  margin: 0 4px;
  flex-shrink: 0;
}
@media (max-width: 600px) {
  .estimator-progress {
    padding: 12px 10px;
  }
  .estimator-progress-label {
    font-size: 0.72rem;
  }
  .estimator-progress-line {
    width: 18px;
  }
  .estimator-progress-num {
    width: 26px;
    height: 26px;
    font-size: 0.75rem;
  }
}

/* ---- Collapsible appliance groups ---- */
.appliance-groups {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.appliance-group {
  border: 1px solid #e0e7ee;
  border-radius: 16px;
  background: #fbfcfe;
  overflow: hidden;
}
.appliance-group[open] {
  background: #fff;
  border-color: #cfe5dc;
  box-shadow: 0 6px 18px rgba(20, 130, 100, 0.05);
}
.appliance-group-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  min-height: 52px;
}
.appliance-group-summary::-webkit-details-marker {
  display: none;
}
.appliance-group-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: #edf2f7;
  color: #3d5a73;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.appliance-group[open] .appliance-group-icon {
  background: #dff8ef;
  color: #087b5c;
}
.appliance-group-title {
  font-weight: 800;
  font-size: 0.95rem;
  color: #0b1d38;
  flex: 1;
}
.appliance-group-count {
  font-size: 0.75rem;
  font-weight: 700;
  color: #5a7a6a;
  background: #eef7f3;
  padding: 3px 9px;
  border-radius: 999px;
  min-width: 1.5em;
  text-align: center;
}
.appliance-group-count:empty {
  display: none;
}
.appliance-group-chevron {
  color: #8a9bab;
  transition: transform 0.2s ease;
  font-size: 0.8rem;
}
.appliance-group[open] .appliance-group-chevron {
  transform: rotate(180deg);
}
.appliance-group-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
  padding: 0 14px 14px;
}
@media (max-width: 700px) {
  .appliance-group-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- CTA hierarchy: email primary, system request secondary ---- */
.btn-email-estimate {
  background: linear-gradient(135deg, #0c63dd, #0647b9) !important;
  color: #fff !important;
  border: none !important;
  box-shadow: 0 8px 22px rgba(6, 71, 185, 0.22);
}
.btn-email-estimate:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(6, 71, 185, 0.3);
}
[data-system-request],
.btn-system-secondary {
  background: #fff !important;
  color: #0647b9 !important;
  border: 1.5px solid #0647b9 !important;
  box-shadow: none !important;
}
[data-system-request]:hover,
.btn-system-secondary:hover {
  background: #f0f5fc !important;
  transform: translateY(-1px);
}

/* Secondary visual weight for consultation panel submit if present */
.consultation-form .estimator-submit {
  opacity: 0.98;
}

/* ---- Default: groups start collapsed (no open attribute in HTML) ---- */

/* ---- See results button row ---- */
.custom-load-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-top: 14px;
}
.custom-load-row .btn {
  width: auto;
  min-height: 44px;
}
.custom-load-hint {
  flex: 1 1 100%;
  font-size: 0.78rem;
  color: #738298;
}
.estimator-see-results {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
@media (min-width: 701px) {
  .custom-load-hint {
    flex: 1 1 auto;
    margin-left: 4px;
  }
}

/* Brief highlight when jumping to results */
.instant-result-panel.results-highlight {
  box-shadow: 0 0 0 3px rgba(32, 185, 140, 0.45), 0 18px 55px rgba(10, 35, 65, 0.1);
  transition: box-shadow 0.35s ease;
}

/* ---- Aligned quantity / power / hours fields (desktop + tablet) ---- */
.appliance-fields {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 8px !important;
  margin-top: 10px;
  align-items: end;
}
.appliance-fields label {
  display: flex !important;
  flex-direction: column;
  gap: 5px;
  margin: 0;
  min-width: 0;
  font-size: 0.68rem !important;
  font-weight: 700;
  color: #5c6f84;
  line-height: 1.25;
}
/* AC rows may have HP select — keep same column rhythm */
.appliance-fields label > input,
.appliance-fields label > select {
  width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box;
  min-height: 38px !important;
  padding: 8px 8px !important;
  border: 1px solid #d5e0ea;
  border-radius: 8px;
  font-size: 0.82rem !important;
  font-weight: 600;
  line-height: 1.2;
}
/* When a 4th control appears (e.g. HP + other), span cleanly */
.appliance-fields label:nth-child(n+4) {
  grid-column: 1 / -1;
}
@media (min-width: 701px) {
  .appliance-group-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .appliance-card {
    display: flex;
    flex-direction: column;
  }
  .appliance-card .appliance-fields {
    margin-top: auto;
    padding-top: 8px;
  }
}
