/* ==========================================================================
   Premium CRM stylesheet with Light & Dark Themes and Glassmorphism details
   Author: Antigravity AI
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

/* Dynamic Theme Variables */
:root {
    --font-family: 'Plus Jakarta Sans', sans-serif;
    
    /* Light Mode Slate-Navy HSL Values */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-sidebar: #0f172a;
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    
    /* Primary Brand Theme: Slate-800 Deep Navy */
    --primary: #1e293b;
    --primary-rgb: 30, 41, 59;
    --primary-hover: #0f172a;
    
    --border-color: #e2e8f0;
    --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --card-shadow-hover: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: rgba(255, 255, 255, 0.08);
    
    /* Lead Sentiment Ratings Color Palette (Professional light HSL backgrounds with saturated border/text) */
    --rating-cold-bg: #f1f5f9;
    --rating-cold-text: #475569;
    --rating-cold-border: #cbd5e1;
    
    --rating-warm-bg: #fef3c7;
    --rating-warm-text: #b45309;
    --rating-warm-border: #fde68a;
    
    --rating-hot-bg: #fee2e2;
    --rating-hot-text: #b91c1c;
    --rating-hot-border: #fca5a5;
}

[data-theme="dark"] {
    /* Dark Mode Slate-Navy HSL Values */
    --bg-primary: #090d16;
    --bg-secondary: #111827;
    --bg-sidebar: #0b0f19;
    --text-primary: #f3f4f6;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    
    /* Dark Mode Primary Brand: Google/Royal Blue */
    --primary: #3b82f6;
    --primary-rgb: 59, 130, 246;
    --primary-hover: #2563eb;
    
    --border-color: #1f2937;
    --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --card-shadow-hover: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);
    
    --sidebar-text: #9ca3af;
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: rgba(59, 130, 246, 0.15);
    
    /* Lead Sentiment Ratings Dark Mode Palette */
    --rating-cold-bg: #1e293b;
    --rating-cold-text: #94a3b8;
    --rating-cold-border: #334155;
    
    --rating-warm-bg: #78350f;
    --rating-warm-text: #fef3c7;
    --rating-warm-border: #92400e;
    
    --rating-hot-bg: #7f1d1d;
    --rating-hot-text: #fee2e2;
    --rating-hot-border: #991b1b;
}

/* Global Reset & Basic Configurations */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-family);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}
a:hover {
    color: var(--primary-hover);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ==========================================================================
   Authentication Views Layout
   ========================================================================== */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.05) 0%, rgba(99, 102, 241, 0.05) 100%);
    padding: 24px;
}

.auth-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    width: 100%;
    max-width: 440px;
    padding: 40px;
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(20px);
}

.auth-logo {
    font-size: 1.75rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 24px;
    text-align: center;
}

/* Form Styling overrides */
.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control, .form-select {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 11px 16px;
    font-size: 0.95rem;
    transition: all 0.2s ease-in-out;
}

.form-control:focus, .form-select:focus {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
    font-weight: 600;
    padding: 11px 20px;
    border-radius: 10px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: 0 8px 12px -2px rgba(79, 70, 229, 0.3);
    transform: translateY(-1px);
}

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

/* ==========================================================================
   Dashboard & Sidebar Shell Layout
   ========================================================================== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    flex-shrink: 0;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-brand {
    font-size: 1.5rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 32px;
    padding-left: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1;
}

.sidebar-item {
    margin-bottom: 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--sidebar-text);
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.sidebar-link i {
    font-size: 1.15rem;
    width: 20px;
    text-align: center;
}

.sidebar-link:hover {
    color: var(--sidebar-text-hover);
    background-color: var(--sidebar-active-bg);
    transform: translateX(4px);
}

.sidebar-link.active {
    color: #ffffff;
    background-color: var(--primary);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.sidebar-user {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
    margin-top: auto;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #ffffff;
    padding: 8px 12px;
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, #a855f7 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.top-navbar {
    position: sticky;
    top: 0;
    z-index: 1020; /* Below modals (1050) but above standard page content (1) */
    background-color: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border-bottom: 1px solid var(--border-color);
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

[data-theme="dark"] .top-navbar {
    background-color: rgba(17, 24, 39, 0.85) !important;
}

.page-container {
    padding: 32px;
    flex-grow: 1;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

/* ==========================================================================
   UI Components & Cards
   ========================================================================== */
.card-metric {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--card-shadow);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-metric:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-4px);
}

.metric-value {
    font-size: 1.85rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.metric-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.metric-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.bg-primary-soft {
    background-color: rgba(79, 70, 229, 0.1);
    color: var(--primary);
}
.bg-success-soft {
    background-color: rgba(25, 135, 84, 0.1);
    color: #198754;
}
.bg-warning-soft {
    background-color: rgba(255, 193, 7, 0.1);
    color: #b58000;
}
.bg-danger-soft {
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.card-panel {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    padding: 16px;
    margin-bottom: 24px;
}

@media (min-width: 768px) {
    .card-panel {
        padding: 24px;
    }
}

/* Premium styled data tables */
.table-responsive-custom {
    border-radius: 16px !important;
    border: 1px solid rgba(226, 232, 240, 0.8) !important;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.03) !important;
    overflow-x: auto;
    overflow-y: hidden;
    background-color: var(--bg-secondary);
}

.table-custom {
    margin-bottom: 0;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-custom th {
    background-color: var(--bg-primary) !important;
    color: #475569 !important;
    font-weight: 700;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 12px 14px !important;
    vertical-align: middle !important;
    border-bottom: 2px solid #e2e8f0 !important;
}

[data-theme="dark"] .table-custom th {
    color: #94a3b8 !important;
    border-bottom: 2px solid #1f2937 !important;
}

.table-custom td {
    padding: 12px 14px !important;
    color: var(--text-primary);
    vertical-align: middle !important;
    border-bottom: 1px solid rgba(226, 232, 240, 0.6) !important;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] .table-custom td {
    border-bottom: 1px solid rgba(31, 41, 55, 0.6) !important;
}

.table-custom tbody tr {
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.table-custom tbody tr:hover {
    background-color: rgba(99, 102, 241, 0.02) !important;
}

[data-theme="dark"] .table-custom tbody tr:hover {
    background-color: rgba(59, 130, 246, 0.04) !important;
}

/* Customized form checks inside table */
.table-custom .form-check-input {
    border-radius: 6px !important;
    border: 1.5px solid var(--text-muted);
    background-color: var(--bg-secondary);
    transition: all 0.15s ease-in-out;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.table-custom .form-check-input:checked {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15) !important;
}

/* Premium Sentiment Gradients on Left Strips */
.table-custom td .rounded-pill.bg-danger {
    background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%) !important;
    box-shadow: 0 2px 5px rgba(239, 68, 68, 0.3);
    width: 4px !important;
    height: 36px !important;
}

.table-custom td .rounded-pill.bg-warning {
    background: linear-gradient(180deg, #fbbf24 0%, #d97706 100%) !important;
    box-shadow: 0 2px 5px rgba(251, 191, 36, 0.3);
    width: 4px !important;
    height: 36px !important;
}

.table-custom td .rounded-pill.bg-secondary {
    background: linear-gradient(180deg, #94a3b8 0%, #475569 100%) !important;
    box-shadow: 0 2px 5px rgba(148, 163, 184, 0.3);
    width: 4px !important;
    height: 36px !important;
}

/* Premium Tile-style Action Buttons - Colorful by Default */
.table-custom td .btn-link, 
.table-custom td a.lead-action-trigger,
.table-custom td form button.btn-link {
    width: 32px !important;
    height: 32px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
    text-decoration: none !important;
    padding: 0 !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04) !important;
}

/* Edit Button (Blue Theme) */
.table-custom td .ajax-edit-lead-btn {
    background-color: rgba(59, 130, 246, 0.08) !important;
    border: 1px solid rgba(59, 130, 246, 0.25) !important;
    color: #2563eb !important;
}
.table-custom td .ajax-edit-lead-btn:hover {
    background-color: rgba(59, 130, 246, 0.15) !important;
    border-color: rgba(59, 130, 246, 0.45) !important;
    color: #1d4ed8 !important;
    transform: translateY(-1.5px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.15) !important;
}

/* Delete Button (Red Theme) */
.table-custom td form button[title="Delete Lead"],
.table-custom td form button.text-danger {
    background-color: rgba(239, 68, 68, 0.08) !important;
    border: 1px solid rgba(239, 68, 68, 0.25) !important;
    color: #dc2626 !important;
}
.table-custom td form button[title="Delete Lead"]:hover,
.table-custom td form button.text-danger:hover {
    background-color: rgba(239, 68, 68, 0.15) !important;
    border-color: rgba(239, 68, 68, 0.45) !important;
    color: #b91c1c !important;
    transform: translateY(-1.5px);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.15) !important;
}

/* Follow-up Button (Emerald Green Theme) */
.table-custom td .ajax-followup-lead-btn {
    background-color: rgba(16, 185, 129, 0.08) !important;
    border: 1px solid rgba(16, 185, 129, 0.25) !important;
    color: #059669 !important;
}
.table-custom td .ajax-followup-lead-btn:hover {
    background-color: rgba(16, 185, 129, 0.15) !important;
    border-color: rgba(16, 185, 129, 0.45) !important;
    color: #047857 !important;
    transform: translateY(-1.5px);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.15) !important;
}

/* Quick Call Button (Indigo Theme) */
.table-custom td a.lead-action-trigger[data-action-type="LEAD_ACTION_CALL"] {
    background-color: rgba(99, 102, 241, 0.08) !important;
    border: 1px solid rgba(99, 102, 241, 0.25) !important;
    color: #4f46e5 !important;
}
.table-custom td a.lead-action-trigger[data-action-type="LEAD_ACTION_CALL"]:hover {
    background-color: rgba(99, 102, 241, 0.15) !important;
    border-color: rgba(99, 102, 241, 0.45) !important;
    color: #3730a3 !important;
    transform: translateY(-1.5px);
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.15) !important;
}

