/* ==========================================================================
   CONSOLIDATED STYLES - All CSS for Kosmo ID Application
   Includes: Form Styles, Dashboard Styles, Treeview Styles, Admin Panel Styles
   ========================================================================== */

/* ==========================================================================
   CSS VARIABLES / ROOT
   ========================================================================== */

:root {
    /* Layout Variables */
    --sidebar-width: 260px;
    --header-height: 60px;
    --desktop-navbar-height: 60px;

    /* Professional Purple-Gray Palette (Admin Theme) */
    --primary-purple: #5D3A8A;
    --primary-purple-dark: #3E2866;
    --primary-purple-light: #7C5BA8;
    --accent-purple: #8B7AB8;
    --light-purple: #E8E4F0;
    --very-light-purple: #F5F3F8;

    /* Navbar - Professional dark purple-gray */
    --navbar-purple: #3E2866;
    --navbar-purple-dark: #2D1F4A;

    /* Primary Colors (Blue) */
    --primary-500: #3B82F6;
    --primary-600: #2563EB;
    --primary-700: #1D4ED8;
    --primary-50:  #F0F6FF;
    --primary-100: #DBEAFE;
    --primary-200: #BFDBFE;
    --primary-300: #93C5FD;
    --primary-400: #60A5FA;

    /* Accent Colors (Purple) */
    --accent-500: #8B5CF6;
    --accent-400: #A78BFA;
    --accent-50:  #F5F3FF;
    --accent-100: #EDE9FE;

    /* Semantic Colors */
    --success: #059669;
    --success-light: #D1FAE5;
    --success-500: #10B981;
    --success-50:  #ECFDF5;
    --warning: #D97706;
    --warning-light: #FEF3C7;
    --warning-500: #F59E0B;
    --warning-50:  #FFFBEB;
    --danger: #DC2626;
    --danger-light: #FEE2E2;
    --error-500:   #EF4444;
    --error-50:    #FEF2F2;

    /* Neutral / Gray Palette */
    --gray-50: #FAFAFA;
    --gray-100: #F5F5F5;
    --gray-200: #E5E5E5;
    --gray-300: #D4D4D4;
    --gray-400: #A3A3A3;
    --gray-500: #737373;
    --gray-600: #525252;
    --gray-700: #404040;
    --gray-800: #262626;
    --gray-900: #171717;

    /* Neutral Palette (aliases) */
    --neutral-50:  #FAFAFA;
    --neutral-100: #F4F4F5;
    --neutral-200: #E5E7EB;
    --neutral-300: #D4D4D8;
    --neutral-400: #9CA3AF;
    --neutral-500: #6B7280;
    --neutral-600: #4B5563;
    --neutral-700: #374151;
    --neutral-800: #1F2937;
    --neutral-900: #111827;
}


/* ==========================================================================
   GLOBAL / BASE STYLES
   ========================================================================== */

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--gray-50);
    color: var(--neutral-900);
    line-height: 1.6;
    min-height: 100vh;
}

.icon-link {
    color: var(--accent-500) !important;
}


/* ==========================================================================
   MOBILE NAVBAR
   ========================================================================== */

.mobile-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: linear-gradient(90deg, var(--navbar-purple) 0%, var(--primary-purple) 100%);
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 1100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mobile-navbar-brand {
    font-size: 1.125rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mobile-navbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: white;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    transition: background 0.2s;
    padding: 0;
    z-index: 1200;
}

.mobile-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mobile-menu-toggle:active {
    background: rgba(255, 255, 255, 0.2);
}

/* Mobile Notification Button */
.mobile-notification-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.mobile-notification-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.mobile-notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: white;
    color: var(--primary-purple);
    font-size: 0.625rem;
    min-width: 16px;
    height: 16px;
    padding: 0 0.25rem;
    border-radius: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-menu-toggle i {
    pointer-events: none;
}


/* ==========================================================================
   SIDEBAR
   ========================================================================== */

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--navbar-purple) 0%, var(--primary-purple) 100%);
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1050;
    top: 0;
    left: 0;
}

/* Mobile sidebar behavior */
@media (max-width: 991px) {
    .sidebar {
        transition: transform 0.3s ease;
        transform: translateY(-100%);
        top: 56px;
        height: auto;
        max-height: calc(100vh - 56px);
        left: 0;
        right: 0;
        width: 100%;
    }

    .sidebar.show {
        transform: translateY(0);
    }
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-brand {
    padding: 1.5rem 1.25rem;
    font-size: 1.5rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex: 1;
}

.sidebar-nav {
    padding: 1.5rem 0 1rem 0;
}

.nav-item {
    margin: 0.25rem 0.75rem;
}

.nav-link {
    color: rgba(255,255,255,0.8);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s;
}

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

.nav-link i {
    width: 20px;
    text-align: center;
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* Scrollbar Styling */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.5);
}


/* ==========================================================================
   DESKTOP NAVIGATION BAR
   ========================================================================== */

.desktop-navbar {
    background: linear-gradient(90deg, var(--navbar-purple) 0%, var(--primary-purple) 100%);
    color: white;
    height: var(--desktop-navbar-height);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    gap: 2rem;
}

.desktop-navbar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.desktop-nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0.25rem;
    flex: 1;
    overflow-x: auto;
}

.desktop-nav-item {
    flex-shrink: 0;
}

.desktop-nav-link {
    color: rgba(255,255,255,0.85);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
    font-size: 0.9375rem;
}

.desktop-nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

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

.desktop-nav-link i {
    font-size: 1rem;
}


/* ==========================================================================
   LAYOUT
   ========================================================================== */

.admin-layout {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    background: var(--gray-50);
    min-width: 0;
}

