/* KoulFlo — composants. N'utilise que les tokens sémantiques de tokens.css. */

/* Eyebrow */
.kf-eyebrow {
  font-family: var(--kf-font-data);
  font-size: var(--kf-text-xs);
  letter-spacing: var(--kf-tracking-eyebrow);
  text-transform: uppercase;
  color: var(--kf-accent-strong);
}

/* Tag */
.kf-tag {
  display: inline-flex;
  align-items: center;
  font-family: var(--kf-font-data);
  font-size: var(--kf-text-xs);
  padding: 6px var(--kf-space-3);
  border: 1px solid var(--kf-border);
  border-radius: var(--kf-radius-pill);
  color: var(--kf-text);
}

/* Icône */
.kf-icon {
  flex: none;
  display: block;
}

/* Bouton */
.kf-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--kf-space-2);
  min-height: 40px;
  padding: 0 var(--kf-space-4);
  border: 1px solid transparent;
  border-radius: var(--kf-radius-sm);
  font-family: var(--kf-font-ui);
  font-size: var(--kf-text-sm);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--kf-transition), border-color var(--kf-transition), color var(--kf-transition);
}

.kf-button--sm {
  min-height: 32px;
  padding: 0 var(--kf-space-3);
}

.kf-button--primary {
  background: var(--kf-accent);
  color: var(--kf-text-inverse);
}

.kf-button--primary:hover {
  background: var(--kf-accent-strong);
}

.kf-button--secondary {
  background: transparent;
  border-color: var(--kf-border-strong);
  color: var(--kf-text);
}

.kf-button--secondary:hover {
  background: var(--kf-surface-sunken);
}

.kf-button--ghost {
  background: transparent;
  color: var(--kf-accent-strong);
}

.kf-button--ghost:hover {
  background: var(--kf-surface-sunken);
}

.kf-button:disabled,
.kf-button[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: auto;
}

.kf-button:disabled:hover {
  background: var(--kf-accent);
}

.kf-button--secondary:disabled:hover,
.kf-button--ghost:disabled:hover {
  background: transparent;
}

/* Badge de statut */
.kf-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--kf-font-data);
  font-size: var(--kf-text-2xs);
  letter-spacing: var(--kf-tracking-data);
  text-transform: uppercase;
  white-space: nowrap;
}

.kf-status__dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--kf-status-ok);
}

.kf-status--warning .kf-status__dot {
  background: var(--kf-status-warning);
}

.kf-status--offline .kf-status__dot {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--kf-status-offline);
}

.kf-status--on-light.kf-status--warning {
  color: var(--kf-accent-strong);
}

.kf-status--on-light.kf-status--offline {
  color: var(--kf-status-offline);
}

.kf-status--on-dark {
  color: var(--kf-text-inverse);
}

.kf-status--on-dark.kf-status--warning {
  color: var(--kf-accent-on-dark);
}

.kf-status--on-dark.kf-status--warning .kf-status__dot {
  background: var(--kf-accent-on-dark);
}

.kf-status--empty .kf-status__dot {
  background: var(--kf-status-critical);
}

.kf-status--on-light.kf-status--empty {
  color: var(--kf-status-critical);
  font-weight: 500;
}

.kf-status--on-dark.kf-status--empty {
  color: var(--kf-status-critical-on-dark);
  font-weight: 500;
}

.kf-status--on-dark.kf-status--empty .kf-status__dot {
  background: var(--kf-status-critical-on-dark);
}

.kf-status--on-dark.kf-status--offline {
  color: var(--kf-status-offline-on-dark);
}

.kf-status--on-dark.kf-status--offline .kf-status__dot {
  box-shadow: inset 0 0 0 1.5px var(--kf-status-offline-on-dark);
}

