/* ===== AistTopbar — полностью изолированный topbar ===== */

/* ---------- Контейнер header ---------- */
.aist-topbar {
    all: initial;
    display: flex;
    box-sizing: border-box;
    position: sticky;
    top: 0;
    z-index: 10;
    width: 100%;
    height: 76px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    color: #374151;
}

.aist-topbar *,
.aist-topbar *::before,
.aist-topbar *::after {
    box-sizing: border-box;
}

/* ---------- Внутренний контейнер (grid) ---------- */
.aist-topbar .aist-tb-inner {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    grid-template-areas: "left info center right";
    align-items: center;
    width: 100%;
    height: 100%;
    padding: 0 24px;
    gap: 16px;
}

/* ---------- Левая часть (гамбургер + Уведомления) ---------- */
.aist-topbar .aist-tb-left {
    grid-area: left;
    display: flex;
    align-items: center;
    gap: 16px;
}

/* ---------- Гамбургер ---------- */
.aist-topbar .aist-tb-hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: transparent;
    cursor: pointer;
    color: #6b7280;
    flex-shrink: 0;
    padding: 0;
    outline: none;
    z-index: 1;
}

.aist-topbar .aist-tb-hamburger:hover {
    background: #f3f4f6;
    color: #374151;
}

.aist-topbar .aist-tb-hamburger svg {
    fill: currentColor;
}

.aist-topbar .aist-tb-hamburger i {
    font-size: 20px;
}

.aist-topbar.sidebar-disabled .aist-tb-hamburger {
    display: none;
}

/* ---------- Информация (тех. поддержка, менеджер) ---------- */
.aist-topbar .aist-tb-info {
    grid-area: info;
    display: none;
    flex-direction: column;
    gap: 2px;
    font-size: 14px;
    color: #374151;
}

.aist-topbar .aist-tb-info a {
    color: #2563eb;
    text-decoration: none;
}

.aist-topbar .aist-tb-info a:hover {
    text-decoration: underline;
}

/* ---------- Центральная часть ---------- */
.aist-topbar .aist-tb-center {
    grid-area: center;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

/* ---------- Правая часть (юзер) ---------- */
.aist-topbar .aist-tb-right {
    grid-area: right;
    display: flex;
    align-items: center;
    justify-content: end;
    gap: 12px;
}

/* ---------- Круглая кнопка-иконка (уведомления) ---------- */
.aist-topbar .aist-tb-icon-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    outline: none;
    transition: background-color 0.15s, color 0.15s;
    z-index: 1;
}

.aist-topbar .aist-tb-icon-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.aist-topbar .aist-tb-icon-btn svg {
    fill: currentColor;
}

.aist-topbar .aist-tb-icon-btn i {
    font-size: 20px;
}

/* ---------- Индикатор уведомлений (точка) ---------- */
.aist-topbar .aist-tb-notify-dot {
    position: absolute;
    top: 2px;
    right: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fb923c;
}

.aist-topbar .aist-tb-notify-dot::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: #fb923c;
    opacity: 0.75;
    animation: aist-tb-ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes aist-tb-ping {
    75%, 100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* ---------- Обёртка dropdown (общая) ---------- */
.aist-topbar .aist-tb-dropdown-wrap {
    position: relative;
}

/* ---------- Dropdown-панель ---------- */
.aist-topbar .aist-tb-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 17px);
    border-radius: 16px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    z-index: 10;
}
.aist-topbar .aist-tb-dropdown-right {
    right: 0;
}

.aist-topbar .aist-tb-dropdown.open {
    display: flex;
    flex-direction: column;
}

/* ---------- Notification dropdown ---------- */
.aist-topbar .aist-tb-notif-dropdown {
    width: 361px;
    height: 480px;
    padding: 12px;
}

.aist-topbar .aist-tb-notif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #f3f4f6;
    padding-bottom: 12px;
    margin-bottom: 12px;
}

.aist-topbar .aist-tb-notif-header h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.aist-topbar .aist-tb-notif-close {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    padding: 0;
    outline: none;
}

.aist-topbar .aist-tb-notif-close svg {
    fill: currentColor;
}

.aist-topbar .aist-tb-notif-list {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #d0d5dd transparent;
}

.aist-topbar .aist-tb-notif-list::-webkit-scrollbar {
    width: 6px;
}

