/* =================================================================
 * TECH-5607 (AP-F0) — Sidebar styles
 *
 * Proposal styles.css'teki `.adm-sidebar*` kurallarının Blazor variant'ı.
 * MudDrawer ile YAN YANA değil — MainLayout `<aside class="adm-sidebar">`
 * doğrudan kullanır. Eski `.console-sidebar*` kuralları (NavMenu.razor.css)
 * dokunulmaz; yeni shell `AdmSidebar`'ı çağırır.
 * ================================================================= */

.adm-sidebar {
    /* Sticky + viewport yüksekliğinde sabit: sayfa içeriği ne kadar uzun olursa
       olsun sidebar 100vh'de kalır, scroll yalnızca `.adm-sidebar-body`'de olur,
       foot (profil) HER ZAMAN altta görünür. `align-self:start` grid'in stretch
       davranışını iptal eder (yoksa sidebar main içeriğiyle birlikte uzar ve
       foot viewport dışına kayar). (TECH-5605 sidebar fix) */
    position: sticky;
    top: 0;
    align-self: start;
    grid-column: 1;
    background: var(--adm-surface-sidebar);
    border-right: 1px solid var(--adm-line);
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: var(--adm-sidebar-width);
    z-index: var(--adm-z-sidebar);
    overflow: hidden;
    overscroll-behavior: contain;
}

[data-theme="dark"] .adm-sidebar {
    background: var(--adm-surface-sidebar);
    border-right-color: var(--adm-line);
}

/* --- Brand block --- */
.adm-sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--adm-space-3);
    padding: var(--adm-space-5) var(--adm-space-5);
    border-bottom: 1px solid var(--adm-line);
    min-height: var(--adm-topbar-height);
    box-sizing: border-box;
}

.adm-sidebar-brand-mark {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.adm-sidebar-brand-mark img,
.adm-sidebar-brand-mark svg {
    width: 100%;
    height: 100%;
    display: block;
}

.adm-sidebar-brand-text {
    font-family: var(--adm-font-display);
    font-weight: 600;
    letter-spacing: -0.01em;
    font-size: 16px;
    color: var(--adm-text-strong);
    line-height: 1;
}

/* --- Nav body (scrollable middle) --- */
.adm-sidebar-body {
    flex: 1 1 auto;
    padding: var(--adm-space-3) var(--adm-space-3) var(--adm-space-5);
    overflow-y: auto;
}

.adm-sidebar-group {
    margin-bottom: var(--adm-space-5);
}

.adm-sidebar-group-label {
    font-family: var(--adm-font-mono);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 10px;
    font-weight: 500;
    color: var(--adm-text-faint);
    padding: var(--adm-space-2) var(--adm-space-3);
    margin: 0 0 var(--adm-space-1);
}

.adm-sidebar-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.adm-sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--adm-space-3);
    padding: 9px var(--adm-space-3);
    border-radius: var(--adm-radius-md);
    color: var(--adm-text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    transition: background var(--adm-transition-fast), color var(--adm-transition-fast);
    cursor: pointer;
}

.adm-sidebar-link:hover {
    background: var(--adm-surface-hover);
    color: var(--adm-text-strong);
}

.adm-sidebar-link.active,
.adm-sidebar-link.is-active {
    background: var(--adm-primary-tint);
    color: var(--adm-text-strong);
    font-weight: 600;
}

[data-theme="dark"] .adm-sidebar-link.active,
[data-theme="dark"] .adm-sidebar-link.is-active {
    background: rgba(160, 230, 20, 0.18);
    color: var(--adm-primary-light);
}

.adm-sidebar-link .adm-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    opacity: 0.8;
}

.adm-sidebar-link.active .adm-icon,
.adm-sidebar-link.is-active .adm-icon {
    opacity: 1;
}

.adm-sidebar-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.adm-sidebar-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 6px;
    font-family: var(--adm-font-mono);
    font-size: 10px;
    font-weight: 600;
    color: var(--adm-text-strong);
    background: var(--adm-status-gray-bg);
    border-radius: var(--adm-radius-pill);
    line-height: 1;
}

.adm-sidebar-badge.is-alert {
    color: var(--adm-status-red);
    background: var(--adm-status-red-bg);
}

/* --- Foot (user + system info) --- */
.adm-sidebar-foot {
    border-top: 1px solid var(--adm-line);
    padding: var(--adm-space-4) var(--adm-space-4);
    display: flex;
    flex-direction: column;
    gap: var(--adm-space-3);
    flex: 0 0 auto;
}

.adm-sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--adm-space-3);
}

.adm-sidebar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--adm-primary);
    color: var(--adm-primary-contrast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--adm-font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    flex: 0 0 32px;
}

.adm-sidebar-user-meta {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.adm-sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--adm-text-strong);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.adm-sidebar-user-role {
    font-family: var(--adm-font-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--adm-text-faint);
}

.adm-sidebar-user-action {
    width: 28px;
    height: 28px;
    border: 0;
    background: transparent;
    color: var(--adm-text-muted);
    border-radius: var(--adm-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--adm-transition-fast), color var(--adm-transition-fast);
    text-decoration: none;
}

.adm-sidebar-user-action:hover {
    background: var(--adm-surface-hover);
    color: var(--adm-text-strong);
}

.adm-sidebar-user-action .adm-icon {
    width: 16px;
    height: 16px;
}

.adm-sidebar-systeminfo {
    font-family: var(--adm-font-mono);
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--adm-text-faint);
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* --- Backdrop (mobile only, hidden on desktop) --- */
.adm-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.42);
    z-index: var(--adm-z-backdrop);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--adm-transition-base);
}

/* --- Mobile slide-in (≤920px) ---
 * Specificity bilerek artırıldı: `body.adm-body .adm-sidebar` ile shell-içi
 * rule'ların accidental override'ını engeller. Hem `.is-mobile-open` class
 * (Razor re-render path) hem `body.adm-sidebar-mobile-open` (JSInterop yedek
 * path) görünür durumu tetikler — biri başarısız olsa diğeri kapatır. */
@media (max-width: 920px) {
    .adm-sidebar-backdrop {
        display: block;
    }

    .adm-sidebar-backdrop.is-open,
    body.adm-sidebar-mobile-open .adm-sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    body.adm-body .adm-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: var(--adm-sidebar-width);
        max-width: 86vw;
        transform: translateX(-100%);
        transition: transform var(--adm-transition-slow);
        z-index: var(--adm-z-drawer);
        box-shadow: var(--adm-shadow-lg);
        will-change: transform;
    }

    body.adm-body .adm-sidebar.is-mobile-open,
    body.adm-body.adm-sidebar-mobile-open .adm-sidebar {
        transform: translateX(0);
    }

    /* Mobile'da sidebar açıkken sayfa scroll'unu kilitle — backdrop click'i
     * yine çalışır çünkü pointer-events ondaki rule ile yönetilir. */
    body.adm-sidebar-mobile-open {
        overflow: hidden;
    }
}