/* Quick WhatsApp Button (Teal Green Theme) */
.table-custom td a.lead-action-trigger[data-action-type="LEAD_ACTION_WHATSAPP"] {
    background-color: rgba(37, 211, 102, 0.08) !important;
    border: 1px solid rgba(37, 211, 102, 0.25) !important;
    color: #128c7e !important;
}
.table-custom td a.lead-action-trigger[data-action-type="LEAD_ACTION_WHATSAPP"]:hover {
    background-color: rgba(37, 211, 102, 0.15) !important;
    border-color: rgba(37, 211, 102, 0.45) !important;
    color: #075e54 !important;
    transform: translateY(-1.5px);
    box-shadow: 0 4px 8px rgba(37, 211, 102, 0.15) !important;
}


/* Sleek font transition on lead IDs */
.table-custom td a.text-primary.text-decoration-none {
    font-family: var(--font-family) !important;
    font-weight: 700 !important;
    letter-spacing: -0.01em !important;
    transition: all 0.2s ease;
}

.table-custom td a.text-primary.text-decoration-none:hover {
    color: var(--primary-hover) !important;
    text-decoration: underline !important;
}


/* Status Badges */
.badge-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    white-space: nowrap !important;
    flex-shrink: 0;
}

.badge-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
}

/* Theme switch toggle styling */
.theme-switch {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.15rem;
    transition: all 0.2s ease;
}
.theme-switch:hover {
    background-color: var(--border-color);
    transform: scale(1.05);
}

/* Timeline Notes Styling */
.timeline-notes {
    position: relative;
    padding-left: 28px;
    border-left: 2px solid var(--border-color);
    margin-left: 10px;
}

.timeline-note-item {
    position: relative;
    margin-bottom: 24px;
}

.timeline-note-item::before {
    content: '';
    position: absolute;
    left: -35px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--primary);
    border: 3px solid var(--bg-secondary);
    box-shadow: 0 0 0 2px var(--border-color);
}

.timeline-note-card {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
}

/* ==========================================================================
   Animations & Responsive Settings
   ========================================================================== */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsiveness Rules */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    .top-navbar {
        padding: 0 20px;
    }
    
    .page-container {
        padding: 20px;
    }
}

/* Desktop Sidebar Fix for Vertical Scrolling */
@media (min-width: 992px) {
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        height: 100vh !important;
        overflow-y: auto !important;
    }
    .main-content {
        margin-left: 260px !important;
    }
}

/* ==========================================================================
   Print-Friendly Media Stylesheet (PDF & Print Reports Output)
   ========================================================================== */
@media print {
    /* Hide navigation layouts, filter bars, action buttons, and page footers */
    .sidebar,
    .top-navbar,
    .card-panel form,
    .card-panel nav,
    .btn,
    button,
    form,
    th:last-child,
    td:last-child,
    .dropdown-menu,
    .d-flex.gap-2.flex-wrap {
        display: none !important;
    }

    body {
        background: #ffffff !important;
        color: #000000 !important;
        font-family: 'Plus Jakarta Sans', sans-serif !important;
        font-size: 11pt !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .page-container {
        padding: 0 !important;
        margin: 0 !important;
    }

    .card-panel {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        background: transparent !important;
    }

    /* Print Header Sheet */
    .card-panel::before {
        content: "Acme Lead CRM - Reports Export Sheet (System Data)";
        display: block;
        font-size: 16pt;
        font-weight: bold;
        text-align: center;
        margin-bottom: 20px;
        border-bottom: 2px solid #333333;
        padding-bottom: 8px;
        color: #000000 !important;
    }

    /* Clean full-page tables */
    .table-custom {
        width: 100% !important;
        border-collapse: collapse !important;
        margin-top: 10px !important;
    }

    .table-custom th,
    .table-custom td {
        border: 1px solid #cccccc !important;
        padding: 8px 12px !important;
        font-size: 9pt !important;
        color: #000000 !important;
        text-align: left !important;
    }

    .table-custom th {
        background-color: #f0f0f0 !important;
        font-weight: 800 !important;
        text-transform: uppercase !important;
    }

    /* Keep table badges readable in greyscale print */
    .badge-status, .badge {
        background: transparent !important;
        color: #000000 !important;
        border: 1px solid #999999 !important;
        box-shadow: none !important;
        padding: 2px 6px !important;
        font-size: 8pt !important;
    }
}

/* ==========================================================================
   PREMIUM SELECT2 BOOTSTRAP-5 THEME OVERRIDES (High clickability & aesthetics)
   ========================================================================== */
.select2-container--bootstrap-5 {
    display: block;
}

.select2-container--bootstrap-5 .select2-selection {
    position: relative !important; /* Crucial for absolute positioning of children */
    min-height: 44px !important; /* Spacious height, matching other inputs */
    border: 1px solid var(--border-color) !important;
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border-radius: 10px !important;
    display: flex !important;
    align-items: center !important;
    cursor: pointer !important;
    transition: all 0.2s ease-in-out !important;
    padding: 0 12px !important;
    padding-right: 48px !important; /* Prevent text colliding with clear/arrow icons */
}

/* Hover highlights */
.select2-container--bootstrap-5 .select2-selection:hover {
    border-color: var(--primary) !important;
    background-color: var(--bg-secondary) !important;
}

/* Focus and open highlights */
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--primary) !important;
    background-color: var(--bg-secondary) !important;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15) !important;
}

/* Selection Text rendering */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    color: var(--text-primary) !important;
    font-size: 0.92rem !important;
    font-weight: 500 !important;
    padding-left: 0 !important;
    padding-right: 24px !important;
}

/* Search Box Clear Button */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__clear {
    position: absolute !important;
    right: 32px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 1.25rem !important;
    height: 1.25rem !important;
    background-color: transparent !important;
    color: var(--text-secondary) !important;
    font-size: 1rem !important;
    margin: 0 !important;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__clear:hover {
    color: #dc3545 !important;
}

/* Custom premium indicator arrow */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    position: absolute !important;
    right: 12px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 20px !important;
    height: 20px !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23475569' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-size: 12px !important;
    transition: transform 0.2s ease !important;
}

/* Light / Dark variable synchronization for arrow fill in dark mode */
[data-theme="dark"] .select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
}

/* Arrow flip on open */
.select2-container--bootstrap-5.select2-container--open .select2-selection--single .select2-selection__arrow {
    transform: translateY(-50%) rotate(180deg) !important;
}

/* Hide select2 standard design arrow */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow b {
    display: none !important;
}

/* Dropdown Panel */
.select2-container--bootstrap-5 .select2-dropdown {
    border: 1px solid var(--border-color) !important;
    background-color: var(--bg-secondary) !important;
    border-radius: 12px !important;
    box-shadow: var(--card-shadow-hover) !important;
    overflow: hidden !important;
    z-index: 1060 !important;
}

/* Search input field */
.select2-container--bootstrap-5 .select2-search__field {
    border: 1px solid var(--border-color) !important;
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border-radius: 8px !important;
    padding: 8px 12px !important;
    font-size: 0.9rem !important;
}

.select2-container--bootstrap-5 .select2-search__field:focus {
    outline: none !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1) !important;
}

