/* ==========================================================================
   BizFlow — dashboard.css
   Styles propres au tableau de bord.
   Principe : un seul élément fort (la caisse du jour), tout le reste reste
   calme. Une seule animation au chargement : la barre de répartition des
   encaissements qui se remplit.
   ========================================================================== */

/* ---------- Grilles ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.dashboard-grid {
  display: grid;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.dashboard-grid--charts { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.dashboard-grid--main   { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.dashboard-grid--half   { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Teintes réutilisées par les icônes et pastilles */
.tone-primary { --icon-bg: var(--primary-soft); --icon-color: var(--primary); --spark: var(--primary); }
.tone-success { --icon-bg: var(--success-soft); --icon-color: var(--success); --spark: var(--success); }
.tone-warning { --icon-bg: var(--warning-soft); --icon-color: var(--warning); --spark: var(--warning); }
.tone-danger  { --icon-bg: var(--danger-soft);  --icon-color: var(--danger);  --spark: var(--danger); }
.tone-info    { --icon-bg: var(--info-soft);    --icon-color: var(--info);    --spark: var(--series-profit); }
.tone-neutral { --icon-bg: var(--surface-active); --icon-color: var(--text-2); --spark: var(--text-3); }

/* ==========================================================================
   Caisse du jour : le panneau jaune (seul aplat vif) + « À traiter »
   ========================================================================== */
.till {
  --split-mobile: #1e2a78;
  --split-cash: #b0164f;
  --split-card: #0c7a50;
  --split-transfer: #ffffff;

  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.till__main {
  position: relative;
  padding: 30px 32px 24px;
  border-radius: var(--radius-sm);
  background: var(--sun);
  color: var(--sun-ink);
  overflow: hidden;
  --ring: 0 0 0 2px var(--sun), 0 0 0 4px var(--sun-ink);
}

/* Liseré façon wax, en haut du panneau */
.till__main::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: repeating-linear-gradient(135deg, var(--sun-ink) 0 8px, var(--sun) 8px 16px, var(--bissap) 16px 24px, var(--sun) 24px 32px);
}

.till__todo {
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.till__label {
  font-size: var(--fs-md);
  font-weight: 700;
}

.till__todo .till__label {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
}

.till__amount {
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: 5.5rem;
  font-weight: 800;
  font-variation-settings: 'wdth' 75;
  line-height: 0.95;
  letter-spacing: -0.005em; /* garde visible l'espace des milliers (394 400) */
  font-variant-numeric: tabular-nums;
}

.till__currency {
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: 0;
  font-variation-settings: 'wdth' 100;
}

.till__compare {
  margin-top: 8px;
  font-size: var(--fs-md);
}

.till__compare strong {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.till__compare .is-up   { color: #075437; }
.till__compare .is-down { color: #8c0f3f; }

/* Barre de répartition des moyens de paiement */
.till__split {
  display: flex;
  gap: 3px;
  height: 10px;
  margin-top: 20px;
}

.till__segment {
  flex: var(--share) 1 0;
  border-radius: 3px;
  background: var(--color);
  box-shadow: inset 0 0 0 1px rgba(30, 42, 120, 0.35);
  transform-origin: left;
  animation: segment-in 700ms var(--ease-out) both;
  animation-delay: calc(150ms + var(--i) * 80ms);
}

.till__segment--empty {
  background: var(--sun-deep);
  box-shadow: none;
}

@keyframes segment-in {
  from { transform: scaleX(0); opacity: 0; }
  to { transform: scaleX(1); opacity: 1; }
}

.till__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-top: 12px;
}

.till__legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-base);
}

.till__legend .legend-dot {
  box-shadow: inset 0 0 0 1px rgba(30, 42, 120, 0.45);
}

.till__legend-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Liste « À traiter » */
.todo-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 10px -10px 0;
}

.todo {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius);
  transition: background-color var(--dur-fast) var(--ease);
}

.todo:hover {
  background: var(--surface-hover);
}

.todo__icon {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  color: var(--primary);
}

.todo--danger .todo__icon  { color: var(--danger); }
.todo--warning .todo__icon { color: var(--warning); }

.todo__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

.todo__title {
  font-weight: 700;
}

.todo__detail {
  font-size: var(--fs-sm);
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.todo__empty {
  padding: 10px;
  color: var(--text-2);
}

/* ==========================================================================
   Les 4 chiffres sur 30 jours : un seul bandeau, une tendance chacun
   ========================================================================== */
.stats-grid {
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  min-width: 0;
}

.stat-card + .stat-card {
  border-left: 1px solid var(--border);
}

.stat-card__label {
  font-size: var(--fs-base);
  font-weight: 400;
  color: var(--text-2);
}

.stat-card__value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat-card__value.is-profit {
  color: var(--success);
}

.stat-card__currency {
  margin-left: 4px;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--text-3);
  letter-spacing: 0;
}