@media (min-width: 992px) {
    .main-content {
        margin-left: 0;
    }
}

@media (max-width: 991px) {
    .main-content {
        margin-left: 0;
    }
}

/* Top Header */
.top-header {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 1rem;
}

@media (min-width: 992px) {
    .top-header {
        position: relative;
    }
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Content Area */
.content-area {
    padding: 1rem;
}

@media (max-width: 991px) {
    .content-area {
        padding-top: 1rem;
        margin-top: 56px;
    }
}


/* ==========================================================================
   STATS CARDS
   ========================================================================== */

.stats-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    justify-content: center;
}

@media (min-width: 992px) {
    .stats-cards {
        margin-top: 2rem;
        margin-bottom: 2rem;
        justify-content: flex-end;
    }
}

.stat-card {
    background: white;
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid var(--gray-200);
    border-left: 4px solid;
    min-width: 150px;
}

.stat-card.entities {
    border-left-color: var(--primary-purple);
}

.stat-card.users {
    border-left-color: var(--success);
}

.stat-card.pending {
    border-left-color: var(--warning);
}

.stat-label {
    color: var(--gray-500);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--gray-900);
}


/* ==========================================================================
   SEARCH BAR
   ========================================================================== */

.search-bar {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-bar input {
    padding-left: 2.5rem;
    width: 100%;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
}

.search-bar input:focus {
    border-color: var(--primary-purple);
    box-shadow: 0 0 0 3px var(--very-light-purple);
}

.search-bar i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
}


/* ==========================================================================
   FILTER TAGS
   ========================================================================== */

.filter-tags {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-tag {
    padding: 0.5rem 1rem;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    color: var(--gray-600);
}

.filter-tag:hover {
    border-color: var(--primary-purple-light);
    background: var(--very-light-purple);
}

.filter-tag.active {
    background: var(--light-purple);
    color: var(--primary-purple-dark);
    border-color: #D4CFE0;
}

/* Sort Dropdown in Filter Tags */
.filter-tag.dropdown-toggle::after {
    display: none;
}

.filter-tag .bi-chevron-down {
    font-size: 0.75rem;
    transition: transform 0.2s;
}

.filter-tag[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

.sort-dropdown-menu {
    min-width: 180px;
    padding: 0.5rem 0;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.sort-dropdown-menu .dropdown-item {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sort-dropdown-menu .dropdown-item:hover {
    background: var(--very-light-purple);
    color: var(--primary-purple);
}

.sort-dropdown-menu .dropdown-item.active {
    background: var(--light-purple);
    color: var(--primary-purple-dark);
}

.sort-dropdown-menu .dropdown-item i {
    width: 16px;
    text-align: center;
}

/* Clear Filter Button */
.filter-tag.clear-filter {
    border-color: var(--gray-300);
    color: var(--gray-500);
}

.filter-tag.clear-filter:hover {
    border-color: var(--danger);
    background: var(--danger-light);
    color: var(--danger);
}

/* Active sort indicator */
.filter-tag.has-sort {
    background: var(--light-purple);
    color: var(--primary-purple-dark);
    border-color: #D4CFE0;
}


/* ==========================================================================
   CUSTOM MULTI-SELECT COMPONENT
   ========================================================================== */

/* Main filter bar container */
.filter-bar {
    display: flex;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

/* Multi-select container */
.multi-select {
    position: relative;
    min-width: 200px;
    flex: 1;
    max-width: 320px;
}

/* The clickable select box */
.multi-select-box {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.375rem;
    min-height: 42px;
    padding: 0.375rem 2.25rem 0.375rem 0.75rem;
    background: white;
    border: 1.5px solid var(--neutral-300);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.multi-select-box:hover {
    border-color: var(--primary-purple-light);
}

.multi-select.open .multi-select-box {
    border-color: var(--primary-purple);
    box-shadow: 0 0 0 3px rgba(93, 58, 138, 0.15);
}

/* Placeholder text */
.multi-select-placeholder {
    color: var(--neutral-400);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.multi-select-placeholder i {
    font-size: 1rem;
    color: var(--neutral-400);
}

/* Dropdown arrow */
.multi-select-arrow {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--neutral-400);
    font-size: 0.75rem;
    pointer-events: none;
    transition: transform 0.2s;
}

.multi-select.open .multi-select-arrow {
    transform: translateY(-50%) rotate(180deg);
}

/* Selected chips inside the box */
.multi-select-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--light-purple);
    border-radius: 4px;
    font-size: 0.8125rem;
    color: var(--primary-purple-dark);
    white-space: nowrap;
    max-width: 150px;
}

.multi-select-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.multi-select-chip .chip-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 0.125rem;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--primary-purple);
    font-size: 0.75rem;
    padding: 0;
    transition: all 0.15s;
    flex-shrink: 0;
}

.multi-select-chip .chip-remove:hover {
    background: var(--primary-purple);
    color: white;
}

/* Tag chips with custom colors */
.multi-select-chip.tag-chip {
    background: var(--light-purple);
}

/* Dropdown panel */
.multi-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 1050;
    display: none;
    max-height: 300px;
    overflow: hidden;
}

.multi-select.open .multi-select-dropdown {
    display: block;
}

/* Search input inside dropdown */
.multi-select-search {
    padding: 0.75rem;
    border-bottom: 1px solid var(--neutral-100);
}

.multi-select-search input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--neutral-200);
    border-radius: 6px;
    font-size: 0.875rem;
    outline: none;
}

.multi-select-search input:focus {
    border-color: var(--primary-purple-light);
}

.multi-select-search input::placeholder {
    color: var(--neutral-400);
}

