/* assets/kpi.css
   KPI + cards + leaderboard/heatmap helpers.
   Organized + deduplicated.
*/

/* ==========================================================================
   1) Variables
   ========================================================================== */
:root{
  /* KPI */
  --kpi-radius: 12px;
  --kpi-border: rgba(0,0,0,0.08);
  --kpi-shadow: 0 6px 18px rgba(0,0,0,0.06);

  --kpi-bg: #ffffff;
  --kpi-text: rgba(0,0,0,0.88);
  --kpi-muted: rgba(0,0,0,0.55);

  /* Primary KPI accent (amber) */
  --amber: #ffc107;
  --amber-tint: rgba(255,193,7,0.10);
  --amber-border: rgba(255,193,7,0.35);

  /* Delta colors */
  --delta-up: #198754;
  --delta-down: #dc3545;
  --delta-na: rgba(0,0,0,0.45);

  /* Shared card styling */
  --card-radius: 12px;
  --card-shadow: 0 2px 8px rgba(0,0,0,0.06);
  --card-border: rgba(0,0,0,0.06);

  /* Dash v4 interactive tokens: force app accent to blue (not purple) */
  --Dash-Fill-Interactive-Strong: #0d6efd;
  --Dash-Fill-Interactive-Weak: rgba(13,110,253,0.08);
  --Dash-Fill-Primary-Hover: rgba(13,110,253,0.08);
  --Dash-Fill-Primary-Active: rgba(13,110,253,0.16);
}

.mobile-desktop-hint{
  display: none;
}

@media (max-width: 768px){
  .mobile-desktop-hint{
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 12px;
    padding: 12px 13px;
    border: 1px solid rgba(13, 110, 253, 0.18);
    border-radius: 12px;
    background: #eef6ff;
    color: #17324d;
    box-shadow: 0 8px 20px rgba(13, 110, 253, 0.08);
  }

  .mobile-desktop-hint[hidden]{
    display: none !important;
  }

  .mobile-desktop-hint__message{
    display: flex;
    align-items: flex-start;
    gap: 9px;
    min-width: 0;
    font-size: 13px;
    line-height: 1.42;
    font-weight: 650;
  }

  .mobile-desktop-hint__message i{
    margin-top: 1px;
    color: #0d6efd;
    font-size: 16px;
    flex: 0 0 auto;
  }

  .mobile-desktop-hint__close{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: rgba(13, 110, 253, 0.08);
    color: #17446d;
    flex: 0 0 auto;
    line-height: 1;
  }

  .mobile-desktop-hint__close:hover,
  .mobile-desktop-hint__close:focus{
    background: rgba(13, 110, 253, 0.15);
  }

  .mobile-desktop-hint__close i{
    display: block;
    font-size: 13px;
    line-height: 1;
  }
}

/* ==========================================================================
   2) KPI cards (ONLY .kpi-*)
   ========================================================================== */
.kpi-card{
  background: var(--kpi-bg);
  border: 1px solid var(--kpi-border);
  border-radius: var(--kpi-radius);
  box-shadow: var(--kpi-shadow);
  padding: 18px;
  text-align: center;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.kpi-card:hover{
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.08);
}

.kpi-card--primary{
  border-color: var(--amber-border);
  background: linear-gradient(180deg, var(--amber-tint), #ffffff 65%);
  position: relative;
}

.kpi-card--primary::before{
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: 6px;
  height: 3px;
  border-radius: 999px;
  background: rgba(255,193,7,0.85);
}

.kpi-title{
  margin: 2px 0 6px 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--kpi-muted);
  letter-spacing: 0.2px;
}

.kpi-value{
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: var(--kpi-text);
  line-height: 1.1;
}

.kpi-delta{
  margin-top: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--delta-na);
}

/* Optional delta helper classes */
.kpi-delta--up{ color: var(--delta-up); }
.kpi-delta--down{ color: var(--delta-down); }
.kpi-delta--na{ color: var(--delta-na); }

/* ==========================================================================
   3) Spacing helpers
   ========================================================================== */
.section-gap-top{
  margin-top: 18px; /* tweak if needed */
}