.stat-card__foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  font-size: var(--fs-sm);
  color: var(--text-2);
}

/* ==========================================================================
   Graphiques
   ========================================================================== */
.chart-card {
  display: flex;
  flex-direction: column;
}

.chart-summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-8);
  margin: -4px 0 var(--space-4);
}

.chart-summary__item {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 8px;
}

.chart-summary__label {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.chart-summary__value {
  grid-column: 2;
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.chart-container {
  position: relative;
  width: 100%;
}

.chart-container--lg {
  flex: 1;
  min-height: 280px;
  height: 280px;
}

/* Donut */
.donut {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.chart-container--donut {
  width: 196px;
  height: 196px;
  margin: 0 auto;
}

.donut__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.donut__label {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.donut__value {
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.donut__legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.donut__legend li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--fs-sm);
}

.donut__legend-name {
  flex: 1;
  color: var(--text-2);
}

.donut__legend-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.donut__legend-pct {
  width: 44px;
  text-align: right;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Alertes de stock
   ========================================================================== */
.stock-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.stock-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 4px 12px;
}

.stock-item__icon {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: var(--icon-bg);
  color: var(--icon-color);
}

.stock-item__icon .lucide {
  width: 16px;
  height: 16px;
}

.stock-item__name {
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-item__qty {
  font-size: var(--fs-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.stock-item__meta {
  grid-column: 2 / 4;
  display: flex;
  align-items: center;
  gap: 10px;
}

.stock-item__meta .progress {
  flex: 1;
}

.stock-item__min {
  font-size: var(--fs-xs);
  color: var(--text-3);
  white-space: nowrap;
}

/* ==========================================================================
   Fil d'activité
   ========================================================================== */
.timeline {
  display: flex;
  flex-direction: column;
}

.timeline__item {
  position: relative;
  display: flex;
  gap: 14px;
  padding-bottom: var(--space-5);
}

.timeline__item:last-child {
  padding-bottom: 0;
}

/* Ligne verticale reliant les événements (c'est bien une chronologie) */
.timeline__item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 36px;
  bottom: 4px;
  width: 1px;
  background: var(--border);
}

.timeline__icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--icon-bg);
  color: var(--icon-color);
}

.timeline__icon .lucide {
  width: 15px;
  height: 15px;
}

.timeline__body {
  flex: 1;
  min-width: 0;
  padding-top: 5px;
  font-size: var(--fs-sm);
  line-height: 1.45;
}

.timeline__text {
  color: var(--text-2);
}

.timeline__text strong {
  color: var(--text);
  font-weight: 600;
}

.timeline__time {
  margin-top: 2px;
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* ==========================================================================
   Meilleurs produits (classement : la numérotation a un sens)
   ========================================================================== */
.top-products {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.top-product {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 6px 12px;
}

.top-product__rank {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--surface-active);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.top-product:first-child .top-product__rank {
  background: var(--primary-soft);
  color: var(--primary-text);
}

.top-product__name {
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-product__name small {
  margin-left: 6px;
  font-size: var(--fs-xs);
  font-weight: 400;
  color: var(--text-3);
}

.top-product__revenue {
  font-size: var(--fs-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.top-product__bar {
  grid-column: 2 / 4;
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-product__bar .progress {
  flex: 1;
}

.top-product__qty {
  font-size: var(--fs-xs);
  color: var(--text-3);
  white-space: nowrap;
  min-width: 64px;
  text-align: right;
}


/* Bandeau « boutique de démonstration » (masqué dès que la boutique est vidée) */
.demo-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3) var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--info-soft);
  color: var(--info-text);
}
.demo-banner[hidden] { display: none; }
.demo-banner > .lucide { flex: none; width: 20px; height: 20px; }
.demo-banner__text { flex: 1 1 18rem; font-size: var(--fs-sm); }

/* ==========================================================================
   Opérations du jour : un relevé, de la vente la plus ancienne à la plus récente
   ========================================================================== */
.ops-table {
  font-variant-numeric: tabular-nums;
}

.ops-table th {
  white-space: nowrap;
}

.ops-table__time {
  color: var(--text-2);
  white-space: nowrap;
}

.ops-table .row-link {
  font-weight: 700;
  color: var(--text);
}

.ops-table__meta {
  display: block;
  font-size: var(--fs-sm);
  color: var(--text-2);
}

.ops-table__due {
  font-weight: 700;
  color: var(--danger-text);
}

.ops-table__zero {
  color: var(--text-3);
}

.ops-table__total {
  font-weight: 700;
}

.ops-table__empty {
  padding: 28px var(--space-4) !important;
  text-align: center;
  color: var(--text-2);
}

/* Légende de la barre jaune du graphique (période en cours) */
.chart-summary__now {
  align-self: flex-end;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
  color: var(--text-2);
}

.legend-dot--now {
  --dot-color: var(--sun);
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px var(--sun-ink);
}
