/* ==========================================================================
   Shell: sidebar, page header, view tabs, filter chips
   spec: docs/features/62-ui-ux-design-system.md §3
   ========================================================================== */

/* --------------------------------------------------------------------------
   Sidebar (216px)
   -------------------------------------------------------------------------- */

.sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--bg-subtle);
    border-right: 1px solid var(--border);
}

.sidebar__scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 var(--space-3);
}

/* Workspace switcher */
.workspace {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: calc(100% - var(--space-6));
    margin: var(--space-3);
    padding: var(--space-2);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: left;
    transition: background-color var(--motion-fast);
}
.workspace:hover { background: var(--bg-muted); }
.workspace__name {
    flex: 1;
    min-width: 0;
    font-size: var(--t-body-size);
    font-weight: var(--t-body-medium-weight);
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.workspace__chevron { color: var(--text-secondary); flex-shrink: 0; }

/* Nav */
.nav { display: flex; flex-direction: column; gap: 2px; }

.nav__item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    height: 36px;
    padding: 0 var(--space-2);
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    font-size: var(--t-body-size);
    font-weight: var(--t-body-medium-weight);
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--motion-fast), color var(--motion-fast);
    width: 100%;
    text-align: left;
}
.nav__item:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
    text-decoration: none;
}
.nav__item.active,
.nav__item[aria-current="page"] {
    background: var(--bg-muted);
    color: var(--text-primary);
}
.nav__icon { display: inline-flex; flex-shrink: 0; color: inherit; }
.nav__label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nav__count {
    font-size: var(--t-meta-size);
    font-weight: 400;
    color: var(--text-tertiary);
    flex-shrink: 0;
}
.nav__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-inverse);
    flex-shrink: 0;
}
.nav__chevron {
    color: var(--text-tertiary);
    flex-shrink: 0;
    transition: transform var(--motion-base);
}
.nav__chevron--open { transform: rotate(90deg); }

/* Nested children (Perfex needs collapsible groups — §3.1) */
.nav__children {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 2px 0 2px 0;
    padding-left: var(--space-6);
}
.nav__children .nav__item { height: 32px; font-weight: 400; }

/* Section header */
.nav__section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-2) var(--space-2);
    font-size: var(--t-meta-size);
    font-weight: 500;
    color: var(--text-tertiary);
}
.nav__section-action {
    opacity: 0;
    transition: opacity var(--motion-fast);
}
.nav__section:hover .nav__section-action { opacity: 1; }

/* Footer */
.sidebar__footer {
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.sample-card {
    padding: var(--space-3);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.sample-card__title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--t-label-size);
    font-weight: 500;
}
.sample-card__meta {
    margin-top: var(--space-1);
    font-size: var(--t-meta-size);
    color: var(--text-secondary);
}
.sample-card .progress { margin-top: var(--space-2); }

.sidebar__actions { display: flex; align-items: center; gap: var(--space-1); }
.sidebar__actions .btn { flex-shrink: 0; }
.sidebar__actions .u-spacer { flex: 1; }

/* --------------------------------------------------------------------------
   Page header (§3.2)
   -------------------------------------------------------------------------- */

.page-header {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.page-header__title {
    font-size: var(--t-page-title-size);
    font-weight: var(--t-page-title-weight);
    line-height: var(--t-page-title-lh);
    white-space: nowrap;
}

.page-header__breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--t-page-title-size);
    font-weight: var(--t-page-title-weight);
    line-height: var(--t-page-title-lh);
}
.page-header__crumb { color: var(--text-secondary); text-decoration: none; }
.page-header__crumb:hover { color: var(--text-primary); text-decoration: none; }
.page-header__sep { color: var(--text-tertiary); font-weight: 400; }

.page-header__search {
    flex: 1;
    max-width: 420px;
    margin: 0 auto;
}

.page-header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-left: auto;
}

/* --------------------------------------------------------------------------
   View tabs (§3.3) — maps to Perfex saved filters
   -------------------------------------------------------------------------- */

.view-tabs {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    padding: 0 var(--space-6);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.view-tabs__tab {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    height: 40px;
    padding: 0;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: var(--t-body-size);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--motion-fast), border-color var(--motion-fast);
}
.view-tabs__tab:hover { color: var(--text-primary); }
.view-tabs__tab.active {
    color: var(--text-primary);
    font-weight: var(--t-body-medium-weight);
    border-bottom-color: var(--action-primary);
}

.view-tabs__add {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    background: none;
    border: none;
    font-size: var(--t-body-size);
    color: var(--accent-link);
    cursor: pointer;
    white-space: nowrap;
}
.view-tabs__add:hover { color: var(--accent-link-hover); }

/* --------------------------------------------------------------------------
   Filter chip bar (§3.3)
   -------------------------------------------------------------------------- */

.filter-bar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    height: var(--control-height-sm);
    padding: 0 var(--space-3);
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    font-size: var(--t-label-size);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: background-color var(--motion-fast), border-color var(--motion-fast),
                color var(--motion-fast);
}
.chip:hover { background: var(--bg-subtle); color: var(--text-primary); }
.chip--active {
    border-color: var(--action-primary);
    color: var(--text-primary);
    font-weight: 500;
}
.chip__chevron { color: var(--text-tertiary); flex-shrink: 0; }
.chip--icon-only { width: var(--control-height-sm); padding: 0; justify-content: center; }

/* Toolbar row above the table */
.toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0 var(--space-6) var(--space-3);
    flex-shrink: 0;
}
.toolbar__search { max-width: 280px; flex: 1; }

/* --------------------------------------------------------------------------
   Bulk selection action bar (§6 rule 5)
   -------------------------------------------------------------------------- */

.bulk-bar {
    position: absolute;
    left: 50%;
    bottom: var(--space-6);
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    background: var(--action-primary);
    color: var(--text-inverse);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 40;
}
.bulk-bar__count { font-size: var(--t-label-size); font-weight: 500; }
.bulk-bar .btn--ghost { color: var(--text-inverse); }
.bulk-bar .btn--ghost:hover { background: rgba(255, 255, 255, .12); color: var(--text-inverse); }

/* --------------------------------------------------------------------------
   Responsive (§7.5)
   -------------------------------------------------------------------------- */

@media (max-width: 1279px) {
    .sidebar { width: var(--sidebar-rail-width); }
    .sidebar .nav__label,
    .sidebar .nav__count,
    .sidebar .nav__section span,
    .sidebar .workspace__name,
    .sidebar .workspace__chevron,
    .sidebar .sample-card { display: none; }
    .sidebar .nav__item { justify-content: center; padding: 0; }
}

@media (max-width: 1023px) {
    .sidebar { display: none; }
    .page-header__search { max-width: none; }
}
