/* ══════════════════════════════════════════════════════════════════════════════
   RACA SYNC — SCROLL LOCK v1
   Tüm liste ve kanban ekranları için TEK ORTAK scroll zinciri. Bu dosya
   design.css ve raca-table.css'ten SONRA yüklenir, çakışan kuralları
   son sözle bastırır.

   PRENSIP:
   1. Sayfa (html/body/main) hiçbir zaman scroll etmez.
   2. TEK bir iç element scroll eder: .list-scroll / .rs-grid-scroll /
      .rs-kanban* / .cari-kart-grid.
   3. Sticky thead o iç scroll container'a yapışır.
   4. Frozen kolonlar (checkbox + AD) yatay scroll'da yerinde kalır.

   SCROLL ZİNCİRİ (list-page mode):

     html.list-page-html            overflow:hidden  height:100%
       body.list-page                overflow:hidden  height:100dvh
         .main                       display:flex column  overflow:hidden  height:100dvh
           .topbar                   flex:0 0 auto
           .rs-list / .card.is-list  display:flex column  flex:1  overflow:hidden  min-height:0
             .rs-list__header         flex:0 0 auto
             .rs-list__kpis           flex:0 0 auto
             .rs-list__toolbar        flex:0 0 auto
             .rs-list__filters        flex:0 0 auto
             .rs-list__table-wrap    display:flex column  flex:1  overflow:hidden  min-height:0
               .list-scroll           flex:1  overflow:auto  min-height:0    ← GERÇEK SCROLL
                 table.raca-table     thead th position:sticky top:0
   ══════════════════════════════════════════════════════════════════════════════ */


/* ─── 1) ROOT ZİNCİR — html / body / main kilit ───────────────────────────── */

html.list-page-html {
    height: 100% !important;
    overflow: hidden !important;
}
body.list-page {
    height: 100vh !important;  /* fallback */
    height: 100dvh !important; /* modern tarayıcı: dinamik viewport (mobil URL bar hesaba katılır) */
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}
body.list-page .main {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    height: 100dvh !important;
    min-height: 0 !important;
    padding-bottom: 0 !important;
    box-sizing: border-box !important;
}
body.list-page .main > .topbar {
    flex: 0 0 auto !important;
    position: static !important;   /* sticky gereksiz — flex zaten sabit tutuyor */
}


/* ─── 2) İÇ KOLON WRAPPER — .rs-list ve .card.is-list ─────────────────────── */

