:root {
    --brand-blue: #2c3892;
    --brand-purple: #9d2cb3;
    --brand-cyan: #00bcd4;
    --brand-orange: #ff9800;
    --brand-gradient: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
    --brand-soft-bg: #f8fafc;
    
    /* UI Spacing & Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-brand: 0 8px 15px rgba(157, 44, 179, 0.2);
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-pill: 50rem;
}

body {
    font-family: 'Inter', 'Roboto', sans-serif;
    background-color: #f8fafc;
    color: #334155;
    letter-spacing: 0.2px;
}

/* Utilities */
.text-brand { color: var(--brand-purple) !important; }
.bg-brand { background-color: var(--brand-blue) !important; color: white; }
.bg-gradient-brand { background: var(--brand-gradient) !important; color: white; }

/* Loader */
#global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s;
}
.loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(157, 44, 179, 0.1);
    border-radius: 50%;
    border-top-color: var(--brand-purple);
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.loader-hidden {
    opacity: 0;
    visibility: hidden;
}

/* Skeleton Loaders */
.skeleton {
    background: #e2e8f0;
    background: linear-gradient(110deg, #ececec 8%, #f5f5f5 18%, #ececec 33%);
    border-radius: 5px;
    background-size: 200% 100%;
    animation: 1.5s shine linear infinite;
}
@keyframes shine {
    to { background-position-x: -200%; }
}

/* Layout Elements */
#wrapper { overflow-x: hidden; }
#sidebar-wrapper {
    height: 100vh;
    height: 100dvh; /* Modern mobile height */
    margin-left: -250px;
    transition: margin .3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.05);
    z-index: 1050;
    border-right: none !important;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: #ffffff;
    border-right: 1px solid #e2e8f0 !important;
    padding-bottom: 50px; /* Space for the bottom links */
}
#sidebar-wrapper .sidebar-heading {
    padding: 1.5rem 1.25rem;
    font-size: 1.2rem;
    border-bottom: 1px solid #e2e8f0 !important;
}
#sidebar-wrapper .list-group { width: 250px; }

/* Sidebar List Items */
#sidebar-wrapper .list-group-item {
    margin: 6px 12px;
    border-radius: 12px;
    padding: 0.8rem 1.2rem;
    color: #475569;
    font-weight: 500;
    transition: all 0.3s ease;
    border: none;
    background: transparent;
}
#sidebar-wrapper .list-group-item i {
    color: #94a3b8;
    transition: color 0.2s;
}
#sidebar-wrapper .list-group-item:hover {
    background-color: rgba(44, 56, 146, 0.05) !important;
    color: var(--brand-blue);
    margin: 6px 12px;
    border-radius: 12px;
}
#sidebar-wrapper .list-group-item:hover i {
    color: var(--brand-blue);
}
#sidebar-wrapper .list-group-item.active {
    background: rgba(30, 41, 59, 0.95) !important; /* Deep Navy Glass */
    backdrop-filter: blur(12px);
    color: #ffffff !important;
    box-shadow: 0 8px 20px rgba(44, 56, 146, 0.3), 0 0 15px rgba(79, 70, 229, 0.2); /* Glowing Blue Shadow */
    margin: 6px 12px;
    border-radius: 12px;
    border: 1px solid rgba(79, 70, 229, 0.3); /* Blueish border glow */
}
#sidebar-wrapper .list-group-item.active i {
    color: #ffffff !important;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}
#sidebar-wrapper .text-muted {
    color: #64748b !important;
}

/* Custom Scrollbar for Sidebar */
#sidebar-wrapper::-webkit-scrollbar {
    width: 4px;
}
#sidebar-wrapper::-webkit-scrollbar-track {
    background: transparent;
}
#sidebar-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

#page-content-wrapper { min-width: 100vw; }

/* Topbar Refinement */
.navbar {
    background: rgba(255, 255, 255, 0.98) !important;
    backdrop-filter: blur(12px);
    border-bottom: 1px solid #e2e8f0 !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    z-index: 1020;
}

@media (max-width: 767.98px) {
    #sidebar-wrapper {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        height: 100dvh;
        width: 250px;
        margin-left: -250px;
        transition: margin .3s ease;
        overflow-y: auto;
        padding-bottom: 100px; /* Extra padding for mobile navigation bars */
    }
    #wrapper.toggled #sidebar-wrapper { margin-left: 0; }
    #wrapper.toggled::after {
        content: "";
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    #page-content-wrapper { min-width: 100vw !important; }
}

@media (min-width: 768px) {
    #sidebar-wrapper { margin-left: 0; position: sticky; top: 0; height: 100vh; }
    #page-content-wrapper { min-width: 0; width: 100%; }
    #wrapper.toggled #sidebar-wrapper { margin-left: -250px; }
}

/* Table Responsiveness */
.table-responsive {
    border-radius: var(--radius-md);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Material Cards */
.card {
    border: 1px solid rgba(0,0,0,0.02);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #ffffff;
}
.card.hover-elevate:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* Modern Forms */
.form-outline .form-control {
    border-radius: 8px;
}
.form-control:focus {
    border-color: var(--brand-purple);
    box-shadow: 0 0 0 0.25rem rgba(157, 44, 179, 0.15);
}

/* Buttons */
.btn {
    border-radius: 8px;
    text-transform: none;
    font-weight: 500;
    letter-spacing: 0.3px;
    box-shadow: var(--shadow-sm);
}
.btn.rounded-pill {
    border-radius: var(--radius-pill);
}

/* Status Chips (Badges) */
.badge-status {
    padding: 0.5em 1em;
    font-weight: 600;
    letter-spacing: 0.3px;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
}
.bg-status-new { background-color: #e0f2fe; color: #0284c7; }
.bg-status-star { background-color: #fef3c7; color: #d97706; }
.bg-status-callback { background-color: #fff7ed; color: #c2410c; }
.bg-status-visitfollowup { background-color: #ffedd5; color: #9a3412; }
.bg-status-visit { background-color: #dcfce7; color: #16a34a; }
.bg-status-operation { background-color: #e0e7ff; color: #4f46e5; }
.bg-status-junk { background-color: #fee2e2; color: #dc2626; }
.bg-status-dnp { background-color: #f1f5f9; color: #475569; }

/* DataTables Customization */
table.dataTable {
    border-collapse: separate !important;
    border-spacing: 0 0.5rem !important;
}
table.dataTable thead th {
    border-bottom: none !important;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    padding: 1rem !important;
}
table.dataTable tbody tr {
    background: #ffffff;
    box-shadow: var(--shadow-sm);
    border-radius: 8px;
    transition: all 0.2s;
}
table.dataTable tbody tr:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
table.dataTable tbody td {
    border-top: none !important;
    border-bottom: none !important;
    padding: 1rem !important;
    vertical-align: middle;
}
table.dataTable tbody td:first-child { border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
table.dataTable tbody td:last-child { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0 !important;
    margin: 0 4px !important;
    border: none !important;
}
.page-item .page-link {
    border-radius: 50% !important;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    border: none;
    margin: 0 2px;
}
.page-item.active .page-link {
    background: var(--brand-gradient);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* Floating Action Button */
.btn-floating {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1030;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    background: var(--brand-gradient);
    color: white;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn-floating:hover {
    transform: scale(1.1) rotate(5deg);
    color: white;
}
