﻿/* ============================================================
   MainLayout — refined shell
   ============================================================ */

.shell {
    display: grid;
    grid-template-columns: 248px 1fr;
    height: 100dvh;
    overflow: hidden;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.shell-sidebar {
    display: flex;
    flex-direction: column;
    padding: 1rem 0.75rem;
    background: var(--bs-body-bg);
    border-right: 1px solid var(--bs-border-color);
    height: 100dvh;
    overflow-y: auto;
    z-index: 20;
}

/* Brand */
.shell-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.4rem 0.5rem 1rem;
    margin-bottom: 1rem;
}

.shell-brand-mark {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--bs-primary) 22%, transparent), color-mix(in srgb, var(--bs-primary) 6%, transparent));
    border: 1px solid color-mix(in srgb, var(--bs-primary) 28%, transparent);
    flex-shrink: 0;
    overflow: hidden;
}

    .shell-brand-mark img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        padding: 6px;
    }

.shell-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
}

.shell-brand-name {
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.shell-brand-x {
    color: var(--bs-primary);
}

.shell-brand-tag {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--bs-secondary-color);
    font-weight: 500;
}

/* Nav */
.shell-nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
}

.shell-nav-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--bs-secondary-color);
    padding: 0.5rem 0.75rem 0.35rem;
    opacity: 0.7;
}

.shell-nav-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--bs-secondary-color);
    text-decoration: none;
    border-radius: 8px;
    transition: background-color 0.12s ease, color 0.12s ease;
    position: relative;
}

    .shell-nav-item:hover {
        background: color-mix(in srgb, var(--bs-body-color) 5%, transparent);
        color: var(--bs-body-color);
    }

    .shell-nav-item:focus-visible {
        outline: none;
        box-shadow: 0 0 0 var(--bs-focus-ring-width) var(--bs-focus-ring-color);
    }

    .shell-nav-item.is-active {
        background: color-mix(in srgb, var(--bs-primary) 12%, transparent);
        color: var(--bs-primary);
        font-weight: 600;
    }

        .shell-nav-item.is-active svg {
            opacity: 1;
        }

    .shell-nav-item svg {
        flex-shrink: 0;
        opacity: 0.85;
        transition: opacity 0.12s ease;
    }

    .shell-nav-item:hover svg {
        opacity: 1;
    }

/* Sidebar footer */
.shell-sidebar-foot {
    padding-top: 0.75rem;
    margin-top: 0.75rem;
    border-top: 1px solid var(--bs-border-color);
}

.shell-version {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.7rem;
    letter-spacing: 0.03em;
    color: var(--bs-secondary-color);
}

.shell-version-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--bs-success);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--bs-success) 25%, transparent);
}

/* ============================================================
   MAIN COLUMN
   ============================================================ */
.shell-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100dvh;
    overflow: hidden;
    background: color-mix(in srgb, var(--bs-body-bg) 96%, var(--bs-secondary-color) 4%);
}

/* ============================================================
   TOPBAR
   ============================================================ */
.shell-topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.7rem 1.5rem;
    background: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.shell-menu-btn {
    display: none;
}

/* Breadcrumbs */
.shell-crumbs {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    min-width: 0;
}

.shell-crumb-muted {
    color: var(--bs-secondary-color);
}

.shell-crumb-sep {
    color: var(--bs-secondary-color);
    opacity: 0.5;
}

.shell-crumb-current {
    color: var(--bs-body-color);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Actions */
.shell-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.shell-icon-btn {
    position: relative;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--bs-secondary-color);
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

    .shell-icon-btn:hover {
        background: color-mix(in srgb, var(--bs-body-color) 6%, transparent);
        color: var(--bs-body-color);
        border-color: var(--bs-border-color);
    }

    .shell-icon-btn:focus-visible {
        outline: none;
        box-shadow: 0 0 0 var(--bs-focus-ring-width) var(--bs-focus-ring-color);
    }

    .shell-icon-btn .icon-sun {
        display: none;
    }

html[data-bs-theme="dark"] .shell-icon-btn .icon-sun {
    display: block;
}

html[data-bs-theme="dark"] .shell-icon-btn .icon-moon {
    display: none;
}

/* Notification dot */
.shell-notif-dot {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--bs-danger);
    border: 1.5px solid var(--bs-body-bg);
}

/* ============================================================
   USER DROPDOWN
   ============================================================ */
.shell-user-dropdown {
    position: relative;
    z-index: 50;
}

.shell-user {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.25rem 0.4rem 0.25rem 0.75rem;
    margin-left: 0.25rem;
    cursor: pointer;
    background: transparent;
    border: 1px solid transparent;
    border-left: 1px solid var(--bs-border-color);
    transition: background-color 0.12s ease, border-color 0.12s ease;
    text-align: left;
}

    .shell-user:hover,
    .shell-user.is-open {
        background: color-mix(in srgb, var(--bs-body-color) 6%, transparent);
        border-color: var(--bs-border-color);
        border-radius: 8px;
    }

.shell-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--bs-primary) 16%, transparent);
    color: var(--bs-primary);
    display: grid;
    place-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--bs-primary) 28%, transparent);
    flex-shrink: 0;
}

    .shell-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

.shell-user-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}

.shell-user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--bs-body-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.shell-user-role {
    font-size: 0.7rem;
    color: var(--bs-secondary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.shell-user-chev {
    color: var(--bs-secondary-color);
    flex-shrink: 0;
    margin-left: 0.1rem;
    transition: transform 0.2s ease;
}

.shell-user.is-open .shell-user-chev {
    transform: rotate(180deg);
}

/* Dropdown Menu */
.shell-user-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    width: 220px;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 10px;
    box-shadow: 0 10px 40px -10px rgb(0 0 0 / 0.3);
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    animation: menuPopIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes menuPopIn {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.shell-user-menu-header {
    padding: 0.6rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.shell-user-menu-divider {
    height: 1px;
    background: var(--bs-border-color);
    margin: 0.4rem 0;
}

.shell-user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--bs-body-color);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
}

    .shell-user-menu-item:hover {
        background: color-mix(in srgb, var(--bs-danger) 10%, transparent);
        color: var(--bs-danger);
    }

    .shell-user-menu-item svg {
        color: var(--bs-secondary-color);
        transition: color 0.12s ease;
    }

    .shell-user-menu-item:hover svg {
        color: var(--bs-danger);
    }

/* Invisible backdrop to close menu on outside click */
.shell-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: transparent;
}

/* ============================================================
   CONTENT
   ============================================================ */
.shell-content {
    flex: 1;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.shell-content-inner {
    flex: 1;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ============================================================
   MOBILE OVERLAY
   ============================================================ */
.shell-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 0.4);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 15;
}

@media (max-width: 900px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .shell-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 248px;
        transform: translateX(-100%);
        transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
        border-right: 1px solid var(--bs-border-color);
        box-shadow: 8px 0 32px -8px rgb(0 0 0 / 0.2);
    }

        .shell-sidebar.is-open {
            transform: translateX(0);
        }

    body.sidebar-open .shell-overlay {
        display: block;
    }

    .shell-menu-btn {
        display: grid;
    }

    .shell-user-text {
        display: none;
    }

}
