/* ===== Блок пользователя ===== */
.tiptop-userblock {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Inter', system-ui, sans-serif;
    margin-top: 14px;
    overflow: visible !important;
}

/* Кнопка "Войти" */
.user-login-link {
    padding: 6px 16px;
    background: #2c4c6c;
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background 0.2s;
    line-height: 29px;
}
.user-login-link:hover {
    background: #1e3a56;
    color: #fff;
}

/* Контейнер дропдауна */
.user-profile-dropdown {
    position: relative;
    cursor: pointer;
}

/* Переключатель */
.user-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 10px 10px 10px;
    border-radius: 30px;
    background: transparent;
    border: 1px solid #e2e8f0;
    transition: background 0.2s, border-color 0.2s;
    line-height: 10px;
}
.user-toggle:hover {
    background: #f8fafd;
    border-color: #cbd5e1;
}

/* Аватар */
.avatar-img,
.avatar-initials {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.user-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: #1e2f3f;
    white-space: nowrap;
}

.user-toggle .fa-chevron-down {
    font-size: 0.6rem;
    color: #94a3b8;
    margin-left: 2px;
}

/* ===== ВЫПАДАЮЩЕЕ МЕНЮ ===== */
.user-profile-dropdown .dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 240px;
    padding: 8px 0;
    margin: 0;
    list-style: none;
    background: #ffffff;
    border: 1px solid #eef2f8;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.08);
    z-index: 9999;
}

.user-profile-dropdown .dropdown-menu li {
    margin: 0;
    padding: 0;
    list-style: none;
}

.user-profile-dropdown .dropdown-menu li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    color: #1e2f3f;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s, padding-left 0.15s;
    white-space: nowrap;
}

.user-profile-dropdown .dropdown-menu li a:hover {
    background: #f1f5f9;
    padding-left: 26px;
    color: #1e2f3f;
}

.user-profile-dropdown .dropdown-menu li:last-child a {
    border-top: 1px solid #eef2f8;
    margin-top: 6px;
    padding-top: 12px;
    color: #dc2626;
}

.user-profile-dropdown .dropdown-menu li:last-child a:hover {
    background: #fef2f2;
}

/* ===== В offcanvas-меню: раскрываем в потоке ===== */
.offcanvas-menu .user-profile-dropdown {
    width: 100%;
}

.offcanvas-menu .user-profile-dropdown .dropdown-menu {
    position: static;
    width: 100%;
    box-shadow: none;
    border: 1px solid #e2e8f0;
    margin-top: 6px;
    border-radius: 8px;
}

.offcanvas-menu .tiptop-userblock {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 0;
}

/* ===== Кнопки действий ===== */
.action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 3px;
    border-radius: 30px;
    color: #fff !important;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.85rem;
    transition: opacity 0.2s, transform 0.1s;
    white-space: nowrap;
    margin-left: 4px;
    line-height: 28px;
    border: none;
    cursor: pointer;
    min-width: 40px;
}
.action-button:hover {
    opacity: 0.85;
    color: #fff !important;
    text-decoration: none;
    transform: scale(1.02);
}
.action-button:active {
    transform: scale(0.98);
}

/* Роль */
.user-role {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 12px;
    font-size: 0.6rem;
    line-height: 1.4;
    font-weight: 600;
    color: #fff;
    margin-left: 2px;
}

/* Бейдж уведомлений */
.notification-badge {
    display: inline-block;
    min-width: 18px;
    padding: 1px 6px;
    border-radius: 50%;
    font-size: 0.6rem;
    line-height: 1.2;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    margin-left: 2px;
}
.notification-badge:hover {
    opacity: 0.8;
}

/* ===== TOOLTIPS для кнопок ===== */
.has-tooltip {
    position: relative;
}

/* Основной тултип — показываем СНИЗУ от кнопки, чуть левее центра */
.has-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 10px);
    left: calc(50% - 15px);                /* ← смещено чуть левее центра */
    transform: translateX(-50%) translateY(-4px);
    background: #1e2f3f;
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
    z-index: 10000;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

/* Стрелочка СВЕРХУ тултипа — тоже чуть левее */
.has-tooltip::before {
    content: '';
    position: absolute;
    top: calc(100% + 4px);
    left: calc(50% - 15px);                /* ← стрелка тоже смещена */
    transform: translateX(-50%) translateY(-4px);
    border: 6px solid transparent;
    border-bottom-color: #1e2f3f;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
    z-index: 10000;
}

/* Показ при наведении и фокусе */
.has-tooltip:hover::after,
.has-tooltip:hover::before,
.has-tooltip:focus::after,
.has-tooltip:focus::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ===== КОРРЕКТИРОВКА ДЛЯ КРАЙНИХ КНОПОК (главная страница) ===== */

