/* ============================================================
   laforge.css — Stats components, landing page styles,
                 and legacy bloc-60/40 breakpoint.
   Base reset, layout, and shared components are in:
     base.css / layout.css / components.css
   ============================================================ */

/* ── Old stats bar chart (stats-adhesions-date, etc.) ────── */

.stats-label {
  display: inline-block;
  text-align: right;
  width: 600px;
  height: 20px;
  vertical-align: top;
}

.stats-bar {
  display: inline-block;
  border-bottom: solid 1px silver;
  background-color: var(--color-primary);
  height: 18px;
}

.stats-cnt {
  display: inline-block;
  color: silver;
  height: 20px;
  vertical-align: top;
}

/* ── Stats pages header / period controls ────────────────── */

.stats-ventes-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
  margin: 1.5rem 0 1rem;
}

.stats-ventes-title {
  font-size: 1.5rem;
  font-weight: bold;
  margin: 0 0 1rem;
  text-align: center;
}

.stats-period-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  max-width: 100%;
}

.stats-period-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
  margin: 0;
}

.stats-period-btn {
  font: inherit;
  cursor: pointer;
  padding: 0.4rem 0.85rem;
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--color-primary);
}

.stats-period-btn:hover {
  background: var(--color-primary-light);
}

.stats-period-btn.is-active {
  background: var(--color-primary);
  color: #fff;
  font-weight: bold;
}

.stats-period-custom {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
}

.stats-period-custom[hidden] {
  display: none !important;
}

.stats-period-custom-label {
  white-space: nowrap;
}

.stats-period-custom input[type="month"] {
  font: inherit;
  padding: 0.25rem 0.5rem;
}

.stats-month-input {
  font: inherit;
  min-width: 11rem;
  padding: 0.4rem 0.65rem;
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-sm);
  background: #fff;
  color: #1a1a1a;
  cursor: pointer;
  text-align: center;
}

.stats-month-input:hover {
  background: #f5f9fd;
}

.stats-month-input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.stats-month-picker {
  position: absolute;
  z-index: 10000;
  min-width: 280px;
  padding: 0.65rem;
  border-radius: var(--radius-md);
  background: #fff;
  border: 2px solid var(--color-primary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.stats-month-picker[hidden] {
  display: none !important;
}

.stats-month-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.stats-month-picker-head button {
  font: inherit;
  cursor: pointer;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--color-primary);
  line-height: 1;
  padding: 0;
}

.stats-month-picker-head button:hover:not(:disabled) {
  background: var(--color-primary-light);
}

.stats-month-picker-head button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.stats-month-picker-year {
  font: inherit;
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: var(--radius-sm);
}

.stats-month-picker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
}

.stats-month-picker-grid button {
  font: inherit;
  cursor: pointer;
  padding: 0.45rem 0.35rem;
  border: 1px solid #d0d7de;
  border-radius: var(--radius-sm);
  background: #fafbfc;
  color: #24292f;
}

.stats-month-picker-grid button:hover:not(:disabled) {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.stats-month-picker-grid button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.stats-month-picker-grid button.is-current-month {
  font-weight: bold;
  border-color: var(--color-primary);
}

.stats-period-btn-apply {
  margin-left: 0.25rem;
}

.stats-legend-toggle {
  display: none;
  text-align: right;
  margin: -0.5rem 0 0.75rem;
}

.stats-legend-toggle-btn {
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0.2rem 0.6rem;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  background: #f8fafc;
  color: #475569;
}

.stats-legend-toggle-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #1e293b;
}

/* ── Breadcrumb (all stats pages) ────────────────────────── */

.ariane {
  font-size: 0.85rem;
  padding: 0.5rem 0 0.25rem;
  color: #555;
}

.ariane a {
  color: var(--color-primary);
  text-decoration: none;
}

.ariane a:hover {
  text-decoration: underline;
}

.ariane-sep {
  margin: 0 0.4rem;
  color: #aaa;
}

