/**
 * WorkShift Layout — Enterprise SaaS App Shell (Atlassian Design System)
 * Fixed 56px top bar across full width, 264px left sidebar (collapsible / mobile drawer),
 * Full-width scrollable content area (16px/24px/32px/40px padding, 1760px cap on >1920px).
 */

/* =========================================================================
   App Shell Structure
   ========================================================================= */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    background-color: var(--color-bg-page);
    position: relative;
    overflow-x: hidden;
}

/* =========================================================================
   56px Fixed Top Bar
   ========================================================================= */
.app-topbar {
    height: var(--topbar-height);
    padding: 0 var(--space-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    background: var(--color-bg-topbar);
    border-bottom: 1px solid var(--color-topbar-border);
    z-index: var(--z-topbar);
    flex-shrink: 0;
    width: 100%;
    position: sticky;
    top: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex: 1;
    max-width: 680px;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    text-decoration: none;
    color: var(--color-text);
    margin-right: var(--space-2);
    flex-shrink: 0;
}

.topbar-brand:hover {
    text-decoration: none;
    color: var(--color-text);
}

.topbar-brand-name {
    font-size: var(--text-body-lg);
    font-weight: var(--weight-bold);
    color: var(--color-text);
    letter-spacing: -0.01em;
}

.topbar-menu-toggle {
    display: none;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: transparent;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--color-text-subtle);
    transition: background var(--transition-fast), color var(--transition-fast);
    flex-shrink: 0;
}

.topbar-menu-toggle:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
}

.topbar-search-form {
    flex: 1;
    position: relative;
    max-width: 360px;
}

.topbar-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-subtlest);
    pointer-events: none;
    display: flex;
    align-items: center;
}

.topbar-search-input {
    width: 100%;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--color-bg-surface-sunken);
    border: 1px solid var(--color-border);
    padding: 0 var(--space-3) 0 36px;
    font-size: var(--text-body);
    color: var(--color-text);
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.topbar-search-input:focus {
    outline: none;
    border-color: var(--color-brand);
    background: var(--color-bg-surface);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

.topbar-user-pill {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 3px var(--space-2);
    border-radius: var(--radius-full);
    text-decoration: none;
    color: var(--color-text);
    transition: background var(--transition-fast);
}

.topbar-user-pill:hover {
    background: var(--color-bg-hover);
    text-decoration: none;
}

.user-avatar-circle {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: var(--color-brand);
    color: var(--color-brand-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--weight-bold);
    font-size: var(--text-caption);
    flex-shrink: 0;
}

.user-pill-name {
    font-size: var(--text-body);
    font-weight: var(--weight-medium);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* =========================================================================
   App Body (Horizontal split below topbar)
   ========================================================================= */
.app-body {
    display: flex;
    flex: 1;
    min-height: calc(100vh - var(--topbar-height));
    min-height: calc(100dvh - var(--topbar-height));
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* =========================================================================
   Left Sidebar (264px Desktop, Drawer on Mobile)
   ========================================================================= */
.app-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    height: calc(100vh - var(--topbar-height));
    height: calc(100dvh - var(--topbar-height));
    position: sticky;
    top: var(--topbar-height);
    background: var(--color-bg-sidebar);
    border-right: 1px solid var(--color-sidebar-border);
    z-index: var(--z-sidebar);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, width 0.2s ease;
    overflow: hidden;
}

.sidebar-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: var(--space-3);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header-mobile {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3);
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--space-3);
}

.sidebar-close-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--color-text-subtle);
    cursor: pointer;
}

.sidebar-close-btn:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    flex: 1;
}

.nav-section-label {
    font-size: 11px;
    font-weight: var(--weight-bold);
    color: var(--color-text-subtlest);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--space-3) var(--space-3) var(--space-1);
    margin-top: var(--space-2);
}

.nav-section-label:first-child {
    margin-top: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--color-text-subtle);
    text-decoration: none;
    font-size: var(--text-body);
    font-weight: var(--weight-medium);
    transition: background var(--transition-fast), color var(--transition-fast);
    position: relative;
    user-select: none;
}

.nav-item:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
    text-decoration: none;
}