/* Options list */
.multi-select-options {
    max-height: 240px;
    overflow-y: auto;
    padding: 0.375rem 0;
}

/* Option group header */
.multi-select-group {
    padding: 0.5rem 0.75rem 0.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--neutral-500);
}

/* Individual option */
.multi-select-option {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background 0.15s;
}

.multi-select-option:hover {
    background: var(--very-light-purple);
}

.multi-select-option.selected {
    background: var(--light-purple);
}

/* Custom checkbox */
.multi-select-option .option-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--neutral-300);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}

.multi-select-option.selected .option-checkbox {
    background: var(--primary-purple);
    border-color: var(--primary-purple);
}

.multi-select-option .option-checkbox i {
    color: white;
    font-size: 0.75rem;
    opacity: 0;
}

.multi-select-option.selected .option-checkbox i {
    opacity: 1;
}

/* Option icon and label */
.multi-select-option .option-icon {
    width: 20px;
    text-align: center;
    color: var(--neutral-500);
    font-size: 0.9375rem;
}

.multi-select-option.selected .option-icon {
    color: var(--primary-purple);
}

.multi-select-option .option-label {
    flex: 1;
    font-size: 0.875rem;
    color: var(--neutral-700);
}

.multi-select-option.selected .option-label {
    color: var(--primary-purple-dark);
    font-weight: 500;
}

/* Tag color dot */
.tag-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* No results message */
.multi-select-empty {
    padding: 1rem;
    text-align: center;
    color: var(--neutral-400);
    font-size: 0.875rem;
}

/* Search bar */
.filter-search-bar {
    position: relative;
    flex: 1;
    min-width: 180px;
    max-width: 280px;
}

.filter-search-bar input {
    width: 100%;
    height: 42px;
    padding: 0.5rem 0.875rem 0.5rem 2.5rem;
    border: 1.5px solid var(--neutral-300);
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.2s;
    background: white;
}

.filter-search-bar input:hover {
    border-color: var(--primary-purple-light);
}

.filter-search-bar input:focus {
    border-color: var(--primary-purple);
    box-shadow: 0 0 0 3px rgba(93, 58, 138, 0.15);
    outline: none;
}

.filter-search-bar input::placeholder {
    color: var(--neutral-400);
}

.filter-search-bar .search-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--neutral-400);
    font-size: 1rem;
    pointer-events: none;
}

/* Filter bar spacer - pushes stats to right */
.filter-spacer {
    flex: 1;
    min-width: 0;
}

/* Inline stats text */
.filter-stats {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.stats-text {
    font-size: 0.875rem;
    color: var(--gray-500);
    white-space: nowrap;
}

.stats-total {
    color: var(--gray-600);
}

.stats-separator {
    margin: 0 0.5rem;
    color: var(--gray-400);
}

.stats-pending {
    color: var(--warning);
    font-weight: 500;
}

/* Sortable table headers */
.entity-table thead th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s;
}

.entity-table thead th.sortable:hover {
    background: var(--gray-100);
}

.entity-table thead th.sortable .sort-icon {
    display: inline-flex;
    align-items: center;
    margin-left: 0.375rem;
    color: var(--gray-400);
    font-size: 0.75rem;
}

.entity-table thead th.sortable.sorted .sort-icon {
    color: var(--primary-purple);
}

.entity-table thead th.sortable .sort-icon i {
    transition: transform 0.15s;
}

/* Mobile responsive */
@media (max-width: 767.98px) {
    .filter-bar {
        flex-direction: column;
        gap: 0.5rem;
    }

    .multi-select {
        max-width: none;
        width: 100%;
    }

    .filter-search-bar {
        max-width: none;
        width: 100%;
    }
    
    .filter-spacer {
        display: none;
    }
    
    .filter-stats {
        width: 100%;
        justify-content: flex-end;
        padding-top: 0.25rem;
    }

    .multi-select-chip {
        font-size: 0.75rem;
        padding: 0.1875rem 0.375rem;
        max-width: 120px;
    }

    .multi-select-dropdown {
        position: fixed;
        left: 1rem;
        right: 1rem;
        top: auto;
        bottom: 0;
        max-height: 50vh;
        border-radius: 12px 12px 0 0;
    }
}


/* ==========================================================================
   ENTITY TABLE
   ========================================================================== */

.entity-table-container {
    background: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--gray-200);
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.table-header h4 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-900);
}

/* Entity Table */
.entity-table {
    margin-bottom: 1.5rem;
    border: none;
}

.entity-table thead th {
    background: var(--gray-50);
    border: none;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-600);
    padding: 0.875rem 0.75rem;
    white-space: nowrap;
}

.entity-table tbody tr {
    transition: background-color 0.2s;
    border-bottom: 1px solid var(--gray-100);
}

.entity-table tbody tr:last-child {
    border-bottom: none;
}

.entity-table tbody tr:first-child td {
    border-top: none;
}

.entity-table tbody tr:hover {
    background-color: var(--gray-50);
}

.entity-table tbody td {
    vertical-align: middle;
    padding: 1rem 0.75rem;
    border: none;
}

/* Entity Type Icon */
.entity-type-icon {
    width: 36px;
    height: 36px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
}

.entity-type-icon.company {
    background: var(--light-purple);
    color: var(--primary-purple-dark);
}

.entity-type-icon.person {
    background: var(--light-purple);
    color: var(--primary-purple-dark);
}