/* List group options styling */
.select2-container--bootstrap-5 .select2-results__option {
    padding: 10px 16px !important;
    font-size: 0.9rem !important;
    color: var(--text-primary) !important;
    cursor: pointer !important;
    transition: background 0.15s ease !important;
}

/* Hover/Focus list elements */
.select2-container--bootstrap-5 .select2-results__option--highlighted[aria-selected] {
    background-color: var(--primary) !important;
    color: #ffffff !important;
}

/* Selected list element */
.select2-container--bootstrap-5 .select2-results__option[aria-selected="true"] {
    background-color: rgba(79, 70, 229, 0.08) !important;
    color: var(--primary) !important;
    font-weight: 600 !important;
}

/* ==========================================================================
   MOBILE-FIRST PREMIUM APP EXPERIENCES (Bottom Navigation & Mobile Cards)
   ========================================================================== */
@media (max-width: 767.98px) {
    /* Add padding to the bottom of the main content so bottom nav doesn't overlap contents */
    .page-container {
        padding-bottom: 90px !important;
    }
    
    /* Sleek bottom navigation bar */
    .mobile-bottom-nav {
        height: 68px;
        background: rgba(255, 255, 255, 0.88) !important;
        border-top: 1px solid rgba(0, 0, 0, 0.06) !important;
    }
    
    [data-theme="dark"] .mobile-bottom-nav {
        background: rgba(17, 24, 39, 0.88) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
    }
    
    .mobile-nav-link {
        color: var(--text-secondary) !important;
        opacity: 0.65;
        font-weight: 600;
        width: 60px;
    }
    
    .mobile-nav-link:hover, .mobile-nav-link.active {
        opacity: 1;
        color: var(--primary) !important;
    }
    
    .mobile-nav-link.active i {
        transform: translateY(-2px);
        filter: drop-shadow(0 2px 4px rgba(79, 70, 229, 0.25));
    }
    
    .mobile-nav-link i {
        transition: transform 0.2s ease;
    }

    /* Cards styling on mobile */
    .mobile-lead-cards .card {
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    .mobile-lead-cards .card:active {
        transform: scale(0.98);
    }
}

/* ==========================================================================
   PREMIUM DYNAMIC MOBILE BUTTONS (Wow gradients & soft shadows)
   ========================================================================== */
.btn-mobile-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: #ffffff !important;
    border: none !important;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2) !important;
    font-weight: 600 !important;
    transition: all 0.2s ease !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.btn-mobile-success:hover, .btn-mobile-success:active {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(16, 185, 129, 0.3) !important;
}

.btn-mobile-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #4338ca 100%) !important;
    color: #ffffff !important;
    border: none !important;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2) !important;
    font-weight: 600 !important;
    transition: all 0.2s ease !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.btn-mobile-primary:hover, .btn-mobile-primary:active {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(79, 70, 229, 0.3) !important;
}

.btn-mobile-secondary {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%) !important;
    color: #ffffff !important;
    border: none !important;
    box-shadow: 0 4px 10px rgba(100, 116, 139, 0.15) !important;
    font-weight: 600 !important;
    transition: all 0.2s ease !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.btn-mobile-secondary:hover, .btn-mobile-secondary:active {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(100, 116, 139, 0.25) !important;
}

.btn-mobile-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    color: #ffffff !important;
    border: none !important;
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.2) !important;
    font-weight: 600 !important;
    transition: all 0.2s ease !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.btn-mobile-warning:hover, .btn-mobile-warning:active {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(245, 158, 11, 0.3) !important;
}

.btn-mobile-danger-light {
    background-color: rgba(220, 53, 69, 0.08) !important;
    color: #dc3545 !important;
    border: 1px solid rgba(220, 53, 69, 0.15) !important;
    font-weight: 600 !important;
    transition: all 0.2s ease !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.btn-mobile-danger-light:hover, .btn-mobile-danger-light:active {
    background-color: rgba(220, 53, 69, 0.15) !important;
    color: #bd2130 !important;
}

/* ==========================================================================
   RESPONSIVE KPI METRIC CARDS (Sleek 2x2 Grid details for Mobile viewports)
   ========================================================================== */
@media (max-width: 575.98px) {
    .card-metric {
        padding: 14px 12px !important;
        border-radius: 12px !important;
        gap: 6px !important;
        min-height: 94px !important;
        flex-wrap: nowrap !important;
    }
    
    .metric-value {
        font-size: 1.4rem !important;
        margin-bottom: 2px !important;
        line-height: 1.1 !important;
    }
    
    .metric-label {
        font-size: 0.68rem !important;
        line-height: 1.25 !important;
        font-weight: 500 !important;
        letter-spacing: -0.01em !important;
    }
    
    .metric-icon {
        width: 36px !important;
        height: 36px !important;
        font-size: 1.05rem !important;
        border-radius: 8px !important;
        flex-shrink: 0 !important;
    }
}

/* ==========================================================================
   100% GLITCH-FREE MOBILE RESPONSIVE OPTIMIZATION SYSTEM
   ========================================================================== */
html, body, .app-wrapper {
    overflow-x: hidden !important;
    max-width: 100% !important;
    width: 100% !important;
}

@media (max-width: 767.98px) {
    /* Touch Target Auditing (Minimum 44x44px Clickable Area for Touchscreens) */
    .theme-switch, .dropdown button.theme-switch, #mobileSidebarToggle {
        min-width: 44px !important;
        min-height: 44px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .btn:not(.btn-sm):not(.btn-link):not(.btn-xs), 
    .form-control:not(.form-control-sm), 
    .form-select:not(.form-select-sm) {
        min-height: 44px !important;
    }
    
    .btn-sm, .form-control-sm, .form-select-sm {
        min-height: 38px !important;
    }
    
    .dropdown-item, .list-group-item, .page-link {
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
    }
    
    .sidebar-link {
        min-height: 48px !important;
    }
    
    /* Touch target padding overrides */
    .table-custom td a, .mobile-nav-link {
        padding: 8px 12px !important;
        display: inline-flex !important;
        align-items: center !important;
    }
}

@media (max-width: 575.98px) {
    /* Responsive Side Padding */
    .page-container {
        padding: 20px 16px 90px 16px !important;
    }
    
    .card-panel {
        padding: 16px 12px !important;
        border-radius: 12px !important;
    }
    
    /* Auto heading scaling to prevent awkward layout breaks */
    h1, .h1 { font-size: 1.65rem !important; line-height: 1.2 !important; letter-spacing: -0.02em !important; }
    h2, .h2 { font-size: 1.4rem !important; line-height: 1.2 !important; letter-spacing: -0.02em !important; }
    h3, .h3 { font-size: 1.2rem !important; line-height: 1.2 !important; }
    h4, .h4 { font-size: 1.1rem !important; line-height: 1.25 !important; }
    h5, .h5 { font-size: 1rem !important; line-height: 1.25 !important; }
    h6, .h6 { font-size: 0.88rem !important; line-height: 1.3 !important; }
    
    p, .small, .text-secondary {
        font-size: 0.82rem !important;
    }
}

/* ==========================================
   SELECT2 DOUBLE-ARROW OVERLAP FIX
   ========================================== */
.select2-container--bootstrap-5 .select2-selection {
    background-image: none !important;
}

/* ==========================================
   PREMIUM SCROLLBAR FOR FOLLOW-UP DASHBOARD
   ========================================== */
.followup-list-container::-webkit-scrollbar {
    width: 6px !important;
}
.followup-list-container::-webkit-scrollbar-track {
    background: rgba(148, 163, 184, 0.05) !important;
    border-radius: 10px !important;
}
.followup-list-container::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3) !important;
    border-radius: 10px !important;
}
.followup-list-container::-webkit-scrollbar-thumb:hover {
    background: rgba(79, 70, 229, 0.5) !important;
}




/* Lead Action Trigger Buttons (Call & WhatsApp in lists/cards) */
.lead-action-trigger.btn-outline-primary,
.lead-action-trigger.btn-outline-success,
.lead-action-trigger.btn-outline-secondary {
    width: 2.6rem !important;
    height: 2.6rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1rem !important;
    padding: 0 !important;
    line-height: 1 !important;
}

.lead-action-trigger.btn-outline-primary i,
.lead-action-trigger.btn-outline-success i,
.lead-action-trigger.btn-outline-secondary i {
    font-size: 1rem !important;
}

/* ==========================================================================
   PREMIUM SMOOTHNESS & ULTIMATE HIGH-FIDELITY OVERLAYS (CRM UI SMOOTHNESS)
   ========================================================================== */

