/* Tablo bileseni - dtable, satir yardimcilari, sayfalama, sirala gostergesi, uygulanan filtre cipleri */

/* ============================================================
   12. TABLES (dtable)
   ============================================================ */
.mac-table-wrap, .table-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
/* Dogrudan tablo tasiyan kap yatay KAYAR — kirpmayi surdurur ama son sutun erisilebilir kalir.
   Kaba `overflow: visible` YAZILMAZ: o zaman tablo kaptan tasip HOST'U yatay kaydirir. Satir
   menusu fixed portal oldugu icin kabin acilmasina gerek yok. overflow-y hidden kalir:
   kose yuvarlamasi ve dikey kirpma sozlesmesi bozulmaz. */
/* Pano kartlari (`.card`) da listeye dahil: dar sutunda min-content'i sigmayan tablo karttan
   tasip YANDAKI panonun yazisina basiyordu (Talep Istatistik, 900px).
   2026-08-13: markup'taki 128 tablo kabinin hepsi `pai-tablo-kart` tasiyor, yani bu kurala
   bagli tablo KALMADI — guvenlik agi olarak duruyor (JS ile sonradan eklenen tablo, disaridan
   gelen icerik). Kaydirmayi verir ama kenar bandini VERMEZ; bant durum sinifina baglidir. */
.mac-card:has(> table), .mac-table-wrap:has(> table), .table-card:has(> table), .card:has(> table) {
  overflow-x: auto; overflow-y: hidden;
}

/* ------------------------------------------------------------
   Tablo kabi sozlesmesi — `pai-tablo-kart`
   Tabloyu saran kap bu sinifi tasir; yatay kayar, dikey kirpar. Deri (arka plan, kenarlik,
   kose, golge) modulde kalir, burada yalniz mekanik + kaydirma gorunurlugu vardir.
   Ustteki `:has(> table)` kurali ara div'i olan yerlerde eslesmiyor; bu sinif markup'tan
   sorulur, ara kap onu kiramaz.
   ------------------------------------------------------------ */
.pai-tablo-kart {
  overflow-x: auto;
  overflow-y: hidden;
}
.pai-tablo-kart > table { width: 100%; }

/* Uzun liste varyanti: kap dikey de kayar, baslik satiri yapisik kalir.
   Yuzlerce satirlik veri GIRISI ekranlarinda (sayim gibi) ust ozet ve alt aksiyon seridi
   ekrandan cikmasin diye kullanilir — kabuk kaydirmasini devralan ekran bu sinifi yazar.
   Modul CSS'i ortak kabin overflow'unu EZEMEZ; ihtiyac buysa varyant burada tanimlanir. */
.pai-tablo-kart.uzun { overflow-y: auto; }
.pai-tablo-kart.uzun > table > thead th { position: sticky; top: 0; z-index: 2; }

/* Kalici ince cubuk: genel 10px'lik cubuktan ince, tablo kabina ozel.
   Buraya `scrollbar-width` YAZILMAZ — yazan elemanda Chrome bu webkit kurallarini yok sayar. */
.pai-tablo-kart::-webkit-scrollbar { height: 8px; }
.pai-tablo-kart::-webkit-scrollbar-track { background: transparent; }
.pai-tablo-kart::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb); border-radius: 4px;
  border: 2px solid transparent; background-clip: padding-box;
}
.pai-tablo-kart::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); background-clip: padding-box; }

/* Kenar bandi — "bu tarafta devam ediyor". Durum sinifini tablo.js yazar.
   box-shadow DEGIL gradyan: ic golgede en yogun nokta kenarda degil, offset/blur/spread
   birbirini yiyor — koyu temada %95 beyazla bile fark edilmiyordu (olculdu). Gradyanda
   bandin genisligi ve yogunlugu tam kontrollu.
   Kaydirinca kaymaz: `background-attachment` varsayilani `scroll`, yani arka plan icerikle
   degil KABIN kutusuyla hizalanir.
   Iki sinif ozgullugu ZORUNLU: modul derisi (`background: var(--surface)`) bu dosyadan
   SONRA yuklenir ve tek sinifli `background-image`i ezerdi. box-shadow'a hic dokunmuyoruz,
   deri golgesi oldugu gibi kaliyor. */