/* Subtle 3px Blue Left Accent Bar on Active Nav Item */
.nav-item.active {
    background: var(--color-bg-selected);
    color: var(--color-brand);
    font-weight: var(--weight-semibold);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 3px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: var(--color-brand);
}

.nav-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    flex-shrink: 0;
}

.nav-item-badge {
    margin-left: auto;
    font-size: 11px;
    font-weight: var(--weight-bold);
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background: var(--color-danger);
    color: #FFFFFF;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: var(--space-3);
    border-top: 1px solid var(--color-border);
}

.sidebar-pro-card {
    padding: var(--space-3);
    background: var(--color-bg-surface-sunken);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
}

.sidebar-pro-card h4 {
    font-size: var(--text-body);
    font-weight: var(--weight-semibold);
    color: var(--color-text);
    margin: 0 0 var(--space-1) 0;
}

.sidebar-pro-card p {
    font-size: var(--text-caption);
    color: var(--color-text-subtle);
    margin: 0 0 var(--space-3) 0;
    line-height: 1.4;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: var(--z-backdrop);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* =========================================================================
   Main Content Area (Full screen width)
   ========================================================================= */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: calc(100vh - var(--topbar-height));
    height: calc(100dvh - var(--topbar-height));
    overflow: hidden;
}

.app-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-8);
    position: relative;
    -webkit-overflow-scrolling: touch;
}

.app-content.full-bleed {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Widescreen container: uses full available width up to 1760px on ultra-wide */
.content-container,
.content-container-narrow,
.content-wrapper {
    width: 100%;
    max-width: 1760px;
    margin: 0;
}

/* Breadcrumbs bar */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-caption);
    color: var(--color-text-subtle);
    margin-bottom: var(--space-4);
}

.breadcrumb a {
    color: var(--color-text-subtle);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--color-text);
    text-decoration: underline;
}

.breadcrumb-separator {
    color: var(--color-text-subtlest);
    font-size: 11px;
}

/* Slide-Over Panel */
.slideover-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-slideover);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.slideover-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.slideover-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 560px;
    max-width: 100vw;
    background: var(--color-bg-surface);
    border-left: 1px solid var(--color-border);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.25);
    z-index: calc(var(--z-slideover) + 1);
    transform: translateX(100%);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.slideover-panel.open {
    transform: translateX(0);
}

.slideover-header {
    height: var(--topbar-height);
    padding: 0 var(--space-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.slideover-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Mobile Bottom Dock (< 640px) */
.clay-bottom-dock {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--dock-height) + env(safe-area-inset-bottom, 0));
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: var(--color-bg-topbar);
    border-top: 1px solid var(--color-border);
    z-index: var(--z-dock);
    justify-content: space-around;
    align-items: center;
}

.dock-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 10px;
    font-weight: var(--weight-medium);
    color: var(--color-text-subtle);
    text-decoration: none;
    height: var(--dock-height);
    width: 25%;
}

.dock-item.active {
    color: var(--color-brand);
    font-weight: var(--weight-semibold);
}

/* =========================================================================
   Responsive Breakpoints
   ========================================================================= */
@media (min-width: 1536px) {
    .app-content {
        padding: var(--space-10);
    }
}

@media (max-width: 1023px) {
    .app-content {
        padding: var(--space-6);
    }
}

@media (max-width: 767px) {
    .topbar-menu-toggle {
        display: inline-flex;
    }

    .app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh;
        height: 100dvh;
        width: 280px;
        transform: translateX(-100%);
        z-index: 100;
        box-shadow: 8px 0 24px rgba(0, 0, 0, 0.4);
    }

    .sidebar-header-mobile,
    .sidebar-close-btn {
        display: flex;
    }

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

    body.sidebar-open .sidebar-backdrop {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }

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

    .topbar-search-form {
        max-width: 200px;
    }

    .user-pill-name {
        display: none;
    }
}

@media (max-width: 639px) {
    .clay-bottom-dock {
        display: flex;
    }

    .app-content {
        padding: var(--space-4) var(--space-4) calc(var(--dock-height) + var(--space-6) + env(safe-area-inset-bottom, 0));
    }

    .slideover-panel {
        width: 100%;
    }
}