/* Кнопка у ЛЕВОГО края — тултип прижимается влево */
.has-tooltip.tooltip-left::after {
    left: 0;
    transform: translateX(0) translateY(-4px);
}
.has-tooltip.tooltip-left::before {
    left: 16px;
    transform: translateX(0) translateY(-4px);
}
.has-tooltip.tooltip-left:hover::after,
.has-tooltip.tooltip-left:hover::before,
.has-tooltip.tooltip-left:focus::after,
.has-tooltip.tooltip-left:focus::before {
    transform: translateX(0) translateY(0);
}

/* Кнопка у ПРАВОГО края — тултип прижимается вправо */
.has-tooltip.tooltip-right::after {
    left: auto;
    right: 0;
    transform: translateX(0) translateY(-4px);
}
.has-tooltip.tooltip-right::before {
    left: auto;
    right: 16px;
    transform: translateX(0) translateY(-4px);
}
.has-tooltip.tooltip-right:hover::after,
.has-tooltip.tooltip-right:hover::before,
.has-tooltip.tooltip-right:focus::after,
.has-tooltip.tooltip-right:focus::before {
    transform: translateX(0) translateY(0);
}

/* ===== В OFFCAVAS: показываем тултипы, но прижимаем к левому краю ===== */
.offcanvas-menu .has-tooltip::after {
    left: 0;
    right: auto;
    transform: translateX(0) translateY(-4px);
    white-space: normal;
    max-width: 220px;
    font-size: 0.72rem;
    padding: 5px 10px;
}
.offcanvas-menu .has-tooltip::before {
    left: 16px;
    right: auto;
    transform: translateX(0) translateY(-4px);
}
.offcanvas-menu .has-tooltip:hover::after,
.offcanvas-menu .has-tooltip:hover::before,
.offcanvas-menu .has-tooltip:focus::after,
.offcanvas-menu .has-tooltip:focus::before {
    transform: translateX(0) translateY(0);
}

/* ===== Общий адаптив ===== */
@media (max-width: 600px) {
    .user-name {
        display: none;
    }
    .action-button {
        padding: 6px 10px;
        min-width: 36px;
    }
    .notification-badge {
        font-size: 0.5rem;
        min-width: 14px;
        padding: 0 4px;
    }
    .user-profile-dropdown .dropdown-menu {
        min-width: 200px;
        right: -10px;
    }
    /* На очень маленьких экранах делаем тултипы компактнее */
    .has-tooltip::after {
        font-size: 0.7rem;
        padding: 4px 8px;
    }
}

/* ===== Отступы, чтобы контент не заезжал под фиксированную шапку ===== */
#sp-main-body,
.body-innerwrapper > .container,
.sp-page-title + .container,
.component-area {
    padding-top: 80px !important;
}

@media (max-width: 768px) {
    #sp-main-body,
    .body-innerwrapper > .container,
    .sp-page-title + .container,
    .component-area {
        padding-top: 60px !important;
    }
}

.breadcrumb,
.sp-breadcrumb,
.breadcrumbs {
    position: relative !important;
    z-index: 9998 !important;
    margin-top: 0 !important;
}

#sp-header {
    overflow: visible !important;
}
/* Пункт меню с бейджем: ссылка становится flex-контейнером */
.user-profile-dropdown .dropdown-menu li a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.user-profile-dropdown .dropdown-menu li a .dropdown-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-profile-dropdown .dropdown-menu li a .dropdown-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,.1);
}

/* ===== Значки рядом с модулем ===== */
.tiptop-userblock .header-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 30px;
    color: #fff !important;
    font-weight: 600;
    font-size: 0.8rem;
    text-decoration: none;
    line-height: 1;
    transition: opacity .2s, transform .1s;
    box-shadow: 0 2px 6px rgba(0,0,0,.12);
}

.tiptop-userblock .header-badge i {
    font-size: 0.85rem;
    color: #fff !important;
}

.tiptop-userblock .header-badge:hover {
    opacity: .88;
    transform: translateY(-1px);
    color: #fff !important;
}

.tiptop-userblock .header-badge .header-badge-count {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: .01em;
    min-width: 14px;
    text-align: center;
}

/* ===== Компактный дропдаун ===== */
.user-profile-dropdown .dropdown-menu {
    min-width: 190px;
    padding: 4px 0;
    border-radius: 10px;
    box-shadow: 0 8px 22px rgba(0,0,0,.10);
}

.user-profile-dropdown .dropdown-menu li a {
    padding: 7px 14px;
    font-size: 0.84rem;
    line-height: 1.25;
    gap: 6px;
}

.user-profile-dropdown .dropdown-menu li a:hover {
    padding-left: 18px;
}

.user-profile-dropdown .dropdown-menu li:last-child a {
    padding-top: 9px;
    margin-top: 4px;
}

@media (max-width: 600px) {
    .user-profile-dropdown .dropdown-menu {
        min-width: 170px;
        right: -8px;
    }
    .user-profile-dropdown .dropdown-menu li a {
        padding: 6px 12px;
        font-size: 0.82rem;
    }
}