.ariane-current {
  color: #333;
}

/* ── Product sales table (stats-ventes-produits) ─────────── */

.produits-filters-sticky {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #fff;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.07);
  margin-bottom: 0.5rem;
}

.produits-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.produits-filter-item {
  flex: 1 1 0;
  min-width: 130px;
  max-width: 240px;
}

.produits-search-wrap {
  position: relative;
}

.produits-search-icon {
  position: absolute;
  left: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  color: #888;
  display: flex;
  align-items: center;
  pointer-events: none;
}

.produits-search-input {
  font: inherit;
  width: 100%;
  box-sizing: border-box;
  padding: 0.4rem 0.65rem 0.4rem 2rem;
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-sm);
}

.produits-search-wrap.is-active .produits-search-input,
.produits-filter-select.is-active {
  border-color: crimson;
}

.produits-filter-select {
  font: inherit;
  width: 100%;
  box-sizing: border-box;
  padding: 0.4rem 0.65rem;
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-sm);
  background: #fff;
}

.produits-check-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  cursor: pointer;
}

.produits-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.produits-kpi-card {
  flex: 1 1 120px;
  max-width: 220px;
  background: var(--color-primary-light);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  text-align: center;
}

.produits-kpi-value {
  font-size: 1.4rem;
  font-weight: bold;
  color: var(--color-primary);
  line-height: 1.2;
}

.produits-kpi-label {
  font-size: 0.72rem;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.2rem;
}

.produits-table {
  width: auto;
  max-width: 100%;
  white-space: nowrap;
}

.produits-th {
  padding: 6px 16px;
  background-color: gainsboro;
  text-align: left;
  white-space: nowrap;
}

.produits-th.num {
  text-align: right;
}

.produits-th.sortable {
  cursor: pointer;
  user-select: none;
}

.produits-th.sortable:hover {
  background-color: #d0d7de;
}

.sort-arrow {
  display: inline-block;
  width: 1em;
  font-size: 0.75em;
  color: var(--color-primary);
}

.produits-table td {
  padding: 5px 16px;
}

.produits-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.produits-row-unavailable td {
  color: #aaa;
}

.produits-label-link {
  color: inherit;
  text-decoration: none;
  font-weight: bold;
}

.produits-label-link:hover {
  text-decoration: underline;
  color: var(--color-primary);
}

.produits-ref {
  font-size: 0.78em;
  color: #888;
}

.produits-id-cell {
  color: #888;
  font-size: 0.85em;
  white-space: nowrap;
}

.produits-no-result {
  padding: 1rem;
  color: #666;
  font-style: italic;
}

/* ── Clickable text cells (product name, supplier, category) */

