/* ==========================================================================
   Premium pastel sidebar
   Loaded after modern-ui.css and the layout's inline styles, so it wins.
   Items are flat (no boxed look), single line, each with a soft pastel icon tile.
   ========================================================================== */

#sidebar, .sidebar {
    background: linear-gradient(180deg, #ffffff 0%, #fbfaff 55%, #f7f5ff 100%) !important;
    border-right: 1px solid #eeebfb !important;
    box-shadow: 6px 0 30px -18px rgba(76, 29, 149, 0.25) !important;
}
#sidebar::-webkit-scrollbar-thumb { background: #e4defc !important; }

/* Brand card */
#sidebar .sidebar-brand {
    min-height: 0 !important;
    margin: 14px 14px 10px !important;
    width: auto !important;
    padding: 12px 14px !important;
    border-radius: 18px !important;
    background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 55%, #fdf2f8 100%) !important;
    border: 1px solid #ffffff !important;
    box-shadow: 0 10px 24px -18px rgba(99, 102, 241, 0.6), inset 0 1px 0 #ffffff !important;
}
#sidebar .sidebar-brand a {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    transform: none !important;
    margin: 0 !important;
    padding: 0 !important;
}
#sidebar .sidebar-brand img {
    background: #ffffff !important;
    padding: 4px !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 12px -6px rgba(15, 23, 42, 0.25) !important;
}
#sidebar .sidebar-brand span,
#sidebar .sidebar-brand .fw-bold {
    color: #1e1b4b !important;
    font-family: 'Outfit', sans-serif;
    font-weight: 800 !important;
    letter-spacing: 0.6px !important;
}

/* Section headers */
#sidebar .menu-header {
    font-size: 0.68rem !important;
    font-weight: 800 !important;
    letter-spacing: 1.4px !important;
    color: #a1a1c2 !important;
    padding: 16px 14px 6px !important;
    list-style: none;
}
#sidebar .sidebar-menu { padding: 4px 12px 12px !important; }

/* Menu items: flat, single line */
#sidebar .nav-link-custom,
#sidebar .sidebar-menu > li > a {
    display: flex !important;
    align-items: center !important;
    gap: 9px !important;
    padding: 7px 10px !important;
    margin-bottom: 3px !important;
    border-radius: 14px !important;
    background: transparent !important;
    border: 1px solid transparent !important;
    box-shadow: none !important;
    color: #475569 !important;
    font-size: 0.86rem !important;
    font-weight: 600 !important;
    line-height: 1.25 !important;
    transform: none !important;
}
#sidebar .nav-link-custom > span:not(.badge) {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Icon tile (the drag grip stays a small plain icon) */
#sidebar .nav-link-custom > i:not(.drag-grip) {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 1rem !important;
    background: var(--tile-bg, #f1f5f9);
    color: var(--tile-ink, #64748b) !important;
    transition: transform 0.2s ease, background 0.2s ease;
}
#sidebar .nav-link-custom > i.drag-grip {
    width: 10px;
    margin: 0 -4px 0 -6px !important;
    font-size: 0.8rem !important;
    color: #c4c4d8 !important;
    opacity: 0 !important;
}
#sidebar .draggable-item:hover .nav-link-custom > i.drag-grip { opacity: 1 !important; }

/* Pastel tile per module */
#sidebar [data-order-key="dashboard"]  { --tile-bg: #ede9fe; --tile-ink: #7c3aed; }
#sidebar [data-order-key^="projects"] { --tile-bg: #e0f2fe; --tile-ink: #0284c7; }
#sidebar [data-order-key^="brokerage"] { --tile-bg: #d1fae5; --tile-ink: #059669; }
#sidebar [data-order-key^="crm"]      { --tile-bg: #ffedd5; --tile-ink: #ea580c; }
#sidebar [data-order-key^="invoices"] { --tile-bg: #f3e8ff; --tile-ink: #9333ea; }
#sidebar [data-order-key^="vouchers"] { --tile-bg: #ccfbf1; --tile-ink: #0d9488; }
#sidebar [data-order-key^="payroll"]  { --tile-bg: #e0e7ff; --tile-ink: #4f46e5; }
#sidebar [data-order-key*="share"]     { --tile-bg: #fce7f3; --tile-ink: #db2777; }
#sidebar [data-order-key*="notif"]     { --tile-bg: #fef9c3; --tile-ink: #ca8a04; }
#sidebar [data-order-key*="refer"]     { --tile-bg: #fee2e2; --tile-ink: #e11d48; }

