/*
 * WI Low-Income (Appendix C) Calculator styles — dev spec row WI-LOW.
 * Written fresh from the series' shared base pattern (NOT namespace-swapped —
 * swap-generation dropped rules twice: serial ob-grid, shared label-pair).
 *
 * Namespace: .wi-lw-calc
 * Palette: slate #293e4d, hint #576f81, accent #0071e3, border #dfe3e6.
 */

.wi-lw-calc {
  max-width: 720px;
  margin: 2em auto;
  padding: 1.75em;
  background: #fff;
  border: 1px solid #dfe3e6;
  border-radius: 8px;
  font-family: Roboto, Arial, sans-serif;
  font-size: 16px;
  color: #222;
  line-height: 1.5;
}

.wi-lw-calc__title {
  margin-top: 0;
  font-family: 'Roboto Slab', Roboto, serif;
  color: #293e4d;
}

/* ---------- Fields: identical geometry for every control ---------- */

.wi-lw-calc__field {
  margin: 0 0 1.25em;
}

.wi-lw-calc__field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4em;
}

/* One shared control style: same width, height, border, radius.
   Divi resets neutralized via explicit properties + !important. */
.wi-lw-calc__field input,
.wi-lw-calc__field select {
  display: block !important;
  width: 100% !important;
  height: 48px !important;
  margin: 0 !important;
  padding: 0 14px !important;
  border: 1px solid #c9c9c9 !important;
  border-radius: 6px !important;
  background: #fff !important;
  color: #222 !important;
  font-family: inherit !important;
  font-size: 1em !important;
  line-height: 46px !important;
  box-shadow: none !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: textfield !important;
}

/* Custom chevron for selects (background shorthand clears Divi's image) */
.wi-lw-calc__field select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%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='%23555' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 14px center !important;
  background-color: #fff !important;
  padding-right: 36px !important;
}

/* Chrome 135+ native picker icon stacked on our chevron — hide it */
.wi-lw-calc__field select::picker-icon {
  display: none !important;
}

.wi-lw-calc__field select::-ms-expand {
  display: none !important;
}

.wi-lw-calc__field input:focus,
.wi-lw-calc__field select:focus {
  outline: none !important;
  border-color: #0071e3 !important;
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15) !important;
}

.wi-lw-calc__field input::placeholder {
  color: #9a9a9a;
  opacity: 1;
}

/* Date inputs: 46px line-height breaks Chrome's internal date layout */
.wi-lw-calc__field input[type=date] {
  line-height: normal !important;
}

/* Currency fields: $ overlaid INSIDE the input */
.wi-lw-calc__money {
  position: relative;
  display: block;
}

.wi-lw-calc__symbol {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 400;
  font-size: 1em;
  color: #9a9a9a;
  pointer-events: none;
  line-height: 1;
}

.wi-lw-calc__money input {
  text-align: right;
  font-variant-numeric: tabular-nums;
  padding-left: 28px !important;
}

/* Required / optional markers */
.wi-lw-calc__required {
  color: #c0392b;
}

.wi-lw-calc__optional {
  font-weight: 400;
  color: #576f81;
  font-size: 0.9em;
}

.wi-lw-calc__hint {
  font-size: 0.88em;
  color: #576f81;
  margin: 0.45em 0 0;
  line-height: 1.45;
}

.wi-lw-calc__legend {
  font-size: 0.85em;
  color: #576f81;
  margin: 0 0 1em;
}

/* Submit button */
.wi-lw-calc__submit {
  display: inline-block !important;
  background: #0071e3 !important;
  color: #fff !important;
  border: 0 !important;
  border-radius: 6px !important;
  padding: 0.75em 1.5em !important;
  font-family: inherit !important;
  font-size: 1em !important;
  font-weight: 600 !important;
  cursor: pointer;
  width: auto !important;
  height: auto !important;
  line-height: 1.4 !important;
}

.wi-lw-calc__submit:hover {
  background: #005bb8 !important;
}

/* ---------- Result areas ---------- */

.wi-lw-calc__result {
  margin-top: 1.25em;
}

.wi-lw-calc__error {
  background: #fdf0ef;
  border: 1px solid #f0c4c0;
  border-radius: 6px;
  padding: 0.85em 1em;
  margin: 1em 0;
}

.wi-lw-calc__warning {
  background: #eef4fb;
  border: 1px solid #c7ddf5;
  border-radius: 6px;
  padding: 0.85em 1em;
  margin: 1em 0;
}

