/* ─── DMU Tab Bar ───
   Fixed between topbar (65px) and content.
   When visible, main shifts down by --dmu-tabs-h.
   Contains: scrollable tabs (left) + page actions (right)
*/

:root {
    --dmu-tabs-h: 50px;
}

/* ─── Tab Bar Container (flex: tabs | actions) ─── */

#dmu-tabs {
    position: fixed;
    top: 65px;
    left: 260px;
    right: 0;
    height: var(--dmu-tabs-h);
    z-index: 1030;

    background: var(--dmu-topbar-bg);
    border-bottom: 1px solid var(--dmu-topbar-border);

    display: none;
    transition: left 0.25s ease;
}

#dmu-tabs:not(.d-none) {
    display: flex;
    align-items: stretch;
}

/* ─── Offset main when tabs visible ─── */

body.dmu-tabs-visible main {
    margin-top: calc(65px + var(--dmu-tabs-h));
}

/* ─── Collapsed sidebar ─── */

body.sidebar-collapsed #dmu-tabs {
    left: 72px;
}

/* ─── Mobile ─── */

@media (max-width: 991.98px) {
    #dmu-tabs {
        left: 0;
        z-index: 1019;
    }

    body.sidebar-collapsed #dmu-tabs {
        left: 0;
    }

    .dmu-tab {
        flex-shrink: 0;
    }
}

/* ─── Inner scrollable track (tabs) ─── */

.dmu-tabs-inner {
    position: relative;
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 0 var(--main-spacing-horizontal, 1.5rem);
    gap: 4px;
    height: 100%;
    align-items: center;
}

.dmu-tabs-inner::-webkit-scrollbar {
    display: none;
}

/* ─── Page Actions (right side: search + buttons) ─── */

#dmu-page-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 var(--main-spacing-horizontal, 1.5rem) 0 0.75rem;
    height: 100%;
}

/* Left divider separating tabs from actions */
#dmu-page-actions.has-actions {
    border-left: 1px solid var(--dmu-topbar-border);
}

/* Hide entirely when no actions (no search, no buttons) */
#dmu-page-actions:not(.has-actions) {
    display: none !important;
}

/* Action buttons inside page-actions: match search input/button height */
#dmu-page-actions .btn-icon-only {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#dmu-page-actions .btn-icon-start {
    height: 36px;
}

/* ─── Search form inside page actions ─── */

.dmu-page-search {
    display: flex;
    align-items: center;
    position: relative;
}

.dmu-page-search .form-control {
    font-size: 0.875rem;
    min-width: 200px;
    max-width: 300px;
    height: 36px;
}

/* Recent searches dropdown — position below the tabs bar */
.dmu-page-search .dmu-recent-searches {
    width: min(520px, calc(100vw - 2rem));
    top: calc(100% + 6px);
    right: 0;
    left: auto;
}

/* ─── Mobile search toggle ─── */

/* Toggle button: hidden on desktop, shown on mobile */
#dmu-page-actions .dmu-search-toggle {
    display: none;
}

@media (max-width: 767.98px) {

    /* Show toggle button */
    #dmu-page-actions .dmu-search-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        flex-shrink: 0;
    }

    /* Active state when search is open */
    .dmu-search-toggle.is-active {
        background: var(--primary) !important;
        border-color: var(--primary) !important;
        color: #fff !important;
    }

    .dmu-search-toggle.is-active svg {
        color: #fff !important;
        stroke: #fff !important;
    }

    /* Search form: overlay the entire tab bar */
    .dmu-page-search {
        position: absolute !important;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        display: flex !important;
        align-items: center;
        padding: 0 var(--main-spacing-horizontal, 1rem);
        background: var(--dmu-topbar-bg);
        z-index: 5;

        opacity: 0;
        visibility: hidden;
        transform: translateX(20px);
        pointer-events: none;
        transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s 0.25s;
    }

    .dmu-page-search.is-open {
        opacity: 1;
        visibility: visible;
        transform: translateX(0);
        pointer-events: auto;
        transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s 0s;
    }

    /* Inner wrapper fills the overlay */
    .dmu-page-search > .d-flex {
        flex: 1;
    }

    /* Input takes all available space */
    .dmu-page-search .form-control {
        min-width: 0 !important;
        max-width: none !important;
        flex: 1;
    }

    /* Close button inside overlay */
    .dmu-search-close {
        flex-shrink: 0;
    }

    /* Recent searches dropdown: full-width on mobile */
    .dmu-page-search .dmu-recent-searches {
        position: fixed;
        left: 0.5rem;
        right: 0.5rem;
        width: auto;
    }
}