/* Logo */
.kf-logo {
  display: inline-flex;
  align-items: center;
  gap: var(--kf-space-2);
  font-family: var(--kf-font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
  font-size: 22px;
}

.kf-logo--dark {
  color: var(--kf-text-inverse);
}

.kf-logo--light {
  color: var(--kf-text);
}

.kf-logo--sm {
  font-size: 18px;
}

.kf-logo--lg {
  font-size: var(--kf-text-3xl);
}

.kf-logo__mark {
  width: 1.05em;
  height: 1.05em;
  flex: none;
}

.kf-logo--monogram {
  position: relative;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: var(--kf-radius-md);
  background: var(--kf-surface-inverse);
  border: 1px solid var(--kf-border-strong);
  color: var(--kf-text-inverse);
  font-size: 20px;
}

.kf-logo__arcs {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.kf-logo__initials {
  position: relative;
}

/* Jauge de niveau (cartes tireuses) */
.kf-level-gauge {
  position: relative;
  width: var(--kf-gauge-size, 184px);
  max-width: 100%;
  aspect-ratio: 1;
  margin: 0;
  container-type: inline-size; /* textes du centre proportionnels à la jauge (cqi) */
}

.kf-level-gauge__svg {
  display: block;
  width: 100%;
  height: 100%;
}

.kf-level-gauge__track {
  stroke: var(--kf-gauge-track);
}

.kf-level-gauge__arc,
.kf-level-gauge__flow {
  transition: stroke-dashoffset var(--kf-motion-duration) var(--kf-motion-ease), stroke 400ms ease, stroke-opacity 400ms ease;
}

.kf-level-gauge__arc {
  stroke: var(--kf-gauge-level);
}

.kf-level-gauge__arc--idle,
.kf-level-gauge__flow--idle {
  stroke-opacity: 0;
}

.kf-level-gauge__flow {
  stroke: var(--kf-gauge-flow-rest);
}

.kf-level-gauge--flow-live .kf-level-gauge__flow {
  stroke: var(--kf-gauge-flow);
}

.kf-level-gauge--warning .kf-level-gauge__arc {
  stroke: var(--kf-gauge-level-warning);
}

.kf-level-gauge--empty .kf-level-gauge__track--level {
  stroke: var(--kf-gauge-track-critical);
}

.kf-level-gauge__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
}

.kf-level-gauge__pct {
  font-family: var(--kf-font-display);
  font-size: 20cqi;
  font-weight: 600;
  font-variant-numeric: lining-nums tabular-nums;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--kf-text-inverse);
}

.kf-level-gauge__pct small {
  margin-left: 2px;
  font-family: var(--kf-font-data);
  font-size: 0.4em;
  font-weight: 400;
  color: var(--kf-text-inverse-muted);
}

.kf-level-gauge--warning .kf-level-gauge__pct {
  color: var(--kf-gauge-level-warning);
}

.kf-level-gauge__sub {
  font-family: var(--kf-font-data);
  font-size: var(--kf-text-xs);
  font-variant-numeric: tabular-nums;
  color: var(--kf-text-inverse-muted);
}

.kf-level-gauge__alert {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--kf-radius-pill);
  background: var(--kf-status-critical);
  color: var(--kf-cream);
  font-family: var(--kf-font-data);
  font-size: var(--kf-text-xs);
  font-weight: 500;
  letter-spacing: var(--kf-tracking-data);
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 0 0 4px var(--kf-surface-inverse);
}

.kf-level-gauge--s .kf-level-gauge__sub {
  display: none;
}

/* XL (vue barman) : fluide, textes lisibles à distance */
.kf-level-gauge--xl .kf-level-gauge__pct {
  font-size: 22cqi;
}

.kf-level-gauge--xl .kf-level-gauge__sub {
  font-size: 8cqi;
  color: var(--kf-text-inverse);
}

.kf-level-gauge--xl .kf-level-gauge__alert {
  gap: 2cqi;
  padding: 2.5cqi 5cqi;
  font-size: 5.5cqi;
}

.kf-level-gauge--xl .kf-level-gauge__alert .kf-icon {
  width: 6cqi;
  height: 6cqi;
}

/* Tuile KPI */
.kf-kpi {
  display: flex;
  flex-direction: column;
  gap: var(--kf-space-1);
  min-width: 0;
  padding: var(--kf-space-4) var(--kf-space-5);
  background: var(--kf-surface-raised);
  border: 1px solid var(--kf-border);
  border-radius: var(--kf-radius-md);
}

