/* =========================================
   THEME VARIABLES (LIGHT / DARK)
   Sidebar stays dark in BOTH modes.
========================================== */

html {
    /* Sidebar – always dark */
    --dmu-sidebar-bg: var(--background-navcolor-dark, #020617);
    --dmu-sidebar-border: rgba(148, 163, 184, 0.25);
    --dmu-sidebar-text: #e5e7eb;
    --dmu-sidebar-muted: rgba(148, 163, 184, 0.85);
    --dmu-sidebar-link: rgba(209, 213, 219, 0.9);
    --dmu-sidebar-link-hover-bg: #252525;
    --dmu-sidebar-pill-bg: #303030;

    /* Topbar – LIGHT (default) */
    --dmu-topbar-bg: #ffffff;
    --dmu-topbar-border: rgba(148, 163, 184, 0.25);
    --dmu-topbar-title: #0f172a;
    --dmu-topbar-subtitle: #6b7280;

    /* Topbar action pill */
    --dmu-topbar-link-bg: linear-gradient(120deg, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.98));
    --dmu-topbar-link-border: rgba(148, 163, 184, 0.45);
    --dmu-topbar-link-text: rgba(209, 213, 219, 0.9);
    --dmu-topbar-link-hover-bg: radial-gradient(circle at top left, rgba(94, 234, 212, 0.16), rgba(15, 23, 42, 1));
    --dmu-topbar-link-hover-border: rgba(94, 234, 212, 0.6);
    --dmu-topbar-link-hover-text: #f9fafb;

    --dmu-topbar-divider: rgba(148, 163, 184, 0.25);

    /* Dropdown – LIGHT (default) */
    --dmu-dropdown-bg: rgba(255, 255, 255, 0.98);
    --dmu-dropdown-border: rgba(148, 163, 184, 0.25);
    --dmu-dropdown-text: #111827;
    --dmu-dropdown-hover-bg: #0000001A;
    --dmu-dropdown-hover-text: #0f172a;
    --dmu-dropdown-active-text: #1f2937;
}

