/* ========================================================================== 
   SHELL.CSS — SUP_MAUI uygulama kabuğu
   Layout, sidebar ve topbar için tek otorite. Sayfa içi bileşen stilleri
   components.css/app.css katmanında kalır.
   ========================================================================== */

:root {
    --shell-sidebar-width: 252px;
    --shell-sidebar-collapsed-width: 72px;
    --shell-topbar-height: 64px;
    --shell-content-max-width: 1680px;
    --shell-mobile-sidebar-width: min(296px, 88vw);
    --shell-sidebar-bg: #0b1730;
    --shell-sidebar-bg-elevated: #102041;
    --shell-sidebar-border: rgba(255, 255, 255, 0.08);
    --shell-sidebar-text: rgba(255, 255, 255, 0.72);
    --shell-sidebar-text-strong: #ffffff;
    --shell-sidebar-muted: rgba(255, 255, 255, 0.46);
    --shell-sidebar-hover: rgba(255, 255, 255, 0.07);
    --shell-sidebar-active: rgba(96, 165, 250, 0.15);
    --shell-sidebar-active-border: #60a5fa;
}

[data-theme="dark"] {
    --shell-sidebar-bg: #081225;
    --shell-sidebar-bg-elevated: #0d1a34;
    --shell-sidebar-border: rgba(255, 255, 255, 0.075);
}

.app-skip-link {
    position: fixed;
    top: var(--space-3);
    left: var(--space-3);
    z-index: 99999;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    background: var(--color-primary);
    color: var(--color-text-on-primary);
    font-weight: var(--font-weight-body-strong);
    transform: translateY(-160%);
    transition: transform var(--duration-transition) var(--ease-out);
}

    .app-skip-link:focus {
        transform: translateY(0);
        text-decoration: none;
    }

.app-shell {
    min-height: 100dvh;
    display: grid;
    grid-template-columns: var(--shell-sidebar-width) minmax(0, 1fr);
    background: var(--color-surface);
    color: var(--color-text-primary);
    transition: grid-template-columns var(--duration-expand) var(--ease-out);
}

    .app-shell.sidebar-collapsed {
        grid-template-columns: var(--shell-sidebar-collapsed-width) minmax(0, 1fr);
    }

.app-shell__main {
    min-width: 0;
    min-height: 100dvh;
    display: grid;
    grid-template-rows: var(--shell-topbar-height) minmax(0, 1fr);
}

.app-shell__content {
    min-width: 0;
    min-height: 0;
    overflow: auto;
    padding: clamp(var(--space-4), 1.45vw, var(--space-6));
    background: linear-gradient(180deg, color-mix(in srgb, var(--color-primary) 3%, transparent), transparent 180px), var(--color-surface);
    scroll-behavior: smooth;
}

    .app-shell__content > * {
        width: min(100%, var(--shell-content-max-width));
        margin-inline: auto;
    }

.app-shell__backdrop {
    display: none;
}

/* Sidebar ---------------------------------------------------------------- */
.app-sidebar {
    position: sticky;
    top: 0;
    height: 100dvh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    background: radial-gradient(circle at 25% 0%, rgba(59, 130, 246, 0.14), transparent 34%), var(--shell-sidebar-bg);
    border-right: 1px solid var(--shell-sidebar-border);
    color: var(--shell-sidebar-text);
    z-index: 40;
}

    .app-sidebar::after {
        content: "";
        position: absolute;
        inset: 0 0 auto;
        height: 1px;
        background: linear-gradient(90deg, transparent, rgba(255,255,255,.15), transparent);
        pointer-events: none;
    }

.app-sidebar__brand {
    min-height: var(--shell-topbar-height);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-bottom: 1px solid var(--shell-sidebar-border);
}

.app-sidebar__brand-mark {
    width: 54px;
    height: 34px;
    flex: 0 0 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 5px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .16);
}

.app-sidebar__brand-logo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.app-sidebar__brand-text {
    min-width: 0;
    display: grid;
    gap: 1px;
    line-height: 1.15;
}

    .app-sidebar__brand-text strong {
        color: var(--shell-sidebar-text-strong);
        font-size: 15px;
        letter-spacing: .03em;
    }

    .app-sidebar__brand-text span {
        color: var(--shell-sidebar-muted);
        font-size: var(--font-size-caption1);
    }

