/* ===================================
   UNIFIED LAYOUT - PLATAFORMA INTEGRADA
   Jonathan Ive Design Philosophy
   Precision. Restraint. Purpose.
   =================================== */

/* ============ CSS VARIABLES ============ */
:root {
    --sidebar-width-expanded: 264px;
    --sidebar-width-collapsed: 136px;
    --sidebar-transition: 280ms cubic-bezier(0.4, 0, 0.2, 1);
    --content-radius: 20px;
    --content-padding: 12px;
}

/* ============ BODY OVERRIDE ============ */
body.unified-mode {
    overflow: hidden;
    background: #2A201C;
}

body.unified-mode::before {
    display: none;
}

body.unified-mode .background-gradient {
    display: none;
}

/* ============ LAYOUT SHELL ============ */
.unified-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* ============ SIDEBAR ============ */
.unified-sidebar {
    width: var(--sidebar-width-expanded);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    background: #2A201C;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-right: none;
    z-index: 300;
    transition: width var(--sidebar-transition), transform 320ms cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-font-smoothing: antialiased;
    overflow-x: clip;
    overflow-y: visible;
}

.unified-sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
    overflow-x: visible;
}

/* ---- Brand / Logo ---- */
.unified-sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 14px 8px 6px;
    flex-shrink: 0;
    cursor: default;
    user-select: none;
    transition: padding var(--sidebar-transition);
    overflow: hidden;
}

.unified-sidebar-brand img {
    height: 24px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    filter: brightness(1.05) contrast(1.05);
    flex-shrink: 0;
    transition: height var(--sidebar-transition), filter var(--sidebar-transition);
}

.unified-sidebar.collapsed .unified-sidebar-brand {
    padding: 22px 2px 10px;
    overflow: visible;
}

.unified-sidebar.collapsed .unified-sidebar-brand img {
    width: 120px;
    height: auto;
    max-width: none;
    filter: brightness(1.02) contrast(1.05);
}

.unified-sidebar-brand-text {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 11px;
    color: #C8102E;
    letter-spacing: 0.5px;
    line-height: 1;
    text-transform: uppercase;
    white-space: nowrap;
    transition: opacity var(--sidebar-transition), font-size var(--sidebar-transition);
}

/* Expanded brand: stacked layout */
.unified-sidebar:not(.collapsed) .unified-sidebar-brand {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 16px 20px 8px;
    overflow: hidden;
}

.unified-sidebar:not(.collapsed) .unified-sidebar-brand img {
    height: 30px;
}

.unified-sidebar:not(.collapsed) .unified-sidebar-brand-text {
    font-size: 18px;
    text-transform: none;
    letter-spacing: 0.2px;
}

/* ---- Toggle Button ---- */
.unified-sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin: 4px auto 4px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: background 150ms, color 150ms;
    flex-shrink: 0;
}

.unified-sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
}

.unified-sidebar-toggle svg {
    width: 20px;
    height: 20px;
}

.unified-sidebar:not(.collapsed) .unified-sidebar-toggle {
    margin: 4px 12px 4px auto;
}

/* ---- Scrollable Nav ---- */
.unified-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px 12px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    transition: padding var(--sidebar-transition);
}

.unified-sidebar:not(.collapsed) .unified-sidebar-nav {
    padding: 4px 12px 12px;
}

.unified-sidebar-nav::-webkit-scrollbar {
    display: none;
}

/* ---- Section Group ---- */
.unified-nav-section {
    margin-bottom: 2px;
}

/* ---- Section Label ---- */
.unified-nav-label {
    font-family: 'Sofia Pro Regular', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.55);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0 12px;
    margin-top: 20px;
    margin-bottom: 6px;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--sidebar-transition), margin var(--sidebar-transition);
}

.unified-nav-section:first-child .unified-nav-label {
    margin-top: 8px;
}

/* Collapsed: hide labels */
.unified-sidebar.collapsed .unified-nav-label {
    opacity: 0;
    height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* ---- Nav Divider ---- */
.unified-nav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 12px 12px 4px;
    transition: margin var(--sidebar-transition);
}

