/* App shell — sidebar, header, toolbar (layout iskeleti) */

/* Ofis (SMMM) + Yönetim paneli: menü sabit, içerik .app-content içinde kayar */
html:has(body[data-page="dashboard"]),
html:has(body[data-page="admin"]) {
    height: 100%;
}
body[data-page="dashboard"],
body[data-page="admin"] {
    height: 100%;
    overflow: hidden;
}
body[data-page="dashboard"] .app-shell,
body[data-page="admin"] .app-shell,
body[data-page="admin"] .admin-shell {
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

.app-shell {
    --app-sidebar-w: 16.5rem;
    --app-header-h: 3.5rem;
    --app-brand-h: 3.5rem;
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
}

.app-sidebar {
    width: var(--app-sidebar-w);
    min-width: var(--app-sidebar-w);
    max-width: var(--app-sidebar-w);
    background: #fff;
    border-right: 1px solid #e2e8f0;
    position: relative;
    align-self: stretch;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    z-index: 40;
    display: flex;
    flex-direction: column;
    color: #0f172a;
}

.app-sidebar__brand {
    flex: 0 0 auto;
    min-height: var(--app-brand-h);
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
    display: flex;
    align-items: center;
    z-index: 2;
}
.app-sidebar__brand--mm {
    align-items: stretch;
    min-height: 0;
    height: auto;
    overflow: visible;
}
.admin-shell .app-sidebar__brand {
    align-items: stretch;
    min-height: 0;
    height: auto;
}

.app-sidebar__logo {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.625rem;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.app-sidebar__title {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-sidebar__tenant {
    font-size: 0.6875rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.125rem;
}

.app-sidebar__footer {
    flex: 0 0 auto;
    padding: 0.75rem 1rem;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

.app-sidebar__footer-text {
    font-size: 0.6875rem;
    color: #64748b;
}

.sidebar-overlay {
    display: none;
}

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

body[data-page="dashboard"] .app-main,
body[data-page="admin"] .app-main {
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
}
body[data-page="dashboard"] .app-sidebar,
body[data-page="admin"] .app-sidebar {
    height: 100%;
    max-height: 100%;
}
body[data-page="dashboard"] .app-subheader,
body[data-page="admin"] .app-header {
    flex: 0 0 auto;
}
body[data-page="dashboard"] .app-content,
body[data-page="admin"] .app-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.app-header {
    position: relative;
    flex: 0 0 auto;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: var(--app-header-h);
    padding: 0.5rem 0.875rem;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}

.theme-dark .app-header {
    background: rgba(15, 23, 42, 0.92);
    border-bottom-color: #334155;
}

.app-header__start,
.app-header__center,
.app-header__end {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.app-header__start { flex: 1 1 auto; }
.app-header__center { flex: 0 1 auto; }
.app-header__end { flex: 0 0 auto; justify-content: flex-end; }

.app-page-title {
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.theme-dark .app-page-title { color: #f1f5f9; }

.app-header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #334155;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

.app-header-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.app-header-btn--icon {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
}

.app-header-btn--primary {
    color: #fff;
    background: #2563eb;
    border-color: #2563eb;
}

.app-header-btn--primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.app-header-btn__icon {
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
}

.app-toolbar {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.app-toolbar-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.app-toolbar-btn svg {
    width: 1.125rem;
    height: 1.125rem;
}

.app-toolbar-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.theme-dark .app-toolbar-btn:hover {
    background: #334155;
    color: #f1f5f9;
}

.app-toolbar-btn__badge {
    position: absolute;
    top: 0.15rem;
    right: 0.15rem;
    min-width: 1rem;
    height: 1rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 1rem;
    text-align: center;
}

.app-profile {
    position: relative;
    margin-left: 0.25rem;
}

.app-profile__trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem 0.25rem 0.25rem;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.app-profile__trigger:hover,
.app-profile.is-open .app-profile__trigger {
    background: #f8fafc;
    border-color: #e2e8f0;
}

.theme-dark .app-profile__trigger:hover,
.theme-dark .app-profile.is-open .app-profile__trigger {
    background: #1e293b;
    border-color: #334155;
}

.app-profile__avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.app-profile__info {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    text-align: left;
}

.app-profile__name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.2;
    max-width: 10rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-profile__role {
    font-size: 0.6875rem;
    color: #64748b;
    line-height: 1.2;
}

.app-profile__chevron {
    display: none;
    width: 1rem;
    height: 1rem;
    color: #94a3b8;
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .app-profile__info,
    .app-profile__chevron {
        display: flex;
    }
}

.theme-dark .app-profile__name { color: #f1f5f9; }
.theme-dark .app-profile__role { color: #94a3b8; }

.app-dropdown {
    position: absolute;
    top: calc(100% + 0.375rem);
    right: 0;
    min-width: 14rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
    z-index: 80;
}

.app-dropdown.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.app-dropdown--wide { min-width: 18rem; max-width: min(24rem, 92vw); }

.app-dropdown__header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
}

.app-dropdown__title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #0f172a;
}

.app-dropdown__subtitle {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.125rem;
}

.app-dropdown__body {
    padding: 0.375rem;
    max-height: min(60vh, 24rem);
    overflow-y: auto;
}

.app-dropdown__item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.5rem 0.625rem;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    font-size: 0.8125rem;
    color: #334155;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.app-dropdown__item svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    opacity: 0.75;
}

.app-dropdown__item:hover { background: #f8fafc; }
.app-dropdown__item--danger { color: #dc2626; }
.app-dropdown__item--danger:hover { background: #fef2f2; }

.app-dropdown__divider {
    height: 1px;
    margin: 0.375rem 0.5rem;
    background: #e2e8f0;
}

.app-dropdown__empty {
    padding: 0.75rem 0.625rem;
    font-size: 0.8125rem;
    color: #94a3b8;
    text-align: center;
}

.theme-dark .app-dropdown {
    background: #1e293b;
    border-color: #334155;
}

.theme-dark .app-dropdown__title { color: #f1f5f9; }
.theme-dark .app-dropdown__subtitle { color: #94a3b8; }
.theme-dark .app-dropdown__item { color: #cbd5e1; }
.theme-dark .app-dropdown__item:hover { background: #334155; }

.app-content {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    padding: 1rem;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

@media (min-width: 768px) {
    .app-content { padding: 1.25rem; }
}

.impersonation-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
    color: #92400e;
    font-size: 0.8125rem;
}

.impersonation-banner__btn {
    padding: 0.25rem 0.625rem;
    border-radius: 0.375rem;
    border: 1px solid #fcd34d;
    background: #fff;
    color: #92400e;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

/* Admin sekmeleri — SMMM gibi: yalnız .app-content kayar.
   Gizli sekmeler #admin-tab-park'a taşınır (scrollHeight'a girmez).
   ASLA position:absolute/left:-9999 kullanma. */
body[data-page="admin"] .app-content,
.admin-shell .app-content {
    display: block !important;
    padding: 0.75rem 1rem 1.25rem !important;
    align-content: start;
}
@media (min-width: 768px) {
    body[data-page="admin"] .app-content,
    .admin-shell .app-content {
        padding: 0.75rem 1.25rem 1.5rem !important;
    }
}
/* Egress / Yedekleme: üst padding SMMM ile aynı sıkılık */
body.admin-ops-open[data-page="admin"] .app-content,
body.admin-ops-open .admin-shell .app-content {
    padding-top: 0.75rem !important;
}

.admin-tab-park,
#admin-tab-park {
    display: none !important;
    position: absolute !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    visibility: hidden !important;
    pointer-events: none !important;
    contain: strict;
}

body[data-page="admin"] .admin-tab.hidden,
.admin-shell .admin-tab.hidden,
body[data-page="admin"] .admin-tab[hidden],
.admin-tab-park .admin-tab {
    display: none !important;
    position: static !important;
    inset: auto !important;
    height: auto !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}
body[data-page="admin"] .app-content > .admin-tab:not(.hidden):not([hidden]),
.admin-shell .app-content > .admin-tab:not(.hidden):not([hidden]) {
    display: block !important;
    width: 100%;
    margin: 0;
    padding: 0;
    min-height: 0;
    height: auto;
    overflow: visible;
    position: relative;
}

/* Kabuk viewport'a sabitlendiği için sidebar menüsü uzunsa kendi
   içinde kaysın (küçük ekranda alt öğeler kesilmesin). */
.admin-shell .app-sidebar .sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

@media (max-width: 1023px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        height: 100dvh;
        max-height: 100dvh;
        transform: translateX(-105%);
        transition: transform 0.25s ease;
        box-shadow: 0 12px 40px rgba(15, 23, 42, 0.25);
    }

    .app-sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        z-index: 35;
        transition: opacity 0.2s ease, visibility 0.2s ease;
    }

    .sidebar-overlay.is-visible {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    body.sidebar-drawer-open {
        overflow: hidden;
    }
}

@media (min-width: 1024px) {
    .sidebar-overlay {
        display: none !important;
    }
    .app-header { padding: 0.5rem 1.25rem; }
}

/* ─────────────────────────────────────────────────────────────────────────
   TAM EKRAN OVERLAY AÇIKKEN "chrome" KATMANLARINI GERİ İT
   #licenseLockOverlay / #passwordChangeOverlay / #neoOdemeModal açıldığında
   JS body'ye .neo-modal-open ekler. Sol menü, üst bar, alt bar ve sticky tablo
   başlıkları kendi stacking context'leriyle overlay'in üstünde kalıp "çirkin"
   görünüyordu; modal açıkken bunların z-index'ini sıfırlayıp overlay'in (z 11000+)
   altına indiriyoruz. Overlay kapanınca sınıf kalkar, her şey normale döner.
   ───────────────────────────────────────────────────────────────────────── */
body.neo-modal-open .app-header,
body.neo-modal-open .app-subheader,
body.neo-modal-open .app-sidebar,
body.neo-modal-open .app-sidebar__brand,
body.neo-modal-open .app-sidebar__brand--mm,
body.neo-modal-open .sidebar-nav,
body.neo-modal-open .sidebar-nav--panel,
body.neo-modal-open .impersonation-banner,
body.neo-modal-open .app-content table thead th,
body.neo-modal-open .ui-table thead th,
body.neo-modal-open .mp-table-toolbar,
body.neo-modal-open .mp-table-chrome,
body.neo-modal-open .mp-bar,
body.neo-modal-open .mp-bar--inline,
body.neo-modal-open .gib-portal-table-card .mp-bar--inline,
body.neo-modal-open .teb-export-menu,
body.neo-modal-open .sgk-filter-panel,
body.neo-modal-open #tab-faydali-gib .sgk-filter-panel,
body.neo-modal-open #tab-faydali-sgk .sgk-filter-panel {
    z-index: 0 !important;
}
/* Overlay açıkken .app-content içindeki hiçbir pozisyonlu kutu overlay'in (fixed, body
   seviyesi, z 11000+) üstüne çıkamasın — stacking context'leri etkisizleştir. */
body.neo-modal-open .app-content {
    z-index: auto !important;
    isolation: auto !important;
}
/* GENEL GÜVENLİK: Overlay açıkken .app-content içindeki pozisyonlu (relative/absolute/
   sticky) ve pozitif z-index'li TÜM kutuların katmanını sıfırla. Böylece gelecekteki
   herhangi bir sekme/panel de overlay'in üstüne sızamaz (tek tek düzeltmeye gerek yok).
   Not: Yüksek z'li in-page açılır menüler (ör. 10050+) overlay zaten üstünde olduğu için
   sorun değil; bu kural yalnız chrome/panel sızmalarını kapatır. */
body.neo-modal-open .app-content [class*="filter-panel"],
body.neo-modal-open .app-content [class*="toolbar"],
body.neo-modal-open .app-content [class*="mp-bar"],
body.neo-modal-open .app-content [class*="mp-table-chrome"],
body.neo-modal-open .app-content [class*="table-card"],
body.neo-modal-open .app-content thead,
body.neo-modal-open .app-content [class*="sticky"] {
    z-index: 0 !important;
}
/* EN SON GÜVENLİK AĞI: Overlay açıkken .app-content içindeki STICKY öğeleri geçici
   olarak relative yap — sticky "yapışma" (ve oluşturduğu stacking context) kalkar,
   hiçbir şerit overlay'in üstüne sızamaz. Yalnızca sticky'yi hedefler; absolute/relative
   layout'a dokunmaz. Modal kapanınca normale döner. */
body.neo-modal-open .app-content [style*="sticky"],
body.neo-modal-open .mp-bar--inline,
body.neo-modal-open .gib-portal-table-card .mp-bar--inline,
body.neo-modal-open .app-content thead th {
    position: relative !important;
    top: auto !important;
    z-index: 0 !important;
}