/* Modern gradient for sidebar to feel high-end */
.sidebar {
    background: linear-gradient(180deg, #0c1220 0%, #030712 100%) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.03) !important;
}

/* Page fade-in slide effect */
.page-container {
    animation: smoothFadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

@keyframes smoothFadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Sidebar navigation link transitions */
.sidebar-link {
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}
.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.04) !important;
    padding-left: 22px !important;
    color: #ffffff !important;
}
.sidebar-link.active {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%) !important;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.35) !important;
    transform: scale(1.02) !important;
}

/* Metric Cards ultra smooth interactions */
.card-metric {
    border-color: rgba(226, 232, 240, 0.7) !important;
    background: linear-gradient(145deg, var(--bg-secondary) 0%, var(--bg-primary) 100%) !important;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
}
[data-theme="dark"] .card-metric {
    border-color: rgba(31, 41, 55, 0.7) !important;
    background: linear-gradient(145deg, #111827 0%, #090d16 100%) !important;
}
.card-metric:hover {
    transform: translateY(-6px) scale(1.015) !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.06), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
}

/* Table rows smooth hover highlight */
.table-custom tbody tr {
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
}
.table-custom tbody tr:hover {
    background-color: rgba(59, 130, 246, 0.03) !important;
    box-shadow: inset 4px 0 0 var(--primary) !important;
}

/* Premium Card Panels styled like glassmorphism */
.card-panel {
    background-color: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    backdrop-filter: blur(8px) !important;
    transition: border-color 0.3s ease, box-shadow 0.3s ease !important;
}
.card-panel:hover {
    border-color: rgba(59, 130, 246, 0.3) !important;
    box-shadow: 0 10px 20px -10px rgba(0, 0, 0, 0.04) !important;
}

/* Inputs premium glowing focus */
.form-control, .form-select {
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}
.form-control:focus, .form-select:focus {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15) !important;
    background-color: var(--bg-secondary) !important;
}

/* Rounded luxury buttons styling */
.btn:not(.btn-link) {
    font-weight: 600 !important;
    border-radius: 30px !important;
    padding: 10px 22px !important;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}
.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%) !important;
    border: none !important;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25) !important;
}
.btn-primary:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4) !important;
}
.btn-primary:active {
    transform: translateY(0) !important;
}

/* Micro animations for badges and alerts */
.badge {
    transition: transform 0.2s ease !important;
}
.badge:hover {
    transform: translateY(-1px) scale(1.03) !important;
}