body.list-page .rs-list,
body.list-page .card.is-list,
body.list-page .main > .rs-list,
body.list-page .main > .card.is-list {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

/* Nested: RSStokPage → .rs-list > .card.is-list */
body.list-page .rs-list > .card.is-list {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}


/* ─── 3) SABİT ÜST ALANLAR — flex:0 auto (natural height, kaymaz) ─────────── */

body.list-page .rs-page-head,
body.list-page .rs-list__header,
body.list-page .rs-list__kpis,
body.list-page .rs-list__toolbar,
body.list-page .rs-list__filters,
body.list-page .rs-list__stats,
body.list-page .rs-kpi-grid,
body.list-page .rs-toolbar,
body.list-page .rs-stats,
body.list-page .list-toolbar,
body.list-page .list-filter,
body.list-page .list-meta,
body.list-page .list-header,
body.list-page .rs-filter-bar {
    flex: 0 0 auto !important;
    min-height: 0 !important;
    margin-top: 0 !important;
}


/* ─── 4) TABLO WRAP — dış çerçeve HİÇBİR ZAMAN scroll etmez ───────────────── */
/*
   Kritik: bir liste ekranında sadece BİR element scroll etmeli. Wrap'lerin
   overflow:auto olması iç .list-scroll ile çift scroll üretir. Wrap'i hep
   hidden yap, iç scroll container tek yerde kalsın.
*/

body.list-page .rs-list__table-wrap,
body.list-page .rs-table-wrap,
body.list-page .rs-grid-wrap {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

/* Tablonun DIRECT parent'ı wrap ise (list-scroll olmadan direk table) —
   wrap'in kendisi scroll olur (fallback). Sadece bu case. */
body.list-page .rs-list > .rs-table-wrap:not(:has(.list-scroll)):not(:has(.rs-grid-scroll)) {
    overflow: auto !important;
}


/* ─── 5) GERÇEK SCROLL CONTAINER — TEK YER ────────────────────────────────── */
/*
   Bunlar TEK scroll container. Sticky thead buna yapışır. Yatay scrollbar
   bunun kendi altında görünür.
*/

body.list-page .list-scroll,
body.list-page .rs-grid-scroll,
body.list-page .rs-list > .list-scroll,
body.list-page .rs-list > .rs-grid-scroll,
body.list-page .card.is-list > .list-scroll,
body.list-page .card.is-list > .rs-grid-scroll,
body.list-page .rs-list > .card.is-list > .list-scroll,
body.list-page .rs-list__table-wrap > .list-scroll,
body.list-page .rs-list__table-wrap > .rs-grid-scroll,
body.list-page .rs-table-wrap > .list-scroll,
body.list-page .rs-table-wrap > .rs-grid-scroll,
body.list-page .rs-grid-wrap > .list-scroll,
body.list-page .rs-grid-wrap > .rs-grid-scroll {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    height: auto !important;   /* JS'in eski `height` yazımını temizle */
    overflow-y: auto !important;
    overflow-x: auto !important;
    box-sizing: border-box !important;
}


/* ─── 6) ÇİFT SCROLL ÖNLEME — .list-scroll içindeki her şey visible ─────── */
/*
   Stok kanban gibi bazı ekranlarda <div class="list-scroll"><div class="rs-kanban-grid">
   yapısı var. İç kanban container'ın overflow:auto olması çift scroll üretir.
   Kural: .list-scroll içindeki alt div'ler asla scroll etmez.
*/

body.list-page .list-scroll > .rs-kanban,
body.list-page .list-scroll > .rs-kanban-grid,
body.list-page .list-scroll > .stk-kanban,
body.list-page .list-scroll > .cari-kart-grid,
body.list-page .list-scroll > .gorev-kanban,
body.list-page .list-scroll > .pot-kanban,
body.list-page .list-scroll .rs-kanban-grid,
body.list-page .list-scroll .cari-kart-grid,
body.list-page .list-scroll .stk-kanban,
body.list-page .rs-grid-scroll .rs-kanban-grid,
body.list-page .rs-grid-scroll .cari-kart-grid {
    overflow: visible !important;
    max-height: none !important;
    height: auto !important;
    min-height: 0 !important;
    display: block !important;  /* grid parent olabilir; block ile scroll gerekmez */
}
/* Kanban grid iç layout korunsun (grid template) — sadece scroll'u kapadık */
body.list-page .list-scroll > .rs-kanban-grid,
body.list-page .list-scroll > .cari-kart-grid,
body.list-page .list-scroll .rs-kanban-grid,
body.list-page .list-scroll .cari-kart-grid {
    display: grid !important;   /* geri getir */
}


/* ─── 7) KANBAN CONTAINER'LARI — .rs-list direct child ise kendi scroll'u ── */
/*
   Kanban ekranlarında (Görev, Potansiyel) .rs-kanban / .gorev-kanban vs.
   doğrudan .rs-list veya .card.is-list altında konumlanır (list-scroll YOK).
   Bu durumda kendisi scroll container olur.
*/

body.list-page .rs-list > .rs-kanban,
body.list-page .rs-list > .stk-kanban,
body.list-page .rs-list > .rs-kanban-grid,
body.list-page .rs-list > .cari-kart-grid,
body.list-page .card.is-list > .rs-kanban,
body.list-page .card.is-list > .stk-kanban,
body.list-page .card.is-list > .rs-kanban-grid,
body.list-page .card.is-list > .cari-kart-grid {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    height: auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
}

/* Sütun-akış kanban (Görev/Potansiyel): dikey + yatay */
body.list-page .rs-list > .gorev-kanban,
body.list-page .rs-list > .pot-kanban,
body.list-page .card.is-list > .gorev-kanban,
body.list-page .card.is-list > .pot-kanban,
body.list-page .rs-list__table-wrap > .gorev-kanban,
body.list-page .rs-list__table-wrap > .pot-kanban,
/* GÖREV MODÜLÜ 2026-09-05 (fix ekran kayması):
   Görev modülü .gorev-layout > .gorev-main > .gorev-kanban 3 seviyeli
   yerleşim kullanıyor. Yukarıdaki selector'lar 2 seviyeli olduğu için
   .gorev-kanban scroll parent'ını tanıyamıyordu → kanban büyüyünce
   sayfa scroll olup toolbar/sticky kayıyordu. */
body.list-page .gorev-main > .gorev-kanban,
body.list-page .gorev-main > .kanban.gorev-kanban,
body.list-page .gorev-main > .gorev-kb,
body.list-page .gorev-main > .pot-kanban,
body.list-page .gorev-main > .card.is-list,
body.list-page .gorev-main > .card.is-list > .gorev-kb,
body.list-page .gorev-main > .card.is-list > .pot-kanban {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    height: auto !important;
    overflow-y: auto !important;
    overflow-x: auto !important;
    box-sizing: border-box !important;
}

/* Görev modülünün özel layout container'ları — scroll chain integrasyonu */
body.list-page .gorev-layout {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
}
body.list-page .gorev-main {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}
body.list-page .gorev-sidebar {
    flex: 0 0 auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    min-height: 0 !important;
}


/* ─── 8) STICKY THEAD — MAKSIMUM GARANTI ──────────────────────────────────── */
/*
   Chrome/Edge/Firefox'ta sticky'nin ÇALIŞMASI için gerekli 5 KOŞUL zorlanır:
   1. Tablo: border-collapse:separate (collapse'te Chrome sticky BOZAR)
   2. Thead th: position:sticky + top:0 + opak background
   3. Row'lara content-visibility/contain YOK (implicit containing block yaratır)
   4. Scroll container'ın herhangi bir ata'sı transform/filter/contain OLMAZ
   5. Table'a position:relative (Chrome sticky için yardımcı)

   Not: body class'ı olmayabilir → HEM body.list-page HEM genel selector kullan.
   Böylece "list-page" script'i eklenmese bile sticky yine çalışır.
*/

/* --- Tablo temel: collapse KAPALI, position hazır --- */
.list-scroll table.raca-table,
.rs-grid-scroll table.raca-table,
.list-scroll table.rs-grid,
.rs-grid-scroll table.rs-grid,
.card.is-list .list-scroll table,
.rs-list .list-scroll table,
.rs-list .rs-grid-scroll table {
    border-collapse: separate !important;
    border-spacing: 0 !important;
    position: relative !important;
}

/* --- İçerik satırları asla layout containment yaratmasın --- */
.list-scroll table tbody tr,
.list-scroll table thead tr,
.list-scroll table thead th,
.rs-grid-scroll table tbody tr,
.rs-grid-scroll table thead tr,
.rs-grid-scroll table thead th {
    content-visibility: visible !important;
    contain: none !important;
    will-change: auto !important;
}

/* --- Scroll container'ın kendisi containing block yaratmasın --- */
.list-scroll,
.rs-grid-scroll {
    transform: none !important;
    filter: none !important;
    perspective: none !important;
    contain: none !important;
    will-change: auto !important;
}

/* --- STICKY THEAD (ana kolon başlık satırı) --- */
.list-scroll table.raca-table thead th,
.rs-grid-scroll table.raca-table thead th,
.list-scroll table.rs-grid thead th,
.rs-grid-scroll table.rs-grid thead th,
.card.is-list .list-scroll table thead th,
.rs-list .list-scroll table thead th,
.rs-list .rs-grid-scroll table thead th {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 30 !important;
    background: #fafbfd !important;  /* opak, transparent DEĞİL */
}

/* --- Filter satırı (2. sticky sıra) --- */
.list-scroll table.raca-table thead tr.rt-filter-row th,
.rs-grid-scroll table.raca-table thead tr.rt-filter-row th,
.list-scroll table.rs-grid thead tr.rt-filter-row th,
.rs-grid-scroll table.rs-grid thead tr.rt-filter-row th,
.card.is-list .list-scroll table thead tr.rt-filter-row th,
.rs-list .list-scroll table thead tr.rt-filter-row th,
.rs-list .rs-grid-scroll table thead tr.rt-filter-row th {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 28px !important;   /* 1. header'ın altına */
    z-index: 29 !important;
    background: #ffffff !important;
}


/* ─── 9) FROZEN SOL KOLONLAR — checkbox + AD sabit ────────────────────────── */
/*
   Mevcut raca-table.css'te frozen kolon davranışı .card.is-list scope'unda
   tanımlı. Aynı davranışı .rs-list scope'una da genişlet — Stok gibi
   .rs-list root kullanan ekranlarda da çalışsın.
*/

body.list-page .list-scroll table.raca-table th[data-col="sec"],
body.list-page .list-scroll table.raca-table td[data-col="sec"],
body.list-page .rs-grid-scroll table.raca-table th[data-col="sec"],
body.list-page .rs-grid-scroll table.raca-table td[data-col="sec"],
body.list-page .list-scroll table.rs-grid th[data-col="sec"],
body.list-page .list-scroll table.rs-grid td[data-col="sec"],
body.list-page .rs-grid-scroll table.rs-grid th[data-col="sec"],
body.list-page .rs-grid-scroll table.rs-grid td[data-col="sec"] {
    position: sticky !important;
    left: 0 !important;
    z-index: 2;
    background: #fff;
}
body.list-page .list-scroll table.raca-table th[data-col="ad"],
body.list-page .list-scroll table.raca-table td[data-col="ad"],
body.list-page .rs-grid-scroll table.raca-table th[data-col="ad"],
body.list-page .rs-grid-scroll table.raca-table td[data-col="ad"],
body.list-page .list-scroll table.rs-grid th[data-col="ad"],
body.list-page .list-scroll table.rs-grid td[data-col="ad"],
body.list-page .rs-grid-scroll table.rs-grid th[data-col="ad"],
body.list-page .rs-grid-scroll table.rs-grid td[data-col="ad"] {
    position: sticky !important;
    left: var(--rt-col-sec-w, 32px) !important;
    z-index: 2;
    background: #fff;
    border-right: 2px solid #d4d8e6;
}
/* Corner cell (sticky top + sticky left) — z-index yükseğe çıksın */
body.list-page .list-scroll table.raca-table thead th[data-col="sec"],
body.list-page .list-scroll table.raca-table thead th[data-col="ad"],
body.list-page .rs-grid-scroll table.raca-table thead th[data-col="sec"],
body.list-page .rs-grid-scroll table.raca-table thead th[data-col="ad"],
body.list-page .list-scroll table.rs-grid thead th[data-col="sec"],
body.list-page .list-scroll table.rs-grid thead th[data-col="ad"],
body.list-page .rs-grid-scroll table.rs-grid thead th[data-col="sec"],
body.list-page .rs-grid-scroll table.rs-grid thead th[data-col="ad"] {
    z-index: 12 !important;
    background: #fafbfd !important;
}
body.list-page .list-scroll table.raca-table thead tr.rt-filter-row th[data-col="sec"],
body.list-page .list-scroll table.raca-table thead tr.rt-filter-row th[data-col="ad"],
body.list-page .rs-grid-scroll table.raca-table thead tr.rt-filter-row th[data-col="sec"],
body.list-page .rs-grid-scroll table.raca-table thead tr.rt-filter-row th[data-col="ad"] {
    z-index: 11 !important;
    background: #ffffff !important;
}


/* ─── 10) NON-LIST-PAGE (form/detay/rapor/modal) DOKUNMA ──────────────────── */
/*
   body class'ı list-page değilse hiçbir kural uygulanmaz. Mevcut form/detay/
   modal sayfaları etkilenmez. Sadece body.list-page olan ekranlar bu
   scroll zincirine tabidir.
*/


/* ─── 11) SIDEBAR — position:fixed varsayımı korunur ──────────────────────── */

body.list-page .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    height: 100dvh !important;
    height: 100vh !important;
    z-index: 100;
}


/* ─── 12) SAĞDAKI DIŞ SCROLLBAR'I GİZLE (extra güvenlik) ──────────────────── */
/*
   Bazı tarayıcılarda overflow:hidden olsa da scrollbar rezerv edilebilir.
   scrollbar-gutter kullan → scrollbar hiç görünmez.
*/

html.list-page-html,
body.list-page {
    scrollbar-gutter: auto !important;
    scrollbar-width: none;
}
html.list-page-html::-webkit-scrollbar,
body.list-page::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}


