/* ============================================================
   SPM Tool — Sidebar v2 (Fase 2)
   Scopeado con `body.sidebar-v2`. Depende de design-system.css.
   ============================================================ */

body.sidebar-v2 {
    font-family: var(--font-ui);
    background: var(--color-gray-50);
    color: var(--color-navy-900);
}

/* Reemplaza el sidebar viejo por el nuevo ------------------ */
body.sidebar-v2 .sb-v2 {
    width: 240px;
    height: 100vh;
    background: #fafbfc;
    border-right: 1px solid var(--color-gray-300);
    padding: 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-family: var(--font-ui);
    position: sticky;
    top: 0;
    flex-shrink: 0;
    overflow-y: auto;
    transition: width var(--transition-base), padding var(--transition-base);
}

body.sidebar-v2 .sb-v2.collapsed {
    width: 64px;
    padding: 16px 6px;
}

body.sidebar-v2 .sb-v2__toggle {
    position: absolute;
    top: 14px;
    right: -12px;
    width: 24px;
    height: 24px;
    border: 1px solid var(--color-gray-300);
    background: #fff;
    color: var(--color-gray-800);
    border-radius: 50%;
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 10px;
    z-index: 2;
    transition: background var(--transition-fast);
}

body.sidebar-v2 .sb-v2__toggle:hover { background: var(--color-gray-100); }

body.sidebar-v2 .sb-v2.collapsed .sb-v2__toggle i {
    transform: rotate(180deg);
}

/* Brand ------------------------------------------------------ */
body.sidebar-v2 .sb-v2__brand {
    padding: 2px 6px 16px;
    display: flex;
    align-items: center;
}

body.sidebar-v2 .sb-v2__brand a {
    display: inline-flex;
    text-decoration: none;
}

body.sidebar-v2 .sb-v2__logo-full {
    max-width: 180px;
    height: auto;
    display: block;
}

body.sidebar-v2 .sb-v2__logo-mini {
    width: 32px;
    height: 32px;
    display: none;
}

body.sidebar-v2 .sb-v2.collapsed .sb-v2__logo-full { display: none; }
body.sidebar-v2 .sb-v2.collapsed .sb-v2__logo-mini { display: block; margin: 0 auto; }

/* Search ----------------------------------------------------- */
body.sidebar-v2 .sb-v2__search {
    position: relative;
    margin: 0 4px 14px;
}

body.sidebar-v2 .sb-v2.collapsed .sb-v2__search { display: none; }

body.sidebar-v2 .sb-v2__search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-gray-600);
    font-size: 12px;
    pointer-events: none;
}

body.sidebar-v2 .sb-v2__search input {
    width: 100%;
    padding: 7px 34px 7px 30px;
    background: #fff;
    border: 1px solid var(--color-gray-350);
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    color: var(--color-navy-900);
    outline: none;
    font-family: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

body.sidebar-v2 .sb-v2__search input:focus {
    border-color: var(--color-navy-700);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-navy-700) 15%, transparent);
}

body.sidebar-v2 .sb-v2__search-kbd {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: var(--color-gray-600);
    border: 1px solid var(--color-gray-300);
    border-radius: 3px;
    padding: 1px 4px;
    background: var(--color-gray-100);
}

/* Section labels -------------------------------------------- */
body.sidebar-v2 .sb-v2__section-label {
    padding: 10px 10px 4px;
    font-size: 10px;
    color: var(--color-gray-600);
    text-transform: uppercase;
    letter-spacing: var(--letter-caps);
    font-weight: var(--fw-medium);
}

body.sidebar-v2 .sb-v2.collapsed .sb-v2__section-label {
    text-align: center;
    padding: 10px 0 4px;
    font-size: 0;
}

body.sidebar-v2 .sb-v2.collapsed .sb-v2__section-label::after {
    content: "";
    display: block;
    width: 20px;
    height: 1px;
    background: var(--color-gray-300);
    margin: 4px auto 0;
}

/* Nav items ------------------------------------------------- */
body.sidebar-v2 .sb-v2__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: left;
    color: var(--color-gray-850);
    font-size: var(--fs-base);
    font-weight: var(--fw-regular);
    font-family: inherit;
    text-decoration: none;
    transition: background var(--transition-fast), color var(--transition-fast);
}

body.sidebar-v2 .sb-v2__item:hover {
    background: var(--color-gray-150);
    color: var(--color-navy-900);
}

body.sidebar-v2 .sb-v2__item--active {
    background: var(--color-gray-250);
    color: var(--color-navy-900);
    font-weight: var(--fw-medium);
}

body.sidebar-v2 .sb-v2__item--active .sb-v2__item-icon { color: var(--color-navy-700); }

body.sidebar-v2 .sb-v2__item-icon {
    width: 16px;
    height: 16px;
    display: inline-grid;
    place-items: center;
    color: var(--color-gray-700);
    flex-shrink: 0;
}

body.sidebar-v2 .sb-v2__item-icon svg { width: 16px; height: 16px; }