/* Custom premium popup toasts */
.toast-notification {
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    border-radius: 12px !important;
}
@keyframes toastSlideIn {
    from {
        transform: translateY(100px) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Responsive Left Border Helper on Desktop */
@media (min-width: 768px) {
    .border-start-md {
        border-left: 1px solid var(--border-color, rgba(0, 0, 0, 0.08)) !important;
        padding-left: 1.5rem !important;
    }
}

/* Premium Follow-up Remarks Bubble Styling */
.table-custom td .remarks-bubble {
    background-color: #f8fafc;
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.82rem;
    color: #334155;
    line-height: 1.45;
    max-width: 240px;
    max-height: 72px;
    overflow-y: auto;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    transition: all 0.2s ease-in-out;
}

.table-custom tr:hover td .remarks-bubble {
    background-color: var(--bg-secondary) !important;
    border-color: rgba(99, 102, 241, 0.25) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02) !important;
}

[data-theme="dark"] .table-custom td .remarks-bubble {
    background-color: rgba(31, 41, 55, 0.4);
    border: 1px solid rgba(75, 85, 99, 0.4);
    color: #cbd5e1;
}

[data-theme="dark"] .table-custom tr:hover td .remarks-bubble {
    background-color: rgba(17, 24, 39, 0.6) !important;
    border-color: rgba(59, 130, 246, 0.3) !important;
}

.table-custom td .remarks-bubble i {
    font-size: 0.85rem;
    margin-top: 3px;
    flex-shrink: 0;
    opacity: 0.7;
    color: var(--text-muted);
}

/* ==========================================================================
   HIGH-CONTRAST DARK MODE ACCENTUATIONS & OVERRIDES
   ========================================================================== */

/* Glowing soft backgrounds for dark mode */
[data-theme="dark"] .bg-primary-soft {
    background-color: rgba(59, 130, 246, 0.16) !important;
    color: #60a5fa !important;
}
[data-theme="dark"] .bg-success-soft {
    background-color: rgba(16, 185, 129, 0.16) !important;
    color: #34d399 !important;
}
[data-theme="dark"] .bg-warning-soft {
    background-color: rgba(245, 158, 11, 0.16) !important;
    color: #fbbf24 !important;
}
[data-theme="dark"] .bg-danger-soft {
    background-color: rgba(239, 68, 68, 0.16) !important;
    color: #f87171 !important;
}

/* Force standard text-dark elements to light in dark mode */
[data-theme="dark"] .text-dark {
    color: var(--text-primary) !important;
}

/* Elevate default light backgrounds to card slate-navy in dark mode */
[data-theme="dark"] .bg-light:not(.sidebar-link) {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Boost readability of muted description texts against dark background panels */
[data-theme="dark"] .text-muted,
[data-theme="dark"] .timeline-note-card .text-muted {
    color: #94a3b8 !important;
}

/* ==========================================================================
   GLOBAL PREMIUM BUTTON ACCESSIBILITY & CONTRAST ADJUSTMENTS
   ========================================================================== */

/* Base transitions and border resets for all buttons */
.btn {
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Base style correction for outline buttons on light mode */
.btn-outline-primary {
    border-color: var(--primary) !important;
    color: var(--primary) !important;
}
.btn-outline-primary:hover {
    background-color: var(--primary) !important;
    color: #ffffff !important;
}

/* Premium Dark Mode Button Adaptations */
[data-theme="dark"] .btn-outline-primary {
    border-color: #60a5fa !important;
    color: #60a5fa !important;
}
[data-theme="dark"] .btn-outline-primary:hover {
    background-color: #2563eb !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2) !important;
}

[data-theme="dark"] .btn-outline-success {
    border-color: #34d399 !important;
    color: #34d399 !important;
}
[data-theme="dark"] .btn-outline-success:hover {
    background-color: #059669 !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2) !important;
}

[data-theme="dark"] .btn-outline-danger {
    border-color: #f87171 !important;
    color: #f87171 !important;
}
[data-theme="dark"] .btn-outline-danger:hover {
    background-color: #dc2626 !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.2) !important;
}

[data-theme="dark"] .btn-outline-secondary {
    border-color: #94a3b8 !important;
    color: #94a3b8 !important;
}
[data-theme="dark"] .btn-outline-secondary:hover {
    background-color: #475569 !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(148, 163, 184, 0.15) !important;
}

/* Normalize btn-light to translucent slate-card style in dark mode */
[data-theme="dark"] .btn-light {
    background-color: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: var(--text-primary) !important;
}
[data-theme="dark"] .btn-light:hover {
    background-color: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
}

/* Custom Button Enhancements for Dark Mode */
[data-theme="dark"] .btn-primary {
    background: linear-gradient(135deg, #60a5fa 0%, #2563eb 100%) !important;
    border: none !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3) !important;
}
[data-theme="dark"] .btn-primary:hover {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%) !important;
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.45) !important;
    transform: translateY(-2px) !important;
}

[data-theme="dark"] .btn-secondary {
    background: linear-gradient(135deg, #4b5563 0%, #374151 100%) !important;
    border: none !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(75, 85, 99, 0.2) !important;
}
[data-theme="dark"] .btn-secondary:hover {
    background: linear-gradient(135deg, #374151 0%, #1f2937 100%) !important;
    box-shadow: 0 6px 16px rgba(75, 85, 99, 0.3) !important;
    transform: translateY(-2px) !important;
}

[data-theme="dark"] .btn-success {
    background: linear-gradient(135deg, #34d399 0%, #059669 100%) !important;
    border: none !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25) !important;
}
[data-theme="dark"] .btn-success:hover {
    background: linear-gradient(135deg, #10b981 0%, #047857 100%) !important;
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4) !important;
    transform: translateY(-2px) !important;
}

[data-theme="dark"] .btn-danger {
    background: linear-gradient(135deg, #f87171 0%, #dc2626 100%) !important;
    border: none !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.25) !important;
}
[data-theme="dark"] .btn-danger:hover {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%) !important;
    box-shadow: 0 6px 16px rgba(220, 53, 69, 0.4) !important;
    transform: translateY(-2px) !important;
}

[data-theme="dark"] .btn-warning {
    background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%) !important;
    border: none !important;
    color: #0f172a !important;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25) !important;
}
[data-theme="dark"] .btn-warning:hover {
    background: linear-gradient(135deg, #f59e0b 0%, #b45309 100%) !important;
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.4) !important;
    transform: translateY(-2px) !important;
}

[data-theme="dark"] .btn-info {
    background: linear-gradient(135deg, #22d3ee 0%, #0891b2 100%) !important;
    border: none !important;
    color: #0f172a !important;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.25) !important;
}
[data-theme="dark"] .btn-info:hover {
    background: linear-gradient(135deg, #06b6d4 0%, #0e7490 100%) !important;
    box-shadow: 0 6px 16px rgba(6, 182, 212, 0.4) !important;
    transform: translateY(-2px) !important;
}

[data-theme="dark"] .btn-dark {
    background-color: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
}
[data-theme="dark"] .btn-dark:hover {
    background-color: rgba(255, 255, 255, 0.25) !important;
    color: #ffffff !important;
}

/* Force hardcoded bg-white containers to dynamically adapt to dark secondary backgrounds */
[data-theme="dark"] .bg-white {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Highly visible and ultra-premium Theme Toggle and Notification controls */
.theme-switch {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.15rem;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}
.theme-switch:hover {
    background-color: var(--border-color) !important;
    transform: scale(1.08) rotate(15deg) !important;
    color: var(--primary) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
}

[data-theme="dark"] .theme-switch {
    background-color: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
    color: #60a5fa !important;
}
[data-theme="dark"] .theme-switch:hover {
    background-color: rgba(255, 255, 255, 0.15) !important;
    color: #3b82f6 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35) !important;
}

/* Dark Theme overrides for Leaflet map elements and controls */
[data-theme="dark"] .leaflet-control-layers,
[data-theme="dark"] .leaflet-bar,
[data-theme="dark"] .leaflet-bar a,
[data-theme="dark"] .leaflet-popup-content-wrapper,
[data-theme="dark"] .leaflet-popup-tip {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
}
[data-theme="dark"] .leaflet-control-layers-list {
    color: var(--text-primary) !important;
}
[data-theme="dark"] .leaflet-bar a {
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border-color) !important;
}
[data-theme="dark"] .leaflet-bar a:hover {
    background-color: var(--bg-primary) !important;
    color: var(--primary) !important;
}
[data-theme="dark"] .leaflet-popup-content-wrapper {
    box-shadow: var(--card-shadow-hover) !important;
    border-radius: 12px !important;
}

/* Table cells background color matching theme to prevent white-on-white text collision */
.table-custom td {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
}
[data-theme="dark"] .table-custom th {
    background-color: var(--bg-primary) !important;
    color: #cbd5e1 !important;
}

/* High-contrast subtle badge overrides for readability */
.bg-primary-subtle {
    background-color: rgba(59, 130, 246, 0.12) !important;
    color: #1e3a8a !important; 
    border: 1px solid rgba(59, 130, 246, 0.25) !important;
}
.bg-warning-subtle {
    background-color: rgba(245, 158, 11, 0.12) !important;
    color: #78350f !important; 
    border: 1px solid rgba(245, 158, 11, 0.25) !important;
}
.bg-success-subtle {
    background-color: rgba(16, 185, 129, 0.12) !important;
    color: #064e3b !important; 
    border: 1px solid rgba(16, 185, 129, 0.25) !important;
}
.bg-danger-subtle {
    background-color: rgba(239, 68, 68, 0.12) !important;
    color: #7f1d1d !important; 
    border: 1px solid rgba(239, 68, 68, 0.25) !important;
}
.bg-secondary-subtle {
    background-color: rgba(100, 116, 139, 0.12) !important;
    color: #1e293b !important; 
    border: 1px solid rgba(100, 116, 139, 0.25) !important;
}

[data-theme="dark"] .bg-primary-subtle {
    background-color: rgba(59, 130, 246, 0.2) !important;
    color: #60a5fa !important; 
    border-color: rgba(59, 130, 246, 0.35) !important;
}
[data-theme="dark"] .bg-warning-subtle {
    background-color: rgba(245, 158, 11, 0.2) !important;
    color: #fbbf24 !important; 
    border-color: rgba(245, 158, 11, 0.35) !important;
}
[data-theme="dark"] .bg-success-subtle {
    background-color: rgba(16, 185, 129, 0.2) !important;
    color: #34d399 !important; 
    border-color: rgba(16, 185, 129, 0.35) !important;
}
[data-theme="dark"] .bg-danger-subtle {
    background-color: rgba(239, 68, 68, 0.2) !important;
    color: #f87171 !important; 
    border-color: rgba(239, 68, 68, 0.35) !important;
}
[data-theme="dark"] .bg-secondary-subtle {
    background-color: rgba(148, 163, 184, 0.2) !important;
    color: #cbd5e1 !important; 
    border-color: rgba(148, 163, 184, 0.35) !important;
}

/* Brighter placeholder text for inputs */
::placeholder {
    color: #94a3b8 !important; 
    opacity: 1 !important;
}
[data-theme="dark"] ::placeholder {
    color: #cbd5e1 !important; 
    opacity: 0.85 !important;
}
input[type="date"]::-webkit-datetime-edit-text,
input[type="date"]::-webkit-datetime-edit-month-field,
input[type="date"]::-webkit-datetime-edit-day-field,
input[type="date"]::-webkit-datetime-edit-year-field {
    color: #475569 !important;
}
[data-theme="dark"] input[type="date"]::-webkit-datetime-edit-text,
[data-theme="dark"] input[type="date"]::-webkit-datetime-edit-month-field,
[data-theme="dark"] input[type="date"]::-webkit-datetime-edit-day-field,
[data-theme="dark"] input[type="date"]::-webkit-datetime-edit-year-field {
    color: #cbd5e1 !important;
}

/* Ensure that the dropdown arrows in the "Advanced Filter Directory" are visible against the dark input background */
[data-theme="dark"] .form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23cbd5e1' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
}

/* Enforce "Dark Text on Light Background" inside Follow-up list cards and column overlays */
.followup-list-container .card,
.followup-list-container .card * {
    color: #1e293b !important;
}
.followup-list-container .card .text-secondary {
    color: #475569 !important;
}
.followup-list-container .card .text-muted {
    color: #64748b !important;
}
.followup-list-container .card .text-danger {
    color: #dc3545 !important; 
}
.followup-list-container .card .text-warning-emphasis {
    color: #b58000 !important; 
}
.followup-list-container .card .text-primary {
    color: #0d6efd !important; 
}
.followup-list-container .card h6.text-dark {
    color: #0f172a !important; 
}
.card-panel[style*="background-color"] h6.text-danger {
    color: #dc3545 !important;
}
.card-panel[style*="background-color"] h6.text-warning-emphasis {
    color: #b58000 !important;
}
.card-panel[style*="background-color"] h6.text-primary {
    color: #0d6efd !important;
}

/* Sidebar active state item and centering overrides */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 14px !important; 
    padding: 12px 18px !important; 
}
.sidebar-link i {
    font-size: 1.2rem !important;
    width: 24px !important; 
    text-align: center !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Premium Circular Action Buttons for User Management and Tables */
.table-custom td .btn-sm.rounded-circle,
.table-custom td form button.btn-sm.rounded-circle {
    width: 36px !important;
    height: 36px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.95rem !important;
    border-radius: 50% !important;
    padding: 0 !important;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
    border-width: 1px !important;
}

/* Edit profile (Secondary/Steel outline) */
.table-custom td .edit-user-trigger {
    background-color: rgba(108, 117, 125, 0.08) !important;
    border-color: rgba(108, 117, 125, 0.3) !important;
    color: #4b5563 !important;
}
.table-custom td .edit-user-trigger:hover {
    background-color: #6c757d !important;
    border-color: #6c757d !important;
    color: #ffffff !important;
    transform: translateY(-2px) scale(1.05) !important;
    box-shadow: 0 4px 10px rgba(108, 117, 125, 0.25) !important;
}
[data-theme="dark"] .table-custom td .edit-user-trigger {
    background-color: rgba(156, 163, 175, 0.12) !important;
    border-color: rgba(156, 163, 175, 0.35) !important;
    color: #cbd5e1 !important;
}
[data-theme="dark"] .table-custom td .edit-user-trigger:hover {
    background-color: #9ca3af !important;
    border-color: #9ca3af !important;
    color: #0f172a !important;
    box-shadow: 0 4px 10px rgba(156, 163, 175, 0.3) !important;
}

/* Key Reset (Warning/Gold) */
.table-custom td .pass-reset-trigger {
    background-color: rgba(245, 158, 11, 0.08) !important;
    border-color: rgba(245, 158, 11, 0.3) !important;
    color: #b45309 !important;
}
.table-custom td .pass-reset-trigger:hover {
    background-color: #f59e0b !important;
    border-color: #f59e0b !important;
    color: #0f172a !important;
    transform: translateY(-2px) scale(1.05) !important;
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.25) !important;
}
[data-theme="dark"] .table-custom td .pass-reset-trigger {
    background-color: rgba(245, 158, 11, 0.12) !important;
    border-color: rgba(245, 158, 11, 0.35) !important;
    color: #fbbf24 !important;
}
[data-theme="dark"] .table-custom td .pass-reset-trigger:hover {
    background-color: #fbbf24 !important;
    border-color: #fbbf24 !important;
    color: #0f172a !important;
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.35) !important;
}

