/* =========================================================================
   Calculadoras — formulario a la izquierda, resultado a la derecha
   ========================================================================= */

.calc {
  width: 100%;
  margin: 0 auto;
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--text);

  --sec1: #4f46e5;   /* bookmaker 1 / casa */
  --sec2: #0e9384;   /* bookmaker 2 / exchange */
  --sec3: #f79009;   /* bookmaker 3 */
}

.calc [hidden],
.calc-panel[hidden],
.calc-advanced[hidden],
.calc-extra[hidden],
#sectionReembolso[hidden],
#calc-context[hidden] {
  display: none !important;
}

.calc-input {
  display: flex;
  min-width: 0;
}

.calc-input input {
  flex: 1 1 auto;
  min-width: 0;
}

.calc-addon {
  flex: 0 0 auto;
}

/* contexto de la fila desde la que se abrió */
#calc-context {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

#calc-context .ctx-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
}

#calc-context .ctx-item strong {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* -------------------------------------------------------------------------
   Rejilla de dos columnas
   ------------------------------------------------------------------------- */

.calc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  align-items: start;
  gap: 22px;
}

.calc-col {
  min-width: 0;
}

.calc-col--out {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 84px;
}

/* -------------------------------------------------------------------------
   Formulario
   ------------------------------------------------------------------------- */

.calc form {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.calc-top {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px 18px;
  background: linear-gradient(180deg, #f7f8ff, #fbfcff);
  border-bottom: 1px solid var(--border);
}

.calc-top .calc-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  flex: 1 1 240px;
}

.calc-top .calc-input {
  width: 100%;
  min-width: 0;
}

.calc-top label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.calc-top select {
  width: 100%;
  min-width: 0;
  max-width: none;
}

/* cabecera de cada bloque, con número y color */
.calc-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 14px 18px 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.calc-legend__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--sec1);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.calc-legend--b2 .calc-legend__num { background: var(--sec2); }
.calc-legend--b3 .calc-legend__num { background: var(--sec3); }

.calc-zone {
  margin: 0;
  padding: 4px 18px 16px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
}