.unified-sidebar.collapsed .unified-nav-divider {
    margin: 8px 10px 4px;
}

/* ---- Nav Item ---- */
.unified-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 0 12px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    font-family: 'Sofia Pro Regular', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13.5px;
    cursor: pointer;
    transition: background 150ms cubic-bezier(0.4, 0, 0.2, 1),
                color 150ms cubic-bezier(0.4, 0, 0.2, 1),
                transform 100ms cubic-bezier(0.4, 0, 0.2, 1),
                flex-direction var(--sidebar-transition),
                height var(--sidebar-transition),
                padding var(--sidebar-transition),
                border-radius var(--sidebar-transition);
    text-align: left;
    white-space: nowrap;
    overflow: visible;
    position: relative;
}

.unified-nav-item:hover {
    background: rgba(255, 255, 255, 0.07);
}

.unified-nav-item:active {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(0.98);
}

/* ---- Active Nav Item: fuses with white content panel ---- */
.unified-nav-item.active {
    background: #F5EFEA;
    color: #2F2723;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
}

.unified-sidebar:not(.collapsed) .unified-nav-item.active {
    border-radius: 10px;
}

.unified-sidebar:not(.collapsed) .unified-nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: #C8102E;
    border-radius: 0 3px 3px 0;
    box-shadow: 0 0 8px rgba(200, 16, 46, 0.3);
}

.unified-nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.65);
    opacity: 1;
    transition: color 150ms, opacity 150ms, width var(--sidebar-transition), height var(--sidebar-transition);
}

.unified-nav-item:hover svg {
    color: rgba(255, 255, 255, 0.85);
}

.unified-nav-item.active svg {
    color: #2F2723;
}

.unified-nav-item-label {
    transition: opacity var(--sidebar-transition), font-size var(--sidebar-transition);
    overflow: hidden;
}

/* ---- Collapsed Nav Items: icon centered + tiny label below ---- */
.unified-sidebar.collapsed .unified-nav-item {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 54px;
    padding: 6px 4px 4px;
    border-radius: 12px;
    text-align: center;
}

.unified-sidebar.collapsed .unified-nav-item svg {
    width: 28px;
    height: 28px;
}

.unified-sidebar.collapsed .unified-nav-item-label {
    font-size: 9px;
    opacity: 0.6;
    height: auto;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.2;
    pointer-events: none;
    white-space: nowrap;
    color: rgba(255, 255, 255, 0.6);
}

.unified-sidebar.collapsed .unified-nav-item.active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border-radius: 12px;
    margin-right: 0;
}

.unified-sidebar.collapsed .unified-nav-item.active::after {
    display: none;
}

.unified-sidebar.collapsed .unified-nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 22px;
    background: #C8102E;
    border-radius: 0 3px 3px 0;
    box-shadow: 0 0 8px rgba(200, 16, 46, 0.3);
    bottom: auto;
    right: auto;
    pointer-events: none;
}

.unified-sidebar.collapsed .unified-nav-item.active svg {
    color: #fff;
    opacity: 1;
    filter: none;
}

.unified-sidebar.collapsed .unified-nav-item.active .unified-nav-item-label {
    opacity: 1;
    color: #fff;
}

/* ---- Sidebar Profile (Bottom) ---- */
.unified-sidebar-user {
    position: relative;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 12px;
    flex-shrink: 0;
    transition: padding var(--sidebar-transition);
}

.unified-sidebar:not(.collapsed) .unified-sidebar-user {
    padding: 10px 12px;
}

.unified-sidebar.collapsed .unified-sidebar-user {
    padding: 10px 8px;
}

.sidebar-profile-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 6px 10px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: background 200ms, transform 100ms;
    font-family: 'Sofia Pro Regular', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13.5px;
    text-align: left;
    white-space: nowrap;
}

.sidebar-profile-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.sidebar-profile-btn:active {
    transform: scale(0.98);
}

