/* ==========================================================================
   returns-insights.css
   - Consolidated + cleaned (no duplicates)
   - Fixes: card growing with many rows → table scrolls inside fixed-height card
   - Keeps: premium “insight card” styling + hover + sticky header
   ========================================================================== */

/* ==========================================================================
   0) Shared sizing
   - Adjust this ONE variable to match your graph-card heights.
   ========================================================================== */
:root{
  --returns-insight-height: clamp(380px, 37vh, 560px);
  --returns-radius: 12px;
  --returns-border: rgba(0,0,0,0.08);
  --returns-muted: rgba(0,0,0,0.55);
  --returns-text: rgba(0,0,0,0.82);
  --returns-title: rgba(0,0,0,0.84);
  --returns-subtitle: rgba(0,0,0,0.56);
  --returns-kicker: rgba(0,0,0,0.52);
  --returns-hairline: rgba(0,0,0,0.06);
} 

.returns-loading-shell{
  position: relative;
}

.returns-loading-shell .dash-spinner{
  transform: scale(0.9);
  opacity: 0.9;
}

.returns-toast.toast{
  border: 1px solid rgba(220,53,69,0.30);
  border-left: 6px solid rgba(220,53,69,0.95);
  border-radius: 12px;
  box-shadow: 0 16px 34px rgba(220,53,69,0.20), 0 6px 14px rgba(0,0,0,0.14);
  background: linear-gradient(180deg, rgba(220,53,69,0.12), #ffffff 58%);
}

.returns-toast .toast-header{
  background: transparent;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  font-weight: 800;
}

.returns-toast .toast-body{
  font-weight: 600;
  color: rgba(0,0,0,0.82);
}

/* ==========================================================================
   1) Returns “simple” table card (returns-card)
   - If you still use returns-card anywhere, keep this.
   - Fixed height so it never grows; body scrolls.
   ========================================================================== */
.returns-card{
  height: var(--returns-insight-height);   /* ✅ prevents growth */
  display: flex;
  flex-direction: column;
  min-height: 0;                          /* ✅ required for flex scrolling */
  border-radius: var(--returns-radius);
}

/* Header zone */
.returns-card__header{
  flex: 0 0 auto;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  padding: 10px 12px;
  margin-bottom: 6px;

  border-bottom: 1px solid var(--returns-border);
  background: linear-gradient(
    180deg,
    rgba(220,53,69,0.08),
    rgba(255,255,255,0.0)
  );
}

.returns-card__icon{
  font-size: 16px;
}

.returns-card__title{
  font-size: 13px;
  font-weight: 800;
  color: rgba(0,0,0,0.75);
  letter-spacing: 0.2px;
}

/* Body scrolls */
.returns-card__body{
  flex: 1 1 auto;
  min-height: 0;          /* ✅ allows overflow inside flex child */
  overflow: auto;         /* ✅ scroll here */
  padding-top: 4px;
  background: #fff;
  border-radius: 10px;
}

/* Make Dash DataTable cooperate with the scroll container */
.returns-card__body .dash-table-container,
.returns-card__body .dash-spreadsheet-container{
  height: 100%;
}

/* Hover */
.returns-card__body .dash-spreadsheet-container tr:hover td{
  background: rgba(220,53,69,0.06);
}

/* Sticky header inside scroll area */
.returns-card__body .dash-spreadsheet-container thead th{
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
  border-bottom: 1px solid rgba(0,0,0,0.10);
}


/* ==========================================================================
   2) Insight card (recommended)
   - Use this for the “Top combinations” premium card.
   - Fixed height; header + controls; table scrolls; sticky table header.
   ========================================================================== */
.insight-card{
  height: var(--returns-insight-height);   /* ✅ prevents growth */
  display: flex;
  flex-direction: column;
  min-height: 0;                          /* ✅ allows inner scroll */
  border-radius: var(--returns-radius);
}

/* Header */
.insight-card__header{
  flex: 0 0 auto;

  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;

  padding: 6px 4px 10px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  margin-bottom: 8px;
}

.insight-card__kicker{
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: rgba(0,0,0,0.45);
}

.insight-card__title{
  font-size: 15px;
  font-weight: 900;
  color: var(--returns-text);
  margin-top: 2px;
}

.insight-card__subtitle{
  font-size: 12px;
  font-weight: 600;
  color: var(--returns-muted);
  margin-top: 4px;
  max-width: 320px;
}

/* Controls (Top N dropdown) */
.insight-card__header-right{
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  min-width: 140px;
}

.insight-card__control-label{
  font-size: 11px;
  font-weight: 800;
  color: var(--returns-muted);
}

/* Body: THIS is the scroll container */
.insight-card__body{
  flex: 1 1 auto;
  min-height: 0;        /* ✅ critical */
  overflow: auto;       /* ✅ scroll here (not the whole card) */
  border-radius: 10px;
  background: #fff;
}

.insight-card__body--grid{
  overflow: hidden;
}

/* DataTable fill + behave inside scroll container */
.insight-card__body .dash-table-container,
.insight-card__body .dash-spreadsheet-container{
  height: 100%;
}

/* Sticky header inside the scrolling body */
.insight-card__body .dash-spreadsheet-container thead th{
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
  border-bottom: 1px solid rgba(0,0,0,0.10);
}

/* Hover highlight */
.insight-card__body .dash-spreadsheet-container tr:hover td{
  background: rgba(0,0,0,0.03);
}

/* Footer hint */
.insight-card__footer{
  flex: 0 0 auto;
  margin-top: 10px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(0,0,0,0.45);
}

.insight-card__topn{
  width: 170px;           /* maak breder */
}

.insight-card__topn .Select-control{
  min-height: 34px;
  border-radius: 10px;
}

.returns-grid--compact.ag-theme-quartz{
  --ag-font-size: 12px;
  --ag-row-height: 72px;
  --ag-header-height: 40px;
}

.returns-grid--compact .ag-header-cell,
.returns-grid--compact .ag-cell{
  padding-left: 10px;
  padding-right: 10px;
}

.returns-grid.returns-grid--top-combinations{
  height: 100%;
  border: 1px solid rgba(0,0,0,0.06);
}

.returns-grid--top-combinations .ag-root-wrapper{
  border: none;
}

.returns-grid--top-combinations .ag-cell-wrapper{
  align-items: center;
}

.returns-grid--top-combinations .ag-cell-value{
  align-items: center;
  display: flex;
  height: 100%;
  overflow: visible;
  white-space: normal;
}

.returns-grid--top-combinations .product-summary{
  display: flex;
  align-items: center;
  gap: 12px;
  height: 100%;
  min-width: 0;
  width: 100%;
}

.returns-grid--top-combinations .product-summary__thumb{
  width: 40px;
  height: 40px;
  display: block;
  object-fit: contain;
  object-position: center center;
  background: transparent;
  border: none;
  flex: 0 0 auto;
}

.returns-grid--top-combinations .product-summary__thumb--empty{
  border-radius: 999px;
  background: rgba(15,23,42,0.08);
}

.returns-grid--top-combinations .product-summary__content{
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  justify-content: center;
}

.returns-grid--top-combinations .product-summary__title{
  font-weight: 700;
  line-height: 1.25;
  transform: translateY(2px);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
}

.returns-grid--top-combinations .product-summary__meta{
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: rgba(0,0,0,0.58);
}


/* Scope alles onder .returns-grid zodat je andere grids niet breekt */
.returns-grid{
  border-radius: var(--returns-radius);
  overflow: hidden; /* rondingen ook echt zichtbaar */
  border: 1px solid var(--returns-border);
  background: #fff;
}

/* Match fonts met de rest */
.returns-grid .ag-root-wrapper,
.returns-grid .ag-root-wrapper *{
  font-family: inherit;
}

/* Theme tuning via CSS variables (Quartz / Alpine ondersteunen dit goed) */
.returns-grid.ag-theme-quartz{
  --ag-font-size: 13px;
  --ag-row-height: 38px;
  --ag-header-height: 40px;
  --ag-accent-color: #0d6efd;
  --ag-checkbox-checked-color: #0d6efd;

  --ag-border-color: rgba(0,0,0,0.08);
  --ag-header-background-color: rgba(0,0,0,0.02);
  --ag-odd-row-background-color: rgba(0,0,0,0.015);

  --ag-selected-row-background-color: rgba(13,110,253,0.10);
  --ag-row-hover-color: rgba(0,0,0,0.03);

  --ag-header-foreground-color: rgba(0,0,0,0.70);
  --ag-foreground-color: rgba(0,0,0,0.82);

  --ag-border-radius: var(--returns-radius);
}

.returns-grid .ag-header{
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.returns-grid .ag-header-cell-label{
  font-weight: 800;
  letter-spacing: 0.2px;
}

.returns-grid .ag-header-cell{
  padding-left: 12px;
  padding-right: 12px;
}

.returns-grid .ag-cell-wrapper{
  align-items: center;
}

.returns-grid .ag-cell-value{
  align-items: center;
  display: flex;
  height: 100%;
}

/* cell padding + zachte vertical separators */
.returns-grid .ag-cell{
  padding-left: 12px;
  padding-right: 12px;
  border-right: 1px solid rgba(0,0,0,0.04);
}
.returns-grid .ag-cell:last-child{
  border-right: none;
}

.returns-grid .cell-image{
  padding-bottom: 0;
  padding-top: 0;
}

/* zebra (als je theme var niet genoeg is) */
.returns-grid .ag-row-odd{
  background-color: rgba(0,0,0,0.015);
}

/* hover */
.returns-grid .ag-row-hover{
  background-color: rgba(0,0,0,0.03) !important;
}

/* selected rows */
.returns-grid .ag-row-selected{
  background-color: rgba(13,110,253,0.10) !important;
}

.returns-grid .ag-filter-toolpanel-header,
.returns-grid .ag-tool-panel-wrapper{
  font-size: 12px;
}

.returns-grid .ag-input-field-input{
  border-radius: 10px;
  padding: 6px 10px;
}

/* dropdowns / set filter list */
.returns-grid .ag-set-filter-list{
  border-radius: 10px;
}

.returns-grid .ag-cell-focus,
.returns-grid .ag-cell:focus{
  outline: none !important;
  box-shadow: inset 0 0 0 2px rgba(13,110,253,0.18);
  border-radius: 8px;
}

.chart-card__graph{
  flex: 1 1 0;     /* 👈 dit is de sleutel */
  min-height: 0;
  overflow: hidden;
}

/* ==========================================================================
   Grid card wrapper (header + actions)
   ========================================================================== */
.grid-card{
  border: 1px solid var(--returns-border);
  border-radius: var(--returns-radius);
  background: #fff;
  overflow: hidden;
  margin-top: 22px;
}

.grid-card__header{
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  background: rgba(0,0,0,0.03);
}

.grid-card__title{
  font-size: 16px;        
  font-weight: 700;
  color: rgba(0,0,0,0.85);
  letter-spacing: 0.2px;
}

.grid-card__subtitle{
  font-size: 12px;
  font-weight: 600;
  color: var(--returns-muted);
  margin-top: 2px;
  max-width: 620px;
}

.grid-card__header-right{
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.grid-card__search{
  height: 38px;
  min-width: 220px;
  width: min(32vw, 300px);
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.10);
  font-size: 13px;
  outline: none;
  flex: 0 0 auto;
}

.grid-card__search::placeholder{
  color: rgba(0,0,0,0.56);
}
.grid-card__search:focus{
  box-shadow: 0 0 0 3px rgba(13,110,253,0.12);
  border-color: rgba(13,110,253,0.25);
}

.grid-card__btn{
  height: 38px;
  min-width: 128px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.10);
  background: #fff;
  font-weight: 800;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
  flex: 0 0 auto;
}
.grid-card__btn:hover{
  background: rgba(0,0,0,0.02);
}

@media (max-width: 768px){
  .grid-card__header-right{
    width: 100%;
    justify-content: flex-start;
  }

  .grid-card__search{
    width: 100%;
    min-width: 0;
  }
}

/* ==========================================================================
   Returns grid: stable rows + premium feel
   ========================================================================== */

/* monospace IDs */
.returns-grid .cell-mono{
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

/* money */
.returns-grid .cell-money{
  font-weight: 900;
  letter-spacing: 0.1px;
}

/* clamp long text to 3 lines (no wobble) */
.returns-grid .cell-clamp{
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Pills (kleur via classRules) */
.returns-grid .cell-pill{
  font-weight: 900;
}
.returns-grid .cell-pill.pill--ok{
  color: rgba(25,135,84,0.95);
}
.returns-grid .cell-pill.pill--bad{
  color: rgba(220,53,69,0.95);
}
.returns-grid .cell-pill.pill--neutral{
  color: rgba(0,0,0,0.70);
}

/* Nette range selection highlight (AG Grid gebruikt eigen classes) */
.returns-grid .ag-cell-range-selected{
  box-shadow: inset 0 0 0 1px rgba(13,110,253,0.25);
}

/* Selected row iets subtieler (je had ‘m al) */
.returns-grid .ag-row-selected{
  background-color: rgba(13,110,253,0.10) !important;
}

/* AG Grid filter/search inputs: geef ruimte links voor het icoon */
.returns-grid .ag-input-field-input.ag-text-field-input,
.returns-grid .ag-input-field-input.ag-number-field-input{
  padding-left: 22px !important;
}


/* Alleen voor de insight-card (Retour-inzichten) */
.insight-card__kicker{
  color: var(--returns-kicker);
  font-weight: 900;
  letter-spacing: 0.7px;
}

.insight-card__subtitle{
  color: var(--returns-subtitle);
  font-weight: 600;
  line-height: 1.3;
}

/* header spacing: iets strakker */
.insight-card__header{
  padding: 8px 8px 10px;
  border-bottom: 1px solid var(--returns-hairline);
}

@media (max-width: 992px){
  .insight-card__header{
    flex-wrap: wrap;
  }

  .insight-card__subtitle{
    max-width: none;
  }

  .insight-card__header-right{
    width: 100%;
    min-width: 0;
    align-items: flex-start;
  }

  .insight-card__topn{
    width: min(220px, 100%);
  }
}



/* ==========================================================================
   3) IMPORTANT usage note (layout)
   - For equal heights across the row, make sure your dbc.Row stretches cols:
     dbc.Row(..., className="gx-3 gy-0 section-gap-top align-items-stretch")
   - And each dbc.Col contains ONE card with height set (above).
   ========================================================================== */