.produits-set-search,
.produits-filter-chip {
  display: inline;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.produits-set-search {
  font-weight: bold;
}

.produits-set-search:hover,
.produits-filter-chip:hover {
  text-decoration: underline;
  color: var(--color-primary);
}

/* ── Product label cell flex layout ─────────────────────── */

.produits-label-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.produits-label-left {
  flex: 1 1 auto;
  min-width: 0;
}

/* ── Edit product link ───────────────────────────────────── */

.produits-edit-btn {
  display: inline-block;
  flex-shrink: 0;
  margin-left: auto;
  font-size: 0.75em;
  padding: 0.15em 0.5em;
  border: 1px solid #ccc;
  border-radius: var(--radius-sm);
  color: #555;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: middle;
  line-height: 1.6;
}

.produits-edit-btn:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ── Reset filters button ────────────────────────────────── */

.produits-reset-btn {
  font: inherit;
  font-size: 0.85em;
  padding: 0.35em 0.8em;
  border: 1px solid #ccc;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  color: #555;
  flex: 0 0 auto;
}

.produits-reset-btn:hover {
  background: #f5f5f5;
  border-color: #999;
  color: #333;
}

/* ── Back to top button ──────────────────────────────────── */

.back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  border: 2px solid var(--color-primary);
  background: #fff;
  color: var(--color-primary);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.back-to-top:hover {
  background: var(--color-primary);
  color: #fff;
}

/* ── Landing page (produit-fiche) ────────────────────────── */

.landingItem {
  display: flex;
  padding-bottom: 10px;
  align-items: center;
}

.qqoqpc {
  color: var(--color-primary);
  font-size: 18px;
  font-weight: bold;
}

hr.landing {
  margin-top: 20px;
  border: 0;
  height: 1px;
  background-image: linear-gradient(to right, var(--color-primary), white, white);
}

/* ── Chart section heading (within a stats page) ─────────── */

.stats-chart-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  margin: var(--space-5) 0 var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.stats-chart-title:first-child {
  margin-top: var(--space-3);
  padding-top: 0;
  border-top: none;
}

.stats-chart-total {
  display: inline-block;
  margin-left: var(--space-3);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted, #6b7280);
  background: var(--color-bg-subtle, #f3f4f6);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.1em 0.7em;
  vertical-align: middle;
  letter-spacing: 0.01em;
}

/* ── Stats menu hub ──────────────────────────────────────── */

.stats-menu-title {
  font-size: 1.6rem;
  font-weight: bold;
  color: var(--color-primary);
  margin: 1rem 0 1.5rem;
}

.stats-hub {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.stats-section-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}

.stats-section-head img {
  height: 30px;
  width: auto;
  flex-shrink: 0;
  opacity: 0.8;
}

.stats-section-head h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-primary);
  margin: 0;
}

/* Stats hub desktop cards — centered text */
.stats-hub .card--square {
  align-items: center;
  text-align: center;
}

/* Chevron — hidden on desktop, shown on mobile */
.card__chevron {
  display: none;
  flex-shrink: 0;
  color: var(--color-text-soft);
  margin-left: auto;
}

/* card__body wraps title + desc so they can grow together in row layout */
.card__body {
  min-width: 0;
}

.stats-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}

.stats-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  aspect-ratio: 1 / 1;
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px solid #e0e6ef;
  padding: 0.75rem 0.85rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s, transform 0.2s;
}

.stats-card:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.13);
  transform: translateY(-2px);
  border-color: var(--color-primary);
}

.stats-card:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.stats-card-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.3rem;
}

.stats-card-desc {
  font-size: 0.78rem;
  color: #555;
  line-height: 1.35;
}

/* ── Legacy two-column layout ────────────────────────────── */

@media (max-width: 768px) {
  .bloc-60,
  .bloc-40 {
    width: 100%;
  }

  /* Shrink the old bar-chart label so it doesn't overflow */
  .stats-label {
    width: 100%;
    text-align: left;
  }

  .stats-section-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
  }

  .stats-section-head img {
    height: 24px;
  }

  .stats-section-head h2 {
    font-size: 1rem;
  }

  /* Stats hub: tablet — 2-col grid, drop fixed square ratio so text breathes */
  .stats-hub .card--square {
    aspect-ratio: unset;
    justify-content: flex-start;
    min-height: 80px;
  }
}

/* Stats hub: phone — compact list layout */
@media (max-width: 480px) {
  .stats-hub {
    gap: var(--space-5);
  }

  /* Force single-column list */
  .stats-hub .grid--auto-fill {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }

  /* Cards become horizontal rows */
  .stats-hub .card--square {
    aspect-ratio: unset;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-3);
    min-height: 64px;
    padding: var(--space-3) var(--space-4);
  }

  .stats-hub .card__body {
    flex: 1 1 auto;
  }

  /* Show the right-arrow chevron */
  .stats-hub .card__chevron {
    display: block;
  }

  /* Section header: tighter */
  .stats-section-head {
    margin-bottom: var(--space-2);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--color-border);
  }

  .stats-section-head h2 {
    font-size: 0.95rem;
  }

  .stats-section-head img {
    height: 22px;
  }
}