/* DARK MODE OVERRIDES – any "dark-*" color is treated as dark mode */
html[data-color^="dark-"] {
    /* Topbar background + border (dark theme colors) */
    --dmu-topbar-bg: var(--background-navcolor-dark, #020617);
    --dmu-topbar-border: rgba(var(--separator-rgb, 71, 71, 71), 0.9);
    --dmu-topbar-title: var(--light-text, #f0f0f0);
    --dmu-topbar-subtitle: var(--muted, #727272);

    /* Topbar action pill: use your purple gradient */
    --dmu-topbar-link-bg: linear-gradient(135deg,
            var(--gradient-1-darker, #613783),
            var(--gradient-1, #9e62c7));
    --dmu-topbar-link-border: rgba(var(--primary-rgb, 151, 103, 183), 0.9);
    --dmu-topbar-link-text: var(--light-text, #f0f0f0);

    /* Hover state for action pill */
    --dmu-topbar-link-hover-bg: linear-gradient(135deg,
            var(--gradient-1, #9e62c7),
            var(--gradient-2, #a264cb));
    --dmu-topbar-link-hover-border: rgba(var(--secondary-rgb, 213, 159, 228), 1);
    --dmu-topbar-link-hover-text: var(--light-text, #f0f0f0);

    /* Divider in topbar */
    --dmu-topbar-divider: rgba(var(--separator-rgb, 71, 71, 71), 0.85);

    /* Dropdown panel in topbar */
    --dmu-dropdown-bg: var(--foreground, #1d1d1d);
    --dmu-dropdown-border: rgba(var(--separator-rgb, 71, 71, 71), 0.9);
    --dmu-dropdown-text: var(--light-text, #f0f0f0);
    --dmu-dropdown-hover-bg: rgba(var(--primary-rgb, 151, 103, 183), 0.20);
    --dmu-dropdown-hover-text: var(--light-text, #f0f0f0);
    --dmu-dropdown-active-text: var(--light-text-darker, #e9e9e9);
}

html[data-color^="dark-"] .text-dark {
    color: var(--light-text, #f0f0f0) !important;
}

/* =========================================
   GLOBAL / MODALS / CONTAINER
========================================== */

.modal-backdrop {
    z-index: 99998 !important;
}

.modal {
    z-index: 99999 !important;
}

.container {
    padding-top: var(--main-spacing-vertical) !important;
    padding-bottom: 0 !important;
}

/* ROOT LAYOUT: sidebar + main */
#root {
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    /* keep this for the table overflow fix */
}

/* =========================================
   TOPBAR (MERGED – search + actions inline)
========================================== */

#topbar.topbar {
    position: fixed;
    top: 0;
    left: 260px;
    right: 0;
    height: 65px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: var(--main-spacing-horizontal) !important;
    padding-right: var(--main-spacing-horizontal) !important;
    background: var(--dmu-topbar-bg);
    border-bottom: 1px solid var(--dmu-topbar-border) !important;
    backdrop-filter: blur(10px);
    z-index: 1050;
    gap: 1rem;
    transition: left 0.25s ease, background-color 0.6s ease-in-out,
        color 0.6s ease-in-out, border-color 0.6s ease-in-out,
        box-shadow 0.6s ease-in-out;
}

.topbar-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
    min-width: 0;
}

#topbar .dropdown-menu {
    z-index: 1100;
}

.topbar-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--dmu-topbar-title);
}

.topbar-subtitle {
    font-size: 0.75rem;
    color: var(--dmu-topbar-subtitle);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.topbar-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.78rem;
    text-decoration: none;
    color: var(--dmu-topbar-link-text);
    border: 1px solid var(--dmu-topbar-link-border);
    background: var(--dmu-topbar-link-bg);
    transition:
        background 0.15s ease,
        color 0.15s ease,
        border-color 0.15s ease,
        transform 0.08s ease;
}

.topbar-link .icon {
    opacity: 0.85;
}

.topbar-link:hover {
    background: var(--dmu-topbar-link-hover-bg);
    color: var(--dmu-topbar-link-hover-text);
    border-color: var(--dmu-topbar-link-hover-border);
    transform: translateY(-1px);
}

.topbar-divider {
    width: 1px;
    height: 25px;
    background: var(--dmu-topbar-divider);
}

.topbar-profile {
    cursor: pointer;
}

/* =========================================
   RECENT SEARCHES & SUGGESTIONS DROPDOWN
========================================== */

/* -----------------------------------------
   Dropdown Shell
------------------------------------------ */
.dmu-recent-searches {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: min(520px, 100%);
    background: var(--foreground, #fff);
    border: 1px solid var(--separator, rgba(0, 0, 0, .12));
    border-radius: 12px;
    z-index: 50;
}

.dmu-recent-searches-header {
    padding: 9px 16px;
}

.dmu-recent-searches-title {
    font-size: 11px;
    font-weight: 500;
    opacity: .75;
}

.dmu-divider {
    height: 1px;
    background: var(--separator, rgba(0, 0, 0, .12));
    margin: 4px 0;
}

.dmu-recent-searches-empty {
    font-size: 12px;
    opacity: .7;
    padding: 10px;
}

/* -----------------------------------------
   Lists Layout
------------------------------------------ */
.dmu-recent-searches-list,
.dmu-suggest-list {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* -----------------------------------------
   Recent Rows
------------------------------------------ */
.dmu-recent-search-row {
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 10px;
}

.dmu-recent-search-item {
    flex: 1 1 auto;
    width: 100%;
    border: 0;
    background: transparent;
    padding: 8px 10px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
}

.dmu-recent-search-remove {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border: 0;
    background: transparent;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: .75;
}

.dmu-recent-search-remove:hover {
    background: rgba(0, 0, 0, .04);
    opacity: 1;
}

html[data-color^="dark-"] .dmu-recent-search-remove:hover {
    background: rgba(255, 255, 255, .06);
}

.dmu-recent-search-remove-icon {
    width: 16px !important;
    height: 16px !important;
}

.dmu-recent-search-remove:hover svg {
    stroke: var(--primary) !important;
}

/* -----------------------------------------
   Suggestions Rows
------------------------------------------ */
.dmu-suggest-item {
    width: 100%;
    border: 0;
    background: transparent;
    padding: 8px 10px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
}

/* -----------------------------------------
   Shared Icon + Text
------------------------------------------ */
.dmu-recent-search-icon {
    width: 16px !important;
    height: 16px !important;
    opacity: .7;
}

.dmu-recent-search-text {
    font-size: 13px;
    font-weight: 400;
}

/* Default (dark mode): white text + icon */
html[data-color^="dark-"] .dmu-recent-search-text,
html[data-color^="dark-"] .dmu-suggest-item .dmu-recent-search-text {
    color: #ffffff;
}

html[data-color^="dark-"] .dmu-recent-search-icon,
html[data-color^="dark-"] .dmu-suggest-item .dmu-recent-search-icon {
    color: #ffffff;
    stroke: #ffffff;
    opacity: .9;
}


/* -----------------------------------------
   Dark mode – per-item remove X white
------------------------------------------ */
html[data-color^="dark-"] .dmu-recent-search-remove {
    color: #ffffff;
}

html[data-color^="dark-"] .dmu-recent-search-remove svg,
html[data-color^="dark-"] .dmu-recent-search-remove-icon {
    color: #ffffff;
    stroke: #ffffff;
    opacity: .9;
}

/* -----------------------------------------
   Background Hover / Active States
------------------------------------------ */
/* Recent item background on hover */
.dmu-recent-search-row:hover .dmu-recent-search-item {
    background: rgba(0, 0, 0, .04);
}

html[data-color^="dark-"] .dmu-recent-search-row:hover .dmu-recent-search-item {
    background: rgba(255, 255, 255, .06);
}

/* Suggestions background on hover */
.dmu-suggest-item:hover {
    background: rgba(0, 0, 0, .04);
}

html[data-color^="dark-"] .dmu-suggest-item:hover {
    background: rgba(255, 255, 255, .06);
}

/* Keyboard active highlight */
.dmu-recent-search-item.is-active,
.dmu-suggest-item.is-active {
    background: rgba(0, 0, 0, .06);
}

html[data-color^="dark-"] .dmu-recent-search-item.is-active,
html[data-color^="dark-"] .dmu-suggest-item.is-active {
    background: rgba(255, 255, 255, .10);
}

/* -----------------------------------------
   Link Hover Style (Primary + Underline)
   Hover stays primary in BOTH modes
------------------------------------------ */
.dmu-suggest-item:hover .dmu-recent-search-text,
.dmu-recent-search-row:hover .dmu-recent-search-text,
.dmu-suggest-item.is-active .dmu-recent-search-text,
.dmu-recent-search-item.is-active .dmu-recent-search-text {
    color: var(--primary) !important;
    text-decoration: underline;
}

.dmu-suggest-item:hover .dmu-recent-search-icon,
.dmu-recent-search-row:hover .dmu-recent-search-icon,
.dmu-suggest-item.is-active .dmu-recent-search-icon,
.dmu-recent-search-item.is-active .dmu-recent-search-icon {
    color: var(--primary) !important;
    stroke: var(--primary) !important;
    opacity: 1;
}

/* =========================================
   MAIN AREA
   Hero is gone – single 65px offset.
========================================== */

main {
    margin-left: 260px;
    flex: 1 1 auto;
    padding-left: var(--main-spacing-horizontal) !important;
    margin-top: 65px;
    min-width: 0;

    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 65px);

    transition: margin-left 0.25s ease;
}

/* Backwards compat – no-op now, same values */
main.no-hero {
    margin-top: 65px;
    min-height: calc(100vh - 65px);
}

main>.container {
    flex: 1 1 auto;
    padding-top: 2rem;
    padding-bottom: 2rem;
}

/* =========================================
   COLLAPSED SIDEBAR → TOPBAR / MAIN SHIFT
========================================== */

body.sidebar-collapsed main {
    margin-left: 72px;
}

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

body.sidebar-collapsed .topbar-profile .sidebar-footer-text {
    display: none;
}

body.sidebar-collapsed .topbar-profile .d-flex.align-items-center.gap-2 {
    gap: 0.25rem;
}

/* =========================================
   RESPONSIVE TOPBAR / MAIN (MOBILE)
========================================== */

@media (max-width: 991.98px) {
    #root {
        flex-direction: column;
    }

    #topbar.topbar {
        left: 0;
        right: 0;
        z-index: 1030;
    }

    main {
        margin-left: 0;
        flex: 1 1 auto;
        padding-left: var(--main-spacing-horizontal) !important;
        margin-top: 65px;
        min-width: 0;
        min-height: auto;
    }

    main.no-hero {
        margin-top: 65px;
    }
}

/* =========================================
   THEME TRANSITIONS / REDUCED MOTION
========================================== */

html,
body,
.dmu-table-card,
.dmu-table-wrapper,
#topbar .dropdown-menu {
    transition:
        background-color 0.6s ease-in-out,
        color 0.6s ease-in-out,
        border-color 0.6s ease-in-out,
        box-shadow 0.6s ease-in-out;
}

/* Neutral overlay that softly fades during switch */
html::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 99999;

    opacity: 0;
    background: rgba(15, 23, 42, 0.04);
    transition: opacity 0.6s ease-in-out;
}

html.theme-transitioning::before {
    opacity: 1;
}

/* Disable transitions when we explicitly say "no transition" (initial load / SPA sync) */
html.theme-no-transition,
html.theme-no-transition body,
html.theme-no-transition #nav.sidebar,
html.theme-no-transition #topbar.topbar,
html.theme-no-transition main,
html.theme-no-transition .dmu-table-card,
html.theme-no-transition .dmu-table-wrapper,
html.theme-no-transition #topbar .dropdown-menu,
html.theme-no-transition::before {
    transition: none !important;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {

    html,
    body,
    #nav.sidebar,
    #topbar.topbar,
    main,
    .dmu-table-card,
    .dmu-table-wrapper,
    #topbar .dropdown-menu,
    html::before {
        transition: none !important;
    }
}

/* ─── Company Card Background ─── */

.dmu-card-bg {
    background: url('/img/background/company-card-bg.png') center center / cover no-repeat;
    opacity: 0.35;
}

.dmu-card-bg-gradient {
    background: linear-gradient(to bottom, rgba(255,255,255,0) 40%, rgba(255,255,255,1) 100%);
}

html[data-color^="dark-"] .dmu-card-bg {
    background-image: url('/img/background/company-card-dark-bg.png');
}

html[data-color^="dark-"] .dmu-card-bg-gradient {
    background: linear-gradient(to bottom, rgba(var(--foreground-rgb, 29,29,29),0) 40%, rgba(var(--foreground-rgb, 29,29,29),1) 100%);
}


/* ─── Topbar notification + mail indicators ─── */

.dmu-notification-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 9px;
    height: 9px;
    background-color: #dc3545;
    /* danger */
    border-radius: 50%;
}

.dmu-topbar-mail-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--danger, #dc3545);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
}