.kf-kpi__label {
  font-family: var(--kf-font-data);
  font-size: var(--kf-text-2xs);
  letter-spacing: var(--kf-tracking-eyebrow);
  text-transform: uppercase;
  color: var(--kf-text-muted);
}

.kf-kpi__value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: var(--kf-space-1);
}

.kf-kpi__number {
  font-family: var(--kf-font-display);
  font-size: var(--kf-text-4xl);
  font-weight: 600;
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--kf-text);
}

.kf-kpi__unit {
  font-family: var(--kf-font-data);
  font-size: var(--kf-text-sm);
  color: var(--kf-text-muted);
}

.kf-kpi__hint {
  font-family: var(--kf-font-data);
  font-size: var(--kf-text-xs);
  color: var(--kf-text-muted);
}

.kf-kpi--flow .kf-kpi__number {
  color: var(--kf-accent-strong);
}

.kf-kpi--warning {
  border-color: var(--kf-status-warning);
  box-shadow: inset 3px 0 0 var(--kf-status-warning);
}

/* Carte tireuse */
.kf-tap-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: var(--kf-space-5);
  background: var(--kf-surface-inverse);
  color: var(--kf-text-inverse);
  border-radius: var(--kf-radius-lg);
}

.kf-tap-card__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--kf-space-3);
}

.kf-tap-card__name {
  font-size: var(--kf-text-lg);
}

.kf-tap-card__sub {
  margin-top: 2px;
  font-family: var(--kf-font-data);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--kf-text-inverse-muted);
  overflow-wrap: anywhere;
}

.kf-tap-card__gauge {
  display: flex;
  justify-content: center;
  flex: 1;
  align-items: center;
  padding: var(--kf-space-5) 0 var(--kf-space-5);
}

/* Hors ligne : le niveau reste lisible, seul le débit (donnée périmée) est atténué */
.kf-tap-card--offline .kf-readout--flow {
  opacity: 0.5;
}

.kf-tap-card--empty {
  box-shadow: inset 0 0 0 1px var(--kf-gauge-track-critical);
}

.kf-readouts {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: var(--kf-space-3);
  margin: 0;
  padding-top: var(--kf-space-4);
  border-top: 1px solid var(--kf-border-inverse);
}

.kf-readout {
  display: flex;
  flex-direction: column-reverse;
  min-width: 0;
}

.kf-readout__val {
  margin: 0;
  font-family: var(--kf-font-data);
  font-size: var(--kf-text-xl);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  color: var(--kf-accent-on-dark);
}

.kf-readout--level .kf-readout__val {
  color: var(--kf-text-inverse);
}

.kf-readout__val small {
  font-size: var(--kf-text-xs);
  color: var(--kf-text-inverse-muted);
}

.kf-readout--last .kf-readout__val,
.kf-readout--none .kf-readout__val {
  color: var(--kf-text-inverse);
}

.kf-readout--live .kf-readout__lab {
  color: var(--kf-accent-on-dark);
}

.kf-readout__live {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--kf-accent-on-dark);
  vertical-align: 1px;
  animation: kf-pulse 1.2s ease-in-out infinite;
}

@keyframes kf-pulse {
  50% { opacity: 0.3; }
}

.kf-readout__lab {
  margin-top: 2px;
  font-family: var(--kf-font-data);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--kf-text-inverse-muted);
  overflow-wrap: anywhere;
}

/* Alerte */
.kf-alert {
  padding: 14px var(--kf-space-4);
  background: var(--kf-surface-sunken);
  border: 1px solid var(--kf-border);
  border-left: 3px solid var(--kf-status-warning);
  border-radius: var(--kf-radius-sm);
}

.kf-alert--alert {
  border-left-color: var(--kf-status-alert);
}

.kf-alert--resolved {
  background: transparent;
  border-left-color: var(--kf-border);
}

.kf-alert--resolved .kf-alert__title,
.kf-alert--resolved .kf-alert__message {
  color: var(--kf-text-muted);
}