.calc-zone--b1 { border-left-color: var(--sec1); background: #fbfbff; }
.calc-zone--b2 { border-left-color: var(--sec2); background: #f7fdfc; }
.calc-zone--b3 { border-left-color: var(--sec3); background: #fffdf7; }

.calc-zone--last {
  border-bottom: 0;
}

.calc-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
}

.calc-field-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 250px;
  min-width: 0;
}

.calc-field-row label {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.calc-field-row .calc-input {
  flex: 0 0 164px;
  display: flex;
  min-width: 0;
}

.calc input[type="number"],
.calc input[type="text"],
.calc select {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.calc input:focus,
.calc select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

.calc input[readonly] {
  background: var(--surface-2);
  color: var(--muted);
}

.calc .calc-input input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.calc-addon {
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-left: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.calc-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  background: var(--surface-2);
}

.calc-btn {
  min-height: 40px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease;
}

.calc-btn:hover {
  background: var(--accent-600);
}

.calc-btn--ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.calc-btn--ghost:hover {
  background: var(--surface-2);
}

/* -------------------------------------------------------------------------
   Columna de resultados
   ------------------------------------------------------------------------- */

.calc-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 34px 22px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.calc-empty p {
  margin: 0;
  max-width: 28ch;
  font-size: 13.5px;
  line-height: 1.5;
}

.calc-empty__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-600);
  font-size: 20px;
  font-weight: 700;
}

.calc:has(#sectionResult:not([hidden])) .calc-empty,
.calc:has(#resultAdvanced:not([hidden])) .calc-empty {
  display: none;
}

.calc-panel,
.calc-advanced,
.calc-extra {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.calc-panel__head {
  padding: 11px 16px;
  border-bottom: 1px solid #e2e5f5;
  background: #eef0fb;
  color: #4a5570;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* resultado: beneficio grande + filas de reparto */
.calc-result {
  padding: 16px;
}

.calc-result__hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 12px 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #f7f9ff, #eef1ff);
  text-align: center;
}

.calc-result__label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.calc-result__value {
  color: var(--text);
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.calc-result__value.ok { color: var(--ok); }
.calc-result__value.ko { color: var(--ko); }

.calc-result__rating {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.calc-result__rating b {
  color: var(--text);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.calc-result__rows {
  margin: 14px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calc-result__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.calc-result__row dt,
.calc-result__row dd {
  margin: 0;
  color: var(--muted);
  white-space: nowrap;
}

.calc-result__row b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.calc-result__row dd {
  text-align: right;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--muted-2);
  vertical-align: middle;
}

.dot--b1 { background: var(--sec1); }
.dot--b2 { background: var(--sec2); }
.dot--b3 { background: var(--sec3); }

/* -------------------------------------------------------------------------
   Desglose
   ------------------------------------------------------------------------- */

.calc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.calc-table th {
  padding: 9px 6px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.calc-table td {
  padding: 9px 6px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.calc-table tr:last-child td {
  border-bottom: 0;
}

.calc-table tbody tr td:first-child {
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
}

.calc-table tbody tr td:first-child::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--sec1);
  vertical-align: middle;
}

.calc-table tbody tr:nth-child(2) td:first-child::before { background: var(--sec2); }
.calc-table tbody tr:nth-child(3) td:first-child::before { background: var(--sec3); }

.calc-table .ok,
.calc-table .ko {
  font-weight: 600;
}

/* -------------------------------------------------------------------------
   Avanzado: underlay / standard / overlay
   ------------------------------------------------------------------------- */

.calc-advanced {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 22px;
  padding: 0;
}

.calc-card {
  padding: 16px 18px;
  border-right: 1px solid var(--border);
  border-top: 3px solid var(--border-strong);
}

.calc-card:last-child {
  border-right: 0;
}

.calc-card:nth-child(1) { border-top-color: #f79009; }
.calc-card:nth-child(2) { border-top-color: var(--accent); }
.calc-card:nth-child(3) { border-top-color: #0e9384; }

.calc-card__title {
  margin-bottom: 10px;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.calc-card__body {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.9;
}

.calc-card__body p {
  margin: 0;
}

.calc-card__body .strong {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ayudas (igualada / reembolso) */
.calc-extra {
  margin-top: 14px;
  padding: 16px 18px;
}

.calc-extra .calc-field-row label {
  text-align: left;
}

.calc-extra .calc-input {
  flex-basis: 190px;
}

/* -------------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------------- */

@media (min-width: 941px) {
  .calc-layout {
    align-items: stretch;
  }

  .calc-col--out {
    height: 100%;
  }

  .calc-empty {
    flex: 1;
    justify-content: center;
  }
}

@media (max-width: 940px) {
  .calc-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .calc-col--out {
    position: static;
  }
}

@media (max-width: 680px) {
  .calc-top {
    flex-direction: column;
    gap: 10px;
  }

  .calc-top .calc-field {
    flex: 1 1 auto;
  }

  .calc-top .calc-input {
    flex: 1 1 auto;
    width: auto;
    margin-left: 0;
  }

  .calc-top select {
    max-width: none;
  }

  .calc-field-row {
    flex-wrap: wrap;
    gap: 6px;
  }

  .calc-field-row label {
    flex: 1 1 100%;
    text-align: left;
  }

  .calc-field-row .calc-input {
    flex: 1 1 100%;
  }

  .calc-zone {
    padding-left: 14px;
    padding-right: 14px;
  }

  .calc-actions {
    flex-direction: column-reverse;
  }

  .calc-btn {
    width: 100%;
  }

  .calc-result__value {
    font-size: 30px;
  }

  .calc-result__row {
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
  }

  .calc-result__row dd {
    text-align: left;
  }

  .calc-table {
    font-size: 12px;
  }

  .calc-table th,
  .calc-table td {
    padding: 8px 4px;
  }

  .calc-card {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .calc-card:last-child {
    border-bottom: 0;
  }
}