.sidebar-profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #C8102E, #8E0A21);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.sidebar-profile-avatar svg {
    width: 18px;
    height: 18px;
    color: rgba(255, 255, 255, 0.9);
}

.sidebar-profile-name {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity var(--sidebar-transition);
}

.sidebar-profile-chevron {
    width: 16px;
    height: 16px;
    color: rgba(255, 255, 255, 0.4);
    flex-shrink: 0;
    transition: opacity var(--sidebar-transition), transform 200ms;
}

/* Collapsed: avatar-only centered */
.unified-sidebar.collapsed .sidebar-profile-btn {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    gap: 2px;
    border-radius: 12px;
}

.unified-sidebar.collapsed .sidebar-profile-name {
    font-size: 9px;
    opacity: 0.6;
    line-height: 1.2;
}

.unified-sidebar.collapsed .sidebar-profile-chevron {
    display: none;
}

/* Sidebar Profile Dropdown */
.sidebar-profile-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    width: 260px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
    padding: 8px;
    z-index: 9999;
    animation: sidebarDropUp 200ms cubic-bezier(0.2, 0, 0, 1);
}

@keyframes sidebarDropUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.sidebar-profile-dropdown-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px 12px;
    border-bottom: 1px solid #F0F0F4;
}

.sidebar-profile-dropdown-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #C8102E, #8E0A21);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-profile-dropdown-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.sidebar-profile-dropdown-avatar svg {
    width: 20px;
    height: 20px;
    color: rgba(255, 255, 255, 0.9);
}

.sidebar-profile-dropdown-name {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    color: #1D1D22;
    line-height: 1.3;
}

.sidebar-profile-dropdown-role {
    font-family: 'Sofia Pro Regular', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 12px;
    color: #8E8E93;
    line-height: 1.3;
}

.sidebar-profile-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    font-family: 'Sofia Pro Regular', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13.5px;
    color: #1D1D22;
    transition: background 150ms;
}

.sidebar-profile-dropdown-item:hover {
    background: #F2F2F7;
}

.sidebar-profile-dropdown-item svg {
    width: 18px;
    height: 18px;
    color: #636366;
    flex-shrink: 0;
}

.sidebar-profile-dropdown-admin {
    color: #C8102E;
}

.sidebar-profile-dropdown-admin svg {
    color: #C8102E;
}

.sidebar-profile-dropdown-admin:hover {
    background: rgba(200, 16, 46, 0.06);
}

.sidebar-profile-dropdown-divider {
    height: 1px;
    background: #F0F0F4;
    margin: 4px 8px;
}

.sidebar-profile-dropdown-logout {
    color: #8E8E93;
}

.sidebar-profile-dropdown-logout:hover {
    background: rgba(255, 59, 48, 0.06);
    color: #FF3B30;
}

.sidebar-profile-dropdown-logout:hover svg {
    color: #FF3B30;
}

.unified-user-admin-badge {
    width: 12px;
    height: 12px;
    color: #C8102E;
    margin-left: 4px;
    vertical-align: middle;
    display: inline-block;
    position: relative;
    top: -1px;
}

/* ---- Admin Panel Link Button ---- */
.unified-admin-link-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(200, 16, 46, 0.08);
    border: none;
    border-radius: 8px;
    color: #C8102E;
    cursor: pointer;
    transition: background 150ms, color 150ms, transform 150ms;
    flex-shrink: 0;
}

.unified-admin-link-btn:hover {
    background: rgba(200, 16, 46, 0.15);
    transform: scale(1.05);
}

.unified-admin-link-btn svg {
    width: 16px;
    height: 16px;
}

.unified-sidebar.collapsed .unified-admin-link-btn {
    display: none;
}

/* ============ CONTENT AREA ============ */
.unified-content {
    margin-left: var(--sidebar-width-expanded);
    flex: 1;
    height: 100vh;
    overflow: hidden;
    position: relative;
    background: #2A201C;
    padding: var(--content-padding);
    padding-left: 12px;
    transition: margin-left var(--sidebar-transition), padding var(--sidebar-transition);
    display: flex;
    flex-direction: column;
}

