:root {
    /* DEFAULT LIGHT MODE COLORS */
    --bg-dark-base: #f8fafc;
    --bg-dark-surface: #ffffff;
    --bg-dark-input: #ffffff;
    
    --primary-color: #2C5EAD;
    --primary-hover: #1f488a;
    --success-color: #1591DC;
    --success-hover: #1178b6;
    --warning-color: #4BB8FA;
    --warning-hover: #3ca2df;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --info-color: #C4E2F5;
    --info-hover: #adcce0;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    
    --border-glass: rgba(0, 0, 0, 0.08);
    --border-glass-bright: rgba(0, 0, 0, 0.15);
    --bg-glass: #ffffff;
    --bg-glass-dark: #ffffff;
    
    --font-inter: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-outfit: 'Poppins', sans-serif;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* DARK MODE OVERRIDES */
.dark-theme, html.dark-theme {
    --bg-dark-base: #090d16;
    --bg-dark-surface: #0f172a;
    --bg-dark-input: rgba(15, 23, 42, 0.55);
    
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glass-bright: rgba(255, 255, 255, 0.15);
    --bg-glass: rgba(30, 41, 59, 0.45);
    --bg-glass-dark: #0f172a;
}

/* Base Body Styling */
body {
    background-color: var(--bg-dark-base);
    color: var(--text-primary);
    font-family: var(--font-inter);
    min-height: 100vh;
    overflow-x: hidden;
    letter-spacing: -0.1px;
}

/* Typography Utilities */
.font-outfit {
    font-family: var(--font-outfit);
}
.text-gradient {
    background: linear-gradient(135deg, #ffffff 30%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.text-success-glow {
    color: #34d399;
    text-shadow: 0 0 10px rgba(52, 211, 153, 0.3);
}
.text-warning-glow {
    color: #fbbf24;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.3);
}
.text-danger-glow {
    color: #f87171;
    text-shadow: 0 0 10px rgba(248, 113, 113, 0.3);
}
.text-info-glow {
    color: #38bdf8;
    text-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark-base);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Background Glow Bubbles */
.glow-bubble-1, .glow-bubble-2 {
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    opacity: 0.2;
    pointer-events: none;
}
.glow-bubble-1 {
    top: 10%;
    left: -100px;
    background: var(--primary-color);
}
.glow-bubble-2 {
    bottom: 10%;
    right: -100px;
    background: var(--info-color);
}

/* Auth Pages Styling */
.auth-wrapper {
    position: relative;
    background-color: var(--bg-dark-base);
    overflow: hidden;
}
.auth-card {
    border-radius: 20px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transform: translateY(0);
    transition: var(--transition-smooth);
}
.auth-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

/* Layout Containers */
.app-container {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: 260px;
    background-color: var(--bg-dark-surface);
    border-right: 1px solid var(--border-glass);
    flex-shrink: 0;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    z-index: 1060; /* Ensure mobile drawer slides on top of navbar */
}
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.content-wrapper {
    flex-grow: 1;
}

/* Top Navbar */
.top-navbar {
    background-color: rgba(9, 13, 22, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-glass);
    z-index: 1050; /* Stack on top of cards, but below mobile sidebar drawer */
    position: relative;
}
.profile-avatar {
    width: 28px;
    height: 28px;
    font-size: 11px;
}

/* Sidebar Menu navigation link states */
.sidebar .nav-link {
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--transition-smooth);
}
.sidebar .nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary) !important;
}
.sidebar .nav-link.active {
    background: rgba(44, 94, 173, 0.15) !important;
    border: 1px solid rgba(44, 94, 173, 0.25);
    color: var(--text-primary) !important;
}
.sidebar .nav-link.active i {
    color: var(--primary-color) !important;
}

/* Glassmorphic Cards styling */
.bg-glass {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
}
.bg-glass-dark {
    background: var(--bg-glass-dark);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
}
.border-glass {
    border: 1px solid var(--border-glass);
}
.border-dashed {
    border-style: dashed !important;
}

/* Glowing widgets backgrounds */
.bg-primary-glow {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    box-shadow: 0 4px 15px rgba(44, 94, 173, 0.3);
}
.bg-success-glow {
    background: linear-gradient(135deg, var(--success-color), var(--success-hover));
    box-shadow: 0 4px 15px rgba(21, 145, 220, 0.3);
}
.bg-warning-glow {
    background: linear-gradient(135deg, var(--warning-color), var(--warning-hover));
    box-shadow: 0 4px 15px rgba(75, 184, 250, 0.3);
}
.bg-danger-glow {
    background: linear-gradient(135deg, var(--danger-color), var(--danger-hover));
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}
.bg-info-glow {
    background: linear-gradient(135deg, var(--info-color), var(--info-hover));
    box-shadow: 0 4px 15px rgba(196, 226, 245, 0.25);
    color: #0f172a !important; /* Ensure readable dark text on light yellow background */
}

