/* ========================================
   Header Layout (from source.css)
   ======================================== */

.navbar {
    background: var(--header-bg) !important;
    height: var(--header-height) !important;
    min-height: var(--header-height) !important;
    padding: 0 !important;
    border: 2px solid var(--header-border);
    border-bottom: none;
    border-top: none;
    box-shadow: none;
    top: 0 !important;
    z-index: 1060 !important;
    position: fixed !important;
    width: 100% !important;
}

.navbar .container-fluid {
    display: flex !important;
    height: var(--header-height) !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0 16px !important;
}

/* Логотип */
.header-logo {
    display: flex;
    align-items: center;
    padding: 4px 0;
    text-decoration: none;
}

.admin-logo-img {
    height: 28px;
    width: auto;
    max-width: 160px;
    object-fit: contain;
    display: block;
    border-radius: 6px;
    padding: 2px 8px;
    background: transparent;
    transition: all 0.2s ease;
}

.header-logo:hover .admin-logo-img {
    opacity: 0.9;
    transform: scale(1.02);
}

/* Общий стиль для всех кнопок в header */
.header-dropdown-btn,
.header-view-site-btn,
.header-quick-action-btn {
    min-width: 28px;
    height: 28px;
    padding: 0 10px !important;
    border: none !important;
    background: rgba(255, 255, 255, 0.08) !important;
    border-radius: 6px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #a0a5aa !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    text-decoration: none !important;
    transition: background 0.15s ease, color 0.15s ease !important;
    box-shadow: none !important;
    outline: none !important;
    position: relative;
    white-space: nowrap;
}

.header-dropdown-btn,
.header-view-site-btn {
    width: 28px;
    padding: 0 !important;
}

.header-dropdown-btn:hover,
.header-view-site-btn:hover,
.header-quick-action-btn:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
}

.header-dropdown-btn:focus,
.header-dropdown-btn:active,
.header-view-site-btn:focus,
.header-view-site-btn:active,
.header-quick-action-btn:focus,
.header-quick-action-btn:active {
    background: rgba(255, 255, 255, 0.2) !important;
}

.header-dropdown-btn::after {
    display: none !important;
}

.header-view-site-btn span {
    display: none !important;
}

/* Иконки быстрого доступа - соединенные кнопки */
.header-quick-actions {
    gap: 0;
    border-radius: 8px;
    overflow: visible !important;
    background: rgba(255, 255, 255, 0.1);
    position: relative;
}

.header-quick-action-btn {
    border-radius: 0 !important;
    margin: 0 !important;
    background: transparent !important;
}

.header-quick-action-btn:first-child {
    border-top-left-radius: 8px !important;
    border-bottom-left-radius: 8px !important;
}

.header-quick-action-btn:last-child {
    border-top-right-radius: 8px !important;
    border-bottom-right-radius: 8px !important;
}

/* Кнопка Интеграции - должна быть в том же стиле, что и другие */
#integrations-dropdown-toggle {
    border-radius: 0 !important;
}

.integrations-dropdown-wrapper:last-child #integrations-dropdown-toggle {
    border-top-right-radius: 8px !important;
    border-bottom-right-radius: 8px !important;
}

.header-quick-action-btn:hover {
    background: rgba(255, 255, 255, 0.15) !important;
}

.header-quick-action-btn.active {
    background: rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
}

.header-quick-action-btn i {
    font-size: 12px;
    margin-right: 4px;
}

.header-quick-action-btn span {
    font-size: 11px;
}

/* Иконки в header (только иконки без текста) */
.header-icon-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-icon-btn {
    min-width: 28px;
    width: 28px;
    height: 28px;
    padding: 0 !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    background: rgba(255, 255, 255, 0.08) !important;
    border-radius: 6px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #ffffff !important;
    font-size: 12px !important;
    text-decoration: none !important;
    transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease !important;
    box-shadow: none !important;
    outline: none !important;
    cursor: pointer;
}

.header-icon-btn:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    border-color: rgba(255, 255, 255, 0.25) !important;
    color: #ffffff !important;
}

