/* ========================================
   APEX Navigation System
   Sidebar, header, breadcrumbs, collapsed states
   Consolidated from: sidebar-modern.css, header-modern.css,
   navigation.css, module-layout.css (nav parts),
   base.html inline styles
   ======================================== */


/* ========================================
   1. MODERN SIDEBAR (Light Theme - Default)
   ======================================== */

.apex-sidebar-modern {
    width: var(--sidebar-width, 280px);
    height: 100vh;
    background: var(--color-surface);
    border-right: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: var(--z-fixed);
    overflow: hidden;
}

/* Brand Header */
.sidebar-modern-header {
    padding: var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.sidebar-brand-modern {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    gap: var(--space-2);
}

.brand-logo {
    width: 40px;
    height: 40px;
    background: var(--color-primary-gradient);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow-primary);
}

.brand-logo svg, .brand-logo i {
    color: var(--color-text-inverse);
    font-size: 20px;
}

.brand-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: opacity 0.2s ease, width 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
}

.brand-name {
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
    color: var(--color-primary);
    line-height: 1;
}

.brand-subtitle {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Sidebar Toggle */
.sidebar-toggle {
    position: absolute;
    top: 2rem;
    right: -12px;
    width: 24px;
    height: 24px;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    z-index: 10;
    color: var(--color-text-muted);
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    color: var(--color-primary);
    transform: scale(1.1);
}

/* Navigation Container */
.sidebar-nav-modern {
    flex: 1;
    padding: var(--space-2) var(--space-3);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav-modern::-webkit-scrollbar { width: 4px; }
.sidebar-nav-modern::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav-modern::-webkit-scrollbar-thumb { background: var(--color-background-alt); border-radius: 2px; }

/* Navigation List */
.nav-list-modern { list-style: none; margin: 0; padding: 0; }
.nav-item-modern { margin: var(--space-1) 0; }

/* Navigation Link */
.nav-link-modern {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    border-radius: var(--radius-lg);
    transition: var(--transition-smooth);
    position: relative;
}

.nav-link-modern:hover {
    background: var(--color-background);
    color: var(--color-text);
}

/* Active State - Pill Shape with Glow */
.nav-link-modern.active {
    background: var(--color-primary-gradient);
    color: var(--color-text-inverse);
    border-radius: 9999px;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
}

.nav-link-modern.active:hover {
    background: var(--color-primary-gradient);
    color: var(--color-text-inverse);
    opacity: 0.95;
}

.nav-link-modern.active::after {
    content: '';
    position: absolute;
    right: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: var(--radius-full);
}

/* Navigation Icon Container */
.nav-icon-modern {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    font-size: 16px;
    transition: var(--transition-fast);
}

.nav-link-modern:not(.active) .nav-icon-modern { background: var(--color-background); }

/* Icon color variants */
.nav-icon-modern.icon-blue { color: var(--color-primary); background: rgba(37, 99, 235, 0.1); }
.nav-icon-modern.icon-teal { color: var(--color-secondary); background: rgba(13, 148, 136, 0.1); }
.nav-icon-modern.icon-purple { color: var(--color-accent-purple); background: var(--color-accent-purple-bg); }
.nav-icon-modern.icon-pink { color: var(--color-accent-pink); background: var(--color-accent-pink-bg); }
.nav-icon-modern.icon-orange { color: var(--color-accent-orange); background: var(--color-accent-orange-bg); }
.nav-icon-modern.icon-green { color: var(--color-success); background: var(--color-success-bg); }

.nav-link-modern.active .nav-icon-modern {
    background: rgba(255, 255, 255, 0.15);
    color: var(--color-text-inverse);
}

.nav-text-modern { flex: 1; }

/* Navigation Badge */
.nav-badge-modern {
    padding: 2px 8px;
    background: var(--color-error);
    color: var(--color-text-inverse);
    font-size: 10px;
    font-weight: var(--font-bold);
    border-radius: var(--radius-full);
    min-width: 20px;
    text-align: center;
}

.nav-link-modern.active .nav-badge-modern { background: rgba(255, 255, 255, 0.25); }

/* Section Headers */
.nav-section-header {
    padding: var(--space-4) var(--space-4) var(--space-2);
    font-size: 11px;
    font-weight: var(--font-semibold);
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: var(--tracking-widest);
}


/* ========================================
   2. SIDEBAR FOOTER
   ======================================== */

.sidebar-footer-modern {
    padding: var(--space-4);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.footer-user-card {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--color-background);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition-fast);
}

.footer-user-card:hover { background: var(--color-background-alt); }

.footer-avatar {
    width: 40px;
    height: 40px;
    background: var(--color-primary-gradient);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-inverse);
    font-weight: var(--font-bold);
    font-size: var(--text-sm);
}