.aist-topbar .aist-tb-notif-list::-webkit-scrollbar-track {
    background: transparent;
}

.aist-topbar .aist-tb-notif-list::-webkit-scrollbar-thumb {
    background-color: #d0d5dd;
    border-radius: 3px;
}

.aist-topbar .aist-tb-notif-list::-webkit-scrollbar-thumb:hover {
    background-color: #98a2b3;
}

.aist-topbar .aist-tb-notif-list li a {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid #f3f4f6;
    border-radius: 8px;
    text-decoration: none;
    color: #6b7280;
    font-size: 14px;
    line-height: 1.4;
    overflow-wrap: break-word;
    word-break: break-word;
    min-width: 0;
}

.aist-topbar .aist-tb-notif-list li a:hover {
    background: #f3f4f6;
}

.aist-topbar .aist-tb-notif-list .aist-tb-notif-name {
    font-weight: 500;
    color: #1f2937;
}

.aist-topbar .aist-tb-notif-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6b7280;
    margin-top: 6px;
}

.aist-topbar .aist-tb-notif-meta-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #9ca3af;
}

.aist-topbar .aist-tb-notif-footer {
    margin-top: 12px;
}

.aist-topbar .aist-tb-notif-footer a {
    display: flex;
    justify-content: center;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
}

.aist-topbar .aist-tb-notif-footer a:hover {
    background: #f9fafb;
    color: #1f2937;
}

/* ---------- User area ---------- */
.aist-topbar .aist-tb-user-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    text-decoration: none;
    color: #374151;
    background: none;
    border: none;
    padding: 0;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    z-index: 1;
}

.aist-topbar .aist-tb-user-toggle:hover {
    color: #111827;
}

.aist-topbar .aist-tb-user-name {
    font-weight: 500;
    white-space: nowrap;
}

.aist-topbar .aist-tb-user-org-badge {
    font-size: 12px;
    padding: 4px 8px;
    text-align: center;
    border-radius: 8px;
    background: #f3f5f7;
    color: #374151;
    margin-top: 4px;
}

.aist-topbar .aist-tb-user-chevron {
    transition: transform 0.2s ease;
    stroke: #6b7280;
    flex-shrink: 0;
}

.aist-topbar .aist-tb-dropdown-wrap.open .aist-tb-user-chevron {
    transform: rotate(180deg);
}

/* ---------- User dropdown ---------- */
.aist-topbar .aist-tb-user-dropdown {
    width: 300px;
}

/* User info block */
.aist-topbar .aist-tb-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.aist-topbar .aist-tb-user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #f3f4f6;
    flex-shrink: 0;
}

.aist-topbar .aist-tb-user-avatar i {
    font-size: 24px;
    color: #6b7280;
}

.aist-topbar .aist-tb-user-details {
    min-width: 0;
}

.aist-topbar .aist-tb-user-details-name {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aist-topbar .aist-tb-user-details-sub {
    display: block;
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Management org block */
.aist-topbar .aist-tb-mgmt-org {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
}

.aist-topbar .aist-tb-mgmt-org-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.aist-topbar .aist-tb-mgmt-org-left i {
    flex-shrink: 0;
    font-size: 20px;
    color: #6b7280;
}

.aist-topbar .aist-tb-mgmt-org-name {
    font-size: 12px;
    color: #374151;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aist-topbar .aist-tb-mgmt-org-btn {
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: transparent;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
    cursor: pointer;
}

.aist-topbar .aist-tb-mgmt-org-btn:hover {
    background: #f9fafb;
}

/* Menu list */
.aist-topbar .aist-tb-menu {
    list-style: none;
    margin: 0;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-bottom: 1px solid #e5e7eb;
}

.aist-topbar .aist-tb-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
}

.aist-topbar .aist-tb-menu a i {
    font-size: 24px;
    color: #6b7280;
    flex-shrink: 0;
}

.aist-topbar .aist-tb-menu a:hover {
    background: #f3f4f6;
}

.aist-topbar .aist-tb-menu a:hover i {
    color: #374151;
}

/* Logout */
.aist-topbar .aist-tb-logout {
    padding: 8px 8px 12px;
}

.aist-topbar .aist-tb-logout a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
}

.aist-topbar .aist-tb-logout a i {
    font-size: 24px;
    color: #6b7280;
    flex-shrink: 0;
}

