/*
 * CCB Design System — casca da aplicação
 * Sidebar (seções + itens), topbar (busca, alertas, usuário), breadcrumb e
 * cabeçalho de página. Mobile: sidebar vira gaveta (off-canvas).
 */
html, body { height: 100%; }
body.ds-app {
    margin: 0;
    background: var(--ds-bg);
    color: var(--ds-text);
    font-family: var(--ds-font);
    font-size: var(--ds-fs-base);
    -webkit-font-smoothing: antialiased;
}

.ds-shell { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.ds-sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: var(--ds-sidebar-w);
    display: flex; flex-direction: column;
    background: var(--ds-surface);
    border-right: 1px solid var(--ds-border);
    z-index: 1040;
    transition: transform var(--ds-transition);
}
.ds-brand {
    display: flex; align-items: center; gap: var(--ds-space-3);
    height: var(--ds-topbar-h);
    padding: 0 var(--ds-space-5);
    color: var(--ds-text); text-decoration: none;
    flex-shrink: 0;
}
.ds-brand:hover { color: var(--ds-text); text-decoration: none; }
.ds-brand__mark {
    width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
    display: grid; place-items: center;
    background: var(--ds-primary); color: var(--ds-text-inverse);
    font-weight: var(--ds-fw-bold); font-size: 0.6875rem; letter-spacing: 0;
}
.ds-brand__name { font-weight: var(--ds-fw-bold); font-size: var(--ds-fs-md); line-height: 1.1; }
.ds-brand__sub  { display: block; margin-top: 2px; font-size: 0.6875rem; line-height: 1.3; color: var(--ds-text-muted); font-weight: var(--ds-fw-medium); }

.ds-nav { flex: 1; overflow-y: auto; padding: var(--ds-space-2) var(--ds-space-3) var(--ds-space-4); margin: 0; list-style: none; }
.ds-nav__section {
    margin: var(--ds-space-5) var(--ds-space-3) var(--ds-space-2);
    font-size: 0.6875rem; font-weight: var(--ds-fw-semibold);
    letter-spacing: .08em; text-transform: uppercase;
    color: var(--ds-text-muted);
    list-style: none;
}
.ds-nav__section:first-child { margin-top: var(--ds-space-2); }
.ds-nav .nav-item { list-style: none; margin: 2px 0; }
.ds-nav .nav-link {
    display: flex; align-items: center; gap: var(--ds-space-3);
    padding: 9px var(--ds-space-3);
    border-radius: var(--ds-radius-sm);
    color: var(--ds-text-2);
    font-weight: var(--ds-fw-medium);
    text-decoration: none; cursor: pointer;
    transition: background var(--ds-transition), color var(--ds-transition);
}
.ds-nav .nav-link i:first-child { width: 18px; text-align: center; color: var(--ds-text-muted); font-size: 0.95rem; }
.ds-nav .nav-link:hover { background: var(--ds-surface-2); color: var(--ds-text); text-decoration: none; }
.ds-nav .nav-item.active > .nav-link { background: var(--ds-primary-50); color: var(--ds-primary-700); }
.ds-nav .nav-item.active > .nav-link i:first-child { color: var(--ds-primary); }
/* Item sem permissão (auth-manager adiciona .nav-item-locked e .nav-lock-icon) */
.ds-nav .nav-item-locked > .nav-link { color: var(--ds-text-muted); opacity: .7; }
.ds-nav .nav-lock-icon { margin-left: auto; font-size: 0.7rem; color: var(--ds-text-muted); }
.ds-nav .nav-item.ds-hidden-by-search { display: none; }

.ds-sidebar__user {
    display: flex; align-items: center; gap: var(--ds-space-3);
    padding: var(--ds-space-4) var(--ds-space-5);
    border-top: 1px solid var(--ds-border);
    flex-shrink: 0;
}
.ds-sidebar__user .ds-avatar { flex-shrink: 0; }
.ds-sidebar__user-name { font-weight: var(--ds-fw-semibold); font-size: var(--ds-fs-sm); color: var(--ds-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.ds-sidebar__user-role { font-size: var(--ds-fs-xs); color: var(--ds-text-muted); display: flex; align-items: center; gap: 6px; }
.ds-sidebar__user-role::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ds-success); }

