/* ---- App Shell ---- */
body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-shell--auth .header {
    display: none;
}

.app-shell--auth .app-layout {
    padding: 0;
}

/* ---- Text Logo ---- */
.logo-text {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    user-select: none;
    display: inline-flex;
    align-items: baseline;
}

.logo-text--lg {
    font-size: 2rem;
}

.logo-text__ai {
    background: linear-gradient(135deg, var(--brand-cyan), var(--brand-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 900;
}

/* ---- Header ---- */
.header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-xl);
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 50;
    flex-shrink: 0;
}

.header__left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.header__brand {
    display: flex;
    align-items: baseline;
    gap: var(--space-sm);
}

.header__title {
    font-size: var(--text-xl);
    font-weight: 700;
}

.header__brand-sub {
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-tertiary);
    letter-spacing: 0.02em;
}

.header__brand-sub .logo-text__ai {
    font-size: var(--text-xs);
    font-weight: 800;
}

.header__right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

/* ---- Auth Card Brand Sub ---- */
.auth-card__brand-sub {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-tertiary);
    margin-top: var(--space-xs);
}

.auth-card__brand-sub .logo-text__ai {
    font-size: var(--text-sm);
    font-weight: 800;
}

/* ---- App Switcher ---- */
.app-switcher {
    position: relative;
}

.app-switcher__trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 6px 10px;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.app-switcher__trigger:hover {
    background: var(--bg-secondary);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}

.app-switcher__trigger svg {
    opacity: 0.6;
}

.app-switcher__dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 160px;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    padding: var(--space-xs);
    z-index: 100;
}

.app-switcher__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.app-switcher__item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.app-switcher__item--active {
    color: var(--brand-purple);
    font-weight: 600;
}

.app-switcher__item-check {
    font-size: var(--text-xs);
    color: var(--brand-purple);
}

/* ---- App Layout (Sidebar + Content) ---- */
.app-layout {
    display: flex;
    flex: 1;
    min-height: calc(100vh - var(--header-height));
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width var(--transition-base);
    overflow: hidden;
}

.sidebar--collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
    height: 52px;
}

.sidebar__title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar--collapsed .sidebar__title {
    opacity: 0;
}

.sidebar__toggle {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.sidebar__toggle:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.sidebar__nav {
    flex: 1;
    padding: var(--space-sm);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar__nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar__nav-item:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.sidebar__nav-item--active {
    background: rgba(139, 92, 246, 0.1);
    color: var(--brand-purple);
}

.sidebar__nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar__nav-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar--collapsed .sidebar__nav-label {
    opacity: 0;
    width: 0;
}

.sidebar__nav-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: var(--space-sm) var(--space-md);
}

.sidebar__nav-group-title {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--space-md) var(--space-md) var(--space-xs);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar--collapsed .sidebar__nav-group-title {
    opacity: 0;
}

.sidebar__footer {
    padding: var(--space-md);
    border-top: 1px solid var(--border-subtle);
}

/* ---- Content Area ---- */
.content-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-xl);
    min-width: 0;
}

/* ---- Main Content (full-width, no sidebar) ---- */
.main-content {
    padding: var(--space-xl);
    min-height: calc(100vh - var(--header-height));
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        z-index: 40;
        transform: translateX(-100%);
        transition: transform var(--transition-base);
    }

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

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        top: var(--header-height);
        background: rgba(0, 0, 0, 0.5);
        z-index: 39;
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--transition-base);
    }

    .sidebar-overlay--visible {
        opacity: 1;
        pointer-events: auto;
    }

    .content-area {
        padding: var(--space-lg);
    }
}

@media (max-width: 640px) {
    .header {
        padding: 0 var(--space-md);
    }

    .content-area {
        padding: var(--space-md);
    }
}
