/* ============================================================
   Sidebar — Shell, Navigation, Brand, Toggle, Overlay
   ============================================================ */


/* ── Sidebar Shell ────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    width: var(--sidebar-width);
    flex: none;
    padding-top: 0;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100vh;
    transform: translateX(0);
    transition: transform var(--dur-slow) var(--ease-out-expo);
    background: var(--sidebar-gradient) !important;
    border-right: none;
    box-shadow: 2px 0 12px 0 rgba(0, 0, 0, 0.25);
}

.sidebar.sidebar-collapsed { transform: translateX(-100%); }

/* Custom scrollbar — thin & transparent */
.sidebar {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

.sidebar::-webkit-scrollbar       { width: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background-color: rgba(255, 255, 255, 0.08); border-radius: 10px; }
.sidebar::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, 0.2); }

.shadow-1 { box-shadow: 2px 0 12px 0 rgba(0, 0, 0, 0.25) !important; }


/* ── Mobile Navbar ────────────────────────────────────────── */
.navbar {
    z-index: 1000;
    background: var(--sidebar-bg-dark) !important;
    box-shadow: 0 1px 8px rgba(0, 40, 80, 0.12);
    display: none !important;
    padding: 0.5rem 0.75rem;
}

.navbar-brand {
    font-size: 1.125rem;
    font-weight: 600;
    padding-left: 0;
    color: #fff !important;
    gap: 0.625rem;
}

.navbar-brand .avatar { width: 2.25rem; height: 2.25rem; }
.navbar-brand span    { letter-spacing: -0.01em; color: #fff !important; }


/* ── Sidebar Toggle Button ────────────────────────────────── */
.sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    margin-right: 0.75rem;
    background: transparent;
    border: none;
    border-radius: var(--bs-border-radius-sm);
    color: var(--bs-gray-700);
    cursor: pointer;
    flex-shrink: 0;
    transition:
        background-color var(--dur-fast) var(--ease-out-expo),
        color var(--dur-fast) var(--ease-out-expo);
}

.navbar .sidebar-toggle       { color: rgba(255, 255, 255, 0.85); }
.navbar .sidebar-toggle:hover { background-color: rgba(255, 255, 255, 0.1); color: #fff; }
.sidebar-toggle:hover         { background-color: var(--bs-gray-100); color: var(--bs-heading-color); }
.sidebar-toggle:active        { background-color: var(--bs-gray-200); }
.sidebar-toggle:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 2px; }
.sidebar-toggle svg           { display: block; }

/* Animated hamburger lines */
.sidebar-toggle .toggle-line {
    transition:
        transform var(--dur-normal) var(--ease-out-expo),
        opacity var(--dur-fast) ease;
    transform-origin: center;
}

.sidebar-toggle.active .toggle-line-top { transform: translateY(6px) rotate(45deg); }
.sidebar-toggle.active .toggle-line-mid { opacity: 0; }
.sidebar-toggle.active .toggle-line-bot { transform: translateY(-6px) rotate(-45deg); }


/* ── Sidebar Overlay (mobile) ─────────────────────────────── */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition:
        opacity var(--dur-normal) var(--ease-out-expo),
        visibility var(--dur-normal) var(--ease-out-expo);
    pointer-events: none;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}


/* ── Sidebar Navigation ───────────────────────────────────── */
.show > .nav-link { background-color: transparent !important; }

#navbarVerticalMenuUsersMenu { margin-left: 15px; }

/* Primary nav links (top-level) */
.navbar-vertical-content .nav-link:not(.sidebar-submenu .nav-link) {
    color: rgba(255, 255, 255, 0.88) !important;
    padding: 0.4375rem 0.75rem !important;
    margin-bottom: 2px;
    letter-spacing: 0.005em;
    font-size: 0.8125rem;
    font-weight: 470;
    border-radius: 8px;
    margin-right: 0.375rem;
}

/* Shared base for ALL sidebar nav links */
.navbar-vertical-content .nav-link {
    align-items: center !important;
    display: flex !important;
    color: rgba(255, 255, 255, 0.88) !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.navbar-vertical-content .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.06) !important;
    color: rgba(255, 255, 255, 0.95) !important;
}

.navbar-vertical-content .nav-link:focus-visible {
    background-color: rgba(255, 255, 255, 0.06) !important;
    color: rgba(255, 255, 255, 0.95) !important;
    outline: 1.5px solid rgba(255, 255, 255, 0.15);
    outline-offset: -1.5px;
}

