/* =========================================================
   Application shell
   ========================================================= */

.application-shell {
    display: grid;
    grid-template-columns:
        var(--sidebar-width)
        minmax(0, 1fr);

    min-height:
        calc(
            100vh
            - var(--topbar-height)
        );
}


/* =========================================================
   Sidebar
   ========================================================= */

.sidebar {
    position: sticky;
    top: var(--topbar-height);

    align-self: start;

    display: flex;
    flex-direction: column;

    height:
        calc(
            100vh
            - var(--topbar-height)
        );

    padding:
        var(--space-5)
        var(--space-3);

    overflow-y: auto;

    background:
        linear-gradient(
            180deg,
            rgba(124, 92, 252, 0.025),
            transparent 22%
        ),
        rgba(10, 14, 22, 0.96);

    border-right:
        1px solid
        var(--border-default);
}


.sidebar-section {
    margin-bottom:
        var(--space-6);
}


.sidebar-label {
    padding:
        0
        var(--space-3);

    margin-bottom:
        var(--space-2);

    color:
        var(--text-muted);

    font-family:
        var(--font-mono);

    font-size:
        10px;

    font-weight:
        700;

    letter-spacing:
        0.11em;

    text-transform:
        uppercase;
}


.sidebar-nav {
    display: flex;
    flex-direction: column;

    gap: 2px;
}


.sidebar-nav-item {
    position: relative;

    display: flex;
    align-items: center;
    gap: var(--space-3);

    width: 100%;
    min-height: 38px;

    padding:
        8px
        10px;

    color:
        var(--text-secondary);

    background:
        transparent;

    border:
        1px solid
        transparent;

    border-radius:
        var(--radius-sm);

    font-size:
        var(--text-sm);

    font-weight:
        520;

    text-align: left;

    cursor: pointer;

    transition:
        color var(--transition-fast),
        background var(--transition-fast),
        border-color var(--transition-fast);
}


.sidebar-nav-item:hover {
    color:
        var(--text-primary);

    background:
        rgba(255, 255, 255, 0.025);

    border-color:
        rgba(255, 255, 255, 0.04);

    transform: none;
}


.sidebar-nav-item.active {
    color:
        var(--text-primary);

    background:
        linear-gradient(
            90deg,
            rgba(124, 92, 252, 0.12),
            rgba(124, 92, 252, 0.035)
        );

    border-color:
        rgba(124, 92, 252, 0.14);
}


.sidebar-nav-item.active::before {
    position: absolute;

    top: 8px;
    bottom: 8px;
    left: -4px;

    width: 2px;

    content: "";

    background:
        linear-gradient(
            180deg,
            var(--accent-purple-light),
            var(--accent-cyan)
        );

    border-radius:
        999px;

    box-shadow:
        0 0 12px
        rgba(124, 92, 252, 0.55);
}


.sidebar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 18px;
    height: 18px;

    flex: 0 0 18px;

    color:
        var(--text-muted);

    font-family:
        var(--font-mono);

    font-size:
        14px;
}


.sidebar-nav-item.active
.sidebar-icon {
    color:
        var(--accent-purple-light);
}


/* =========================================================
   Recent projects
   ========================================================= */

.sidebar-projects {
    display: flex;
    flex-direction: column;

    gap: 2px;
}


.sidebar-project {
    display: flex;
    align-items: center;
    gap: var(--space-2);

    width: 100%;

    padding:
        7px
        10px;

    overflow: hidden;

    color:
        var(--text-secondary);

    background:
        transparent;

    border:
        1px solid
        transparent;

    border-radius:
        var(--radius-sm);

    font-size:
        var(--text-sm);

    font-weight:
        500;

    text-align: left;

    cursor: pointer;
}


.sidebar-project:hover {
    color:
        var(--text-primary);

    background:
        rgba(255, 255, 255, 0.025);

    transform: none;
}


.sidebar-project.active {
    color:
        var(--text-primary);

    background:
        rgba(59, 200, 255, 0.055);

    border-color:
        rgba(59, 200, 255, 0.10);
}


.sidebar-project-dot {
    width: 6px;
    height: 6px;

    flex: 0 0 6px;

    background:
        var(--text-muted);

    border-radius:
        50%;
}


