/* Product Estimation Calculator — front-end styles */

.pec-estimator {
  --pec-color-bg: #ffffff;
  --pec-color-surface: #faf8f5;
  --pec-color-text: #1e1e1e;
  --pec-color-text-muted: #6b6b6b;
  --pec-color-border: #d8d3cc;
  --pec-color-border-strong: #1e1e1e;

  /* Primary/button colour: #49a942 (brand green) by default. Override it
     from Settings → Product Estimator if a different colour is needed. */
  --pec-color-accent: var(--pec-accent-override, #49a942);
  --pec-color-accent-text: var(--pec-accent-text-override, #ffffff);

  --pec-color-error: #b3261e;
  --pec-color-error-bg: #fdecea;
  --pec-radius: 4px;

  box-sizing: border-box;
  max-width: 960px;
  margin: 0 auto;
  background: var(--pec-color-bg);
  border: 1px solid var(--pec-color-border);
  border-radius: var(--pec-radius);
  /* Font: uses an explicit override when set, otherwise inherits whatever
     font-family the current theme already applies to body text. */
  font-family: var(--pec-font-override, inherit);
  color: var(--pec-color-text);
  line-height: 1.5;
}

.pec-estimator *,
.pec-estimator *::before,
.pec-estimator *::after {
  box-sizing: border-box;
}

.pec-estimator__section {
  padding: 32px;
  border-bottom: 1px solid var(--pec-color-border);
}

.pec-estimator__section:last-child {
  border-bottom: none;
}

.pec-estimator__title {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.pec-estimator__header p {
  margin: 0;
  color: var(--pec-color-text-muted);
  font-size: 0.95rem;
  max-width: 640px;
}

.pec-estimator .pec-h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 16px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Form: measurement, product type, product, calculate — one responsive row */
.pec-estimator .pec-form {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  align-items: end;
  margin-bottom: 24px;
}

.pec-estimator .pec-field {
  display: flex;
  flex-direction: column;
}

.pec-estimator .pec-field label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.pec-estimator .pec-field select,
.pec-estimator .pec-field input[type="text"] {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 10px 12px;
  border: 1px solid var(--pec-color-border-strong);
  border-radius: var(--pec-radius);
  background: var(--pec-color-bg);
  color: var(--pec-color-text);
  line-height: normal;
  height: 44px;
}

.pec-estimator .pec-field select:focus,
.pec-estimator .pec-field input[type="text"]:focus {
  outline: 2px solid var(--pec-color-accent);
  outline-offset: 1px;
}

.pec-estimator .pec-field select:disabled {
  background: var(--pec-color-surface);
  color: var(--pec-color-text-muted);
  cursor: not-allowed;
}

.pec-estimator .pec-calculate-btn {
  height: 44px;
  position:relative;
  top:-20px;
}

.pec-estimator .pec-field-error {
  display: none;
  color: var(--pec-color-error);
  background: var(--pec-color-error-bg);
  border: 1px solid var(--pec-color-error);
  border-radius: var(--pec-radius);
  padding: 8px 12px;
  font-size: 0.85rem;
  margin-top: 8px;
}

.pec-estimator .pec-field-error.is-visible {
  display: block;
}

/* Buttons */
.pec-estimator .pec-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: var(--pec-radius);
  border: 1px solid var(--pec-color-border-strong);
  cursor: pointer;
  text-align: center;
  background: var(--pec-color-bg);
  color: var(--pec-color-text);
}

.pec-estimator .pec-btn:focus-visible {
  outline: 3px solid var(--pec-color-accent);
  outline-offset: 2px;
}

.pec-estimator .pec-btn-primary {
  background: var(--pec-color-accent);
  color: var(--pec-color-accent-text);
  border-color: var(--pec-color-accent);
}

.pec-estimator .pec-btn-primary:hover {
  filter: brightness(0.9);
}

.pec-estimator .pec-btn-secondary:hover {
  background: var(--pec-color-surface);
}

.pec-estimator .pec-btn:disabled {
  cursor: not-allowed;
  filter: grayscale(40%);
  opacity: 0.5;
}

.pec-estimator .pec-btn-delete {
  display: inline-flex;
  align-items: center;
  background: var(--pec-color-surface);
  border: 1px solid var(--pec-color-border);
  border-radius: var(--pec-radius);
  color: var(--pec-color-text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 16px;
}

.pec-estimator .pec-btn-delete:hover {
  background: var(--pec-color-error-bg);
  border-color: var(--pec-color-error);
  color: var(--pec-color-error);
}

.pec-estimator .pec-btn-delete--small {
  font-size: 0.8rem;
  padding: 6px 12px;
}

.pec-estimator .pec-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

/* Result card */
.pec-estimator .pec-result-card {
  display: none;
  background: var(--pec-color-surface);
  border: 1px solid var(--pec-color-border);
  border-radius: var(--pec-radius);
  padding: 24px;
  margin-bottom: 24px;
}

.pec-estimator .pec-result-card.is-visible {
  display: block;
}

.pec-estimator .pec-result-card__quantity {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.pec-estimator .pec-result-card__coverage {
  font-size: 0.9rem;
  color: var(--pec-color-text-muted);
  margin: 0 0 4px;
}

/* Estimate list */
.pec-estimator .pec-estimate-list {
  display: none;
}

.pec-estimator .pec-estimate-list.is-visible {
  display: block;
}

.pec-estimator table.pec-estimate-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.pec-estimator table.pec-estimate-table th,
.pec-estimator table.pec-estimate-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--pec-color-border);
}

.pec-estimator table.pec-estimate-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--pec-color-text-muted);
  font-weight: 600;
}

.pec-estimator .pec-estimate-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

/* Responsive */
@media (max-width: 640px) {
  .pec-estimator .pec-estimator__section {
    padding: 20px;
  }

  .pec-estimator .pec-form {
    grid-template-columns: 1fr;
  }

  .pec-estimator .pec-result-card__quantity {
    font-size: 1.3rem;
  }

  .pec-estimator .pec-btn-row,
  .pec-estimator .pec-estimate-footer {
    flex-direction: column;
    align-items: stretch;
  }
}