/* ─── Individual Tab ─── */

.dmu-tab {
    display: flex;
    align-items: center;
    flex-shrink: 1;
    max-width: 200px;
    min-width: 80px;
    height: calc(var(--dmu-tabs-h) - 18px);
    padding: 0 0.25rem 0 0.75rem;
    border-radius: var(--border-radius-md, 6px);
    border: 1px solid rgba(128, 128, 128, 0.2);
    transition: background 0.15s ease;
    position: relative;
    cursor: default;
}

.dmu-tab:hover {
    background: var(--dmu-dropdown-hover-bg);
}

.dmu-tab.active {
    background: rgba(var(--primary-rgb, 151, 103, 183), 0.18);
    border: 1px solid rgba(var(--primary-rgb, 151, 103, 183), 0.25);
}

/* ─── Tab Link ─── */

.dmu-tab-link {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1;
    text-decoration: none !important;
    color: var(--dmu-topbar-subtitle) !important;
    height: 100%;
    padding-right: 0.25rem;
}

.dmu-tab.active .dmu-tab-link {
    color: var(--dmu-topbar-title) !important;
}

.dmu-tab-title {
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* ─── Active Dot ─── */

.dmu-tab.active .dmu-tab-title::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    margin-right: 6px;
    vertical-align: middle;
    flex-shrink: 0;
}

/* ─── Pin Icon ─── */

.dmu-tab-pin-icon {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
    margin-right: 3px;
    opacity: 0.45;
}

/* ─── Close Button ─── */

.dmu-tab-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border: none;
    background: none;
    padding: 0;
    border-radius: var(--border-radius-sm, 4px);
    color: var(--dmu-topbar-subtitle);
    opacity: 0.4;
    transition: opacity 0.1s ease, background 0.1s ease, color 0.1s ease;
    cursor: pointer;
}

.dmu-tab:hover .dmu-tab-close,
.dmu-tab.active .dmu-tab-close {
    opacity: 1;
}

.dmu-tab.dmu-tab-sole-home .dmu-tab-close {
    display: none;
}

.dmu-tab-close:hover {
    background: var(--dmu-dropdown-hover-bg);
    color: var(--danger, #dc3545);
}

.dmu-tab-close svg {
    width: 12px;
    height: 12px;
    pointer-events: none;
}

/* ─── Drag & Drop ─── */

.dmu-tab[draggable="true"] {
    cursor: grab;
}

.dmu-tab[draggable="true"]:active {
    cursor: grabbing;
}

.dmu-tabs-inner.is-dragging .dmu-tab:not(.is-dragging) {
    opacity: 0.45;
}

.dmu-tab.is-dragging {
    opacity: 0.35;
}

/* ─── Background tab flash ─── */

@keyframes dmu-tab-flash {
    0%   { background-color: rgba(var(--primary-rgb, 151, 103, 183), 0.30); }
    100% { background-color: transparent; }
}

.dmu-tab.dmu-tab-flash {
    animation: dmu-tab-flash 1.5s ease-out;
}

.dmu-tab-drop-indicator {
    position: absolute;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--primary);
    border-radius: 1px;
    pointer-events: none;
    z-index: 1;
}

/* ─── Theme transition sync ─── */

#dmu-tabs {
    transition:
        left 0.25s ease,
        background-color 0.6s ease-in-out,
        border-color 0.6s ease-in-out;
}

html.theme-no-transition #dmu-tabs {
    transition: none !important;
}

/* ─── Tab Context Menu ─── */

.dmu-tab-ctx,
.dmu-link-ctx {
    position: fixed;
    z-index: 10000;
    min-width: 200px;
    margin-top: 0;

    opacity: 0;
    transition: none;
    transform: scale(0.96);
    animation: dmu-ctx-in 0.15s ease forwards;
}

@keyframes dmu-ctx-in {
    to {
        opacity: 1;
        transform: scale(1);
    }
}