/* Card Widget specific */
.widget-card {
    transition: var(--transition-smooth);
}
.widget-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.15);
}
.widget-icon {
    width: 42px;
    height: 42px;
    font-size: 16px;
    border-radius: 50%;
}

/* Hero card design */
.card-hero {
    overflow: hidden;
}
.glow-hero {
    position: absolute;
    top: -50px;
    right: -50px;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.45) 0%, rgba(14, 165, 233, 0.15) 100%);
    filter: blur(40px);
    z-index: 0;
}

/* Form elements overrides */
.form-control, .form-select {
    background-color: var(--bg-dark-input);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition-smooth);
}
.form-control:focus, .form-select:focus {
    background-color: rgba(15, 23, 42, 0.85);
    border-color: var(--primary-color);
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.25);
    color: var(--text-primary);
}
.placeholder-muted::placeholder {
    color: var(--text-muted) !important;
}

/* Table styling for dark theme */
.table-glass {
    border-collapse: separate;
    border-spacing: 0 6px;
}
.table-glass tbody tr {
    background: rgba(30, 41, 59, 0.2);
    transition: var(--transition-smooth);
    border-radius: 8px;
}
.table-glass tbody tr:hover {
    background: rgba(30, 41, 59, 0.4) !important;
}
.table-glass th, .table-glass td {
    padding: 12px 16px !important;
    border: none !important;
}
.table-glass tbody tr td:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}
.table-glass tbody tr td:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

/* Notifications Bell drop menu & General Dropdowns z-index fix */
.dropdown-menu {
    z-index: 1200 !important;
    background: var(--bg-glass-dark) !important;
    border: 1px solid var(--border-glass) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
}
.notification-menu {
    width: 320px;
    background: var(--bg-glass-dark) !important;
    border: 1px solid var(--border-glass) !important;
    border-radius: 12px !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25) !important;
    z-index: 1200 !important;
}
.dropdown-item {
    color: var(--text-primary) !important;
    font-family: var(--font-outfit);
    font-size: 13.5px;
    padding: 8px 16px;
    transition: var(--transition-smooth);
}
.dropdown-item:hover, .dropdown-item:focus {
    background-color: var(--primary-color) !important;
    color: var(--text-primary) !important;
}
.dropdown-divider {
    border-color: var(--border-glass) !important;
}
.notification-item {
    transition: var(--transition-smooth);
}
.notification-item.unread {
    background: rgba(99, 102, 241, 0.06);
}
.notification-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* Button glow accents */
.btn {
    font-size: 13.5px;
    border-radius: 8px;
    transition: var(--transition-smooth);
}
.btn-primary-glow {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.25);
    border: none;
}
.btn-primary-glow:hover {
    background: linear-gradient(135deg, var(--primary-hover), #1f488a);
    box-shadow: 0 6px 20px rgba(44, 94, 173, 0.4);
    transform: translateY(-1px);
}
.btn-success-glow {
    background: linear-gradient(135deg, var(--success-color), var(--success-hover));
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.25);
    border: none;
}
.btn-success-glow:hover {
    background: linear-gradient(135deg, var(--success-hover), #047857);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}
.btn-warning-glow {
    background: linear-gradient(135deg, var(--warning-color), var(--warning-hover));
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.25);
    border: none;
}
.btn-warning-glow:hover {
    background: linear-gradient(135deg, var(--warning-hover), #b45309);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
    transform: translateY(-1px);
}
.btn-danger-glow {
    background: linear-gradient(135deg, var(--danger-color), var(--danger-hover));
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.25);
    border: none;
}
.btn-danger-glow:hover {
    background: linear-gradient(135deg, var(--danger-hover), #b91c1c);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}
.btn-info-glow {
    background: linear-gradient(135deg, var(--info-color), var(--info-hover));
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.25);
    border: none;
}
.btn-info-glow:hover {
    background: linear-gradient(135deg, var(--info-hover), #0369a1);
    box-shadow: 0 6px 20px rgba(14, 165, 233, 0.4);
    transform: translateY(-1px);
}
.btn-xs {
    padding: 3px 8px;
    font-size: 10.5px;
}

/* Tab panes formatting */
.nav-tabs .nav-link {
    color: var(--text-secondary);
    border-bottom: 2px solid transparent !important;
}
.nav-tabs .nav-link:hover {
    color: var(--text-primary);
}
.nav-tabs .nav-link.active {
    color: var(--primary-color) !important;
    border-bottom: 2px solid var(--primary-color) !important;
    font-weight: 600;
}

/* Modal formatting override */
.modal-content {
    background: var(--bg-glass-dark);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass-bright);
}

/* Support system thread styles */
.user-message {
    border-left: 3px solid var(--primary-color);
}
.admin-message {
    border-left: 3px solid var(--success-color);
}

/* -------------------------------------------------------------
   VISUAL TREE VIEW DIAGRAM GRAPHICS
   ------------------------------------------------------------- */
.visual-tree-container {
    text-align: center;
    position: relative;
    user-select: none;
}
.tree-level {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}
.tree-node {
    display: inline-block;
    transition: var(--transition-smooth);
}
.tree-node:hover {
    transform: scale(1.02);
}
.tree-node .node-wrapper {
    transition: var(--transition-smooth);
}
.tree-node:hover .node-wrapper {
    box-shadow: 0 10px 25px rgba(99,102,241,0.25);
    border-color: var(--border-glass-bright);
}
.active-node .node-wrapper {
    box-shadow: 0 5px 20px rgba(44, 94, 173, 0.4) !important;
}
.node-avatar-small {
    font-size: 9px;
}
.empty-slot .node-wrapper {
    background: rgba(15, 23, 42, 0.25) !important;
}

/* Downline list widgets */
.widget-icon-small {
    width: 32px;
    height: 32px;
}

/* Responsive Drawer Styles for Sidebar */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: -260px;
        bottom: 0;
        height: 100vh;
        box-shadow: 20px 0 40px rgba(0, 0, 0, 0.4);
    }
    .sidebar.show {
        left: 0;
    }
}