body.sidebar-v2 .sb-v2__item-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.sidebar-v2 .sb-v2.collapsed .sb-v2__item-label { display: none; }
body.sidebar-v2 .sb-v2.collapsed .sb-v2__search-kbd { display: none; }

body.sidebar-v2 .sb-v2__item-chev {
    font-size: 10px;
    color: var(--color-gray-600);
    transition: transform var(--transition-fast);
}

body.sidebar-v2 .sb-v2__item--open .sb-v2__item-chev { transform: rotate(90deg); }

body.sidebar-v2 .sb-v2__badge {
    font-size: 10px;
    font-weight: var(--fw-medium);
    padding: 1px 7px;
    border-radius: var(--radius-full);
    background: var(--color-navy-700);
    color: #fff;
    margin-left: auto;
}

body.sidebar-v2 .sb-v2.collapsed .sb-v2__badge,
body.sidebar-v2 .sb-v2.collapsed .sb-v2__item-chev { display: none; }

/* Subgroup (Teams) ------------------------------------------- */
body.sidebar-v2 .sb-v2__subgroup {
    display: none;
    margin-top: 2px;
    margin-bottom: 2px;
    padding-left: 0;
}

body.sidebar-v2 .sb-v2__subgroup--open { display: block; }

body.sidebar-v2 .sb-v2.collapsed .sb-v2__subgroup--open {
    display: block;
    padding-left: 0;
}

body.sidebar-v2 .sb-v2__item--sub {
    padding: 5px 10px 5px 38px;
    font-size: var(--fs-sm);
    color: var(--color-gray-800);
    border-radius: var(--radius-md);
}

body.sidebar-v2 .sb-v2__item--sub.sb-v2__item--active {
    background: var(--color-gray-250);
    color: var(--color-navy-900);
    font-weight: var(--fw-medium);
}

body.sidebar-v2 .sb-v2.collapsed .sb-v2__item--sub {
    padding: 5px 6px;
    justify-content: center;
    font-size: 10px;
    font-weight: var(--fw-medium);
    text-align: center;
}

body.sidebar-v2 .sb-v2.collapsed .sb-v2__item--sub .sb-v2__item-label-full { display: none; }
body.sidebar-v2 .sb-v2__item--sub .sb-v2__item-label-short { display: none; }
body.sidebar-v2 .sb-v2.collapsed .sb-v2__item--sub .sb-v2__item-label-short { display: inline; }

/* User profile (bottom) ------------------------------------- */
body.sidebar-v2 .sb-v2__user {
    margin-top: auto;
    padding: 12px 10px 4px;
    border-top: 1px solid var(--color-gray-300);
    display: flex;
    align-items: center;
    gap: 10px;
}

body.sidebar-v2 .sb-v2__avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #d8b896, #8a6b4f);
    color: #fff;
    font-size: 11px;
    font-weight: var(--fw-semibold);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    overflow: hidden;
}

body.sidebar-v2 .sb-v2__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

body.sidebar-v2 .sb-v2__user-info {
    flex: 1;
    min-width: 0;
}

body.sidebar-v2 .sb-v2__user-name {
    font-size: var(--fs-md);
    font-weight: var(--fw-medium);
    color: var(--color-navy-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.sidebar-v2 .sb-v2__user-email {
    font-size: 10.5px;
    color: var(--color-gray-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.sidebar-v2 .sb-v2__signout {
    color: var(--color-gray-700);
    text-decoration: none;
    padding: 6px;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast), color var(--transition-fast);
    display: inline-grid;
    place-items: center;
}

body.sidebar-v2 .sb-v2__signout:hover {
    background: var(--color-gray-200);
    color: var(--color-danger);
}

body.sidebar-v2 .sb-v2.collapsed .sb-v2__user-info,
body.sidebar-v2 .sb-v2.collapsed .sb-v2__signout { display: none; }

body.sidebar-v2 .sb-v2.collapsed .sb-v2__user {
    justify-content: center;
    padding: 12px 0 4px;
}

/* Body layout: sidebar + main ------------------------------- */
body.sidebar-v2 {
    display: flex;
    height: 100vh;
    margin: 0;
    overflow: hidden;
}

body.sidebar-v2 .main-content {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
}

/* Responsive: collapse en mobile por defecto ---------------- */
@media (max-width: 768px) {
    body.sidebar-v2 .sb-v2 { width: 64px; padding: 16px 6px; }
    body.sidebar-v2 .sb-v2 .sb-v2__logo-full,
    body.sidebar-v2 .sb-v2 .sb-v2__search,
    body.sidebar-v2 .sb-v2 .sb-v2__item-label,
    body.sidebar-v2 .sb-v2 .sb-v2__item-chev,
    body.sidebar-v2 .sb-v2 .sb-v2__badge,
    body.sidebar-v2 .sb-v2 .sb-v2__user-info,
    body.sidebar-v2 .sb-v2 .sb-v2__signout { display: none; }
    body.sidebar-v2 .sb-v2 .sb-v2__logo-mini { display: block; margin: 0 auto; }
}