/* Shield/Permissions (Primary/Blue) */
.table-custom td .btn-outline-primary.rounded-circle {
    background-color: rgba(59, 130, 246, 0.08) !important;
    border-color: rgba(59, 130, 246, 0.3) !important;
    color: #2563eb !important;
}
.table-custom td .btn-outline-primary.rounded-circle:hover {
    background-color: #3b82f6 !important;
    border-color: #3b82f6 !important;
    color: #ffffff !important;
    transform: translateY(-2px) scale(1.05) !important;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.25) !important;
}
[data-theme="dark"] .table-custom td .btn-outline-primary.rounded-circle {
    background-color: rgba(96, 165, 250, 0.12) !important;
    border-color: rgba(96, 165, 250, 0.35) !important;
    color: #60a5fa !important;
}
[data-theme="dark"] .table-custom td .btn-outline-primary.rounded-circle:hover {
    background-color: #60a5fa !important;
    border-color: #60a5fa !important;
    color: #0f172a !important;
    box-shadow: 0 4px 10px rgba(96, 165, 250, 0.35) !important;
}

/* Delete (Danger/Red) */
.table-custom td .btn-outline-danger.rounded-circle {
    background-color: rgba(239, 68, 68, 0.08) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
    color: #dc2626 !important;
}
.table-custom td .btn-outline-danger.rounded-circle:hover {
    background-color: #ef4444 !important;
    border-color: #ef4444 !important;
    color: #ffffff !important;
    transform: translateY(-2px) scale(1.05) !important;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.25) !important;
}
[data-theme="dark"] .table-custom td .btn-outline-danger.rounded-circle {
    background-color: rgba(248, 113, 113, 0.12) !important;
    border-color: rgba(248, 113, 113, 0.35) !important;
    color: #f87171 !important;
}
[data-theme="dark"] .table-custom td .btn-outline-danger.rounded-circle:hover {
    background-color: #f87171 !important;
    border-color: #f87171 !important;
    color: #0f172a !important;
    box-shadow: 0 4px 10px rgba(248, 113, 113, 0.35) !important;
}

/* ==========================================================================
   INPUT FIELDS VISIBILITY, ACCESS & CONTRAST POLISH
   ========================================================================== */

/* Light mode defined input borders and backgrounds */
.form-control,
.form-select,
textarea {
    background-color: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
}

/* Light mode focus glow state */
.form-control:focus,
.form-select:focus,
textarea:focus {
    border-color: #4299e1 !important;
    box-shadow: 0 0 0 1px #4299e1 !important;
    background-color: #ffffff !important;
}

/* Dark mode inputs and dropdowns polish */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="dark"] .input-group-text,
[data-theme="dark"] .select2-container--bootstrap-5 .select2-selection {
    background-color: #1a202c !important;
    border: 1px solid #2d3748 !important;
    color: #f3f4f6 !important;
}

/* Dark mode select chevron arrow */
[data-theme="dark"] .form-select,
[data-theme="dark"] select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
}

/* Dark mode focus state glow */
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] .select2-container--bootstrap-5.select2-container--focus .select2-selection,
[data-theme="dark"] .select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: #4299e1 !important;
    box-shadow: 0 0 0 1px #4299e1 !important;
    background-color: #1a202c !important;
}

/* Sibling focus sync within input groups */
.input-group:focus-within .input-group-text,
.input-group:focus-within .form-control {
    border-color: #4299e1 !important;
}
[data-theme="dark"] .input-group:focus-within .input-group-text,
[data-theme="dark"] .input-group:focus-within .form-control {
    border-color: #4299e1 !important;
}

/* Select2 dropdown panel theme matching */
[data-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown {
    background-color: #1a202c !important;
    border-color: #2d3748 !important;
}
[data-theme="dark"] .select2-container--bootstrap-5 .select2-search__field {
    background-color: #111827 !important;
    border-color: #2d3748 !important;
}

/* High-contrast placeholder overrides */
::placeholder {
    color: #64748b !important;
    opacity: 1 !important;
}
::-webkit-input-placeholder {
    color: #64748b !important;
    opacity: 1 !important;
}
:-moz-placeholder {
    color: #64748b !important;
    opacity: 1 !important;
}
::-moz-placeholder {
    color: #64748b !important;
    opacity: 1 !important;
}
:-ms-input-placeholder {
    color: #64748b !important;
    opacity: 1 !important;
}

[data-theme="dark"] ::placeholder {
    color: #cbd5e1 !important;
    opacity: 0.85 !important;
}
[data-theme="dark"] ::-webkit-input-placeholder {
    color: #cbd5e1 !important;
    opacity: 0.85 !important;
}
[data-theme="dark"] :-moz-placeholder {
    color: #cbd5e1 !important;
    opacity: 0.85 !important;
}
[data-theme="dark"] ::-moz-placeholder {
    color: #cbd5e1 !important;
    opacity: 0.85 !important;
}
[data-theme="dark"] :-ms-input-placeholder {
    color: #cbd5e1 !important;
    opacity: 0.85 !important;
}

/* ==========================================================================
   MODAL CONTRAST, TYPOGRAPHY AUDIT & CARD DEFINITIONS
   ========================================================================== */

/* Theme-aware modals header, body, and footer default white layout for Light Mode */
.modal-content,
.modal-header,
.modal-body,
.modal-footer {
    background-color: #ffffff !important;
    border-color: #cbd5e1 !important;
}

/* Light mode modals text colors */
.modal-content h1,
.modal-content h2,
.modal-content h3,
.modal-content h4,
.modal-content h5,
.modal-content h6,
.modal-content label,
.modal-content .form-label,
.modal-content p,
.modal-content small,
.modal-content span:not(.badge):not(.btn):not(.select2-selection__rendered):not(.select2-selection__clear),
.modal-content div:not(.select2-container):not(.select2-dropdown):not(.select2-search):not(.select2-results):not(.btn):not(.badge):not(.input-group),
.modal-content .text-muted,
.modal-content .text-secondary,
.modal-content .text-dark {
    color: #1A202C !important;
}

/* Light mode modals close buttons & icons */
.modal-content .btn-close {
    filter: none !important;
    opacity: 0.85 !important;
    background-color: transparent !important;
}
.modal-content .btn-close:hover {
    opacity: 1 !important;
}
.modal-content i,
.modal-content .fa-solid,
.modal-content .fa-regular {
    color: #1A202C !important;
}
.modal-content .btn i,
.modal-content .btn .fa-solid,
.modal-content .btn .fa-regular,
.modal-content .badge i,
.modal-content .badge .fa-solid,
.modal-content .badge .fa-regular {
    color: inherit !important;
}

/* Ensure all tables inside modals have dark text and clean contrast on light rows */
.modal-content table,
.modal-content table th,
.modal-content table td,
.modal-content table tbody tr,
.modal-content table thead th {
    color: #2D3748 !important;
    background-color: transparent !important;
    border-color: #cbd5e1 !important;
}
.modal-content thead {
    background-color: #f1f5f9 !important;
}
.modal-content .table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.02) !important;
}
.modal-content .table-hover tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.04) !important;
}

/* Premium translucent dynamic badges inside modals */
.modal-content .badge {
    text-shadow: none !important;
    box-shadow: none !important;
}
.modal-content .badge.bg-light.text-dark {
    background-color: #f1f5f9 !important;
    color: #1e293b !important;
    border: 1px solid #cbd5e1 !important;
}
.modal-content .badge.bg-info.text-dark {
    background-color: rgba(13, 202, 240, 0.15) !important;
    color: #055160 !important;
    border: 1px solid rgba(13, 202, 240, 0.3) !important;
}
.modal-content .badge.bg-success {
    background-color: rgba(25, 135, 84, 0.15) !important;
    color: #0f5132 !important;
    border: 1px solid rgba(25, 135, 84, 0.3) !important;
}
.modal-content .badge.bg-primary {
    background-color: rgba(13, 110, 253, 0.15) !important;
    color: #084298 !important;
    border: 1px solid rgba(13, 110, 253, 0.3) !important;
}

