/**
 * Sidebar: grouped style (templates/element/new/sidebar_group_menu.php) and the menu search box
 * (templates/element/new/sidebar_menu_search.php). Loads after startbar-enhancements.css.
 * Theme tokens only, so light/dark and a theme colour change both follow automatically.
 */

/* ---------- search box (both styles) ---------- */
.startbar .sgm-search {
    padding: 4px 2px 8px;
}

.startbar .sgm-search .input-group-text,
.startbar .sgm-search .form-control {
    background-color: var(--bs-tertiary-bg, var(--bs-body-bg));
    border-color: var(--bs-border-color);
}

.startbar .sgm-search .input-group-text {
    color: var(--bs-secondary-color);
    border-right: 0;
}

.startbar .sgm-search .form-control {
    border-left: 0;
    box-shadow: none;
}

.startbar .sgm-search-results .nav-link small {
    display: block;
    font-size: 10px;
    font-weight: 400;
    color: var(--bs-secondary-color);
    line-height: 14px;
}

.startbar .sgm-search-empty {
    font-size: 12px;
    color: var(--bs-secondary-color);
    padding: 8px 12px;
}

/* ---------- grouped style ---------- */
.startbar .sgm {
    list-style: none;
}

.startbar .sgm-view {
    animation: sgm-slide-from-right 0.2s ease;
}

.startbar .sgm-view.sgm-from-left {
    animation-name: sgm-slide-from-left;
}