.header-icon-btn:focus,
.header-icon-btn:active {
    background: rgba(255, 255, 255, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

.header-icon-btn i {
    font-size: 12px;
}

/* Dropdown в header-icon-btn */
.header-icon-btn.dropdown-toggle::after {
    display: none !important;
}

/* Мобильная версия header */
@media (max-width: 767.98px) {
    .navbar {
        height: var(--header-height-mobile) !important;
        min-height: var(--header-height-mobile) !important;
        border: none !important;
        box-shadow: none !important;
    }

    .navbar .container-fluid {
        height: var(--header-height-mobile) !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 0 12px !important;
        width: 100% !important;
    }

    .navbar .container-fluid > div:first-child {
        flex-shrink: 0 !important;
        min-width: auto !important;
    }

    /* Мобильная версия логотипа - оставляем как есть */
    .admin-logo-img {
        height: 32px;
        width: auto;
        max-width: 140px;
        border-radius: 8px;
        padding: 2px;
    }

    .header-dropdown-btn,
    .header-view-site-btn,
    .header-quick-action-btn {
        width: 28px !important;
        min-width: 28px !important;
        max-width: 28px !important;
        height: 28px !important;
        padding: 0 !important;
        flex-shrink: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .header-icon-btn {
        width: 28px !important;
        min-width: 28px !important;
        height: 28px !important;
    }

    .header-icon-btn i {
        font-size: 12px !important;
    }

    .navbar .container-fluid > div:last-child,
    .header-right-actions {
        display: flex !important;
        align-items: center !important;
        flex-shrink: 0 !important;
        margin-left: auto !important;
        justify-content: flex-end !important;
        width: auto !important;
        min-width: auto !important;
        max-width: none !important;
        flex-grow: 0 !important;
        gap: 8px !important;
    }

    /* Убеждаемся, что все дочерние элементы выравниваются правильно */
    .header-right-actions > * {
        flex-shrink: 0 !important;
        margin: 0 !important;
    }

    .header-quick-actions {
        background: transparent !important;
        gap: 8px !important;
        flex-shrink: 0 !important;
        display: flex !important;
        align-items: center !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 0 !important;
        overflow: visible !important;
        position: relative !important;
    }

    /* Dropdown контейнеры в header должны быть position: relative */
    .header-right-actions .dropdown {
        position: relative !important;
        display: inline-block !important;
    }

    /* Убеждаемся, что dropdown меню позиционируются правильно */
    .header-right-actions .dropdown-menu {
        position: absolute !important;
        right: 0 !important;
        left: auto !important;
        top: calc(100% + 8px) !important;
        margin-top: 0 !important;
        transform: none !important;
        display: none !important;
        z-index: 1060 !important;
    }

    /* Bootstrap show класс для отображения dropdown */
    .header-right-actions .dropdown-menu.show {
        display: block !important;
    }

    /* Для Bootstrap 5 */
    .header-right-actions .dropdown-menu[data-bs-popper] {
        position: absolute !important;
        right: 0 !important;
        left: auto !important;
        top: calc(100% + 8px) !important;
        margin-top: 0 !important;
        transform: none !important;
    }

    /* Для интеграций dropdown */
    .header-right-actions .integrations-dropdown-wrapper {
        position: relative !important;
        display: inline-block !important;
    }

    .header-right-actions .integrations-dropdown-menu {
        position: absolute !important;
        right: 0 !important;
        left: auto !important;
        top: calc(100% + 8px) !important;
        margin-top: 0 !important;
        transform: none !important;
        z-index: 1060 !important;
    }

    /* На мобильных каждая кнопка должна быть отдельной с отступами */
    .header-quick-actions .header-quick-action-btn {
        margin: 0 !important;
        border-radius: 8px !important;
        background: rgba(255, 255, 255, 0.1) !important;
    }

    .header-quick-action-btn {
        border-radius: 8px !important;
    }

    /* На мобильных все кнопки должны быть отдельными с одинаковыми скруглениями */
    .header-quick-action-btn:first-child,
    .header-quick-action-btn:last-child,
    .header-quick-action-btn {
        border-radius: 8px !important;
    }

    .header-quick-action-btn:not(.active) {
        background: rgba(255, 255, 255, 0.1) !important;
    }

    .header-quick-action-btn.active {
        background: rgba(255, 255, 255, 0.3) !important;
        color: #ffffff !important;
    }

    .header-quick-action-btn span {
        display: none !important;
    }

    /* На мобильных убираем отступы у иконок для точного центрирования */
    .header-quick-action-btn i {
        margin: 0 !important;
        line-height: 1 !important;
    }

    /* Dropdown меню Интеграции на мобильных - плоский строгий дизайн как на ПК */
    .integrations-dropdown-wrapper {
        position: relative !important;
        display: inline-block !important;
    }

    .integrations-dropdown-menu {
        position: absolute !important;
        top: calc(100% + 8px) !important;
        right: 0 !important;
        left: auto !important;
        margin-top: 0 !important;
        z-index: 1055 !important;
        min-width: 180px !important;
        max-width: calc(100vw - 24px) !important;
        display: none !important;
        opacity: 0;
        visibility: hidden;
        transform: none;
        transition: opacity 0.15s ease, visibility 0.15s ease;
        pointer-events: none;
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
    }

    .integrations-dropdown-wrapper.show .integrations-dropdown-menu,
    .integrations-dropdown-menu.show {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        pointer-events: auto !important;
    }

    .integrations-dropdown-menu .dropdown-item {
        border-radius: 0 !important;
        padding: 12px 16px !important;
        font-size: 14px !important;
        transition: background-color 0.15s ease !important;
        color: #333 !important;
        white-space: nowrap;
        border-bottom: 1px solid #f0f0f0 !important;
        background: transparent !important;
    }

    .integrations-dropdown-menu .dropdown-item:last-child {
        border-bottom: none !important;
    }

    .integrations-dropdown-menu .dropdown-item:hover,
    .integrations-dropdown-menu .dropdown-item:active {
        background: #f5f5f5 !important;
        color: #333 !important;
        transform: none !important;
    }

    .integrations-dropdown-menu .dropdown-item.active {
        background: #0073aa !important;
        color: #ffffff !important;
        font-weight: 500 !important;
        border-bottom-color: #0073aa !important;
    }

    .integrations-dropdown-menu .dropdown-item.active:hover {
        background: #005a87 !important;
        color: #ffffff !important;
    }

    .header-logo {
        text-decoration: none !important;
    }

    /* Плоский строгий дизайн для всех dropdown меню */
    .dropdown-menu {
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        margin-top: 8px !important;
        z-index: 1050 !important;
        min-width: 180px !important;
        background: #ffffff !important;
        position: absolute !important;
        right: 0 !important;
        left: auto !important;
        top: 100% !important;
        transform: none !important;
    }

    /* Dropdown контейнеры должны быть position: relative */
    .dropdown {
        position: relative !important;
    }

    .dropdown-menu .dropdown-item {
        border-radius: 0 !important;
        padding: 12px 16px !important;
        font-size: 14px !important;
        transition: background-color 0.15s ease !important;
        border-bottom: 1px solid #f0f0f0 !important;
        background: transparent !important;
    }

    .dropdown-menu .dropdown-item:last-child {
        border-bottom: none !important;
    }

    .dropdown-menu .dropdown-item:hover,
    .dropdown-menu .dropdown-item:focus {
        background: #f5f5f5 !important;
        color: #333 !important;
        transform: none !important;
    }

    .dropdown-menu .dropdown-item.active {
        background: #0073aa !important;
        color: #ffffff !important;
        font-weight: 500 !important;
    }

    .dropdown-menu .dropdown-item.active:hover {
        background: #005a87 !important;
        color: #ffffff !important;
    }

    /* Специальные стили для dropdown меню Интеграции */
    .integrations-dropdown-wrapper {
        position: relative !important;
        display: inline-block !important;
    }

    .integrations-dropdown-menu {
        position: absolute !important;
        top: calc(100% + 8px) !important;
        right: 0 !important;
        left: auto !important;
        margin-top: 0 !important;
        z-index: 1055 !important;
        min-width: 180px !important;
        display: none !important;
        opacity: 0;
        visibility: hidden;
        transform: none !important;
        transition: opacity 0.2s ease, visibility 0.2s ease;
        pointer-events: none;
    }

    .integrations-dropdown-wrapper.show .integrations-dropdown-menu,
    .integrations-dropdown-menu.show {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        pointer-events: auto !important;
    }

    /* Убираем overflow: hidden для контейнера с dropdown */
    .header-right-actions {
        overflow: visible !important;
    }

    .header-quick-actions {
        overflow: visible !important;
    }

    .dropdown-item {
        border-radius: 0 !important;
        padding: 12px 16px !important;
        font-size: 14px !important;
        transition: background-color 0.15s ease !important;
        border-bottom: 1px solid #f0f0f0 !important;
    }

    .dropdown-item:last-child {
        border-bottom: none !important;
    }

    .dropdown-item:hover {
        background: #f5f5f5 !important;
        color: #333 !important;
        transform: none !important;
    }
}
