/* ============================================================
   Pages — page-scoped composition
   ============================================================ */

/* ---------- Reyon (Marka) Analizi — reyon picker ---------- */
.dept-picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}
.dept-picker__btn {
  height: 38px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-input);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform 80ms var(--ease-out);
}
.dept-picker__btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.dept-picker__btn:active { transform: scale(0.97); }
.dept-picker__btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 4px var(--blue-400, #2e6bff);
}
.dept-picker__btn.is-active {
  background: var(--gradient-brand);
  border-color: transparent;
  color: #fff;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.18);
}

/* ---------- Dashboard grid ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.kpi-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
}
.kpi-card__top { display: flex; align-items: center; justify-content: space-between; }
.kpi-card__icon {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  background: var(--gradient-brand-soft);
  color: var(--text-brand);
}
.kpi-card__icon svg { width: 20px; height: 20px; }

.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-4);
}
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }
/* Grid items default to min-width: auto (their min-content size), not 0 —
   a fixed fr track (unlike auto-fill/minmax elsewhere in this file) has no
   minmax() floor to fall back on, so a child whose min-content briefly
   exceeds its fr share (a Chart.js canvas that hasn't reflowed to its new
   container width yet is the reproducible case) blows the *track*, and
   with it .dash-grid and every ancestor's scrollWidth, out past <main>'s
   overflow-x: hidden. Resetting min-width to 0 lets the 2fr/1fr split
   actually govern sizing, so any real overflow stays contained inside the
   child (see .chart-host's own overflow: hidden) instead of escaping it.
 */
.dash-grid > * { min-width: 0; }

.chart-surface { min-height: 320px; display: flex; flex-direction: column; }
.chart-surface .card__body { flex: 1; display: flex; flex-direction: column; gap: var(--space-4); }

/* Skeleton compositions used on the empty dashboard */
.skeleton-row { display: flex; align-items: center; gap: var(--space-3); }
.skeleton-stack { display: flex; flex-direction: column; gap: var(--space-2); flex: 1; }

.skeleton-bars {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  min-height: 200px;
  padding-top: var(--space-4);
}
.skeleton-bars .skeleton { flex: 1; border-radius: var(--radius-sm) var(--radius-sm) 4px 4px; }

/* ---------- Generic module placeholder ---------- */
.module-pending { min-height: 420px; display: grid; place-items: center; }

/* ---------- Settings page ---------- */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-4);
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) 0;
}
.setting-row + .setting-row { border-top: 1px solid var(--border-subtle); }
.setting-row__label { font-weight: var(--weight-medium); }
.setting-row__hint { font-size: var(--text-sm); color: var(--text-muted); margin-top: 2px; }

/* Segmented control (theme picker) */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}
.segmented__option {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-3);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.segmented__option svg { width: 14px; height: 14px; }
.segmented__option:hover { color: var(--text-primary); }
.segmented__option.is-selected {
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* ---------- Excel Upload module ---------- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-8) var(--space-5);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.dropzone:hover { border-color: var(--blue-400); background: var(--bg-hover); }
.dropzone.is-dragover {
  border-color: var(--blue-400);
  background: var(--bg-active);
  transform: scale(1.005);
}
.dropzone__icon {
  display: grid;
  place-items: center;
  width: 64px; height: 64px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-lg);
  background: var(--gradient-brand-soft);
  color: var(--text-brand);
}
.dropzone__title { font-size: var(--text-lg); }
.dropzone__hint { font-size: var(--text-sm); color: var(--text-muted); }
.dropzone__actions { margin-top: var(--space-3); }

.import-progress { display: flex; align-items: center; gap: var(--space-4); }
.import-progress__spinner {
  width: 34px; height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--blue-500);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.import-success__body { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.import-success__icon { color: var(--positive); flex-shrink: 0; }
.import-success__text { flex: 1; min-width: 220px; }

.import-error { margin-bottom: var(--space-4); }
.import-error__body { display: flex; align-items: flex-start; gap: var(--space-3); }
.import-error__icon { color: var(--negative); flex-shrink: 0; margin-top: 2px; }

.import-stats,
.import-totals {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-4);
}
.stat-tile { display: flex; flex-direction: column; gap: var(--space-1); }
.stat-tile__value { font-size: var(--text-xl); font-weight: var(--weight-semibold); letter-spacing: -0.01em; }
.stat-tile__value--positive { color: var(--positive); }
.stat-tile__value--negative { color: var(--negative); }