.sidebar-collapsed .unified-content {
    margin-left: var(--sidebar-width-collapsed);
}

/* ---- Rounded Content Container ---- */
.unified-content-rounded {
    flex: 1;
    background: #fff;
    border-radius: var(--content-radius);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.1);
    position: relative;
    /* Anti-aliasing fix: promote to own compositing layer to smooth rounded clip edges */
    isolation: isolate;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
}

.unified-content-inner {
    flex: 1;
    overflow: auto;
}

.unified-desktop-user-access {
    display: flex;
    justify-content: flex-end;
    padding: 10px 16px 8px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    background: #fff;
    border-radius: var(--content-radius) var(--content-radius) 0 0;
}

.unified-desktop-user-access .dash-topbar-user-wrap {
    width: 240px;
    max-width: 100%;
    flex: 0 0 240px;
}

.unified-desktop-user-access .dash-topbar-dropdown {
    z-index: 120;
}

/* ============ MOBILE ============ */
.unified-mobile-header {
    display: none;
    height: 56px;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 0;
    z-index: 50;
    flex-shrink: 0;
}

.unified-mobile-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #48484A;
    cursor: pointer;
    border-radius: 10px;
    transition: background 150ms;
}

.unified-mobile-toggle:hover {
    background: rgba(0, 0, 0, 0.04);
}

.unified-mobile-toggle svg {
    width: 22px;
    height: 22px;
}

.unified-mobile-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.unified-mobile-brand img {
    height: 24px;
    width: auto;
}

.unified-mobile-brand span {
    font-family: 'Sofia Pro Bold', sans-serif;
    font-size: 16px;
    color: #C8102E;
}

.unified-mobile-spacer {
    flex: 1;
}

.unified-mobile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #E5E5EA;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.unified-mobile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.unified-mobile-avatar svg {
    width: 16px;
    height: 16px;
    color: #8E8E93;
}

.unified-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transition: opacity 300ms, visibility 300ms;
}

.unified-sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 768px) {
    .unified-sidebar {
        transform: translateX(-100%);
        z-index: 200;
        box-shadow: none;
        width: 280px !important;
    }

    .unified-sidebar.open {
        transform: translateX(0);
        box-shadow: 12px 0 40px rgba(0, 0, 0, 0.3);
    }

    .unified-sidebar.collapsed.open .unified-nav-label {
        opacity: 1;
        height: auto;
        margin-top: 20px;
        margin-bottom: 6px;
        padding: 0 12px;
    }

    .unified-sidebar.collapsed.open .unified-nav-item {
        flex-direction: row;
        height: 36px;
        padding: 0 12px;
        gap: 10px;
        text-align: left;
        border-radius: 8px;
    }

    .unified-sidebar.collapsed.open .unified-nav-item-label {
        font-size: 13.5px;
        opacity: 1;
    }

    .unified-sidebar.collapsed.open .sidebar-profile-btn {
        flex-direction: row;
        padding: 6px 10px;
        gap: 10px;
        border-radius: 10px;
    }

    .unified-sidebar.collapsed.open .sidebar-profile-name {
        font-size: 13.5px;
        opacity: 1;
    }

    .unified-sidebar.collapsed.open .sidebar-profile-chevron {
        display: block;
    }

    .unified-sidebar-overlay {
        display: block;
    }

    .unified-content {
        margin-left: 0 !important;
        padding: 8px;
        padding-top: 0;
    }

    .unified-mobile-header {
        display: flex;
    }

    .unified-desktop-user-access {
        display: none;
    }

    .unified-sidebar-toggle {
        display: none;
    }

    .unified-content-rounded {
        border-radius: 16px;
    }

    /* On mobile, sidebar is overlay — content needs all 4 corners rounded */
    .unified-content-rounded {
        border-radius: 16px !important;
    }
}