/* Active — frosted glass with accent */
.navbar-vertical-content .nav-link.active {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #fff !important;
    font-weight: 520;
}

.nav-link-title { color: inherit !important; }

/* Nav icons */
.nav-icon {
    opacity: 0.78;
    flex: 0 0 1.125rem;
    width: 1.125rem;
    text-align: center;
    font-size: 0.9375rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.navbar-vertical-content .nav-link:hover .nav-icon  { opacity: 0.95; }
.navbar-vertical-content .nav-link.active .nav-icon { opacity: 1; }

/* Section headers */
.sidebar .dropdown-header {
    color: rgba(255, 255, 255, 0.55) !important;
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding-left: 0.75rem;
    margin-top: 0.25rem;
    margin-bottom: 0.5rem;
}

.sidebar .dropdown-header .bg-light {
    background: rgba(0, 105, 166, 0.3) !important;
    color: rgba(255, 255, 255, 0.92) !important;
    border: 1px solid rgba(0, 105, 166, 0.25);
    font-size: 0.6rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 550;
}

/* Collapse chevron */
.navbar-vertical-content .nav-link .bi-caret-down-fill {
    font-size: 0.45rem;
    opacity: 0.4;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.navbar-vertical-content .nav-link:hover .bi-caret-down-fill { opacity: 0.7; }

.navbar-vertical-content .nav-link[aria-expanded="true"] .bi-caret-down-fill {
    transform: rotate(180deg);
    opacity: 0.8;
}

/* Submenu */
.sidebar .sidebar-submenu { border-color: rgba(255, 255, 255, 0.08) !important; }

.sidebar-submenu .nav-link {
    font-size: 0.775rem !important;
    padding: 0.375rem 0.75rem 0.375rem 0.625rem !important;
    color: rgba(255, 255, 255, 0.82) !important;
    margin-bottom: 0 !important;
    margin-right: 0 !important;
    border-radius: 7px !important;
    font-weight: 440 !important;
    letter-spacing: 0.005em !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.sidebar-submenu .nav-link:hover {
    color: #fff !important;
    background-color: rgba(255, 255, 255, 0.07) !important;
}

.sidebar-submenu .nav-link.active {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.1) !important;
    font-weight: 520 !important;
}

.sidebar-submenu .nav-link i       { font-size: 0.7rem; opacity: 0.72; flex: 0 0 0.875rem; width: 0.875rem; text-align: center; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); }
.sidebar-submenu .nav-link:hover i { opacity: 1; }
.sidebar-submenu .nav-link.active i { opacity: 1; }


/* ── Sidebar Brand ────────────────────────────────────────── */
.sidebar .sidebar-brand-name {
    color: #fff !important;
    font-weight: 650;
    letter-spacing: -0.02em;
    font-size: 0.975rem;
}

.sidebar .sidebar-brand-divider {
    display: none;
}

.sidebar-brand-wrapper {
    padding: 1rem 1rem 0.875rem;
    position: relative;
}

.sidebar-brand-wrapper::after {
    content: "";
    position: absolute;
    left: 1rem;
    right: 1rem;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.12) 50%, transparent 100%);
    pointer-events: none;
}

.sidebar-logo-circle {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: transform var(--dur-fast) var(--ease-out-expo);
}

.sidebar-logo-circle img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.sidebar-brand-wrapper:hover .sidebar-logo-circle { transform: scale(1.05); }


/* ── Sidebar Role Badge ───────────────────────────────────── */
.sidebar-role-badge {
    padding: 0 1rem;
    margin-bottom: 0.75rem;
}

.sidebar-role-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.25rem 0.75rem;
    border-radius: 50rem;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.sidebar-role-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sidebar-role-dot-platform-admin { background: var(--bs-warning); box-shadow: 0 0 6px rgba(255, 137, 86, 0.5); }