.column-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* ---------- Data preview table ---------- */
.table-scroll { overflow-x: auto; margin-top: var(--space-2); }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  white-space: nowrap;
}
.data-table th {
  position: sticky;
  top: 0;
  padding: var(--space-2) var(--space-3);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-strong);
  background: transparent;
}
.data-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}
.data-table td:first-child { color: var(--text-primary); font-weight: var(--weight-medium); }
.data-table tbody tr { transition: background-color var(--dur-fast) var(--ease-out); }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table .is-numeric { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- KPI cards (live) ---------- */
.kpi-card__value {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  margin-top: 2px;
}
.kpi-card__value--text {
  font-size: var(--text-lg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-card__sub { font-size: var(--text-sm); color: var(--text-muted); margin-top: 2px; }
.kpi-card__spark { color: var(--text-brand); align-self: flex-end; }

/* ---------- Chart host ---------- */
/* overflow: hidden is a real constraint, not decoration: Chart.js resizes
   its canvas asynchronously via ResizeObserver, and a burst of layout
   changes in a short window (e.g. several viewport resizes in a row) can
   leave the canvas's own rendered width briefly stale/wider than its
   grid/flex track before the observer catches up. Without this, that
   excess width silently propagates into every ancestor's scrollWidth —
   `.dash-grid`, `.page`, `.main` — and gets cropped by <main>'s
   overflow-x: hidden exactly like the field-grid overflow this stylesheet
   otherwise fixes with real track sizing. Clipping it here, at the one
   element whose child (the canvas) doesn't have layout-safe sizing
   guarantees, contains the problem instead of letting it surface three
   ancestors away.
 */
.chart-host { position: relative; width: 100%; overflow: hidden; }
.dash-grid--flip { grid-template-columns: 1fr 2fr; }
@media (max-width: 900px) { .dash-grid--flip { grid-template-columns: 1fr; } }

/* ---------- Leaderboards ---------- */
.board-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.board-list__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}
.board-list__item + .board-list__item { border-top: 1px solid var(--border-subtle); }
.board-list__rank {
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--gradient-brand-soft);
  color: var(--text-brand);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}
.board-list__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--weight-medium);
}
.board-list__meta { color: var(--text-muted); font-weight: var(--weight-regular); }
.board-list__value { font-variant-numeric: tabular-nums; font-weight: var(--weight-semibold); }
.board-list__value.is-negative { color: var(--negative); }

/* ---------- Score bar ---------- */
.score-bar { display: inline-flex; align-items: center; gap: var(--space-2); }
.score-bar__track {
  width: 64px; height: 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-hover);
  overflow: hidden;
}
.score-bar__fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--gradient-brand);
  transition: width var(--dur-slow) var(--ease-out);
}
.score-bar__value {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 20px;
  text-align: right;
}

/* ---------- Data grid chrome ---------- */
.grid-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
.grid-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding-top: var(--space-3);
}
.grid-info { font-size: var(--text-sm); color: var(--text-muted); }
.grid-pager { display: flex; align-items: center; gap: var(--space-2); }
.grid-page { font-size: var(--text-sm); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.grid-size {
  height: 30px;
  padding: 0 var(--space-2);
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--text-sm);
}
.icon-btn--sm { width: 30px; height: 30px; }
.icon-btn--sm svg { width: 16px; height: 16px; }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.data-table th.is-sortable { cursor: pointer; user-select: none; }
.data-table th.is-sortable:hover { color: var(--text-primary); }
.th-label { display: inline-flex; align-items: center; gap: 4px; }
.th-sort { transition: transform var(--dur-fast) var(--ease-out); }
.th-sort.is-desc { transform: rotate(180deg); }