.sidebar-project.active
.sidebar-project-dot {
    background:
        var(--accent-teal);

    box-shadow:
        0 0 8px
        rgba(39, 224, 193, 0.5);
}


.sidebar-project-name {
    overflow: hidden;

    text-overflow: ellipsis;
    white-space: nowrap;
}


.sidebar-footer {
    margin-top: auto;

    padding-top:
        var(--space-4);

    border-top:
        1px solid
        var(--border-default);
}


.sidebar-system-status {
    display: flex;
    align-items: center;
    gap: var(--space-2);

    padding:
        var(--space-2)
        var(--space-3);

    color:
        var(--text-muted);

    font-family:
        var(--font-mono);

    font-size:
        var(--text-xs);
}


.system-status-dot {
    width: 7px;
    height: 7px;

    background:
        var(--success);

    border-radius:
        50%;

    box-shadow:
        0 0 10px
        rgba(53, 208, 127, 0.35);
}


/* =========================================================
   Workspace
   ========================================================= */

.workspace {
    min-width: 0;
}


.workspace-commandbar {
    position: sticky;
    z-index: 20;
    top: var(--topbar-height);

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-5);

    min-height: 58px;

    padding:
        10px
        var(--space-7);

    background:
        rgba(8, 11, 18, 0.78);

    border-bottom:
        1px solid
        var(--border-default);

    backdrop-filter:
        blur(16px);

    -webkit-backdrop-filter:
        blur(16px);
}


.workspace-breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);

    min-width: 0;

    color:
        var(--text-muted);

    font-size:
        var(--text-sm);
}


.workspace-breadcrumb strong {
    overflow: hidden;

    color:
        var(--text-primary);

    font-weight:
        600;

    text-overflow: ellipsis;
    white-space: nowrap;
}


.breadcrumb-separator {
    color:
        #414b5d;
}


.command-search {
    display: flex;
    align-items: center;
    gap: var(--space-3);

    width: min(420px, 42vw);

    min-height: 36px;

    padding:
        7px
        10px;

    color:
        var(--text-muted);

    background:
        rgba(16, 21, 32, 0.82);

    border:
        1px solid
        var(--border-default);

    border-radius:
        var(--radius-sm);

    font-size:
        var(--text-sm);

    cursor: default;
}


.command-search:hover {
    transform: none;

    border-color:
        var(--border-default);
}


.command-search-label {
    overflow: hidden;

    flex: 1;

    text-align: left;

    text-overflow: ellipsis;
    white-space: nowrap;
}


.command-key {
    padding:
        2px
        6px;

    color:
        var(--text-muted);

    background:
        rgba(255, 255, 255, 0.035);

    border:
        1px solid
        var(--border-default);

    border-radius:
        var(--radius-xs);

    font-family:
        var(--font-mono);

    font-size:
        10px;
}


/* =========================================================
   Workspace content
   ========================================================= */

.workspace-content {
    width: min(
        1180px,
        calc(100% - 48px)
    );

    margin:
        var(--space-6)
        auto
        80px;
}


/*
 * The legacy .container remains useful for login,
 * but once authenticated the workspace owns layout.
 */
.application-shell
.container {
    width: auto;
    margin: 0;
}


/* =========================================================
   Existing project selector becomes compact project header
   ========================================================= */

#project-overview-card {
    background:
        radial-gradient(
            circle at 0% 0%,
            rgba(124, 92, 252, 0.085),
            transparent 38%
        ),
        linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.02),
            transparent
        ),
        var(--bg-surface-1);
}


#project-overview-card h2 {
    font-size:
        var(--text-lg);
}


.project-context-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;

    margin-bottom:
        var(--space-2);

    color:
        var(--accent-purple-light);

    font-family:
        var(--font-mono);

    font-size:
        10px;

    font-weight:
        700;

    letter-spacing:
        0.12em;

    text-transform:
        uppercase;
}


.project-context-label::before {
    width: 5px;
    height: 5px;

    content: "";

    background:
        var(--accent-purple);

    border-radius:
        50%;

    box-shadow:
        0 0 9px
        rgba(124, 92, 252, 0.55);
}