.footer-user-info { flex: 1; min-width: 0; }

.footer-user-name {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.footer-user-role {
    display: block;
    font-size: 11px;
    color: var(--color-text-light);
    text-transform: capitalize;
}

.hipaa-badge {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    margin-top: var(--space-2);
    font-size: 11px;
    color: var(--color-text-light);
}

.hipaa-badge i { color: var(--color-success); }


/* ========================================
   3. COLLAPSED SIDEBAR STATE
   ======================================== */

.apex-sidebar.collapsed .brand-title {
    width: 0;
    opacity: 0;
    pointer-events: none;
}

.apex-sidebar.collapsed .sidebar-brand-modern img { margin-right: 0; }

.apex-sidebar.collapsed .nav-text-modern {
    opacity: 0;
    width: 0;
    display: none;
}

.apex-sidebar.collapsed .nav-item-modern {
    justify-content: center;
    padding: 0 10px;
}

.apex-sidebar.collapsed .nav-link-modern {
    justify-content: center;
    padding: 12px;
}

.apex-sidebar.collapsed .nav-section-header,
.apex-sidebar.collapsed .nav-badge-modern,
.apex-sidebar.collapsed .footer-user-info {
    display: none;
}

/* Tooltip for collapsed state */
.apex-sidebar.collapsed .nav-link-modern::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: var(--space-3);
    padding: var(--space-2) var(--space-3);
    background: var(--neutral-800);
    color: var(--color-text-inverse);
    font-size: var(--text-xs);
    white-space: nowrap;
    border-radius: var(--radius-md);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-fast);
    z-index: var(--z-tooltip);
}

.apex-sidebar.collapsed .nav-link-modern:hover::after {
    opacity: 1;
    visibility: visible;
}


/* ========================================
   4. HEADER
   ======================================== */

.apex-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: white;
    border-bottom: 1px solid #E2E8F0;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    border: none;
    background: #F8FAFC;
    border-radius: 10px;
    color: #64748B;
    font-size: 1.125rem;
    cursor: pointer;
    transition: all 0.2s ease;
    align-items: center;
    justify-content: center;
}

.mobile-menu-btn:hover { background: #F1F5F9; color: #0F172A; }

/* Header Search */
.header-search {
    flex: 1;
    max-width: 500px;
    position: relative;
}

.header-search .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94A3B8;
    font-size: 0.9375rem;
    pointer-events: none;
}

.header-search .search-input {
    width: 100%;
    height: 44px;
    padding: 0 1rem 0 2.75rem;
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 22px;
    font-size: 0.9375rem;
    color: #0F172A;
    transition: all 0.2s ease;
}