.kf-alert__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--kf-space-2);
}

.kf-app .kf-alert__title {
  font-family: var(--kf-font-ui);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0;
}

.kf-alert--alert .kf-alert__title {
  color: var(--kf-status-alert);
}

.kf-alert__state {
  font-family: var(--kf-font-data);
  font-size: var(--kf-text-2xs);
  letter-spacing: var(--kf-tracking-data);
  text-transform: uppercase;
  color: var(--kf-status-offline);
}

.kf-app .kf-alert__message {
  margin-top: 2px;
  font-size: var(--kf-text-sm);
  overflow-wrap: anywhere;
}

.kf-alert__meta {
  margin-top: var(--kf-space-1);
  font-family: var(--kf-font-data);
  font-size: var(--kf-text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--kf-text-muted);
}

/* Champ */
.kf-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kf-field__label {
  font-size: var(--kf-text-sm);
  font-weight: 600;
}

.kf-field__hint {
  font-family: var(--kf-font-data);
  font-size: var(--kf-text-xs);
  color: var(--kf-text-muted);
}

.kf-input,
.kf-select {
  width: 100%;
  min-height: 40px;
  padding: 0 var(--kf-space-3);
  font: 400 var(--kf-text-md) / 1 var(--kf-font-ui);
  color: var(--kf-text);
  background: var(--kf-surface-raised);
  border: 1px solid var(--kf-border-strong);
  border-radius: var(--kf-radius-sm);
}

.kf-input::placeholder {
  font-family: var(--kf-font-data);
  color: var(--kf-text-muted);
}

.kf-input:focus-visible,
.kf-select:focus-visible {
  border-color: var(--kf-accent);
}

.kf-select {
  appearance: none;
  padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.kf-select--inverse {
  color: var(--kf-text-inverse);
  background-color: var(--kf-surface-inverse-raised);
  border-color: var(--kf-border-inverse);
}

.kf-select--inverse option {
  color: var(--kf-text);
  background: var(--kf-surface-page);
}

/* Barre de niveau */
.kf-level {
  display: inline-block;
  width: 96px;
  height: 6px;
  flex: none;
  overflow: hidden;
  background: var(--kf-surface-sunken);
  border-radius: var(--kf-radius-pill);
  box-shadow: inset 0 0 0 1px var(--kf-border);
}

.kf-level__fill {
  display: block;
  height: 100%;
  background: var(--kf-data-cold);
  border-radius: inherit;
  transition: width var(--kf-motion-duration) var(--kf-motion-ease), background-color 400ms ease;
}

.kf-level--low .kf-level__fill {
  background: var(--kf-status-warning);
}

/* Tableau */
.kf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--kf-text-sm);
}

.kf-table th {
  padding: var(--kf-space-2) var(--kf-space-3);
  font-family: var(--kf-font-data);
  font-size: var(--kf-text-2xs);
  font-weight: 500;
  letter-spacing: var(--kf-tracking-eyebrow);
  text-transform: uppercase;
  text-align: left;
  color: var(--kf-text-muted);
  border-bottom: 1px solid var(--kf-border-strong);
}

.kf-table td {
  padding: var(--kf-space-3);
  border-bottom: 1px solid var(--kf-border);
  vertical-align: middle;
}

.kf-table tbody tr:last-child td {
  border-bottom: none;
}

.kf-table__strong {
  font-weight: 600;
}

.kf-table__row--low td:first-child {
  box-shadow: inset 3px 0 0 var(--kf-status-warning);
}

.kf-level-cell {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--kf-space-2) var(--kf-space-3);
}

@media (max-width: 720px) {
  .kf-table--stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .kf-table--stack,
  .kf-table--stack tbody,
  .kf-table--stack tr,
  .kf-table--stack td {
    display: block;
  }

  .kf-table--stack tr {
    padding: var(--kf-space-3) 0;
    border-bottom: 1px solid var(--kf-border);
  }

  .kf-table--stack tbody tr:last-child {
    border-bottom: none;
  }

  .kf-table--stack td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--kf-space-4);
    padding: var(--kf-space-1) 0;
    border: none;
    text-align: right;
  }

  .kf-table--stack td::before {
    content: attr(data-label);
    flex: none;
    font-family: var(--kf-font-data);
    font-size: var(--kf-text-2xs);
    letter-spacing: var(--kf-tracking-eyebrow);
    text-transform: uppercase;
    color: var(--kf-text-muted);
  }

  .kf-table__row--low td:first-child {
    box-shadow: none;
  }

  .kf-level-cell {
    justify-content: flex-end;
  }
}

