/* Simulateur de deal : curseurs, bascule net / brut, grand livre, répartition. */

/* ---------- Simulateur ---------- */

.simulateur {
  display: grid;
  gap: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  background: var(--card);
}

.simulateur__reglages {
  display: grid;
  gap: 1.375rem;
  align-content: start;
  margin: 0;
  padding: clamp(1.25rem, 0.8rem + 2vw, 2rem);
  border: 0;
  min-width: 0;
}

.curseur {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.5rem 1rem;
  font-size: var(--text-small);
}

.curseur label {
  font-weight: 500;
}

.curseur small,
.bascule small {
  display: block;
  font-weight: 400;
  font-size: var(--text-mini);
  color: var(--muted-foreground);
}

.curseur output {
  font-weight: 500;
}

.curseur input {
  grid-column: 1 / -1;
}

input[type='range'] {
  --rempli: 50%;
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 1.5rem;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--foreground) var(--rempli),
    var(--border-strong) var(--rempli)
  );
}

input[type='range']::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
}

input[type='range']::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--foreground);
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 1.125rem;
  height: 1.125rem;
  margin-top: -0.4375rem;
  border: 2px solid var(--background);
  border-radius: 50%;
  background: var(--foreground);
  box-shadow: 0 0 0 1px var(--foreground);
  transition: transform var(--duree-rapide) ease;
}

input[type='range']::-moz-range-thumb {
  width: 0.875rem;
  height: 0.875rem;
  border: 2px solid var(--background);
  border-radius: 50%;
  background: var(--foreground);
  box-shadow: 0 0 0 1px var(--foreground);
}

input[type='range']:hover::-webkit-slider-thumb,
input[type='range']:active::-webkit-slider-thumb {
  transform: scale(1.15);
}

.bascule {
  display: grid;
  gap: 0.625rem;
  font-size: var(--text-small);
}

.bascule__titre {
  font-weight: 500;
}

.bascule__choix {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--muted);
}

.bascule__choix label {
  position: relative;
  cursor: pointer;
}

.bascule__choix input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.bascule__choix span {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: background-color var(--duree-rapide) ease;
}

.bascule__choix input:checked + span {
  background: var(--foreground);
  color: var(--background);
}

.bascule__choix input:checked + span small {
  color: inherit;
  opacity: 0.7;
}

.bascule__choix input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.simulateur__resultat {
  display: grid;
  gap: 1.75rem;
  align-content: start;
  padding: clamp(1.25rem, 0.8rem + 2vw, 2rem);
  border-top: 1px solid var(--border);
  background: var(--subtle);
  border-radius: 0 0 var(--radius-2xl) var(--radius-2xl);
  min-width: 0;
}

.reste__valeur {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: clamp(2.75rem, 1.6rem + 5.5vw, 5rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.055em;
  color: var(--success);
}

.reste__valeur[data-negatif='oui'] {
  color: var(--destructive);
}

.reste__devise {
  font-size: 0.45em;
  letter-spacing: 0;
  color: var(--muted-foreground);
}

.reste__note {
  margin-top: 0.625rem;
  font-size: var(--text-small);
}

/* Répartition de chaque euro : des gris pour ce qui part, la couleur d'état pour ce qui reste. */
.repartition {
  display: flex;
  gap: 2px;
  height: 0.875rem;
  border-radius: 3px;
  overflow: hidden;
}

.repartition__part {
  flex: 0 0 0%;
  min-width: 0;
}

.repartition__part--urssaf,
.puce--urssaf {
  background: #737373;
}

.repartition__part--commission,
.puce--commission {
  background: #5c5c5c;
}

.repartition__part--lieu,
.puce--lieu {
  background: #a3a3a3;
}

.repartition__part--charges,
.puce--charges {
  background: #474747;
}

.repartition__part--co,
.puce--co {
  background: var(--info);
}

.repartition__part--moi,
.puce--moi {
  background: var(--success);
}

.puce {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.5rem;
  border-radius: 2px;
}

.grand-livre {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-small);
}

.grand-livre th {
  padding: 0.5rem 0;
  font-weight: 400;
  text-align: left;
}

.grand-livre th small {
  margin-left: 0.25rem;
  color: var(--muted-foreground);
}

.grand-livre td {
  padding: 0.5rem 0;
  text-align: right;
}

.grand-livre tbody tr {
  border-top: 1px solid var(--border);
}

.grand-livre__groupe th {
  padding-top: 1rem;
  font-family: var(--font-mono);
  font-size: var(--text-mini);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.grand-livre tbody tr.grand-livre__groupe {
  border-top: 0;
}

.grand-livre tfoot tr {
  border-top: 2px solid var(--foreground);
}

.grand-livre tfoot th,
.grand-livre tfoot td {
  padding-top: 0.75rem;
  font-weight: 600;
}

.grand-livre [hidden] {
  display: none;
}

.suites {
  display: grid;
  gap: 0.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: var(--text-small);
}

.suites__liste {
  display: grid;
  gap: 0.5rem;
}

.suites__liste li {
  position: relative;
  padding-left: 1.125rem;
  text-wrap: pretty;
}

.suites__liste li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.625em;
  width: 0.5rem;
  height: 1px;
  background: var(--muted-foreground);
}

.suites__controle {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--success);
  font-weight: 500;
}

.simulateur__mention {
  max-width: 52rem;
  margin-top: 1.5rem;
  font-size: var(--text-mini);
  line-height: 1.6;
}

@media (min-width: 64rem) {
  .simulateur {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: 0;
  }

  .simulateur__resultat {
    border-top: 0;
    border-left: 1px solid var(--border);
    border-radius: 0 var(--radius-2xl) var(--radius-2xl) 0;
  }
}

/* Sur téléphone le résultat est sous les curseurs : ce rappel le garde à l'écran pendant le réglage. */
.simulateur__rappel {
  position: sticky;
  bottom: 0.75rem;
  z-index: 2;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--foreground);
  color: var(--background);
  font-size: var(--text-small);
  font-weight: 500;
}

.simulateur__rappel .montant {
  font-size: 1.125rem;
}

@media (min-width: 64rem) {
  .simulateur__rappel {
    display: none;
  }
}