.app-sidebar__body {
    min-height: 0;
    padding: var(--space-4) var(--space-3);
    overflow-y: auto;
}

.app-sidebar__section-label {
    display: block;
    padding: 0 var(--space-3) var(--space-2);
    color: var(--shell-sidebar-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.app-sidebar__nav {
    display: grid;
    gap: var(--space-1);
}

.app-nav-link {
    position: relative;
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: var(--shell-sidebar-text);
    text-decoration: none;
    cursor: pointer;
    transition: color var(--duration-hover) var(--ease-out), background-color var(--duration-hover) var(--ease-out), border-color var(--duration-hover) var(--ease-out);
}

    .app-nav-link:hover {
        background: var(--shell-sidebar-hover);
        color: var(--shell-sidebar-text-strong);
        text-decoration: none;
    }

    .app-nav-link.active {
        border-color: rgba(96,165,250,.16);
        background: var(--shell-sidebar-active);
        color: #dbeafe;
        font-weight: 600;
    }

.app-nav-link__indicator {
    position: absolute;
    top: 9px;
    bottom: 9px;
    left: -4px;
    width: 3px;
    border-radius: var(--radius-pill);
    background: transparent;
}

.app-nav-link.active .app-nav-link__indicator {
    background: var(--shell-sidebar-active-border);
    box-shadow: 0 0 14px rgba(96,165,250,.5);
}

.app-nav-link__icon {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    display: grid;
    place-items: center;
}

    .app-nav-link__icon svg {
        width: 20px;
        height: 20px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.7;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

.app-nav-link:first-child .app-nav-link__icon svg {
    fill: currentColor;
    stroke: none;
}

.app-nav-link__label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-nav-link__meta {
    margin-left: auto;
    padding: 2px 6px;
    border: 1px solid var(--shell-sidebar-border);
    border-radius: var(--radius-pill);
    color: var(--shell-sidebar-muted);
    font-size: 9px;
    font-weight: 600;
}

.app-nav-link.is-disabled {
    color: var(--shell-sidebar-muted);
    cursor: default;
}

    .app-nav-link.is-disabled:hover {
        background: transparent;
        color: var(--shell-sidebar-muted);
    }

.app-sidebar__footer {
    display: grid;
    gap: var(--space-2);
    padding: var(--space-3);
    border-top: 1px solid var(--shell-sidebar-border);
    background: color-mix(in srgb, var(--shell-sidebar-bg-elevated) 78%, transparent);
}

.app-sidebar__version {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0 var(--space-3) var(--space-1);
    color: var(--shell-sidebar-muted);
    font-size: 10px;
}

    .app-sidebar__version small {
        margin-left: auto;
        color: inherit;
    }

.app-sidebar__status-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-pill);
    background: #34d399;
    box-shadow: 0 0 0 3px rgba(52,211,153,.12);
}

.app-sidebar.is-collapsed .app-sidebar__brand,
.app-sidebar.is-collapsed .app-nav-link {
    justify-content: center;
}

.app-sidebar.is-collapsed .app-sidebar__brand {
    padding-inline: 0;
}

.app-sidebar.is-collapsed .app-sidebar__brand-mark {
    width: 48px;
    height: 30px;
    flex-basis: 48px;
    padding: 3px 4px;
    border-radius: 7px;
}

.app-sidebar.is-collapsed .app-sidebar__body,
.app-sidebar.is-collapsed .app-sidebar__footer {
    padding-inline: var(--space-2);
}

.app-sidebar.is-collapsed .app-nav-link {
    padding-inline: 0;
}

.app-sidebar.is-collapsed .app-nav-link__indicator {
    left: -1px;
}

/* Topbar ----------------------------------------------------------------- */
.app-topbar {
    position: sticky;
    top: 0;
    min-width: 0;
    height: var(--shell-topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: 0 clamp(var(--space-3), 1.3vw, var(--space-5));
    border-bottom: 1px solid var(--color-divider);
    background: color-mix(in srgb, var(--color-card) 92%, transparent);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    z-index: 30;
}

.app-topbar__left,
.app-topbar__right {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.app-topbar__right {
    flex: 0 0 auto;
}

.app-topbar__divider {
    width: 1px;
    height: 24px;
    margin-inline: var(--space-1);
    background: var(--color-divider);
}

.app-topbar__title {
    min-width: 0;
    display: grid;
    gap: 1px;
    line-height: 1.15;
}

    .app-topbar__title strong,
    .app-topbar__title span,
    .app-user-summary__text strong,
    .app-user-summary__text span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-topbar__title strong {
        font-size: 14px;
        font-weight: 650;
        letter-spacing: -.01em;
    }

    .app-topbar__title span {
        color: var(--color-text-tertiary);
        font-size: 11px;
    }

.app-icon-button {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: color var(--duration-hover) var(--ease-out), background-color var(--duration-hover) var(--ease-out), border-color var(--duration-hover) var(--ease-out);
}

    .app-icon-button svg {
        width: 19px;
        height: 19px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .app-icon-button:hover:not(:disabled) {
        border-color: var(--color-border);
        background: var(--color-hover-bg);
        color: var(--color-text-primary);
    }

    .app-icon-button:active:not(:disabled) {
        background: var(--color-pressed-bg);
    }

    .app-icon-button:disabled {
        color: var(--color-disabled-text);
        cursor: not-allowed;
    }

.app-theme-toggle {
    background: color-mix(in srgb, var(--color-primary) 7%, transparent);
    color: var(--color-primary);
}

.app-topbar__mobile-toggle {
    display: none;
}

.app-user-summary {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 3px 6px 3px 3px;
    border-radius: 10px;
}

.app-user-summary__avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: grid;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--color-primary) 20%, transparent);
    border-radius: 9px;
    background: color-mix(in srgb, var(--color-primary) 10%, var(--color-card));
    color: var(--color-primary);
    font-size: 12px;
    font-weight: 700;
}

.app-user-summary__text {
    min-width: 0;
    max-width: 220px;
    display: grid;
    gap: 1px;
    line-height: 1.15;
}

    .app-user-summary__text strong {
        font-size: 12px;
        font-weight: 650;
    }

    .app-user-summary__text span {
        color: var(--color-text-tertiary);
        font-size: 10px;
        letter-spacing: .02em;
    }

.app-topbar__logout:hover:not(:disabled) {
    border-color: color-mix(in srgb, var(--color-danger) 22%, var(--color-border));
    background: color-mix(in srgb, var(--color-danger) 8%, transparent);
    color: var(--color-danger);
}

.app-button-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: var(--radius-pill);
    animation: app-shell-spin .7s linear infinite;
}