/* Hover */
#sidebar .nav-link-custom:hover,
#sidebar .sidebar-menu > li > a:hover {
    background: rgba(237, 233, 254, 0.6) !important;
    border-color: transparent !important;
    color: #4c1d95 !important;
    transform: none !important;
    box-shadow: none !important;
}
#sidebar .nav-link-custom:hover > i:not(.drag-grip) { transform: scale(1.06); }

/* Active: soft lavender pill with an accent bar and a filled icon tile */
#sidebar .nav-link-custom.active,
#sidebar .sidebar-menu > li > a.active {
    position: relative;
    background: linear-gradient(135deg, #ede9fe 0%, #e0e7ff 100%) !important;
    color: #3b0764 !important;
    font-weight: 800 !important;
    border: 1px solid #ffffff !important;
    box-shadow: 0 10px 22px -16px rgba(124, 58, 237, 0.75) !important;
}
#sidebar .nav-link-custom.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 9px;
    bottom: 9px;
    width: 4px;
    border-radius: 0 6px 6px 0;
    background: linear-gradient(180deg, #8b5cf6, #ec4899);
}
#sidebar .nav-link-custom.active > i:not(.drag-grip) {
    background: linear-gradient(135deg, #c4b5fd, #a78bfa) !important;
    color: #ffffff !important;
    box-shadow: 0 6px 14px -6px rgba(99, 102, 241, 0.8);
}

/* Locked (not in plan) items */
#sidebar .nav-link-custom.text-muted { opacity: 0.7 !important; }
#sidebar .nav-link-custom.text-muted > i:not(.drag-grip) { --tile-bg: #f1f5f9; --tile-ink: #94a3b8; }

/* Small pastel badges (NEW, Locked, counters) */
#sidebar .nav-link-custom .badge {
    font-size: 0.55rem !important;
    font-weight: 800 !important;
    letter-spacing: 0.4px;
    padding: 2px 6px !important;
    border-radius: 999px !important;
    background: #fef3c7 !important;
    color: #b45309 !important;
    border: 1px solid #fde68a !important;
    flex-shrink: 0;
}
#sidebar .nav-link-custom.active .badge {
    background: #ffffff !important;
    color: #7c3aed !important;
    border-color: #ffffff !important;
}

/* Sub menus and the module sub-panel */
#sidebar .sidebar-sub-link { color: #64748b !important; background: transparent !important; border: 0 !important; }
#sidebar .sidebar-sub-link:hover { color: #4c1d95 !important; background: rgba(237, 233, 254, 0.6) !important; }
#sidebar .sidebar-sub-link.active { color: #6d28d9 !important; background: #ede9fe !important; }
#sidebar .sub-sidebar-header { background: transparent !important; border-bottom: 1px solid #eeebfb !important; }
#sidebar .btn-back-modules {
    background: #f5f3ff !important;
    border: 1px solid #ede9fe !important;
    color: #6d28d9 !important;
}
#sidebar .btn-back-modules:hover { background: #ede9fe !important; color: #4c1d95 !important; }

/* Drag & drop target */
#sidebar .draggable-item.drag-over {
    border-top: 2px solid #a78bfa !important;
    background: rgba(237, 233, 254, 0.5) !important;
}

/* Locked items keep a neutral grey badge */
#sidebar .nav-link-custom.text-muted .badge {
    background: #f1f5f9 !important;
    color: #64748b !important;
    border-color: #e2e8f0 !important;
}

/* Module sub-panel title card (was styled for the old dark sidebar) */
#sidebar .sub-sidebar-header > div.p-2.rounded-3 {
    background: linear-gradient(135deg, #f5f3ff, #fdf2f8) !important;
    border: 1px solid #ffffff !important;
    box-shadow: 0 10px 22px -18px rgba(124, 58, 237, 0.7);
}
#sidebar .sub-sidebar-header .text-white { color: #1e1b4b !important; }

/* Touch reorder (phones): lifted item + stop the menu scrolling while you move it */
#sidebar .touch-reordering { touch-action: none; }
#sidebar .draggable-item.touch-held > a {
    background: #fff !important; transform: scale(1.03);
    box-shadow: 0 14px 30px -12px rgba(109, 40, 217, .45) !important;
    outline: 2px dashed #c4b5fd; outline-offset: 2px;
}
#sidebar .draggable-item { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
#sidebar .draggable-item.touch-held { opacity: 1 !important; }