/* Graphique */
.kf-chart {
  margin: 0;
}

.kf-chart__svg {
  display: block;
  width: 100%;
  height: auto;
}

.kf-chart__grid {
  stroke: var(--kf-border);
  stroke-width: 1;
}

.kf-chart__axis {
  stroke: var(--kf-border-strong);
  stroke-width: 1;
}

.kf-chart__tick {
  font-family: var(--kf-font-data);
  font-size: 10.5px;
  fill: var(--kf-text-muted);
}

.kf-chart__bar {
  fill: var(--kf-accent);
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transition: transform var(--kf-motion-duration) var(--kf-motion-ease);
}

.kf-chart__bar:hover {
  fill: var(--kf-accent-strong);
}


.kf-chart__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--kf-space-2) var(--kf-space-5);
  margin-top: var(--kf-space-3);
  font-family: var(--kf-font-data);
  font-size: var(--kf-text-xs);
  color: var(--kf-text-muted);
}

.kf-chart__key {
  display: inline-flex;
  align-items: center;
  gap: var(--kf-space-2);
}

.kf-chart__key::before {
  content: "";
  width: 12px;
  height: 10px;
  border-radius: 2px;
  background: var(--kf-accent);
}


.kf-chart__line {
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.kf-chart__line--flow {
  stroke: var(--kf-accent);
}

.kf-chart__dot {
  fill: var(--kf-surface-raised);
  stroke: var(--kf-accent);
  stroke-width: 2;
  transition: transform var(--kf-motion-duration) var(--kf-motion-ease);
  animation: kf-fade-in 500ms ease-out;
}

.kf-chart__plot {
  transition: transform var(--kf-motion-duration) var(--kf-motion-ease);
}

@keyframes kf-fade-in {
  from { opacity: 0; }
}

/* Boutons de tirage de démonstration (cartes tireuses, tireuses fictives uniquement) */
.kf-tap-card__demo {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--kf-space-2);
  margin-top: var(--kf-space-4);
  padding-top: var(--kf-space-3);
  border-top: 1px dashed var(--kf-border-inverse);
}

.kf-tap-card__demo-label,
.kf-tap-card__demo-note {
  font-family: var(--kf-font-data);
  font-size: var(--kf-text-2xs);
  letter-spacing: var(--kf-tracking-data);
  text-transform: uppercase;
  color: var(--kf-text-inverse-muted);
}

.kf-tap-card__demo-note {
  color: var(--kf-status-critical-on-dark);
}

.kf-tap-card__demo-form {
  display: inline;
}

.kf-demo-button {
  min-height: 28px;
  padding: 0 var(--kf-space-3);
  border: 1px solid var(--kf-accent);
  border-radius: var(--kf-radius-pill);
  background: transparent;
  color: var(--kf-accent-on-dark);
  font-family: var(--kf-font-data);
  font-size: var(--kf-text-xs);
  cursor: pointer;
  transition: background-color var(--kf-transition);
}

.kf-demo-button:hover:not(:disabled) {
  background: rgba(181, 113, 58, 0.18);
}

.kf-demo-button:disabled {
  border-color: var(--kf-border-inverse);
  color: var(--kf-text-inverse-muted);
  cursor: progress;
}

/* Nombres animés (count_controller.js) : chiffres à chasse fixe pour éviter que le texte ne danse */
.kf-count {
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  .kf-level-gauge__arc,
  .kf-level-gauge__flow,
  .kf-level__fill,
  .kf-chart__bar,
  .kf-chart__plot,
  .kf-chart__dot {
    transition: none;
    animation: none;
  }
}