.pai-tablo-kart.kayar-sag,
.pai-tablo-kart.kayar-sol {
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
.pai-tablo-kart.kayar-sag {
  background-image: linear-gradient(to left, var(--kayma-golge), transparent 56px);
}
.pai-tablo-kart.kayar-sol {
  background-image: linear-gradient(to right, var(--kayma-golge), transparent 56px);
}
.pai-tablo-kart.kayar-sol.kayar-sag {
  background-image: linear-gradient(to left, var(--kayma-golge), transparent 56px),
                    linear-gradient(to right, var(--kayma-golge), transparent 56px);
}

.dtable {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.dtable thead th {
  background: var(--gray-surface);
  text-align: left;
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
.dtable thead th.right { text-align: right; }
.dtable thead th.center { text-align: center; }
.dtable tbody td {
  padding: 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}
.dtable tbody tr:last-child td { border-bottom: none; }
.dtable tbody tr {
  cursor: pointer; transition: background 0.15s ease;
}
.dtable tbody tr:hover { background: var(--row-hover-bg); }
.dtable td.right { text-align: right; font-variant-numeric: tabular-nums; }
.dtable td.center { text-align: center; }
.dtable td.muted { color: var(--muted); }
.dtable td.num { font-variant-numeric: tabular-nums; }

/* Row helpers */
.row-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--gray-surface); color: var(--muted);
  font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.prod-cell { line-height: 1.35; min-width: 200px; max-width: 360px; }
.prod-name { font-size: 13px; font-weight: 500; color: var(--text); }
.prod-code {
  font-size: 11px; color: var(--muted);
  margin-top: 2px; font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: center; gap: 6px;
}
.prod-code .bullet { color: rgba(0,0,0,0.18); }
.depo-cell { font-size: 12px; line-height: 1.35; }
.depo-name { font-weight: 500; color: var(--text); }
.depo-loc { color: var(--muted); margin-top: 2px; font-size: 11px; }
.lot-cell { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
/* .empty modifier'i bos-durum bileseninin global `.empty { display:flex }` kuraliyla
   cakisir; tablo hucresinde flex satir yuksekligini bozar (hucre kisalir, alt-border
   yukari kayar). Tablo-hucre davranisini geri sabitle. */
.lot-cell.empty { color: rgba(134,134,139,0.6); display: table-cell; text-align: left; }
.reason-cell { font-size: 12px; color: var(--text); line-height: 1.4; max-width: 320px; }
.tutar { font-size: 13px; font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }

.row-action {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer;
  color: var(--muted); font-size: 14px;
  transition: background 0.15s ease, color 0.15s ease;
}
.row-action:hover { background: var(--hover-bg); color: var(--text); }
.row-action.tehlike:hover { color: var(--red); }

.add-row {
  padding: 12px 14px;
  border-top: 1px dashed var(--border);
  background: rgba(0,122,255,0.02);
}
.add-row a {
  font-size: 12px; color: var(--mac-blue);
  cursor: pointer; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
}
.add-row a:hover { text-decoration: underline; }
.add-row a i { font-size: 11px; }

/* Table footer (pagination) */
.table-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; gap: 16px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface);
}
.footer-left {
  display: flex; align-items: center; gap: 16px;
  font-size: 13px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.per-page { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.per-page-etiket { color: inherit; }
/* Kabuk ve panel `pai-acilir`dan gelir; burasi yalniz olcu derisi. Cubuktaki diger
   kontroller 30px (.pg-btn) — bilesenin 33px varsayilani serit yuksekligini buyutuyordu. */
.per-page .pai-acilir-btn {
  height: 30px; padding: 0 7px 0 10px; gap: 6px;
  font-size: 12px; border-radius: 6px;
}
.pagination { display: flex; align-items: center; gap: 4px; }
.pg-btn {
  min-width: 30px; height: 30px; padding: 0 8px;
  border-radius: 8px; background: var(--surface);
  border: 1px solid var(--border); color: var(--text);
  font-size: 13px; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.15s ease; font-family: var(--font);
  font-variant-numeric: tabular-nums;
}
.pg-btn:hover { background: var(--gray-surface); border-color: var(--border-strong); }
.pg-btn.active {
  background: var(--mac-blue); border-color: var(--mac-blue); color: #fff;
  box-shadow: 0 1px 2px rgba(0,122,255,0.25);
}
.pg-btn.icon i { font-size: 12px; color: var(--muted); }
.pg-btn.icon:hover i { color: var(--text); }

/* ============================================================
   25. SORT INDICATOR (table)
   ============================================================ */

.dtable th.sortable, .ku-tablo th.sortable {
  cursor: pointer; user-select: none;
  padding-right: 22px; position: relative;
  transition: background 0.12s ease;
}
.dtable th.sortable:hover, .ku-tablo th.sortable:hover { background: var(--hover-bg); }

.dtable th.sortable::after, .ku-tablo th.sortable::after {
  content: ''; position: absolute; right: 8px; top: 50%;
  width: 0; height: 0; transform: translateY(-50%);
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--border-strong);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.dtable th.sortable:hover::after, .ku-tablo th.sortable:hover::after { opacity: 0.5; }

.dtable th.sort-asc::after, .ku-tablo th.sort-asc::after {
  border-top: none;
  border-bottom: 5px solid var(--mac-blue);
  opacity: 1;
}
.dtable th.sort-desc::after, .ku-tablo th.sort-desc::after {
  border-top: 5px solid var(--mac-blue);
  border-bottom: none;
  opacity: 1;
}
.dtable th.sort-asc, .dtable th.sort-desc, .ku-tablo th.sort-asc, .ku-tablo th.sort-desc {
  color: var(--mac-blue);
}

/* Element-agnostik siralama basligi — dtable <th> disi, grid-liste <div> basliklari
   (Denetim/AsistanKonusma vb.) icin. Ayni backend sort deseni (tablo-sirala.js) + ayni
   asc/desc ok davranisi. Kullanim: <div class="pai-sirali sort-asc" data-sira="tarih"
   hx-get=... hx-target=... hx-include=... hx-swap="innerHTML">Baslik</div> */
.pai-sirali {
  cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: 5px; width: fit-content;
  transition: color 0.12s ease;
}
.pai-sirali::after {
  content: ''; flex: none;
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--border-strong);
  opacity: 0; transition: opacity 0.15s ease;
}
.pai-sirali:hover::after { opacity: 0.5; }
.pai-sirali.sort-asc::after {
  border-top: none; border-bottom: 5px solid var(--mac-blue); opacity: 1;
}
.pai-sirali.sort-desc::after {
  border-top: 5px solid var(--mac-blue); border-bottom: none; opacity: 1;
}
.pai-sirali.sort-asc, .pai-sirali.sort-desc { color: var(--mac-blue); }

/* ============================================================
   26. APPLIED FILTERS CHIP ROW
   ============================================================ */

.applied-filters {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; flex-wrap: wrap;
  background: rgba(0,122,255,0.04);
  border-bottom: 1px solid var(--border-soft);
  font-size: 12px;
}
.applied-filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 4px 4px 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 12px; color: var(--text);
}
.applied-filter-chip .af-x {
  width: 18px; height: 18px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,0.06);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--muted);
  transition: all 0.12s ease;
}
.applied-filter-chip .af-x:hover { background: var(--red); color: #fff; }
.applied-filter-chip .af-x i { font-size: 9px; }
.applied-filters .af-clear {
  background: transparent; border: 0; color: var(--mac-blue);
  font-size: 12px; font-weight: 500; cursor: pointer;
  margin-left: auto; padding: 4px 8px;
}
.applied-filters .af-clear:hover { text-decoration: underline; }

/* Kirilma tabaniyla ayni dosyada durur — kabuk/yerlesim.css'ten tasindi (yukleme sirasi). */
@container appwin (max-width: 880px) {
  .dtable thead th, .dtable tbody td { padding: 10px 8px; font-size: 12px; }
  .reason-cell { max-width: 200px; }
}