/* ─── 13) EMBED MODE — iframe içinde list-page ────────────────────────────── */

body.embed.list-page {
    height: 100dvh !important;
    overflow: hidden !important;
}
body.embed.list-page .main {
    margin-left: 0 !important;
    width: 100% !important;
    padding-left: 15px !important;
    padding-right: 15px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    height: 100dvh !important;
}


/* ─── 14) FALLBACK — body.list-page class'ı eklenmemişse bile çalışsın ────── */
/*
   Bazı handler'lar list-page class'ı eklemeyi unutmuş olabilir. Bu durumda
   sayfayı body scroll'una bırakıyoruz AMA sticky thead yine çalışsın diye
   raca-table thead'i her yerde sticky yapıyoruz. Bu safety net.

   Non-list-page durumunda sticky thead .main'in scroll'una yapışır.
   .main { overflow-y:auto } zaten var, sadece sticky'nin doğru top offset'i
   gerekir (topbar sticky olduğu için topbar yüksekliği kadar).
*/

body:not(.list-page) .main table.raca-table thead th,
body:not(.list-page) .main table.rs-grid thead th {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: var(--rt-topbar-h, 44px) !important;
    z-index: 30 !important;
    background: #fafbfd !important;
}
body:not(.list-page) .main table.raca-table thead tr.rt-filter-row th,
body:not(.list-page) .main table.rs-grid thead tr.rt-filter-row th {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: calc(var(--rt-topbar-h, 44px) + 28px) !important;
    z-index: 29 !important;
    background: #ffffff !important;
}
body:not(.list-page) .main table.raca-table,
body:not(.list-page) .main table.rs-grid {
    border-collapse: separate !important;
    border-spacing: 0 !important;
    position: relative !important;
}
body:not(.list-page) .main table tbody tr,
body:not(.list-page) .main table thead tr,
body:not(.list-page) .main table thead th {
    content-visibility: visible !important;
    contain: none !important;
}