.sidebar-role-dot-platform  { background: var(--bs-primary); box-shadow: 0 0 6px rgba(0, 105, 166, 0.5); }
.sidebar-role-dot-clinic    { background: var(--bs-success); box-shadow: 0 0 6px rgba(0, 201, 167, 0.5); }
.sidebar-role-dot-staff     { background: var(--bs-indigo, #6610f2); box-shadow: 0 0 6px rgba(102, 16, 242, 0.5); }
.sidebar-role-dot-patient   { background: var(--bs-teal, #20c997);   box-shadow: 0 0 6px rgba(32, 201, 151, 0.5); }
.sidebar-role-dot-user      { background: var(--bs-info);    box-shadow: 0 0 6px rgba(9, 165, 190, 0.5); }


/* ── Sidebar Misc ─────────────────────────────────────────── */
.sidebar-nav { padding: 0 0.5rem 3.5rem 0.5rem; }

.sidebar-section-divider {
    margin-top: 0.875rem !important;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-submenu-label {
    display: block;
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.6rem;
    font-weight: 650;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding-left: 1rem;
    margin-bottom: 0.25rem;
    margin-top: 0.5rem;
}

.sidebar-submenu-divider {
    color: rgba(255, 255, 255, 0.42);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 0.5rem 0.625rem 0.25rem;
    margin-top: 0.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-submenu-divider:first-child {
    border-top: 0;
    margin-top: 0;
}

/* Bottom fade — dark gradient overlay pinned to sidebar */
.sidebar::after {
    content: '';
    position: sticky;
    bottom: 0;
    display: block;
    height: 48px;
    margin-top: -48px;
    background: linear-gradient(to top, var(--sidebar-bg-dark) 5%, transparent);
    pointer-events: none;
    z-index: 101;
    flex-shrink: 0;
}


/* ── Role Accent Stripes ──────────────────────────────────── */
.sidebar[class*="bg-primary-"] { background: var(--sidebar-gradient) !important; }

.sidebar[class*="bg-primary-"]::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 1;
}

.sidebar.bg-primary-platform-admin::before { background: var(--bs-warning); }
.sidebar.bg-primary-agency::before   { background: var(--bs-primary); }
.sidebar.bg-primary-client::before   { background: var(--bs-success); }
.sidebar.bg-primary-customer::before { background: var(--bs-info); }

.navbar[class*="bg-primary-"] { background: var(--sidebar-bg-dark) !important; }


/* ── CRM Pin Toggle Button (positioned on section divider) ──────── */
.sidebar-pinnable-section {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding-right: 0.75rem;
}

.sidebar-pinnable-section > .dropdown-header {
    margin-bottom: 0 !important;
    flex: 1 1 0;
    width: auto !important;
    min-width: 0;
    display: block;
}

.sidebar-pin-btn {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.75rem;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    padding: 0;
    flex-shrink: 0;
}

.sidebar-pin-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.35);
    color: #fff;
}

.sidebar-pin-btn.pinned {
    background: #00c9a7;
    border-color: #00c9a7;
    color: #fff;
}

.sidebar-pin-btn.pinned i {
    transform: rotate(45deg);
}

.sidebar-pin-btn.pinned:hover {
    background: #00b396;
    border-color: #00b396;
}

/* Hide caret when pinned */
.sidebar-crm-pinned .sidebar-crm-pinned-item > .nav-link .bi-caret-down-fill {
    display: none;
}

/* ── Pinned CRM Mode ── */
.sidebar.sidebar-crm-pinned .nav-item:not(.sidebar-crm-pinned-item):not(.sidebar-section-divider) {
    display: none !important;
}

.sidebar.sidebar-crm-pinned .sidebar-section-divider:not(.sidebar-crm-pinned-section) {
    display: none !important;
}

.sidebar.sidebar-crm-pinned .sidebar-crm-pinned-item {
    display: list-item !important;
}

.sidebar.sidebar-crm-pinned .sidebar-crm-pinned-item .collapse {
    display: block !important;
}

.sidebar.sidebar-crm-pinned .sidebar-crm-pinned-item > .nav-link {
    pointer-events: none;
}

/* Hide the pin button when already pinned (unpin header handles it) */
.sidebar.sidebar-crm-pinned .sidebar-pin-btn {
    display: none;
}

.sidebar.sidebar-crm-pinned .sidebar-crm-pinned-item > .nav-link .bi-caret-down-fill {
    display: none;
}

/* Pinned section header */
.sidebar-crm-pinned .sidebar-crm-pinned-header {
    display: flex !important;
}

.sidebar-crm-pinned-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem 0.5rem;
}

.sidebar-crm-pinned-header h6 {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.4);
    margin: 0;
}

.sidebar-crm-unpin-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.625rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.sidebar-crm-unpin-btn:hover {
    background: rgba(237, 76, 120, 0.2);
    color: var(--bs-danger);
}