/* =========================================================
   Existing project tabs
   ========================================================= */

.project-tabs {
    display: flex;
    align-items: center;
    gap: 2px;

    margin:
        0
        0
        var(--space-4);

    padding: 4px;

    overflow-x: auto;

    background:
        rgba(12, 16, 24, 0.92);

    border:
        1px solid
        var(--border-default);

    border-radius:
        var(--radius-md);
}


.project-tab {
    position: relative;

    min-height: 34px;

    padding:
        7px
        11px;

    color:
        var(--text-secondary);

    background:
        transparent;

    border:
        1px solid
        transparent;

    border-radius:
        var(--radius-sm);

    font-size:
        var(--text-sm);

    font-weight:
        560;

    white-space: nowrap;

    transition:
        color var(--transition-fast),
        background var(--transition-fast),
        border-color var(--transition-fast),
        box-shadow var(--transition-fast);
}


.project-tab:hover {
    color:
        var(--text-primary);

    background:
        rgba(255, 255, 255, 0.035);

    border-color:
        rgba(255, 255, 255, 0.045);

    transform: none;
}


.project-tab.active {
    color:
        #ffffff;

    background:
        linear-gradient(
            180deg,
            rgba(124, 92, 252, 0.14),
            rgba(124, 92, 252, 0.06)
        ),
        var(--bg-surface-2);

    border-color:
        rgba(124, 92, 252, 0.28);

    box-shadow:
        inset 0 0 0 1px
        rgba(255, 255, 255, 0.015),
        0 0 18px
        rgba(124, 92, 252, 0.055);
}


.project-tab.active:hover {
    color:
        #ffffff;

    background:
        linear-gradient(
            180deg,
            rgba(124, 92, 252, 0.18),
            rgba(124, 92, 252, 0.08)
        ),
        var(--bg-surface-2);

    border-color:
        rgba(124, 92, 252, 0.34);
}


.project-tab.active::after {
    position: absolute;

    right: 9px;
    bottom: -5px;
    left: 9px;

    height: 2px;

    content: "";

    background:
        linear-gradient(
            90deg,
            var(--accent-purple),
            var(--accent-cyan)
        );

    border-radius:
        999px;
}


/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1100px) {
    .application-shell {
        grid-template-columns:
            var(--sidebar-collapsed-width)
            minmax(0, 1fr);
    }

    .sidebar {
        padding:
            var(--space-4)
            8px;
    }

    .sidebar-label,
    .sidebar-nav-text,
    .sidebar-project-name,
    .sidebar-system-status span {
        display: none;
    }

    .sidebar-nav-item,
    .sidebar-project {
        justify-content: center;

        padding:
            8px;
    }

    .sidebar-icon {
        margin: 0;
    }

    .sidebar-project-dot {
        width: 8px;
        height: 8px;

        flex-basis: 8px;
    }

    .workspace-commandbar {
        padding:
            10px
            var(--space-5);
    }

    .workspace-content {
        width:
            min(
                100% - 32px,
                1180px
            );
    }
}


@media (max-width: 760px) {
    .application-shell {
        display: block;
    }

    .sidebar {
        position: static;

        width: 100%;
        height: auto;

        flex-direction: row;

        padding:
            8px
            12px;

        overflow-x: auto;
        overflow-y: hidden;

        border-right: 0;

        border-bottom:
            1px solid
            var(--border-default);
    }

    .sidebar-section {
        display: flex;

        margin: 0;
    }

    .sidebar-section.recent-projects,
    .sidebar-footer,
    .sidebar-label {
        display: none;
    }

    .sidebar-nav {
        flex-direction: row;
    }

    .sidebar-nav-item {
        width: auto;

        white-space: nowrap;
    }

    .sidebar-nav-text {
        display: inline;
    }

    .workspace-commandbar {
        position: static;

        align-items: flex-start;
        flex-direction: column;

        padding:
            10px
            14px;
    }

    .command-search {
        width: 100%;
    }

    .workspace-content {
        width:
            calc(100% - 24px);

        margin-top:
            var(--space-4);
    }
}
