/* ============================================
   Layout: Sidebar + Topbar + Content
   ============================================ */

.x-layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.x-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--x-sidebar-width);
    background-color: var(--x-gray-900);
    color: var(--x-gray-400);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1040;
    transition: transform var(--x-duration-slow) var(--x-ease);
    display: flex;
    flex-direction: column;
}

.x-sidebar::-webkit-scrollbar {
    width: 3px;
}

.x-sidebar::-webkit-scrollbar-thumb {
    background-color: var(--x-gray-700);
    border-radius: 2px;
}

/* Firefox scrollbar */
.x-sidebar {
    scrollbar-width: thin;
    scrollbar-color: var(--x-gray-700) transparent;
}

.x-sidebar__brand {
    display: flex;
    align-items: center;
    gap: var(--x-space-3);
    padding: var(--x-space-5) var(--x-space-5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.x-sidebar__brand-mark {
    width: 34px;
    height: 34px;
    background-color: var(--x-white);
    color: var(--x-gray-900);
    border-radius: var(--x-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.x-sidebar__brand-glyph {
    font-weight: 600;
    font-size: var(--x-text-xl);
    line-height: 1;
}

.x-sidebar__brand-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.x-sidebar__brand-title {
    font-weight: 600;
    color: var(--x-white);
    font-size: var(--x-text-sm);
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.x-sidebar__brand-text {
    font-size: var(--x-text-xs);
    color: var(--x-gray-600);
    letter-spacing: 0.02em;
}

.x-sidebar__nav {
    flex: 1;
    padding: var(--x-space-4) 0;
}

.x-sidebar__group {
    margin-bottom: var(--x-space-1);
}

.x-sidebar__group-label {
    display: block;
    padding: var(--x-space-3) var(--x-space-5) var(--x-space-1);
    font-size: var(--x-text-xs);
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--x-gray-600);
}

.x-sidebar__link {
    display: flex;
    align-items: center;
    gap: var(--x-space-3);
    padding: var(--x-space-2) var(--x-space-5);
    color: var(--x-gray-500);
    font-size: var(--x-text-sm);
    font-weight: 400;
    text-decoration: none;
    border-left: 2px solid transparent;
    transition-property: color, background-color, border-color;
    transition-duration: var(--x-duration-fast);
    transition-timing-function: var(--x-ease);
    position: relative;
}

.x-sidebar__link:hover {
    color: var(--x-gray-200);
    background-color: rgba(255, 255, 255, 0.03);
}

.x-sidebar__link:focus-visible {
    outline: none;
    color: var(--x-white);
    background-color: rgba(255, 255, 255, 0.06);
}

.x-sidebar__link.active {
    color: var(--x-white);
    font-weight: 500;
    background-color: rgba(75, 111, 160, 0.1);
    border-left-color: var(--x-accent);
}

.x-sidebar__link-icon {
    width: 17px;
    height: 17px;
    opacity: 0.5;
    flex-shrink: 0;
}

.x-sidebar__link:hover .x-sidebar__link-icon {
    opacity: 0.7;
}

.x-sidebar__link.active .x-sidebar__link-icon {
    opacity: 0.9;
}

/* --- Main area --- */
.x-main {
    flex: 1;
    margin-left: var(--x-sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--x-duration-slow) var(--x-ease);
}

/* --- Topbar --- */
.x-topbar {
    position: sticky;
    top: 0;
    height: var(--x-topbar-height);
    background-color: var(--x-white);
    border-bottom: var(--x-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--x-space-6);
    z-index: 1030;
    flex-shrink: 0;
}

.x-topbar__left {
    display: flex;
    align-items: center;
    gap: var(--x-space-3);
}

.x-topbar__title {
    font-size: var(--x-text-base);
    font-weight: 500;
    color: var(--x-gray-800);
}

.x-topbar__meta {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.x-topbar__eyebrow {
    font-size: var(--x-text-xs);
    font-weight: 600;
    color: var(--x-gray-800);
    letter-spacing: -0.01em;
}

.x-topbar__context {
    font-size: var(--x-text-xs);
    color: var(--x-gray-500);
    letter-spacing: 0.01em;
}

.x-topbar__right {
    display: flex;
    align-items: center;
    gap: var(--x-space-4);
}

.x-topbar__user {
    font-size: var(--x-text-sm);
    color: var(--x-gray-600);
}

.x-topbar__logout {
    font-size: var(--x-text-sm);
    color: var(--x-gray-600);
    text-decoration: none;
    padding: var(--x-space-1) var(--x-space-3);
    border-radius: var(--x-radius-sm);
    transition-property: color, background-color;
    transition-duration: var(--x-duration-fast);
    transition-timing-function: var(--x-ease);
}

.x-topbar__logout:hover {
    color: var(--x-danger);
    background-color: var(--x-danger-subtle);
}

/* Sidebar toggle (mobile) */
.x-sidebar-toggle {
    display: none;
    background: none;
    border: none;
    padding: var(--x-space-2);
    cursor: pointer;
    color: var(--x-gray-700);
    line-height: 0;
}

.x-sidebar-toggle svg {
    width: 18px;
    height: 18px;
}

/* --- Content area --- */
.x-content {
    flex: 1;
    padding: var(--x-space-8) var(--x-space-8);
    width: 100%;
    min-width: 0;
}

/* --- Mobile overlay --- */
.x-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(12, 18, 34, 0.4);
    z-index: 1035;
    transition: opacity var(--x-duration-base) var(--x-ease);
}

/* --- Login layout (no sidebar) --- */
.x-layout--login {
    justify-content: center;
    align-items: center;
    background-color: var(--x-gray-100);
}

.x-layout--login .x-main {
    margin-left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.x-layout--login .x-content {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    padding: var(--x-space-5);
    max-width: none;
}

/* ============================================
   Responsive: Mobile (<992px)
   ============================================ */
@media (max-width: 991.98px) {
    .x-sidebar {
        transform: translateX(-100%);
    }

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

    .x-sidebar.is-open ~ .x-sidebar-overlay {
        display: block;
    }

    .x-main {
        margin-left: 0;
    }

    .x-sidebar-toggle {
        display: block;
    }

    .x-content {
        padding: var(--x-space-5) var(--x-space-4);
    }
}