/* Entity Name Cell */
.entity-name-cell {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.entity-name-cell .name {
    font-weight: 600;
    color: var(--gray-900);
    font-size: 0.9375rem;
}

/* Clickable entity name link */
.entity-name-link {
    font-weight: 600;
    color: var(--gray-900);
    font-size: 0.9375rem;
    text-decoration: none;
    transition: color 0.15s;
}

.entity-name-link:hover {
    color: var(--primary-purple);
    text-decoration: underline;
}

.uuid-mobile {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* Entity UUID */
.entity-uuid {
    font-size: 0.8125rem;
    color: var(--gray-500);
    background: var(--gray-50);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}

/* Creator and Time */
.creator-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.creator-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    line-height: 1.3;
    display: block;
}

.creator-email {
    font-size: 0.75rem;
    color: var(--gray-400);
    line-height: 1.3;
    display: block;
}

.update-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.update-date {
    font-size: 0.8125rem;
    color: var(--gray-600);
    line-height: 1.3;
    display: block;
}

.update-time {
    font-size: 0.75rem;
    color: var(--gray-400);
    line-height: 1.3;
    display: block;
}

/* Relations Icons */
.relations-icons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.relation-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--very-light-purple);
    color: var(--primary-purple);
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.relation-icon i {
    font-size: 0.875rem;
}

/* Structure badges for admin dashboard */
.structure-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-500);
}

.structure-badge i {
    font-size: 0.875rem;
}

.structure-badges {
    flex-wrap: nowrap;
}

/* ==========================================================================
   ENTITY PROGRESS BAR
   ========================================================================== */

.entity-progress {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    min-width: 90px;
    max-width: 140px;
}

/* Progress bar wrapper */
.progress-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.progress-bar-track {
    flex: 1;
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.progress-bar-fill.complete {
    background: var(--success);
}

.progress-bar-fill.partial {
    background: var(--warning);
}

.progress-bar-fill.low {
    background: var(--gray-400);
}

.progress-percentage {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-600);
    min-width: 32px;
    text-align: right;
}

/* Section indicators */
.progress-sections {
    display: flex;
    gap: 0.25rem;
}

.section-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    transition: all 0.15s ease;
    cursor: default;
}

.section-dot.complete {
    background: var(--success-light);
    color: var(--success);
}

.section-dot.partial {
    background: var(--warning-light);
    color: var(--warning);
}

.section-dot.incomplete {
    background: var(--gray-100);
    color: var(--gray-400);
}

.section-dot:hover {
    transform: scale(1.1);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .entity-progress {
        min-width: 70px;
        max-width: 100px;
    }
    
    .progress-percentage {
        font-size: 0.6875rem;
        min-width: 28px;
    }
    
    .section-dot {
        width: 18px;
        height: 18px;
        font-size: 0.625rem;
    }
}


/* ==========================================================================
   STATUS BADGES
   ========================================================================== */

.status-badge {
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.status-badge.complete {
    background: var(--success-light);
    color: var(--success);
}

.status-badge.incomplete {
    background: var(--warning-light);
    color: var(--warning);
}

.status-badge.missing {
    background: var(--danger-light);
    color: var(--danger);
}

/* Approval Status Badges */
.approval-badge {
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

.approval-badge:hover {
    filter: brightness(0.95);
}

.approval-badge:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}

.approval-badge.dropdown-toggle::after {
    margin-left: 0.5rem;
    vertical-align: middle;
}

.approval-badge.pending {
    background: var(--warning-light);
    color: var(--warning);
}

.approval-badge.draft {
    background: var(--neutral-200);
    color: var(--neutral-500);
}

.approval-badge.info-required {
    background: #DBEAFE;
    color: #2563EB;
}

.approval-badge.approved {
    background: var(--success-light);
    color: var(--success);
}

.approval-badge.rejected {
    background: var(--danger-light);
    color: var(--danger);
}


/* ==========================================================================
   ACTION BUTTONS
   ========================================================================== */

.action-btns {
    display: flex;
    gap: 0.5rem;
}

.btn-action {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--gray-200);
    background: white;
    color: var(--gray-600);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-action:hover {
    background: var(--gray-50);
    border-color: var(--primary-purple);
    color: var(--primary-purple);
}

.btn-action.btn-warning {
    border-color: var(--warning);
    color: var(--warning);
}

.btn-action.btn-warning:hover {
    background: var(--warning-light);
}

/* Table Footer */
.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.showing-text {
    color: var(--gray-500);
}

/* User Avatar */
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-purple);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    flex-shrink: 0;
}

/* Notification Badge */
.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: white;
    font-size: 0.625rem;
    padding: 0.125rem 0.375rem;
    border-radius: 1rem;
    font-weight: 600;
}


/* ==========================================================================
   PAGINATION
   ========================================================================== */

.pagination .page-link {
    color: var(--primary-purple);
    border-color: var(--gray-200);
    background-color: white;
}

.pagination .page-link:hover {
    color: var(--primary-purple-dark);
    background-color: var(--very-light-purple);
    border-color: var(--primary-purple-light);
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-purple);
    border-color: var(--primary-purple);
    color: white;
}

.pagination .page-item.disabled .page-link {
    color: var(--gray-400);
    background-color: var(--gray-50);
    border-color: var(--gray-200);
}


/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn-primary {
    background-color: var(--primary-purple);
    border-color: var(--primary-purple);
    color: white;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary:hover {
    background-color: var(--primary-purple-dark);
    border-color: var(--primary-purple-dark);
    color: white;
    box-shadow: 0 4px 12px rgba(93, 58, 138, 0.25);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--neutral-100);
    border: 1.5px solid var(--neutral-300);
    color: var(--neutral-700);
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
}

.btn-secondary:hover {
    background: var(--neutral-200);
    border-color: var(--neutral-400);
    color: var(--neutral-800);
}

.btn-outline-secondary {
    color: var(--gray-600);
    border-color: var(--gray-300);
}