/* ==========================================================================
   4) Chart cards (ONLY .chart-card*)
   ========================================================================== */
.chart-card{
  background: #ffffff;
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
  padding: 14px 16px;
}

.chart-card__header{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.chart-card__title{
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: rgba(0,0,0,0.65);
}

.chart-card__graph{
  margin-top: 6px;
}

.chart-card--expandable{
  position: relative;
}

.chart-card__toolbar{
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  margin: -2px 0 8px;
}

.chart-card__modal-title{
  flex: 1 1 auto;
  min-width: 0;
  color: rgba(17,24,39,0.68);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.2;
}

.chart-card__expand-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(15,23,42,0.12);
  border-radius: 8px;
  background: rgba(255,255,255,0.86);
  color: rgba(17,24,39,0.70);
  line-height: 1;
  box-shadow: 0 4px 12px rgba(15,23,42,0.08);
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.chart-card__expand-btn:hover,
.chart-card__expand-btn:focus-visible{
  background: rgba(255,255,255,1);
  border-color: rgba(13,110,253,0.28);
  color: rgba(13,110,253,0.96);
  transform: translateY(-1px);
}

.chart-card__expand-btn:focus-visible{
  outline: 2px solid rgba(13,110,253,0.28);
  outline-offset: 2px;
}

.chart-card-modal-backdrop{
  position: fixed;
  inset: 0;
  z-index: 2990;
  background: rgba(15,23,42,0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.chart-card-modal-backdrop.is-visible{
  opacity: 1;
  pointer-events: auto;
}

body.chart-card-modal-active{
  overflow: hidden;
}

.chart-card.chart-card--modal-open{
  position: fixed !important;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3000;
  width: min(1200px, calc(100vw - 48px));
  height: min(88vh, 900px);
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,0.10);
  background: #ffffff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 30px 70px rgba(15,23,42,0.26);
}

.chart-card.chart-card--modal-open::before{
  display: none;
}

.chart-card.chart-card--modal-open .chart-card__toolbar{
  flex: 0 0 auto;
  min-height: 38px;
  margin: 0 0 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(15,23,42,0.08);
}

.chart-card.chart-card--modal-open .chart-card__modal-title{
  color: rgba(17,24,39,0.86);
  font-size: 15px;
}

.chart-card.chart-card--modal-open .chart-card__graph{
  flex: 1 1 auto;
  height: auto !important;
  min-height: 0;
  margin-top: 0;
}

.chart-card.chart-card--modal-open .dash-graph,
.chart-card.chart-card--modal-open .js-plotly-plot{
  height: 100% !important;
}

@media (max-width: 768px){
  .chart-card.chart-card--modal-open{
    width: calc(100vw - 18px);
    height: calc(100vh - 18px);
    padding: 12px;
    border-radius: 10px;
  }
}

/* ==========================================================================
   5) Section cards (heatmap + leaderboard)  (.section-card*)
   - unified style: no border, subtle shadow
   - fixed-height via clamp on --lg
   - flex rules so inner scroll works
   ========================================================================== */
.section-card{
  border: none !important;
  border-radius: var(--card-radius);
  background: #ffffff;
  box-shadow: var(--card-shadow);

  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* The “large” cards: heatmap + leaderboard */
.section-card--lg{
  height: clamp(380px, 45vh, 560px);
}

/* Ensure dbc.CardBody fills available height and supports inner scrolling */
.section-card--lg > .card-body{
  height: 100%;
}

.section-card__body{
  height: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
}

/* Plotly containers should not add weird borders/background */
.section-card .js-plotly-plot,
.section-card .plot-container{
  width: 100%;
  border: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
}

/* Heatmap specific: keep it contained */
.heatmap{
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* ==========================================================================
   6) Leaderboard (tabs + viewport + slider)
   - viewport scrolls, slider stays bottom
   ========================================================================== */
.leaderboard{
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.leaderboard__viewport{
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.leaderboard__slider{
  flex: 0 0 auto;
  padding-top: 8px;
}

/* Dash Tabs: make content obey flex sizing */
.leaderboard .dash-tabs{
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.leaderboard .dash-tabs-parent{
  height: 100%;
  min-height: 0;
}

.leaderboard .dash-tabs-content{
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden; /* prevents tabs content pushing card larger */
}

/* Some tab implementations wrap content in .tab-content */
.leaderboard__viewport .tab-content{
  height: 100%;
  min-height: 0;
}

.leaderboard .tab{
  border-top: 3px solid transparent !important;
  border-bottom: 1px solid rgba(0,0,0,0.12) !important;
  color: rgba(0,0,0,0.68);
  font-weight: 700;
}

.leaderboard .tab:hover{
  color: #0d6efd;
  background: rgba(13,110,253,0.06) !important;
}

.leaderboard .tab--selected{
  border-top-color: #0d6efd !important;
  color: #0d6efd !important;
  background: #fff !important;
}

.leaderboard .tab:focus,
.leaderboard .tab:focus-visible{
  outline: none !important;
  box-shadow: inset 0 0 0 2px rgba(13,110,253,0.24) !important;
}

.leaderboard__slider .rc-slider-rail{
  background-color: rgba(13,110,253,0.22);
}

.leaderboard__slider .rc-slider-track{
  background-color: #0d6efd;
}

.leaderboard__slider .rc-slider-handle{
  border: 2px solid #0d6efd;
  background-color: #fff;
  box-shadow: none;
}

.leaderboard__slider .rc-slider-handle:hover,
.leaderboard__slider .rc-slider-handle:active,
.leaderboard__slider .rc-slider-handle:focus{
  border-color: #0d6efd;
  box-shadow: 0 0 0 4px rgba(13,110,253,0.20);
}

.leaderboard__slider .rc-slider-dot-active{
  border-color: #0d6efd;
  background-color: #0d6efd;
}

.leaderboard__slider .rc-slider-mark-text-active{
  color: #0b5ed7;
  font-weight: 700;
}

.leaderboard__slider .dash-slider-track{
  background-color: rgba(13,110,253,0.22);
}

.leaderboard__slider .dash-slider-range{
  background-color: #0d6efd;
}

.leaderboard__slider .dash-slider-thumb{
  background-color: #0d6efd;
  border-color: #fff;
}

.leaderboard__slider .dash-slider-thumb:focus,
.leaderboard__slider .dash-slider-thumb:hover{
  outline: 2px solid #0d6efd;
  box-shadow: 0 0 0 4px rgba(13,110,253,0.20);
}


.section-subtitle {
  margin-bottom: 10px;
}

.section-subtitle-title {
  font-size: 13px;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.75);
  letter-spacing: 0.02em;
}

.section-subtitle-text {
  font-size: 14px;                 /* 👈 iets groter */
  line-height: 1.4;
  color: rgba(0, 0, 0, 0.45);       /* 👈 dat lichtgrijs uit je screenshot */
}

.kpi-title {
  display: flex;
  align-items: center;
  justify-content: center; /* 👈 DIT IS DE FIX */
  gap: 6px;
}

.kpi-title__info {
  cursor: pointer;
  font-size: 13px;                     /* net iets groter */
  font-weight: 700;                    /* maakt ‘m steviger */
  color: rgba(13, 110, 253, 0.85);     /* info-blauw, iets voller */
  line-height: 1;
}

.kpi-title__info:hover {
  color: rgba(13, 110, 253, 1);
  transform: translateY(-0.5px);       /* héél subtiel lift-effect */
}

/* Multi-line product titles */
.conversion-grid .cell-wrap {
  white-space: normal;
  line-height: 1.25;
  padding-top: 6px;
  padding-bottom: 6px;
}

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

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

.ux-refresh-body{
  transition: opacity 120ms ease;
}

.ux-refresh-body.is-updating{
  opacity: 0.62;
}

.dash-fallback-toast{
  background: #fff8e1;
  border: 1px solid rgba(255, 193, 7, 0.35);
  color: rgba(58, 44, 0, 0.95);
}

.dash-fallback-toast .toast-header{
  background: rgba(255, 193, 7, 0.14);
  color: rgba(58, 44, 0, 0.95);
  border-bottom: 1px solid rgba(255, 193, 7, 0.35);
}