/* ── Área principal ─────────────────────────────────────────────────────── */
.ds-main { flex: 1; min-width: 0; margin-left: var(--ds-sidebar-w); display: flex; flex-direction: column; }

.ds-topbar {
    position: sticky; top: 0; z-index: 1030;
    height: var(--ds-topbar-h);
    display: flex; align-items: center; gap: var(--ds-space-4);
    padding: 0 var(--ds-space-6);
    background: rgba(245, 247, 251, 0.85);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid transparent;
}
.ds-topbar.is-scrolled { border-bottom-color: var(--ds-border); background: rgba(255, 255, 255, 0.92); }
.ds-icon-btn.ds-topbar__toggle { display: none; }

.ds-search { position: relative; width: min(420px, 100%); }
.ds-search input {
    width: 100%; height: 40px;
    padding: 0 var(--ds-space-4) 0 38px;
    border: 1px solid var(--ds-border); border-radius: var(--ds-radius);
    background: var(--ds-surface); color: var(--ds-text);
    font-size: var(--ds-fs-base);
    transition: border-color var(--ds-transition), box-shadow var(--ds-transition);
}
.ds-search input::placeholder { color: var(--ds-text-muted); }
.ds-search input:focus { outline: none; border-color: var(--ds-primary); box-shadow: var(--ds-focus); }
.ds-search > i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ds-text-muted); font-size: 0.85rem; }
.ds-search__kbd {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    font-size: 0.6875rem; color: var(--ds-text-muted);
    border: 1px solid var(--ds-border); border-radius: 5px; padding: 1px 6px; background: var(--ds-surface-2);
}
.ds-search__results {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    background: var(--ds-surface); border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius); box-shadow: var(--ds-shadow-lg);
    padding: var(--ds-space-2); display: none; max-height: 320px; overflow-y: auto;
}
.ds-search__results.is-open { display: block; }
.ds-search__item {
    display: flex; align-items: center; gap: var(--ds-space-3);
    padding: 8px var(--ds-space-3); border-radius: var(--ds-radius-sm);
    color: var(--ds-text-2); cursor: pointer; border: 0; background: none; width: 100%; text-align: left;
}
.ds-search__item i { width: 18px; text-align: center; color: var(--ds-text-muted); }
.ds-search__item:hover, .ds-search__item.is-active { background: var(--ds-primary-50); color: var(--ds-primary-700); }
.ds-search__empty { padding: 10px var(--ds-space-3); color: var(--ds-text-muted); font-size: var(--ds-fs-sm); }

.ds-topbar__actions { margin-left: auto; display: flex; align-items: center; gap: var(--ds-space-2); }
.ds-icon-btn {
    width: 38px; height: 38px; border-radius: var(--ds-radius);
    display: inline-grid; place-items: center;
    border: 0; background: transparent; color: var(--ds-text-2);
    position: relative; cursor: pointer;
    transition: background var(--ds-transition), color var(--ds-transition);
}
.ds-icon-btn:hover, .ds-icon-btn:focus { background: var(--ds-surface); color: var(--ds-primary); outline: none; }
.ds-icon-btn__dot { position: absolute; top: 9px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--ds-danger); border: 2px solid var(--ds-bg); }

.ds-user-btn {
    display: flex; align-items: center; gap: var(--ds-space-2);
    border: 0; background: transparent; padding: 4px 6px 4px 4px;
    border-radius: var(--ds-radius); cursor: pointer; color: var(--ds-text);
}
.ds-user-btn:hover, .ds-user-btn:focus { background: var(--ds-surface); outline: none; }
.ds-user-btn__name { font-weight: var(--ds-fw-semibold); font-size: var(--ds-fs-sm); max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ds-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: inline-grid; place-items: center;
    background: var(--ds-primary-100); color: var(--ds-primary-700);
    font-weight: var(--ds-fw-semibold); font-size: var(--ds-fs-sm);
    text-transform: uppercase;
}