.btn-outline-secondary:hover {
    background-color: var(--gray-100);
    border-color: var(--gray-400);
    color: var(--gray-700);
}

.btn {
    margin-top: 1rem;
}

/* Align the height of the buttons in input groups */
.input-group button {
    margin: initial;
}


/* ==========================================================================
   FORMS
   ========================================================================== */

/* Form Container */
.form-container {
    background: white;
    padding: 0 0 0 0;
    max-width: 720px;
    margin: 0 auto;
}

/* Fieldset */
fieldset {
    border: 1.5px solid var(--neutral-200);
    border-radius: 12px;
    background: var(--neutral-50);
    padding: 1.5rem;
    margin-bottom: 2rem;
    transition: border-color 0.25s, background 0.25s;
}

fieldset:focus-within {
    border-color: var(--neutral-200);
    background: var(--neutral-50);
    box-shadow: none;
}

fieldset legend {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-500) !important;
}

.surrounded-legend {
    color: var(--neutral-600) !important;
}

.progress-bar {
    background-color: var(--primary-purple);
}

.accordion-button:not(.collapsed) {
    background-color: var(--very-light-purple);
    color: var(--primary-purple);
}

/* Form Groups */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--neutral-600);
    font-weight: 600;
    font-size: 0.9rem;
}

/* Inputs & Selects */
.form-control,
.form-select {
    display: block;
    width: 100%;
    border: 1.5px solid var(--neutral-300);
    border-radius: 8px;
    padding: 0.7rem 0.9rem;
    font-size: 0.95rem;
    line-height: 1.4;
    background: white;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-control:hover,
.form-select:hover {
    border-color: var(--primary-purple-light);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-purple);
    background: var(--very-light-purple);
    box-shadow: 0 0 0 3px rgba(93, 58, 138, 0.15);
}

.form-control:disabled,
.form-select:disabled {
    background: var(--neutral-100);
    border-color: var(--neutral-200);
    color: var(--neutral-500);
}

/* Placeholder */
.form-control::placeholder,
.form-select::placeholder {
    color: var(--neutral-400);
}

/* Checkbox */
.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.form-check-input {
    border: 1.5px solid var(--neutral-400);
    border-radius: 4px;
    width: 1.2em;
    height: 1.2em;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-check-input:checked {
    background-color: var(--primary-purple);
    border-color: var(--primary-purple);
}

.form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(93, 58, 138, 0.2);
}

.form-check-label {
    color: var(--neutral-600);
    font-weight: 500;
}

/* Validation */
.is-valid {
    border-color: var(--success) !important;
    background: var(--success-50);
}

.is-invalid {
    border-color: var(--error-500) !important;
    background: var(--error-50);
}

.valid-feedback {
    color: var(--success);
}

.invalid-feedback {
    color: var(--error-500);
}

/* Section Headers */
.form-section-header {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-purple);
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--light-purple);
}

/* Custom select arrow */
.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%23374151' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' viewBox='0 0 16 16'%3e%3cpath d='m1 6 7 7 7-7'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}


/* ==========================================================================
   HTMX LOADING STATES
   ========================================================================== */

.htmx-indicator {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
}

.htmx-indicator.htmx-request {
    display: flex;
}

.htmx-overlay-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.htmx-overlay-content {
    position: relative;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.htmx-overlay-content img {
    width: 60px;
    height: 60px;
}

.htmx-request .form-control,
.htmx-request .form-select {
    background: var(--neutral-100);
    cursor: wait;
}

/* Target the select element ONLY when the htmx-request class is present */
.htmx-request.form-select {
    color: transparent;
    background-image: url("data:image/svg+xml,%3csvg width='16' height='16' viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M8 1.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13zM0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8z' fill='%236c757d' fill-rule='evenodd'/%3e%3cpath d='M8 1.5A6.5 6.5 0 1 0 8 15V1.5z' fill='%23fff'%3e%3canimateTransform attributeName='transform' type='rotate' from='0 8 8' to='360 8 8' dur='1s' repeatCount='indefinite'/%3e%3c/path%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 1rem 1rem;
}


/* ==========================================================================
   MODALS
   ========================================================================== */

#networkModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 9999;
}

#statusChangeModal .modal-header {
    border-bottom: 1px solid var(--neutral-200);
}

#statusChangeModal .modal-footer {
    border-top: 1px solid var(--neutral-200);
}

#statusChangeModal textarea {
    resize: vertical;
    min-height: 100px;
}

#statusChangeModal .form-text {
    color: var(--neutral-500);
    font-size: 0.8rem;
}

#email-notification-info {
    background-color: var(--very-light-purple);
    border-color: var(--light-purple);
    color: var(--primary-purple);
}


/* ==========================================================================
   TIMELINE
   ========================================================================== */

.timeline {
    position: relative;
    padding-left: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--neutral-200);
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: -30px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 10px;
}

.timeline-content {
    background: var(--neutral-50);
    padding: 12px 15px;
    border-radius: 8px;
    border: 1px solid var(--neutral-200);
    transition: border-color 0.15s ease;
}

.timeline-content:hover {
    border-color: var(--neutral-300);
}


/* ==========================================================================
   BADGE OVERRIDES
   ========================================================================== */

.badge.text-bg-secondary {
    background-color: var(--neutral-500) !important;
}

.badge.text-bg-warning {
    background-color: var(--warning) !important;
    color: white !important;
}

.badge.text-bg-success {
    background-color: var(--success) !important;
}

.badge.text-bg-danger {
    background-color: var(--error-500) !important;
}

.badge.text-bg-info {
    background-color: var(--primary-400) !important;
    color: white !important;
}

.badge.bg-danger {
    background-color: var(--error-500) !important;
}