.wi-lw-calc__no-estimate {
  background: #fff8e8;
  border: 1px solid #f0ddb0;
  border-radius: 6px;
  padding: 0.85em 1em;
  margin: 1em 0;
}

.wi-lw-calc__no-estimate p {
  margin: 0.5em 0 0;
}

.wi-lw-calc__route-link {
  color: #0071e3;
  font-weight: 600;
  text-decoration: underline;
}

.wi-lw-calc__route-link:hover {
  color: #293e4d;
}

/* Table title + table */
.wi-lw-calc__table-title {
  font-weight: 700;
  font-size: 1.05em;
  margin: 0 0 0.5em;
  line-height: 1.4;
}

.wi-lw-calc__table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  /* NOTE: no table-layout:fixed here — the long first header must be free to
     size naturally; fixed widths + nowrap made it overlap the next column */
}

.wi-lw-calc__table th,
.wi-lw-calc__table td {
  border: 1px solid #dcdcdc;
  /* !important: Divi .entry-content tr td (6px 24px, higher specificity)
     overrides em padding and squeezes columns into wrapping */
  padding: 0.5em 0.6em !important;
  text-align: left;
}

.wi-lw-calc__table thead th {
  /* wraps naturally instead of overflowing into the neighboring column */
  white-space: normal;
  background: #f5f5f5;
}

.wi-lw-calc__table tfoot th,
.wi-lw-calc__table tfoot td {
  font-weight: 700;
  background: #f9f9f9;
}

/* Version stamp: governance provenance, rendered with every result */
.wi-lw-calc__version-stamp {
  font-size: 0.85em;
  color: #576f81;
  background: #f5f7f9;
  border-left: 3px solid #0071e3;
  padding: 0.5em 0.75em;
  margin: 0.75em 0;
  line-height: 1.5;
}

.wi-lw-calc__basis-note {
  font-size: 0.92em;
  color: #576f81;
  margin: 0 0 0.75em;
}

.wi-lw-calc__calc-date {
  font-size: 0.85em;
  color: #576f81;
  margin: 0 0 0.5em;
}

.wi-lw-calc__disclaimer {
  font-size: 0.85em;
  color: #576f81;
  margin-top: 1em;
  line-height: 1.5;
}

.wi-lw-calc__source {
  font-size: 0.9em;
  color: #555;
  margin-top: 1em;
}

/* ---------- Responsive: stacked cards on mobile ---------- */
@media (max-width: 768px) {
  .wi-lw-calc__table,
  .wi-lw-calc__table tbody,
  .wi-lw-calc__table tr,
  .wi-lw-calc__table th,
  .wi-lw-calc__table td {
    display: block;
    width: 100%;
  }

  .wi-lw-calc__table {
    border: 0;
  }

  .wi-lw-calc__table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .wi-lw-calc__table-title {
    font-size: 1.05em;
    margin-bottom: 0.6em;
  }

  .wi-lw-calc__table tr {
    border: 1px solid #dcdcdc;
    border-radius: 6px;
    margin-bottom: 0.75em;
    padding: 0.25em 0;
    background: #fff;
  }

  .wi-lw-calc__table tbody th {
    background: #f5f5f5;
    font-weight: 700;
    padding: 0.55em 0.75em;
    border-bottom: 1px solid #dcdcdc;
  }

  .wi-lw-calc__table td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1em;
    padding: 0.45em 0.75em;
    border: 0;
    text-align: right;
    font-variant-numeric: tabular-nums;
  }

  .wi-lw-calc__table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #576f81;
    text-align: left;
  }

  .wi-lw-calc__table tfoot tr {
    display: flex;
    align-items: baseline;
    gap: 0.75em;
    border: 0;
    border-top: 1px solid #dcdcdc;
    border-radius: 0;
    margin-bottom: 0;
  }

  .wi-lw-calc__table tfoot th,
  .wi-lw-calc__table tfoot td {
    width: auto !important;
    border: 0;
    background: transparent !important;
  }

  .wi-lw-calc__table tfoot th {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.45em 0.5em;
    text-align: left;
  }

  .wi-lw-calc__table tfoot td {
    flex: 0 0 auto;
    min-width: 0;
    padding: 0.45em 0.5em 0.55em;
    text-align: right;
    white-space: nowrap;
  }
}

@media (max-width: 480px) {
  .wi-lw-calc {
    padding: 1.25em;
  }
}