.grid-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-7) var(--space-4);
  color: var(--text-muted);
}

/* ---------- Data grid pinned totals row ---------- */
.data-table__totals {
  position: sticky;
  bottom: 0;
  background: var(--bg-surface);
  font-weight: var(--weight-semibold);
}
.data-table__totals td {
  color: var(--text-primary);
  border-top: 1px solid var(--border-strong);
  border-bottom: none;
}
.data-table__totals td:first-child { color: var(--text-primary); }

/* ---------- Yıllık Satış Karşılaştırma ---------- */
.yc-year-picker { display: flex; align-items: center; gap: var(--space-2); }
.yc-year-select {
  height: 34px;
  padding: 0 var(--space-3);
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
}
.yc-year-picker__sep { color: var(--text-muted); font-size: var(--text-sm); }

.yc-change {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-medium);
}
.yc-change__mark { font-size: 10px; line-height: 1; }
.yc-change--up { color: var(--positive); }
.yc-change--down { color: var(--negative); }
.yc-change--flat { color: var(--text-muted); }
.yc-change--new { color: var(--text-brand); }
.yc-change--new svg { width: 12px; height: 12px; }

.yc-tabs-scroll { overflow-x: auto; margin-bottom: var(--space-4); }
.yc-tabs { width: max-content; }

.yc-subtoolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}

.yc-drill {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-brand);
  font: inherit;
  font-weight: var(--weight-medium);
  cursor: pointer;
  text-align: left;
}
.yc-drill:hover { text-decoration: underline; }

.yc-matrix-focus {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.yc-matrix-focus select { min-width: 160px; }

.yc-rank {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}
.yc-rank--gold   { background: rgba(234, 179, 8, 0.18);  color: #eab308; }
.yc-rank--silver { background: rgba(148, 163, 184, 0.2); color: #94a3b8; }
.yc-rank--bronze { background: rgba(217, 119, 6, 0.18);  color: #d97706; }

.yc-flags { display: flex; flex-wrap: wrap; gap: var(--space-1); }

@media (max-width: 640px) {
  .yc-year-picker { flex-wrap: wrap; }
  .yc-year-select { flex: 1; min-width: 90px; }
}

/* ---------- Rakip Fiyat Analizi ---------- */
.price-bot-toolbar { margin: 16px 0; }

/* ---------- Insights ---------- */
.insight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-4);
}
.insight__body { display: flex; gap: var(--space-3); align-items: flex-start; }
.insight__icon {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
}
.insight__icon--positive { background: var(--positive-bg); color: var(--positive); }
.insight__icon--negative { background: var(--negative-bg); color: var(--negative); }
.insight__icon--warning  { background: var(--warning-bg);  color: var(--warning); }
.insight__icon--info     { background: var(--info-bg);     color: var(--text-brand); }
.insight__title { font-size: var(--text-md); margin-bottom: 4px; }
.insight__text { font-size: var(--text-sm); }

/* ---------- Export center ---------- */
.export-tile { display: flex; align-items: center; gap: var(--space-4); }
.export-tile__text { flex: 1; min-width: 0; }

/* ---------- AI Yorumu (compact insight callout) ---------- */
.ai-insight-card__icon { color: var(--text-brand); }
.ai-insight-card__body { display: flex; flex-direction: column; gap: var(--space-3); }
.ai-insight-card__row { display: flex; gap: var(--space-3); align-items: flex-start; font-size: var(--text-sm); color: var(--text-secondary); }
.ai-insight-card__row .insight__icon { width: 28px; height: 28px; flex-shrink: 0; }
.ai-insight-card__row strong { color: var(--text-primary); }

/* ---------- Print (Raporlar → PDF) ---------- */
@media print {
  .sidebar, .topbar, .aurora, .toast-region, .page__actions, .skip-link, .filter-panel { display: none !important; }
  body { overflow: visible; background: #fff; }
  .main { overflow: visible; padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  :root[data-theme="dark"] { color-scheme: light; }
}