/* Light Theme Readability Overrides */
html:not(.dark-theme) body {
    color: #0f172a;
}
html:not(.dark-theme) .text-white {
    color: #0f172a !important;
}
html:not(.dark-theme) .text-white-50 {
    color: #475569 !important;
}
html:not(.dark-theme) .text-muted {
    color: #64748b !important;
}
html:not(.dark-theme) .bg-glass {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
}
html:not(.dark-theme) .bg-glass-dark {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
}
html:not(.dark-theme) .border-glass {
    border-color: rgba(0, 0, 0, 0.08) !important;
}
html:not(.dark-theme) .btn-close-white {
    filter: invert(1) !important;
}
html:not(.dark-theme) .table-dark {
    --bs-table-bg: #ffffff !important;
    --bs-table-color: #0f172a !important;
    --bs-table-hover-bg: #f1f5f9 !important;
    --bs-table-hover-color: #0f172a !important;
    --bs-table-border-color: rgba(0, 0, 0, 0.05) !important;
}
html:not(.dark-theme) .table-glass tbody tr {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
}
html:not(.dark-theme) .table-glass tbody tr:hover {
    background: #f1f5f9 !important;
}
html:not(.dark-theme) .table-glass th {
    color: #475569 !important;
}
html:not(.dark-theme) .sidebar {
    background-color: #ffffff !important;
    border-right: 1px solid rgba(0, 0, 0, 0.08) !important;
}
html:not(.dark-theme) .sidebar .nav-link {
    color: #475569 !important;
}
html:not(.dark-theme) .sidebar .nav-link:hover {
    background: rgba(0, 0, 0, 0.04) !important;
    color: #0f172a !important;
}
html:not(.dark-theme) .sidebar .nav-link.active {
    background: rgba(44, 94, 173, 0.1) !important;
    color: var(--primary-color) !important;
}
html:not(.dark-theme) .sidebar .nav-link.active i {
    color: var(--primary-color) !important;
}
html:not(.dark-theme) .dropdown-menu {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
}
html:not(.dark-theme) .dropdown-item {
    color: #0f172a !important;
}
html:not(.dark-theme) .dropdown-item:hover,
html:not(.dark-theme) .dropdown-item:focus {
    background-color: var(--primary-color) !important;
    color: #ffffff !important;
}
html:not(.dark-theme) .modal-content {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    color: #0f172a !important;
}
html:not(.dark-theme) .form-control,
html:not(.dark-theme) .form-select {
    background-color: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
}
html:not(.dark-theme) .form-control:focus,
html:not(.dark-theme) .form-select:focus {
    background-color: #ffffff !important;
    border-color: var(--primary-color) !important;
}
html:not(.dark-theme) .placeholder-muted::placeholder {
    color: #94a3b8 !important;
}
html:not(.dark-theme) .glow-bubble-1,
html:not(.dark-theme) .glow-bubble-2,
html:not(.dark-theme) .glow-hero {
    opacity: 0.05 !important;
}

/* Dark Mode Notification legibility and style overrides */
.dark-theme .notification-menu .text-muted,
html.dark-theme .notification-menu .text-muted,
.dark-theme .notification-menu .notification-item .text-muted,
html.dark-theme .notification-menu .notification-item .text-muted {
    color: #94a3b8 !important;
}
.dark-theme .notification-menu .border-bottom,
html.dark-theme .notification-menu .border-bottom,
.dark-theme .notification-menu .notification-item,
html.dark-theme .notification-menu .notification-item {
    border-color: rgba(255, 255, 255, 0.08) !important;
}
.dark-theme .notification-item.unread,
html.dark-theme .notification-item.unread {
    background: rgba(44, 94, 173, 0.1) !important;
}
.dark-theme .notification-item:hover,
html.dark-theme .notification-item:hover {
    background: rgba(255, 255, 255, 0.04) !important;
}