.ds-dropdown {
    min-width: 220px; padding: var(--ds-space-2);
    border: 1px solid var(--ds-border); border-radius: var(--ds-radius);
    box-shadow: var(--ds-shadow-lg);
}
.ds-dropdown .dropdown-item {
    display: flex; align-items: center; gap: var(--ds-space-3);
    padding: 8px var(--ds-space-3); border-radius: var(--ds-radius-sm);
    font-size: var(--ds-fs-base); color: var(--ds-text-2);
}
.ds-dropdown .dropdown-item i { width: 16px; text-align: center; color: var(--ds-text-muted); }
.ds-dropdown .dropdown-item:hover { background: var(--ds-surface-2); color: var(--ds-text); }
.ds-dropdown .dropdown-item.is-danger, .ds-dropdown .dropdown-item.is-danger i { color: var(--ds-danger); }
.ds-dropdown__header { padding: 6px var(--ds-space-3) 8px; font-size: var(--ds-fs-xs); color: var(--ds-text-muted); font-weight: var(--ds-fw-semibold); text-transform: uppercase; letter-spacing: .06em; }
.ds-dropdown__empty { display: flex; align-items: center; gap: var(--ds-space-3); padding: var(--ds-space-3); color: var(--ds-text-muted); font-size: var(--ds-fs-sm); }

.ds-session-timer { font-size: var(--ds-fs-xs); font-weight: var(--ds-fw-semibold); color: var(--ds-warning); background: var(--ds-warning-50); border-radius: var(--ds-radius-pill); padding: 2px 8px; }

/* ── Conteúdo ────────────────────────────────────────────────────────────── */
.ds-content { flex: 1; padding: var(--ds-space-2) var(--ds-space-6) var(--ds-space-8); max-width: 1600px; width: 100%; }

.ds-breadcrumb { display: flex; align-items: center; gap: var(--ds-space-2); margin: var(--ds-space-2) 0 var(--ds-space-2); padding: 0; list-style: none; font-size: var(--ds-fs-sm); color: var(--ds-text-muted); }
.ds-breadcrumb li + li::before { content: "\f105"; font-family: "Font Awesome 5 Free"; font-weight: 900; margin-right: var(--ds-space-2); font-size: 0.7rem; color: var(--ds-border-strong); }
.ds-breadcrumb a { color: var(--ds-text-muted); text-decoration: none; cursor: pointer; }
.ds-breadcrumb a:hover { color: var(--ds-primary); }
.ds-breadcrumb [aria-current] { color: var(--ds-primary); font-weight: var(--ds-fw-medium); }

.ds-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--ds-space-4); flex-wrap: wrap; margin-bottom: var(--ds-space-5); }
.ds-page-header__title { margin: 0; font-size: var(--ds-fs-xl); font-weight: var(--ds-fw-bold); color: var(--ds-text); letter-spacing: -.01em; }
.ds-page-header__subtitle { margin: 4px 0 0; color: var(--ds-text-muted); font-size: var(--ds-fs-base); }
.ds-page-header__actions { display: flex; align-items: center; gap: var(--ds-space-2); flex-wrap: wrap; }

.ds-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--ds-space-2); padding: var(--ds-space-4) var(--ds-space-6); color: var(--ds-text-muted); font-size: var(--ds-fs-xs); }

/* ── Responsivo ──────────────────────────────────────────────────────────── */
.ds-backdrop { display: none; }
@media (max-width: 991.98px) {
    .ds-sidebar { transform: translateX(-100%); box-shadow: var(--ds-shadow-lg); }
    .ds-shell.sidebar-open .ds-sidebar { transform: translateX(0); }
    .ds-shell.sidebar-open .ds-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 1035; }
    .ds-main { margin-left: 0; }
    .ds-topbar { padding: 0 var(--ds-space-4); }
    .ds-icon-btn.ds-topbar__toggle { display: inline-grid; }
    .ds-content { padding: var(--ds-space-2) var(--ds-space-4) var(--ds-space-6); }
    .ds-user-btn__name { display: none; }
}
@media (max-width: 575.98px) {
    .ds-search__kbd { display: none; }
    .ds-page-header__title { font-size: var(--ds-fs-lg); }
}