@keyframes sgm-slide-from-right {
    from { opacity: 0; transform: translateX(16px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes sgm-slide-from-left {
    from { opacity: 0; transform: translateX(-16px); }
    to { opacity: 1; transform: translateX(0); }
}

.startbar .startbar-menu .navbar-nav .sgm .sgm-link {
    gap: 10px;
    padding: 5px 8px;
    border-radius: 10px;
}

/* the theme's left accent bar does not belong on pill rows */
.startbar .startbar-menu .navbar-nav .sgm-view > .nav > .nav-item > .sgm-link::before {
    display: none;
}

.startbar .sgm-icon {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    background-color: var(--bs-body-bg);
    color: var(--bs-secondary-color);
    font-size: 14px;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.startbar .startbar-menu .navbar-nav .sgm .sgm-link:hover .sgm-icon {
    border-color: var(--bs-primary);
    color: var(--bs-primary);
}

/* active page link: filled primary pill, white text + white icon box */
.startbar .startbar-menu .navbar-nav .sgm .sgm-view > .nav > .nav-item > .sgm-link.active:not([data-bs-toggle]) {
    background: var(--bs-primary);
    border-color: var(--bs-primary);
    color: var(--bs-white, #fff);
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(var(--bs-primary-rgb), 0.3);
}

.startbar .startbar-menu .navbar-nav .sgm .sgm-view > .nav > .nav-item > .sgm-link.active:not([data-bs-toggle]) span {
    color: var(--bs-white, #fff);
}

.startbar .startbar-menu .navbar-nav .sgm .sgm-view > .nav > .nav-item > .sgm-link.active:not([data-bs-toggle]) .sgm-icon {
    background-color: var(--bs-white, #fff);
    border-color: var(--bs-white, #fff);
    color: var(--bs-primary);
}

/* sub-menu header that is open / holds the current page: light tint, primary text (the child
   link itself carries the highlight) — a filled pill here would hide the theme's primary text */
.startbar .startbar-menu .navbar-nav .sgm .sgm-view > .nav > .nav-item > .sgm-link[data-bs-toggle].active,
.startbar .startbar-menu .navbar-nav .sgm .sgm-view > .nav > .nav-item > .sgm-link[data-bs-toggle][aria-expanded="true"] {
    background: rgba(var(--bs-primary-rgb), 0.08);
    border-color: rgba(var(--bs-primary-rgb), 0.12);
    color: var(--bs-primary);
    box-shadow: none;
}

.startbar .startbar-menu .navbar-nav .sgm .sgm-view > .nav > .nav-item > .sgm-link[data-bs-toggle].active span,
.startbar .startbar-menu .navbar-nav .sgm .sgm-view > .nav > .nav-item > .sgm-link[data-bs-toggle][aria-expanded="true"] span {
    color: var(--bs-primary);
    font-weight: 600;
}

.startbar .startbar-menu .navbar-nav .sgm .sgm-view > .nav > .nav-item > .sgm-link[data-bs-toggle].active .sgm-icon,
.startbar .startbar-menu .navbar-nav .sgm .sgm-view > .nav > .nav-item > .sgm-link[data-bs-toggle][aria-expanded="true"] .sgm-icon {
    border-color: var(--bs-primary);
    color: var(--bs-primary);
}

.startbar .sgm-chevron {
    margin-left: auto;
    font-size: 10px;
    color: var(--bs-secondary-color);
}

.startbar .sgm-divider {
    margin: 6px 4px;
    border-color: var(--bs-border-color);
    opacity: 1;
}

.startbar .sgm-panel-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 2px 8px;
    margin-bottom: 4px;
    background-color: var(--bs-startbar-bg, var(--bs-body-bg));
    border-bottom: 1px solid var(--bs-border-color);
}

.startbar .sgm-back {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    color: var(--bs-secondary-color);
}

.startbar .sgm-back:hover {
    border-color: var(--bs-primary);
    color: var(--bs-primary);
}

.startbar .sgm-panel-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--bs-emphasis-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.startbar .sgm-section-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--bs-secondary-color);
    padding: 10px 8px 4px;
}

/* ---------- collapsed (icon-only) sidebar, xl and up ---------- */
@media (min-width: 1200px) {
    body[data-sidebar-size="collapsed"] .startbar:not(:hover) .sgm-search,
    body[data-sidebar-size="collapsed"] .startbar:not(:hover) .sgm-section-label,
    body[data-sidebar-size="collapsed"] .startbar:not(:hover) .sgm-panel-title,
    body[data-sidebar-size="collapsed"] .startbar:not(:hover) .sgm-divider {
        display: none;
    }

    body[data-sidebar-size="collapsed"] .startbar:not(:hover) .sgm-panel-header {
        justify-content: center;
    }

    body[data-sidebar-size="collapsed"] .startbar:not(:hover) .startbar-menu .navbar-nav .sgm .sgm-link {
        justify-content: center;
        padding: 5px;
    }
}

/* ---------- topbar module switcher (templates/element/new/sidebar_module_switcher.php) ---------- */
.topbar .sgm-switcher {
    margin-left: 8px;
}

.topbar .sgm-switcher-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--bs-emphasis-color);
    background-color: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.topbar .sgm-switcher-button:hover,
.topbar .sgm-switcher-button[aria-expanded="true"] {
    border-color: var(--bs-primary);
    color: var(--bs-primary);
}

.topbar .sgm-switcher-button > i {
    color: var(--bs-primary);
}

.topbar .sgm-switcher-menu {
    min-width: 240px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 6px;
    border-radius: 12px;
}

.topbar .sgm-switcher-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 8px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
}

.topbar .sgm-switcher-menu .sgm-icon {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    background-color: var(--bs-body-bg);
    color: var(--bs-secondary-color);
    font-size: 13px;
}

.topbar .sgm-switcher-check {
    margin-left: auto;
    font-size: 11px;
    visibility: hidden;
}

.topbar .sgm-switcher-menu .dropdown-item.active,
.topbar .sgm-switcher-menu .dropdown-item:active {
    background-color: var(--bs-primary);
    color: var(--bs-white, #fff);
}

.topbar .sgm-switcher-menu .dropdown-item.active .sgm-icon {
    background-color: var(--bs-white, #fff);
    border-color: var(--bs-white, #fff);
    color: var(--bs-primary);
}

.topbar .sgm-switcher-menu .dropdown-item.active .sgm-switcher-check {
    visibility: visible;
}

@media (max-width: 575.98px) {
    .topbar .sgm-switcher-button span {
        max-width: 110px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* ---------- shared module dashboard placeholder (templates/Administer/ModuleDashboards/view.php) ---------- */
.module-dashboard-icon {
    width: 72px;
    height: 72px;
}

/* ---------- Group Menu Builder (templates/Administer/Tasks/group_menu_builder.php) ---------- */
/* Two panes sized to the screen: lists scroll inside their own boxes, so the page (and the
   absolutely positioned footer under it) never moves with the number of menus. */
.gmb-modules,
.gmb-list,
.gmb-children {
    list-style: none;
    margin: 0;
    padding: 0;
}

.gmb-modules {
    max-height: calc(100vh - 330px);
    min-height: 240px;
    overflow-y: auto;
}

.gmb-module {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    margin-bottom: 4px;
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    background-color: var(--bs-body-bg);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.gmb-module:hover {
    border-color: var(--bs-primary);
}

.gmb-module.active {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: var(--bs-white, #fff);
}

.gmb-module.active .gmb-item-icon {
    background-color: var(--bs-white, #fff);
    border-color: var(--bs-white, #fff);
    color: var(--bs-primary);
}

.gmb-module.active .gmb-module-handle,
.gmb-module.active .gmb-module-count {
    color: var(--bs-white, #fff);
}

.gmb-module-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gmb-module-handle {
    cursor: move;
    color: var(--bs-secondary-color);
}

.gmb-module.gmb-drop-hover {
    border: 2px dashed var(--bs-success);
    background-color: rgba(var(--bs-success-rgb), 0.12);
    color: inherit;
}

.gmb-module.gmb-has-match:not(.active) {
    border-color: var(--bs-warning);
}

.gmb-section {
    height: 100%;
    border: 1px solid var(--bs-border-color);
    border-radius: 10px;
    padding: 6px;
    background-color: var(--bs-tertiary-bg, var(--bs-body-bg));
}

.gmb-section-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--bs-secondary-color);
    padding: 2px 4px 6px;
}

.gmb-list {
    max-height: calc(100vh - 360px);
    min-height: 200px;
    overflow-y: auto;
    border-radius: 8px;
    padding: 1px;
}

.gmb-list.gmb-empty {
    border: 1px dashed var(--bs-border-color);
}

.gmb-list.gmb-empty::after {
    content: attr(data-empty-text);
    display: block;
    font-size: 11px;
    color: var(--bs-secondary-color);
    text-align: center;
    padding: 16px 8px;
}

.gmb-children {
    margin: 2px 0 4px 22px;
    padding-left: 6px;
    border-left: 2px solid var(--bs-border-color);
    min-height: 8px;
}

/* an open sub-menu with nothing in it: a drop target with a hint */
.gmb-children.gmb-empty {
    min-height: 34px;
    border: 1px dashed var(--bs-border-color);
    border-radius: 8px;
}

.gmb-children.gmb-empty::after {
    content: attr(data-empty-text);
    display: block;
    font-size: 11px;
    color: var(--bs-secondary-color);
    text-align: center;
    padding: 8px;
}

/* a menu held over a sub-menu's row: release to put it inside */
.gmb-item-row.gmb-drop-hover {
    border: 2px dashed var(--bs-success);
    background-color: rgba(var(--bs-success-rgb), 0.12);
}

.gmb-add-submenu {
    padding: 0 5px;
    font-size: 10px;
    line-height: 18px;
}

.gmb-item-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    margin-bottom: 3px;
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    background-color: var(--bs-body-bg);
    font-size: 12px;
}

.gmb-item-row:hover {
    border-color: var(--bs-primary);
}

.gmb-item-handle {
    cursor: move;
    color: var(--bs-secondary-color);
    padding: 0 2px;
}

.gmb-item-icon {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid var(--bs-border-color);
    background-color: var(--bs-body-bg);
    color: var(--bs-secondary-color);
    font-size: 11px;
}

.gmb-item-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gmb-toggle {
    padding: 0 4px;
    font-size: 10px;
    color: var(--bs-secondary-color);
}

.gmb-placeholder {
    height: 30px;
    margin-bottom: 3px;
    border: 2px dashed var(--bs-primary);
    border-radius: 8px;
    background-color: rgba(var(--bs-primary-rgb), 0.06);
    list-style: none;
}

/* the dragged copy lives on <body> (appendTo), so it floats above both panes */
body > .gmb-item.ui-sortable-helper {
    list-style: none;
    width: 260px !important;
}

body > .gmb-item.ui-sortable-helper .gmb-item-row {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
    border-color: var(--bs-primary);
}

.gmb-item.gmb-match > .gmb-item-row {
    border-color: var(--bs-warning);
    background-color: rgba(var(--bs-warning-rgb), 0.15);
}

.gmb-item.gmb-just-moved > .gmb-item-row {
    border-color: var(--bs-success);
    background-color: rgba(var(--bs-success-rgb), 0.15);
}

@media (max-width: 991.98px) {
    .gmb-modules,
    .gmb-list {
        max-height: none;
    }
}

.gmb-module.active .gmb-module-count {
    background-color: var(--bs-white, #fff) !important;
    color: var(--bs-primary) !important;
}