/* ============ CHAT CONTENT LAYOUT ============ */
.chat-content-layout {
    display: flex;
    height: 100%;
    overflow: hidden;
}

.chat-conversations-panel {
    width: 300px;
    border-right: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(255, 255, 255, 0.97);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.chat-panel-header {
    padding: 20px 16px 12px;
    flex-shrink: 0;
}

.chat-panel-title {
    font-family: 'Sofia Pro Bold', sans-serif;
    font-size: 16px;
    color: #1C1C1E;
    margin-bottom: 12px;
}

.chat-panel-search {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #F2F2F7;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 0 10px;
    transition: border-color 200ms, background 200ms;
}

.chat-panel-search:focus-within {
    border-color: #C8102E;
    background: #fff;
}

.chat-panel-search svg {
    width: 16px;
    height: 16px;
    color: #8E8E93;
    flex-shrink: 0;
}

.chat-panel-search input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 0;
    font-family: 'Sofia Pro Regular', sans-serif;
    font-size: 13px;
    color: #1C1C1E;
    outline: none;
}

.chat-panel-search input::placeholder {
    color: #AEAEB2;
}

.chat-panel-search .chat-clear-search {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    color: #AEAEB2;
    cursor: pointer;
    border-radius: 50%;
    transition: background 150ms, color 150ms;
    padding: 0;
}

.chat-panel-search .chat-clear-search:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #636366;
}

.chat-panel-new-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: calc(100% - 32px);
    margin: 10px 16px 4px;
    padding: 10px;
    background: linear-gradient(135deg, #C8102E 0%, #D41432 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: 'Sofia Pro Bold', sans-serif;
    font-size: 13px;
    cursor: pointer;
    transition: transform 150ms, box-shadow 150ms;
    box-shadow: 0 2px 8px rgba(200, 16, 46, 0.2);
    flex-shrink: 0;
}

.chat-panel-new-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(200, 16, 46, 0.3);
}

.chat-panel-new-btn:active {
    transform: translateY(0);
}

.chat-panel-new-btn svg {
    width: 16px;
    height: 16px;
}

.chat-panel-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 10px;
    scrollbar-width: thin;
    scrollbar-color: #D1D1D6 transparent;
}

.chat-panel-list::-webkit-scrollbar {
    width: 5px;
}

.chat-panel-list::-webkit-scrollbar-track {
    background: transparent;
}

.chat-panel-list::-webkit-scrollbar-thumb {
    background: #D1D1D6;
    border-radius: 10px;
}

.chat-conv-item {
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 150ms;
    margin-bottom: 2px;
    position: relative;
}

.chat-conv-item:hover {
    background: rgba(0, 0, 0, 0.04);
}

.chat-conv-item.active {
    background: rgba(200, 16, 46, 0.07);
}

.chat-conv-item-title {
    font-family: 'Sofia Pro Regular', sans-serif;
    font-size: 13px;
    color: #1C1C1E;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 24px;
    line-height: 1.4;
}

.chat-conv-item.active .chat-conv-item-title {
    font-family: 'Sofia Pro Bold', sans-serif;
    color: #C8102E;
}

.chat-conv-item-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #AEAEB2;
    margin-top: 2px;
}

.chat-conv-item-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: #AEAEB2;
    cursor: pointer;
    opacity: 0;
    transition: opacity 150ms, background 150ms, color 150ms;
    padding: 0;
}

.chat-conv-item:hover .chat-conv-item-delete {
    opacity: 1;
}

.chat-conv-item-delete:hover {
    background: rgba(255, 59, 48, 0.1);
    color: #FF3B30;
}

.chat-conv-item-delete svg {
    width: 14px;
    height: 14px;
}

.chat-panel-empty {
    text-align: center;
    padding: 32px 16px;
    color: #AEAEB2;
    font-size: 13px;
}

.chat-panel-load-more {
    display: block;
    width: calc(100% - 8px);
    margin: 4px 4px 8px;
    padding: 8px;
    background: rgba(200, 16, 46, 0.06);
    color: #C8102E;
    border: none;
    border-radius: 8px;
    font-family: 'Sofia Pro Regular', sans-serif;
    font-size: 12px;
    cursor: pointer;
    transition: background 150ms;
}