/* Enforce high-contrast text-secondary globally for perfect contrast */
.text-secondary {
    color: #475569 !important; /* Strong readable dark slate grey in light mode */
}
[data-theme="dark"] .text-secondary {
    color: #A0AEC0 !important; /* High contrast light grey in dark mode */
}

/* Premium card and layout definition in Dark Mode */
[data-theme="dark"] .card {
    background-color: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

/* Lighten informational cards and allocation explanation containers in dark mode */
[data-theme="dark"] .rule-info-box,
[data-theme="dark"] .bg-light,
[data-theme="dark"] .bg-light-subtle,
[data-theme="dark"] .card-panel[style*="background-color"],
[data-theme="dark"] [style*="background-color: #f8fafc"] {
    background-color: #1e293b !important; /* Lighter dark slate */
    border: 1px solid #4a5568 !important; /* Visible defined borders */
}

/* Override inline background styles for custom warning cards in Dark Mode */
[data-theme="dark"] .card[style*="background-color: #fffcf0"],
[data-theme="dark"] .card[style*="background:#fffcf0"] {
    background-color: rgba(245, 158, 11, 0.1) !important; /* Premium soft dark amber */
    border: 1px solid rgba(245, 158, 11, 0.35) !important;
}

/* Ensure checkbox scroll container in mapping cards has high-fidelity dark styling */
[data-theme="dark"] .bg-white.scrollbar-slim,
[data-theme="dark"] .bg-white.border {
    background-color: #1a202c !important;
    border: 1px solid #4a5568 !important;
}

/* Support explicit steel-grey border and lightened background on all inputs in Dark Mode */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="dark"] .input-group-text,
[data-theme="dark"] .select2-container--bootstrap-5 .select2-selection {
    border: 1px solid #4A5568 !important; /* Explicitly 1px solid #4A5568 steel border */
    background-color: #171923 !important; /* Lighter dark background #171923 */
    color: #EDF2F7 !important; /* Premium light white-grey */
}

/* Support defined borders for light mode input fields */
.form-control,
.form-select,
select,
textarea,
.select2-container--bootstrap-5 .select2-selection {
    border: 1px solid #E2E8F0 !important; /* Explicitly 1px solid #E2E8F0 border in light mode */
    background-color: #ffffff !important;
    color: #1A202C !important;
}

/* Dark mode inputs focus state glow */
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] .select2-container--bootstrap-5.select2-container--focus .select2-selection,
[data-theme="dark"] .select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: #3182CE !important;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.25) !important;
    background-color: #171923 !important;
}

/* High-contrast placeholder text inside dark inputs */
[data-theme="dark"] ::placeholder {
    color: #CBD5E0 !important;
    opacity: 1 !important;
}
[data-theme="dark"] ::-webkit-input-placeholder {
    color: #CBD5E0 !important;
    opacity: 1 !important;
}
[data-theme="dark"] :-moz-placeholder {
    color: #CBD5E0 !important;
    opacity: 1 !important;
}
[data-theme="dark"] ::-moz-placeholder {
    color: #CBD5E0 !important;
    opacity: 1 !important;
}
[data-theme="dark"] :-ms-input-placeholder {
    color: #CBD5E0 !important;
    opacity: 1 !important;
}

/* Table cells light and dark mode overrides */
.table-custom td,
.table-custom th {
    color: #2D3748 !important;
}
[data-theme="dark"] .table-custom td,
[data-theme="dark"] .table-custom th {
    color: #F7FAFC !important;
}

/* Typography Audit for Dark Theme (Primary Labels & Small text) */
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5:not(.modal-content h5),
[data-theme="dark"] h6:not(.modal-content h6),
[data-theme="dark"] label:not(.modal-content label),
[data-theme="dark"] .form-label:not(.modal-content .form-label),
[data-theme="dark"] .text-dark:not(.modal-content .text-dark) {
    color: #EDF2F7 !important;
}
[data-theme="dark"] small:not(.modal-content small),
[data-theme="dark"] .text-muted:not(.modal-content .text-muted) {
    color: #A0AEC0 !important;
}

/* Lighten instruction details in allocation view in Dark Mode */
[data-theme="dark"] .rule-info-box small,
[data-theme="dark"] .rule-info-box p,
[data-theme="dark"] .rule-info-box div,
[data-theme="dark"] [style*="background-color: #f8fafc"] .row,
[data-theme="dark"] [style*="background-color: #f8fafc"] div,
[data-theme="dark"] [style*="background-color: #f8fafc"] p {
    color: #E2E8F0 !important;
}
[data-theme="dark"] .rule-info-box span,
[data-theme="dark"] .rule-info-box h1,
[data-theme="dark"] .rule-info-box h2,
[data-theme="dark"] .rule-info-box h3,
[data-theme="dark"] .rule-info-box h4,
[data-theme="dark"] .rule-info-box h5,
[data-theme="dark"] .rule-info-box h6,
[data-theme="dark"] [style*="background-color: #f8fafc"] span {
    color: #FFFFFF !important;
}

/* Subtle badge contrast rules on auto-routing settings */
[data-theme="dark"] .bg-primary-subtle {
    background-color: rgba(59, 130, 246, 0.2) !important;
    color: #60a5fa !important;
    border: 1px solid rgba(59, 130, 246, 0.4) !important;
}
[data-theme="dark"] .bg-success-subtle {
    background-color: rgba(16, 185, 129, 0.2) !important;
    color: #34d399 !important;
    border: 1px solid rgba(16, 185, 129, 0.4) !important;
}
[data-theme="dark"] .bg-secondary-subtle {
    background-color: rgba(148, 163, 184, 0.2) !important;
    color: #e2e8f0 !important;
    border: 1px solid rgba(148, 163, 184, 0.4) !important;
}

/* Enforce high-contrast text color overrides inside cards for readability */
.card .text-secondary,
.card small {
    color: #475569 !important;
}
[data-theme="dark"] .card .text-secondary,
[data-theme="dark"] .card small {
    color: #cbd5e1 !important;
}

/* Dynamic Daily Follow-up Cards & Column transitions in Dark Mode */
[data-theme="dark"] .card-panel[style*="background-color: #fffbfa"],
[data-theme="dark"] .card-panel[style*="background-color: #fffdf5"],
[data-theme="dark"] .card-panel[style*="background-color: #f7faff"] {
    background-color: #111827 !important; /* Premium deep slate */
    border: 1px solid #1f2937 !important;
}

[data-theme="dark"] .followup-list-container .card[style*="background:#ffffff"],
[data-theme="dark"] .followup-list-container .card[style*="background: #ffffff"] {
    background-color: #1e293b !important; /* Lighter slate card */
    border: 1px solid #4a5568 !important;
}

/* Force names, text, telephone, project and action icons inside followup cards to white/light slate in Dark Mode */
[data-theme="dark"] .followup-list-container .card * {
    color: #cbd5e1 !important;
}
[data-theme="dark"] .followup-list-container .card h5,
[data-theme="dark"] .followup-list-container .card h6,
[data-theme="dark"] .followup-list-container .card .fw-bold,
[data-theme="dark"] .followup-list-container .card-title,
[data-theme="dark"] .followup-list-container .card span,
[data-theme="dark"] .followup-list-container .card small {
    color: #cbd5e1 !important;
}
[data-theme="dark"] .followup-list-container .card h5,
[data-theme="dark"] .followup-list-container .card h6,
[data-theme="dark"] .followup-list-container .card .fw-bold,
[data-theme="dark"] .followup-list-container .card-title {
    color: #FFFFFF !important; /* White headers/names */
}
[data-theme="dark"] .followup-list-container .card a.btn-link,
[data-theme="dark"] .followup-list-container .card .lead-action-trigger,
[data-theme="dark"] .followup-list-container .card i {
    color: #FFFFFF !important; /* White call & whatsapp icons! */
}

/* Force followup reminders status badges to bold and white */
.followup-list-container .badge,
.badge-danger,
.badge-warning,
.badge-success,
.badge-primary,
.badge-info {
    font-weight: 700 !important;
    color: #FFFFFF !important;
}

/* Dark mode modals overrides for complete theme compliance */
[data-theme="dark"] .modal-content,
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-body,
[data-theme="dark"] .modal-footer {
    background-color: #111827 !important; /* Solid dark slate modal background */
    border-color: #1f2937 !important;
}