@keyframes app-shell-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive -------------------------------------------------------------- */
@media (max-width: 904px) {
    .app-shell,
    .app-shell.sidebar-collapsed {
        grid-template-columns: minmax(0, 1fr);
    }

    .app-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: var(--shell-mobile-sidebar-width);
        transform: translateX(-104%);
        transition: transform var(--duration-expand) var(--ease-out);
        box-shadow: 18px 0 48px rgba(0,0,0,.28);
    }

        .app-sidebar.is-mobile-open {
            transform: translateX(0);
        }

    .app-shell__backdrop {
        position: fixed;
        inset: 0;
        display: block;
        border: 0;
        background: rgba(3, 10, 24, .56);
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
        z-index: 35;
        animation: app-backdrop-in var(--duration-transition) var(--ease-out);
    }

    .app-topbar__desktop-toggle {
        display: none;
    }

    .app-topbar__mobile-toggle {
        display: inline-grid;
    }

    .app-topbar__divider--user,
    .app-user-summary__text {
        display: none;
    }
}

@media (max-width: 599px) {
    :root {
        --shell-topbar-height: 58px;
    }

    .app-shell__content {
        padding: var(--space-3);
    }

    .app-topbar {
        padding-inline: var(--space-3);
    }

    .app-topbar__title span,
    .app-topbar__divider:not(.app-topbar__divider--user) {
        display: none;
    }

    .app-topbar__title strong {
        font-size: 13px;
    }

    .app-user-summary {
        padding: 0;
    }

    .app-user-summary__avatar {
        width: 32px;
        height: 32px;
        flex-basis: 32px;
    }
}

@keyframes app-backdrop-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-shell,
    .app-sidebar,
    .app-shell__backdrop,
    .app-button-spinner {
        animation: none;
        transition: none;
    }
}