.chat-panel-load-more:hover {
    background: rgba(200, 16, 46, 0.12);
}

.chat-main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    overflow: hidden;
}

/* Full-width chat (no conversations panel) */
.chat-content-fullwidth {
    display: flex;
    height: 100%;
}

/* Override app-container styles when inside chat panel */
.chat-main-panel .app-container {
    margin-left: 0;
    height: 100%;
}

/* Override header display inside chat main panel - no header needed */
.chat-main-panel .header {
    display: none;
}

@media (max-width: 1024px) {
    .chat-conversations-panel {
        display: none;
    }
}

/* ============ TRAINING EMBEDDED ============ */
.training-embedded-wrapper {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: transparent;
}

/* Override training-shell styles when embedded */
.training-embedded-wrapper .training-shell {
    min-height: auto;
}

.training-embedded-wrapper .training-header {
    display: none;
}

.training-embedded-wrapper .training-tabs {
    display: none;
}

/* Training section styles now in training-sections.css */

/* ============ WIKI EMBEDDED ============ */
.wiki-embedded-wrapper {
    height: 100%;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.wiki-embedded-wrapper > .background-gradient {
    display: none;
}

/* New three-panel wiki layout fills the wrapper */
.wiki-embedded-wrapper .wk-layout {
    flex: 1;
    min-height: 0;
}

/* ---- Embedded Spaces Bar ---- */
.wiki-embedded-spaces-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    border-bottom: 1px solid rgba(200, 16, 46, 0.06);
    flex-shrink: 0;
}

.wiki-embedded-search-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(200, 16, 46, 0.06);
    border: 1px solid rgba(200, 16, 46, 0.1);
    border-radius: 20px;
    color: #C8102E;
    font-family: 'Sofia Pro Regular', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13px;
    cursor: pointer;
    transition: background 150ms, border-color 150ms;
    flex-shrink: 0;
    white-space: nowrap;
}

.wiki-embedded-search-btn:hover {
    background: rgba(200, 16, 46, 0.1);
    border-color: rgba(200, 16, 46, 0.2);
}

.wiki-embedded-search-btn svg {
    width: 15px;
    height: 15px;
}

.wiki-embedded-spaces-list {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    flex: 1;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.wiki-embedded-spaces-list::-webkit-scrollbar {
    display: none;
}

.wiki-embedded-space-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 20px;
    color: #555;
    font-family: 'Sofia Pro Regular', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13px;
    cursor: pointer;
    transition: all 150ms;
    white-space: nowrap;
    flex-shrink: 0;
}

.wiki-embedded-space-pill:hover {
    background: rgba(200, 16, 46, 0.06);
    border-color: rgba(200, 16, 46, 0.12);
    color: #C8102E;
}

.wiki-embedded-space-pill.active {
    background: linear-gradient(135deg, #C8102E 0%, #D41432 100%);
    color: #fff;
    border-color: transparent;
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    box-shadow: 0 2px 8px rgba(200, 16, 46, 0.25);
}

.wiki-embedded-space-icon {
    font-size: 14px;
    line-height: 1;
}

.wiki-embedded-spaces-loading {
    font-size: 13px;
    color: #999;
    padding: 4px 8px;
}

/* ============ USER POPOVER ============ */
.unified-user-popover {
    position: fixed;
    width: 240px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(0, 0, 0, 0.06);
    padding: 16px;
    z-index: 9999;
    transform-origin: bottom left;
}

.unified-user-popover-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.unified-user-popover-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #F2F2F7;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.unified-user-popover-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.unified-user-popover-avatar svg {
    width: 20px;
    height: 20px;
    color: #8E8E93;
}

.unified-user-popover-name {
    font-family: 'Sofia Pro Bold', sans-serif;
    font-size: 14px;
    color: #1C1C1E;
    line-height: 1.3;
}