[data-theme="dark"] .modal-content h1,
[data-theme="dark"] .modal-content h2,
[data-theme="dark"] .modal-content h3,
[data-theme="dark"] .modal-content h4,
[data-theme="dark"] .modal-content h5,
[data-theme="dark"] .modal-content h6,
[data-theme="dark"] .modal-content label,
[data-theme="dark"] .modal-content .form-label,
[data-theme="dark"] .modal-content p,
[data-theme="dark"] .modal-content small,
[data-theme="dark"] .modal-content span,
[data-theme="dark"] .modal-content div,
[data-theme="dark"] .modal-content .text-muted,
[data-theme="dark"] .modal-content .text-secondary,
[data-theme="dark"] .modal-content .text-dark {
    color: #EDF2F7 !important; /* Premium light white-grey */
}

/* Dark mode modal close button and icons */
[data-theme="dark"] .modal-content .btn-close {
    filter: invert(1) !important; /* Invert filters enabled for dark background close button */
    opacity: 0.85 !important;
}
[data-theme="dark"] .modal-content i,
[data-theme="dark"] .modal-content .fa-solid,
[data-theme="dark"] .modal-content .fa-regular {
    color: #EDF2F7 !important;
}

/* Dark mode modal tables */
[data-theme="dark"] .modal-content table,
[data-theme="dark"] .modal-content table th,
[data-theme="dark"] .modal-content table td,
[data-theme="dark"] .modal-content table tbody tr,
[data-theme="dark"] .modal-content table thead th {
    color: #F7FAFC !important;
    border-color: #1f2937 !important;
}

/* Dark mode modal badges */
[data-theme="dark"] .modal-content .badge {
    color: #ffffff !important;
}
[data-theme="dark"] .modal-content .badge.bg-light.text-dark {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: #EDF2F7 !important;
    border: 1px solid #1f2937 !important;
}
[data-theme="dark"] .modal-content .badge.bg-info.text-dark {
    background-color: rgba(13, 202, 240, 0.15) !important;
    color: #0dcaf0 !important;
    border: 1px solid rgba(13, 202, 240, 0.3) !important;
}

/* ==========================================================================
   ROBUST ADVANCED UI/UX CONTRAST & VISIBILITY OVERRIDES
   ========================================================================== */

/* 1. Complete robust dynamic modal backgrounds in Dark Mode */
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-body,
html[data-theme="dark"] .modal-footer,
.dark-mode .modal-content,
.dark-mode .modal-header,
.dark-mode .modal-body,
.dark-mode .modal-footer {
    background-color: #111827 !important;
    border-color: #1f2937 !important;
}

/* Force modal labels, forms, spans and basic texts to white/light-grey in Dark Mode */
html[data-theme="dark"] .modal-content label,
html[data-theme="dark"] .modal-content .form-label,
html[data-theme="dark"] .modal-content p,
html[data-theme="dark"] .modal-content small,
html[data-theme="dark"] .modal-content span:not(.badge):not(.btn),
html[data-theme="dark"] .modal-content .text-secondary,
html[data-theme="dark"] .modal-content .text-muted,
html[data-theme="dark"] .modal-content .text-dark {
    color: #EDF2F7 !important;
}

/* Invert standard Bootstrap close button inside dark modals */
html[data-theme="dark"] .modal-content .btn-close {
    filter: invert(1) !important;
    opacity: 0.85 !important;
}

/* 2. Robust follow-up card panel and column background overrides */
[data-theme="dark"] .col-12.col-lg-4 > .card-panel {
    background-color: #111827 !important;
    border: 1px solid #1f2937 !important;
}

[data-theme="dark"] .followup-list-container .card {
    background-color: #1e293b !important;
    border: 1px solid #4a5568 !important;
}

/* In dark mode, ensure all text and details inside follow-up cards have high fidelity contrast */
[data-theme="dark"] .followup-list-container .card * {
    color: #cbd5e1 !important;
}

[data-theme="dark"] .followup-list-container .card h5,
[data-theme="dark"] .followup-list-container .card h6,
[data-theme="dark"] .followup-list-container .card .fw-bold,
[data-theme="dark"] .followup-list-container .card-title {
    color: #FFFFFF !important;
}

/* Ensure call and whatsapp circular trigger buttons have distinct white outline / icon colors */
[data-theme="dark"] .followup-list-container .card a.btn-outline-primary,
[data-theme="dark"] .followup-list-container .card a.btn-outline-success {
    border-color: rgba(255, 255, 255, 0.4) !important;
}

[data-theme="dark"] .followup-list-container .card a.btn-outline-primary:hover,
[data-theme="dark"] .followup-list-container .card a.btn-outline-success:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

[data-theme="dark"] .followup-list-container .card a.btn-outline-primary i,
[data-theme="dark"] .followup-list-container .card a.btn-outline-success i,
[data-theme="dark"] .followup-list-container .card a.btn i {
    color: #FFFFFF !important;
}

/* 3. Robust follow-up profile summary card text visibility (bypasses JS .text-dark rules) */
[data-theme="dark"] #followupLeadInfoBox {
    background-color: #171923 !important;
    border: 1px solid #2d3748 !important;
}

[data-theme="dark"] #followupLeadInfoBox *,
[data-theme="dark"] #followupLeadInfoBox .text-dark,
[data-theme="dark"] #followupLeadInfoBox strong.text-dark,
[data-theme="dark"] #followupLeadInfoBox span.text-dark {
    color: #EDF2F7 !important;
}

/* Modal table header background and text overrides in Dark Mode */
[data-theme="dark"] .modal-content table thead,
[data-theme="dark"] .modal-content table thead th,
[data-theme="dark"] .modal-content .table-light,
[data-theme="dark"] .modal-content .table-light th {
    background-color: #1f2937 !important;
    color: #EDF2F7 !important;
    border-color: #2d3748 !important;
}

/* Standard checkboxes (non-switch) styling inside Dark Mode */
[data-theme="dark"] .form-check-input:not([role="switch"]):not(.form-switch .form-check-input) {
    background-color: #171923 !important;
    border: 1px solid #4A5568 !important;
}
[data-theme="dark"] .form-check-input:not([role="switch"]):not(.form-switch .form-check-input):checked {
    background-color: #3b82f6 !important;
    border-color: #3b82f6 !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e") !important;
}
[data-theme="dark"] .form-check-input:not([role="switch"]):not(.form-switch .form-check-input):focus {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25) !important;
}

/* Premium sliding switch toggle inputs styling inside Dark Mode */
[data-theme="dark"] .form-switch .form-check-input,
[data-theme="dark"] .form-check-input[role="switch"] {
    background-color: #1a202c !important;
    border: 1px solid #4A5568 !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23a0aec0'/%3e%3c/svg%3e") !important;
    transition: background-position .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out !important;
}

[data-theme="dark"] .form-switch .form-check-input:checked,
[data-theme="dark"] .form-check-input[role="switch"]:checked {
    background-color: #3b82f6 !important;
    border-color: #3b82f6 !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23ffffff'/%3e%3c/svg%3e") !important;
}

[data-theme="dark"] .form-switch .form-check-input:focus,
[data-theme="dark"] .form-check-input[role="switch"]:focus {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25) !important;
}

/* Ensure all standard Bootstrap tables (.table) have transparent backgrounds and high contrast text */
.table {
    background-color: transparent !important;
    color: var(--text-primary) !important;
}
.table th,
.table td,
.table tbody tr,
.table thead {
    background-color: transparent !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Dark Mode overrides for standard Bootstrap tables */
[data-theme="dark"] .table {
    color: #F7FAFC !important;
}
[data-theme="dark"] .table th,
[data-theme="dark"] .table td,
[data-theme="dark"] .table tbody tr,
[data-theme="dark"] .table thead {
    color: #F7FAFC !important;
    border-color: #1f2937 !important;
}

/* Subtle table-hover overlay in Dark Mode */
[data-theme="dark"] .table-hover tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.04) !important;
}

/* ==========================================================================
   FORM VALIDATION CONTRAST & RED ASTERISKS OVERRIDES
   ========================================================================== */

/* Was-validated invalid inputs high-contrast overrides */
.was-validated .form-control:invalid,
.was-validated .form-select:invalid,
.was-validated textarea:invalid,
.form-control.is-invalid,
.form-select.is-invalid,
textarea.is-invalid {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25) !important;
}

/* Was-validated valid inputs high-contrast overrides */
.was-validated .form-control:valid,
.was-validated .form-select:valid,
.was-validated textarea:valid,
.form-control.is-valid,
.form-select.is-valid,
textarea.is-valid {
    border-color: #10b981 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15) !important;
}

/* Force asterisk text-danger to remain red inside modals */
.modal-content span.text-danger,
.modal-content .text-danger,
[data-theme="dark"] .modal-content span.text-danger,
[data-theme="dark"] .modal-content .text-danger {
    color: #ef4444 !important;
}