.badge.bg-warning {
    background-color: var(--warning) !important;
}

.badge.bg-secondary {
    background-color: var(--neutral-500) !important;
}

.badge.bg-item-count {
    background-color: var(--gray-400) !important;
}


/* ==========================================================================
   STATUS LEGEND
   ========================================================================== */

.status-legend {
    background: var(--neutral-50);
    border: 1px solid var(--neutral-200);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1.5rem;
}

.status-legend h6 {
    color: var(--neutral-700);
    margin-bottom: 0.75rem;
}

.status-legend .badge {
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}


/* ==========================================================================
   ENTITY VIEW PAGE
   ========================================================================== */

/* Purple text utility classes */
.text-purple {
    color: var(--primary-purple) !important;
}

.text-purple-light {
    color: var(--primary-purple-light) !important;
}

/* Section headers in entity view */
.entity-section-header {
    font-weight: 700;
    color: var(--primary-purple);
    margin-bottom: 0.75rem;
}

/* Collapsible card header styling */
.card-header[data-bs-toggle="collapse"] {
    cursor: pointer;
    transition: background-color 0.2s;
}

.card-header[data-bs-toggle="collapse"]:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.card-header[data-bs-toggle="collapse"] .bi-chevron-down {
    transition: transform 0.3s;
}

.card-header[data-bs-toggle="collapse"].collapsed .bi-chevron-down {
    transform: rotate(-90deg);
}

.card-header[data-bs-toggle="collapse"][aria-expanded="false"] .bi-chevron-down {
    transform: rotate(-90deg);
}

/* Definition list styling for entity details */
.entity-details dl.row dt {
    font-weight: 500;
    color: var(--neutral-500);
}

.entity-details dl.row dd {
    color: var(--neutral-800);
}

/* Address styling */
.entity-details address {
    font-style: normal;
    line-height: 1.6;
    color: var(--neutral-700);
}

/* Entity view card styling */
.entity-view-card {
    border: 1px solid var(--neutral-200);
    /* border-radius: 0.75rem; */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.entity-view-card .card-header {
    background-color: var(--neutral-50);
    border-bottom: 1px solid var(--neutral-200);
}

.entity-view-card .card-title {
    color: var(--neutral-800);
    font-weight: 600;
}

/* Children section badges */
.entity-view-card .badge.bg-secondary {
    background-color: var(--accent-purple) !important;
}

/* Action buttons in entity view */
.entity-view-actions .btn-outline-secondary {
    border-color: var(--neutral-300);
    color: var(--neutral-700);
}

.entity-view-actions .btn-outline-secondary:hover {
    background-color: var(--neutral-100);
    border-color: var(--neutral-400);
}

.entity-view-actions .btn-outline-primary {
    border-color: var(--primary-purple-light);
    color: var(--primary-purple);
}

.entity-view-actions .btn-outline-primary:hover {
    background-color: var(--very-light-purple);
    border-color: var(--primary-purple);
}

/* Children tables styling */
.entity-children-table {
    font-size: 0.9rem;
}

.entity-children-table thead {
    background-color: var(--neutral-50);
}

.entity-children-table th {
    font-weight: 600;
    color: var(--neutral-600);
    border-bottom: 2px solid var(--neutral-200);
}

.entity-children-table td {
    vertical-align: middle;
    border-bottom: none;
}

.entity-children-table tbody tr:hover {
    background-color: var(--neutral-50);
}

/* Remove borders from all table rows in entity view (except headers) */
.entity-view-card table td {
    border: none;
}

.entity-view-card table tbody tr {
    border: none;
}

.entity-view-card table thead th {
    font-weight: 600;
    color: var(--neutral-600);
    border-bottom: 1px solid var(--neutral-200);
    border-top: none;
    border-left: none;
    border-right: none;
}

.entity-view-card table tbody tr:hover {
    background-color: var(--neutral-50);
}

/* Pending invitation table styling */
.entity-view-card .alert table {
    font-size: 0.85rem;
}

.entity-view-card .alert table td {
    vertical-align: middle;
}

.entity-view-card .alert table td small {
    font-size: 0.75rem;
}

/* Entity type badge in invitation tables */
.entity-view-card .badge-entity-type {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.25em 0.5em;
}

.entity-view-card .badge-entity-type.company {
    background-color: var(--primary-purple) !important;
    color: #fff;
}

.entity-view-card .badge-entity-type.individual {
    background-color: var(--primary-purple-light) !important;
    color: #fff;
}

/* Type badges in children tables - keeping for backwards compatibility */
.entity-children-table .badge.bg-primary {
    background-color: var(--primary-purple) !important;
}

.entity-children-table .badge.bg-info {
    background-color: var(--primary-purple-light) !important;
}


/* ==========================================================================
   TREEVIEW COMPONENT
   ========================================================================== */

/* Base container for the treeview instance */
.custom-treeview-wrapper {
    background-color: #fff;
    padding: 15px;
    border-radius: 5px;
    margin: 10px auto;
}

/* Wrapper for search input and clear button */
.treeview-search-input-wrapper {
    position: relative;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
}

/* Search input specific to the library */
.treeview-search-input {
    width: 100%;
    padding: 8px 30px 8px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 0.9em;
}

/* Styling for the clear button */
.treeview-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #888;
    font-size: 1.2em;
    border: none;
    padding: 0;
    line-height: 1;
    display: none;
}

.treeview-search-clear:hover {
    color: #555;
}

/* Tree structure styling */
.custom-treeview-wrapper ul {
    list-style: none;
    padding-left: 20px;
    margin: 0;
}

.custom-treeview-wrapper li > ul {
    height: 0;
    overflow: hidden;
    transition: height 0.3s ease-out;
}