.header-search .search-input::placeholder { color: #94A3B8; }

.header-search .search-input:focus {
    outline: none;
    background: white;
    border-color: #2563EB;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Search Shortcut Indicator */
.search-shortcut {
    position: absolute;
    right: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    padding: var(--space-1) var(--space-2);
    background: var(--neutral-200);
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: var(--font-medium);
    color: var(--color-text-light);
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    color: #64748B;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.header-btn:hover {
    background: white;
    border-color: #CBD5E1;
    color: #0F172A;
}

.header-divider {
    width: 1px;
    height: 24px;
    background: var(--neutral-200);
    margin: 0 var(--space-2);
}

/* Notification Badge */
.notification-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    color: white;
    font-size: 0.6875rem;
    font-weight: 700;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

/* Notification Panel */
.notification-panel {
    border: 1px solid #E2E8F0;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}

.notification-header {
    background: #F8FAFC;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #E2E8F0;
}

.notification-header h6 { font-size: 0.875rem; font-weight: 600; color: #0F172A; }

.notification-list { max-height: 350px; overflow-y: auto; }

.notification-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #F1F5F9;
    transition: background 0.15s ease;
}

.notification-item:hover { background: #F8FAFC; }
.notification-item:last-child { border-bottom: none; }

/* User Profile Dropdown */
.user-header-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.375rem;
    padding-right: 0.75rem;
    background: white;
    border: 1px solid #E2E8F0;
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-header-profile:hover { background: #F8FAFC; border-color: #CBD5E1; }
.user-header-profile::after { display: none; }

.user-header-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #8B5CF6 0%, #6366F1 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
}

.user-header-info { display: flex; flex-direction: column; text-align: left; }
.user-header-name { font-size: 0.875rem; font-weight: 600; color: #0F172A; line-height: 1.2; }
.user-header-role { font-size: 0.75rem; color: #64748B; line-height: 1.2; }
.user-header-chevron { font-size: 0.625rem; color: #94A3B8; margin-left: 0.25rem; }

/* User Dropdown Menu */
.user-header-profile + .dropdown-menu {
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    padding: 0.5rem;
    min-width: 200px;
}

.user-header-profile + .dropdown-menu .dropdown-item {
    padding: 0.625rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    color: #334155;
    transition: all 0.15s ease;
}

.user-header-profile + .dropdown-menu .dropdown-item:hover {
    background: #F8FAFC;
    color: #0F172A;
}

.user-header-profile + .dropdown-menu .dropdown-item i {
    width: 16px;
    text-align: center;
    color: #64748B;
}

.user-header-profile + .dropdown-menu .dropdown-divider {
    margin: 0.5rem 0;
    border-color: #E2E8F0;
}

.user-header-profile + .dropdown-menu .dropdown-item.text-danger { color: #EF4444; }
.user-header-profile + .dropdown-menu .dropdown-item.text-danger:hover { background: #FEF2F2; color: #DC2626; }


/* ========================================
   5. BREADCRUMB
   ======================================== */

.apex-breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-4) 0;
    font-size: var(--text-sm);
}

.breadcrumb-item { display: flex; align-items: center; }

.breadcrumb-item:not(:last-child)::after {
    content: '/';
    margin-left: var(--space-2);
    color: var(--color-text-light);
}

.breadcrumb-link {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.breadcrumb-link:hover { color: var(--text-primary); }
.breadcrumb-link i { font-size: 12px; }
.breadcrumb-current { color: var(--text-primary); font-weight: var(--font-medium); }


/* ========================================
   6. DARK SIDEBAR (Legacy Navigation Style)
   ======================================== */

.apex-sidebar:not(.apex-sidebar-modern) {
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--dark-navy) 0%, var(--dark-teal) 100%);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-4) 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 2px; }

.nav-list { list-style: none; margin: 0; padding: 0; }

.nav-section {
    padding: var(--space-5) var(--space-5) var(--space-2);
    font-size: 11px;
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255, 255, 255, 0.35);
}

.nav-item { margin: var(--space-1) var(--space-3); }

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    border-radius: var(--radius-lg);
    transition: var(--transition-fast);
    position: relative;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    transform: translateX(2px);
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.12);
    color: white;
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--primary-pink);
    border-radius: 0 2px 2px 0;
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    opacity: 0.8;
}

.nav-link.active .nav-icon { opacity: 1; }
.nav-text { flex: 1; }

.nav-badge {
    background: var(--primary-pink);
    color: white;
    font-size: 10px;
    font-weight: var(--font-bold);
    padding: 2px 6px;
    border-radius: var(--radius-full);
    min-width: 18px;
    text-align: center;
}

/* Submenu */
.nav-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-slow);
}

.nav-item.open .nav-submenu { max-height: 500px; }
.nav-submenu .nav-link { padding-left: var(--space-12); font-size: var(--text-xs); }
.nav-toggle-icon { transition: transform var(--transition-fast); }
.nav-item.open .nav-toggle-icon { transform: rotate(180deg); }

/* Sidebar Footer */
.sidebar-footer {
    padding: var(--space-4);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.1);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-lg);
    transition: background var(--transition-fast);
}

.user-profile:hover { background: rgba(255, 255, 255, 0.05); }

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: var(--font-bold);
    color: white;
}

.user-info { flex: 1; min-width: 0; }

.user-name {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    display: block;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: capitalize;
}

.logout-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.5);
    background: transparent;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--color-error);
}


/* ========================================
   7. RESPONSIVE NAVIGATION
   ======================================== */

@media (max-width: 1024px) {
    .apex-sidebar,
    .apex-sidebar-modern {
        position: fixed;
        transform: translateX(-100%);
        z-index: var(--z-modal);
        transition: transform var(--transition-smooth);
    }

    .apex-sidebar.open,
    .apex-sidebar-modern.open {
        transform: translateX(0);
    }

    .sidebar-overlay,
    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: calc(var(--z-modal) - 1);
    }

    .apex-sidebar.open + .sidebar-overlay,
    .sidebar-backdrop.active {
        display: block;
        opacity: 1;
        visibility: visible;
    }

    .apex-main {
        margin-left: 0;
        width: 100%;
    }

    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 767px) {
    .header-search { display: none; }
    .search-shortcut { display: none; }
    .apex-header { padding: 0.5rem 1rem; }
}

@media (max-width: 640px) {
    .apex-header { padding: 0 var(--space-4); }
}