.aist-topbar .aist-tb-logout a:hover {
    background: #f3f4f6;
}

.aist-topbar .aist-tb-logout a:hover i {
    color: #374151;
}

/* ---------- Техподдержка (мобильная кнопка) ---------- */
.aist-topbar .aist-tb-support-mobile {
    display: none;
}

.aist-topbar .aist-tb-support-mobile .aist-tb-icon-btn i {
    font-size: 20px;
}

.aist-topbar .aist-tb-support-dropdown {
    width: 300px;
}

.aist-topbar .aist-tb-support-header {
    padding: 16px 16px 12px;
    border-bottom: 1px solid #e5e7eb;
}

.aist-topbar .aist-tb-support-header h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.aist-topbar .aist-tb-support-label {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.3;
}

.aist-topbar .aist-tb-support-phone {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    line-height: 1.4;
}

/* ===================================================================
   Адаптив
   =================================================================== */


@media (min-width: 768px) {
    /* Показываем инфо-блок на десктопе */
    .aist-topbar .aist-tb-info {
        display: flex;
    }

    /* Добавляем отступ при развернутом sidebar */
    .aist-topbar {
        padding-left: 290px;
    }

    /* Добавляем отступ при свернутом sidebar */
    .mini-sidebar .aist-topbar {
        padding-left: 74px;
    }
    
    /* Добавляем отступ при свернутом sidebar */
    .aist-topbar.sidebar-disabled {
        padding-left: 0px;
    }
    
}

/* Логотип — скрыт на десктопе по умолчанию */
.aist-topbar .aist-tb-mobile-logo {
    display: none;
}

/* Показываем логотип когда sidebar отключён */
.aist-topbar.sidebar-disabled .aist-tb-mobile-logo {
    display: block;
    height: 40px;
}

/* Строго по центру viewport на десктопе */
@media (min-width: 768px) {
    .aist-topbar.sidebar-disabled .aist-tb-center {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        pointer-events: none;
    }

    .aist-topbar.sidebar-disabled .aist-tb-center * {
        pointer-events: auto;
    }
}

@media (max-width: 767px) {
    .aist-topbar .aist-tb-inner {
        grid-template-columns: auto 1fr auto;
        grid-template-areas: "left center right";
        padding: 0 12px;
        gap: 8px;
    }

    .aist-topbar .aist-tb-info {
        display: none !important;
    }

    .aist-topbar .aist-tb-mobile-logo {
        display: block;
        height: 40px;
    }

    /* sidebar-disabled: логотип прижат влево */
    .aist-topbar.sidebar-disabled .aist-tb-center {
        justify-content: flex-start;
    }

    /* Dropdown на всю ширину экрана */
    .aist-topbar .aist-tb-dropdown {
        position: fixed;
        left: 8px;
        right: 8px;
        top: auto;
        width: auto;
        max-height: calc(100vh - 80px);
        overflow-y: auto;
    }

    .aist-topbar .aist-tb-notif-dropdown {
        width: auto;
        height: auto;
        max-height: calc(100vh - 80px);
    }

    .aist-topbar .aist-tb-support-dropdown {
        width: auto;
    }

    .aist-topbar .aist-tb-user-dropdown {
        width: auto;
    }

    /* Скрываем имя/телефон, показываем только иконку аватара */
    .aist-topbar .aist-tb-user-toggle > div:not(.aist-tb-user-avatar) {
        display: none;
    }

    .aist-topbar .aist-tb-user-chevron {
        display: none;
    }

    /* Показываем кнопку техподдержки */
    .aist-topbar .aist-tb-support-mobile {
        display: block;
    }
}

@media (max-width: 414px) {
    .aist-topbar .aist-tb-icon-btn,
    .aist-topbar .aist-tb-hamburger,
    .aist-topbar .aist-tb-user-avatar--small {
        width: 35px;
        height: 35px;
    }

    .aist-topbar .aist-tb-icon-btn svg,
    .aist-topbar .aist-tb-icon-btn i {
        font-size: 17px;
    }

    .aist-topbar .aist-tb-hamburger svg {
        width: 14px;
        height: 10px;
    }

    .aist-topbar .aist-tb-user-avatar--small i {
        font-size: 18px;
    }
}