.custom-treeview-wrapper li {
    margin: 5px 0;
    position: relative;
    font-size: 0.95em;
    color: #333;
    cursor: default;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Wrapper for expander icon and text (flexbox container) */
.custom-treeview-wrapper .treeview-node-content {
    display: flex;
    align-items: center;
    padding-left: 0;
    cursor: pointer;
    user-select: none;
    padding: 2px 0;
}

/* Style for non-selectable nodes */
.custom-treeview-wrapper .treeview-node-content.not-selectable {
    cursor: default;
    opacity: 0.6;
}

/* Style the actual text span for the node name */
.custom-treeview-wrapper .treeview-node-text {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Styling for the explicit expander icon element */
.treeview-expander {
    display: inline-block;
    width: 20px;
    text-align: center;
    color: #666;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
    margin-right: 5px;
    transition: transform 0.2s ease-in-out;
}

/* Styling for the placeholder span for leaf nodes */
.treeview-expander-placeholder {
    display: inline-block;
    width: 20px;
    flex-shrink: 0;
    margin-right: 5px;
}

.custom-treeview-wrapper li * {
    transition: background-color 0.2s ease-in-out;
}

.custom-treeview-wrapper li.selected > .treeview-node-content {
    background-color: rgba(93, 58, 138, 0.15);
    color: var(--primary-purple);
    border-radius: 3px;
}

/* For search results */
.custom-treeview-wrapper li.hidden {
    display: none !important;
}

/* Apply highlight to the node content wrapper */
.custom-treeview-wrapper li.highlight > .treeview-node-content {
    font-style: italic;
    color: var(--primary-purple-dark);
    border-radius: 3px;
}

/* Reset styles for ALL descendant <li> elements of a highlighted <li> */
.custom-treeview-wrapper li.highlight li {
    font-style: normal;
    color: #333;
    background-color: transparent;
}

/* Ensure that if a nested LI is also a match, it still gets its own highlight. */
.custom-treeview-wrapper li.highlight li.highlight > .treeview-node-content {
    font-style: italic;
    color: var(--primary-purple-dark);
}

.treeview-control-button {
    padding: 8px 15px;
    margin-right: 5px;
    margin-bottom: 3px;
    border: none;
    border-radius: 4px;
    background-color: var(--primary-purple);
    color: white;
    font-size: 0.9em;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex-grow: 1;
    min-width: 110px;
    max-width: 48%;
}

.treeview-control-button:hover {
    background-color: var(--primary-purple-dark);
}

.treeview-control-button:active {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.treeview-checkbox {
    margin-right: 5px;
    flex-shrink: 0;
    cursor: pointer;
    transform: scale(1.1);
}


/* ==========================================================================
   CHEVRON ICON ANIMATION
   ========================================================================== */

.toggle-icon .bi-chevron-right {
    display: inline-block;
    transition: transform 0.3s ease-in-out;
    transform: rotate(0deg);
}

.toggle-icon[aria-expanded="true"] .bi-chevron-right {
    transform: rotate(90deg);
}


/* ==========================================================================
   RESPONSIVE STYLES
   ========================================================================== */

@media (max-width: 991px) {
    .mobile-navbar {
        display: flex;
    }
}

@media (min-width: 992px) {
    .mobile-navbar {
        display: none;
    }

    .sidebar-overlay {
        display: none !important;
    }

    .content-area {
        padding: 2rem;
    }

    .entity-table-container {
        padding: 2rem;
    }
}

@media (max-width: 768px) {
    .form-container {
        padding: 1.25rem;
    }

    fieldset {
        padding: 1rem;
    }

    fieldset legend {
        font-size: 0.9rem;
    }

    .form-control,
    .form-select {
        padding: 0.65rem 0.9rem;
        font-size: 0.9rem;
    }

    .table-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .search-bar {
        width: 100%;
    }

    #status-filter-tabs {
        flex-wrap: wrap;
    }

    #status-filter-tabs .nav-link {
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
    }

    .status-select {
        min-width: 140px;
    }

    .entity-type-icon {
        width: 28px;
        height: 28px;
        font-size: 0.875rem;
    }

    .status-notes {
        max-width: 100%;
    }

    .timeline {
        padding-left: 25px;
    }

    .timeline-marker {
        left: -25px;
        width: 18px;
        height: 18px;
        font-size: 8px;
    }
}

@media (max-width: 767px) {
    .entity-table-container {
        padding: 1rem;
    }

    .entity-table thead th {
        padding: 0.75rem 0.5rem;
        font-size: 0.75rem;
    }

    .entity-table tbody td {
        padding: 0.75rem 0.5rem;
    }

    .entity-type-icon {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .entity-name-cell .name {
        font-size: 0.875rem;
    }

    .relations-icons {
        flex-direction: column;
        gap: 0.25rem;
    }

    .table-footer {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 576px) {
    .btn-group-sm .btn {
        padding: 0.25rem 0.4rem;
    }
}

@media (max-width: 575px) {
    .stat-card {
        padding: 0.75rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .entity-table-container {
        padding: 0.75rem;
    }

    .table-header h4 {
        font-size: 1.25rem;
    }

    .entity-table thead th {
        padding: 0.5rem 0.375rem;
        font-size: 0.7rem;
    }

    .entity-table tbody td {
        padding: 0.5rem 0.375rem;
    }

    .btn-action {
        width: 28px;
        height: 28px;
    }

    .status-badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    .relation-icon {
        font-size: 0.7rem;
        padding: 0.125rem 0.375rem;
    }
}

/* ============================================
   Subject User Form Styles (Token-based forms)
   ============================================ */

.subject-form-page {
    background: linear-gradient(135deg, var(--very-light-purple, #F5F3F8) 0%, var(--gray-100, #F5F5F5) 100%);
    min-height: 100vh;
    padding: 2rem 1rem;
}

.subject-form-container {
    max-width: 600px;
    margin: 0 auto;
}

.subject-form-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    padding: 2rem;
    border: 1px solid var(--gray-200, #E5E5E5);
}

.subject-brand-header {
    text-align: center;
    margin-bottom: 2rem;
}

.subject-brand-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary-purple, #5D3A8A) 0%, var(--primary-purple-light, #7C5BA8) 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    color: white;
    font-size: 1.75rem;
    box-shadow: 0 4px 12px rgba(93, 58, 138, 0.3);
}

.subject-brand-header h1 {
    color: var(--neutral-800, #1F2937);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.subject-brand-header p {
    color: var(--neutral-500, #6B7280);
}

.subject-context-box {
    background: var(--light-purple, #E8E4F0);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--primary-purple, #5D3A8A);
}

.subject-context-box p {
    color: var(--neutral-700, #374151);
    margin-bottom: 0.5rem;
}

.subject-context-box strong {
    color: var(--primary-purple, #5D3A8A);
}

.subject-email-display {
    background: white;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.875rem;
    color: var(--neutral-700, #374151);
    border: 1px solid var(--gray-200, #E5E5E5);
    display: inline-block;
}

.subject-message-box {
    background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    border: 1px solid #C7D2FE;
    color: var(--neutral-700, #374151);
}

.subject-message-box strong {
    color: #4338CA;
}

.subject-message-box i {
    color: #6366F1;
}

.subject-warning-box {
    background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    border: 1px solid #F59E0B;
    color: var(--neutral-700, #374151);
}

.subject-warning-box i {
    color: #D97706;
}

.subject-warning-box strong {
    color: #B45309;
}

.subject-form-card h5 {
    color: var(--neutral-800, #1F2937);
    font-weight: 600;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--gray-200, #E5E5E5);
    margin-bottom: 1.5rem;
}

.subject-form-card h5 i {
    color: var(--primary-purple, #5D3A8A);
}

.subject-form-card .form-label {
    font-weight: 500;
    color: var(--neutral-700, #374151);
    font-size: 0.875rem;
}

.subject-form-card .form-control,
.subject-form-card .form-select {
    border-radius: 8px;
    border: 1px solid var(--gray-300, #D4D4D4);
    padding: 0.625rem 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.subject-form-card .form-control:focus,
.subject-form-card .form-select:focus {
    border-color: var(--primary-purple, #5D3A8A);
    box-shadow: 0 0 0 3px rgba(93, 58, 138, 0.15);
}

.subject-form-card .btn-primary {
    background: linear-gradient(135deg, var(--primary-purple, #5D3A8A) 0%, var(--primary-purple-light, #7C5BA8) 100%);
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    transition: transform 0.2s, box-shadow 0.2s;
}

.subject-form-card .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(93, 58, 138, 0.4);
}

.subject-form-card .btn-primary:active {
    transform: translateY(0);
}

.subject-form-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
}

.subject-form-footer small {
    color: var(--neutral-400, #9CA3AF);
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .subject-form-page {
        padding: 1rem 0.75rem;
    }

    .subject-form-card {
        padding: 1.5rem;
        border-radius: 10px;
    }

    .subject-brand-logo {
        width: 56px;
        height: 56px;
        font-size: 1.5rem;
    }
}

/* =========================================
   Mobile Entity Cards
   ========================================= */
.entity-card {
    background: var(--neutral-50, #f8f9fa);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid var(--neutral-200, #e9ecef);
}

.entity-card .entity-type-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.entity-card .entity-type-icon.company {
    background: var(--purple-light, #e8e0f0);
    color: var(--purple, #6c4f9e);
}

.entity-card .entity-type-icon.person {
    background: var(--purple-lighter, #f0ebf5);
    color: var(--purple-light, #8b6fb0);
}

/* ============================================
   Entity View Page Styles
   ============================================ */

/* Purple outline button for View Network */
.btn.btn-outline-purple {
    border: 1px solid var(--primary-purple, #5D3A8A);
    color: var(--primary-purple, #5D3A8A);
    background-color: transparent;
}

.btn.btn-outline-purple:hover,
.btn.btn-outline-purple:focus {
    background-color: var(--primary-purple, #5D3A8A);
    border-color: var(--primary-purple, #5D3A8A);
    color: white;
}

/* Entity view tags */
.entity-view-tag {
    padding: 0.4em 0.7em;
}

/* Screening questions table */
.screening-questions-table th.col-question {
    width: 60%;
}

.screening-questions-table th.col-required,
.screening-questions-table th.col-status {
    width: 20%;
}

/* Invitation status text */
.invitation-status-text {
    color: var(--primary-purple, #5D3A8A);
}

/* Back link - minimal text style */
.back-link {
    color: #6c757d;
    text-decoration: none;
    font-size: 0.9rem;
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0;
    margin: 0;
    cursor: pointer;
    transition: color 0.15s ease;
    font-family: inherit;
    outline: none;
}

.back-link:hover,
.back-link:focus {
    color: var(--primary-purple, #5D3A8A);
    text-decoration: underline;
    background: none !important;
    background-color: transparent !important;
    box-shadow: none !important;
    outline: none;
}

.back-link:active {
    background: none !important;
    box-shadow: none !important;
}

.back-link i {
    transition: transform 0.15s ease;
}

.back-link:hover i {
    transform: translateX(-2px);
}

/* ==========================================================================
   Identity verification
   ========================================================================== */
.verification {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}
.verification h1 {
    text-align: center;
}