.unified-user-popover-role {
    font-size: 11.5px;
    color: #8E8E93;
    line-height: 1.3;
}

.unified-user-popover-admin {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(200, 16, 46, 0.06);
    border: 1px solid rgba(200, 16, 46, 0.08);
    border-radius: 10px;
    color: #C8102E;
    font-family: 'Sofia Pro Bold', sans-serif;
    font-size: 13px;
    cursor: pointer;
    transition: background 150ms, border-color 150ms;
    width: 100%;
    margin-bottom: 6px;
}

.unified-user-popover-admin:hover {
    background: rgba(200, 16, 46, 0.12);
    border-color: rgba(200, 16, 46, 0.15);
}

.unified-user-popover-admin svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.unified-user-popover-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 10px;
    color: #636366;
    font-family: 'Sofia Pro Regular', sans-serif;
    font-size: 13px;
    cursor: pointer;
    transition: background 150ms, color 150ms;
    width: 100%;
}

.unified-user-popover-logout:hover {
    background: rgba(0, 0, 0, 0.04);
    color: #1C1C1E;
}

.unified-user-popover-logout svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* popover uses fixed positioning, no sidebar-relative overrides needed */

/* ============ SIDEBAR MOBILE CLOSE BUTTON ============ */
.unified-sidebar-mobile-close {
    display: none;
    position: absolute;
    top: 16px;
    right: 12px;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    z-index: 10;
    transition: background 150ms;
}

.unified-sidebar-mobile-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

.unified-sidebar-mobile-close svg {
    width: 18px;
    height: 18px;
}

@media (max-width: 768px) {
    .unified-sidebar-mobile-close {
        display: flex;
    }
}

/* ============ CUSTOM SCROLLBAR ============ */
.dash-home-wrapper::-webkit-scrollbar,
.training-embedded-wrapper::-webkit-scrollbar,
.wiki-embedded-wrapper::-webkit-scrollbar {
    width: 6px;
}

.dash-home-wrapper::-webkit-scrollbar-track,
.training-embedded-wrapper::-webkit-scrollbar-track,
.wiki-embedded-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.dash-home-wrapper::-webkit-scrollbar-thumb,
.training-embedded-wrapper::-webkit-scrollbar-thumb,
.wiki-embedded-wrapper::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
}

.dash-home-wrapper::-webkit-scrollbar-thumb:hover,
.training-embedded-wrapper::-webkit-scrollbar-thumb:hover,
.wiki-embedded-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

.dash-home-wrapper,
.training-embedded-wrapper {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

/* ============ ADMIN PILL BADGE ============ */
.unified-admin-pill {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    background: rgba(200, 16, 46, 0.15);
    color: #C8102E;
    font-family: 'Sofia Pro Bold', sans-serif;
    font-size: 9px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
    line-height: 1.6;
}

/* Popover admin pill */
.unified-user-popover .unified-admin-pill {
    background: rgba(200, 16, 46, 0.1);
    font-size: 9.5px;
    padding: 2px 8px;
}

/* ============ FOCUS & ACCESSIBILITY ============ */
.unified-nav-item:focus-visible {
    outline: 2px solid #C8102E;
    outline-offset: -2px;
}

.unified-mobile-toggle:focus-visible {
    outline: 2px solid #C8102E;
    outline-offset: 2px;
}

/* ============ REDUCED MOTION ============ */
@media (prefers-reduced-motion: reduce) {
    .unified-sidebar,
    .unified-nav-item,
    .unified-sidebar-overlay,
    .unified-content-inner,
    .unified-content-rounded,
    .unified-section-enter,
    .unified-content {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============ PRINT ============ */
@media print {
    .unified-sidebar,
    .unified-mobile-header,
    .unified-sidebar-overlay,
    .chat-conversations-panel {
        display: none !important;
    }

    .unified-content {
        margin-left: 0 !important;
    }

    .unified-content-rounded {
        box-shadow: none;
        border-radius: 0;
    }
}
