:root {
    /* Color Palette - Light Mode Default */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-secondary-rgb: 255, 255, 255;
    --bg-sidebar: #1e293b;
    /* Dark Blue */
    --sidebar-text: #e2e8f0;
    --sidebar-text-muted: #94a3b8;
    --sidebar-accent: #2F78C4;
    /* Bright Blue */

    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --accent-teal: #2F78C4;
    --accent-teal-soft: rgba(47, 120, 196, 0.1);

    --accent-blue: #2F78C4;
    --accent-blue-soft: rgba(47, 120, 196, 0.1);

    --accent-red: #e11d48;
    --accent-red-soft: #fff1f2;

    --accent-amber: #d97706;
    --accent-amber-soft: #fffbeb;

    --border-color: #e2e8f0;
    --sidebar-width: 280px;
    --sidebar-shrunk-width: 90px;
    --layout-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --card-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --card-shadow-hover: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

/* Global Reset for Horizontal Scroll */
html,
body {
    overflow-x: hidden;
    width: 100%;
    margin: 0;
    padding: 0;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-secondary-rgb: 30, 41, 59;
    --bg-sidebar: #1e293b;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-teal: #60a5fa;
    --accent-teal-soft: rgba(96, 165, 250, 0.1);

    --accent-blue: #60a5fa;
    --accent-blue-soft: rgba(96, 165, 250, 0.1);

    --accent-red: #fb7185;
    --accent-red-soft: rgba(251, 113, 133, 0.1);

    --accent-amber: #fbbf24;
    --accent-amber-soft: rgba(251, 191, 36, 0.1);

    --border-color: #334155;
    --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.2);
    --card-shadow-hover: 0 10px 15px -3px rgb(0 0 0 / 0.3);
}

* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Sidebar Styling */
#sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    /* Very subtle border */
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 100;
    transition: var(--layout-transition);
}

/* Scrollbar Styling for Navigation */
#sidebar nav {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

#sidebar nav::-webkit-scrollbar {
    width: 4px;
}

#sidebar nav::-webkit-scrollbar-track {
    background: transparent;
}

#sidebar nav::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
}

/* Active Link Highlights */
/* Sidebar Navigation Item */
.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    color: var(--sidebar-text);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    margin-bottom: 0.25rem;
}

.sidebar-nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #ffffff;
    transform: none;
    /* Removed movement */
    box-shadow: none !important;
}

/* Active State - Left Border Style */
.sidebar-nav-item.active {
    background-color: rgba(47, 120, 196, 0.15) !important;
    color: #ffffff !important;
    border-left: 4px solid var(--sidebar-accent) !important;
    border-radius: 0 0.75rem 0.75rem 0 !important;
    box-shadow: none !important;
    transform: none !important;
    font-weight: 600;
}

.sidebar-nav-item.active i {
    color: var(--sidebar-accent) !important;
}

/* Submenu Styling Removed as per request */

/* User Profile Card */
.user-profile-card {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: auto;
    transition: all 0.2s ease;
    cursor: pointer;
}

.user-profile-card:hover {
    background-color: rgba(255, 255, 255, 0.06);
    border-color: var(--sidebar-accent);
    box-shadow: none;
    /* Removed shadow */
}

.user-profile-img {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    object-fit: cover;
    background-color: var(--accent-teal-soft);
}

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

.user-profile-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-profile-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Shrunk Sidebar Adjustments */
body.sidebar-shrunk .user-profile-info,
body.sidebar-shrunk .user-profile-card .chevron-icon {
    display: none;
}

body.sidebar-shrunk .user-profile-card {
    justify-content: center;
    padding: 0.5rem;
}

/* Dark Mode Adjustments */
[data-theme="dark"] .sidebar-nav-item.active {
    background-color: var(--sidebar-accent);
    box-shadow: none !important;
}


body.sidebar-shrunk #sidebar {
    width: var(--sidebar-shrunk-width);
}

#header-container {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    z-index: 90;
    background-color: var(--bg-sidebar);
    /* Match Sidebar Background */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem 2rem;
    transition: var(--layout-transition);
    color: #ffffff;
}

#header-container h1 {
    color: #ffffff !important;
}

#header-container p {
    color: #94a3b8 !important;
    /* Lighter slate for subtext */
}

#header-container .bg-bg-secondary {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: #f1f5f9 !important;
}

#header-container .bg-bg-secondary:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: var(--accent-teal) !important;
}

[data-theme="dark"] #header-container {
    background-color: var(--bg-sidebar);
}

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 6rem 2rem 2rem 2rem;
    /* Top padding increased for fixed header */
    transition: var(--layout-transition);
}

body.sidebar-shrunk #header-container {
    left: var(--sidebar-shrunk-width);
}

body.sidebar-shrunk .main-content {
    margin-left: var(--sidebar-shrunk-width);
}

/* Shrunk Sidebar Details */
/* Hide certain elements that don't fit the vertical stack */
body.sidebar-shrunk #sidebar p,
body.sidebar-shrunk #sidebar .chevron-icon,
body.sidebar-shrunk .logo-text {
    display: none !important;
}

body.sidebar-shrunk #sidebar .sidebar-header {
    flex-direction: column;
    padding: 1.5rem 0.5rem;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

body.sidebar-shrunk #sidebar .sidebar-header .flex.items-center.gap-3 {
    flex-direction: column !important;
    overflow: visible !important;
    width: 100% !important;
    justify-content: center !important;
}

body.sidebar-shrunk #sidebar .logo-wrapper {
    padding: 0.5rem;
    background: transparent !important;
    box-shadow: none !important;
}

body.sidebar-shrunk #sidebar .logo-wrapper img {
    height: 2rem;
    width: 2rem;
    object-fit: contain;
}

/* Sidebar Nav Item - Vertical Stack */
body.sidebar-shrunk .sidebar-nav-item {
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0.75rem 0.25rem !important;
    min-height: 60px;
}

body.sidebar-shrunk .sidebar-nav-item .flex.items-center.gap-3 {
    flex-direction: column !important;
    gap: 0.25rem !important;
}

body.sidebar-shrunk .sidebar-nav-item i {
    font-size: 1.3rem !important;
    width: auto !important;
    margin: 0 !important;
}

body.sidebar-shrunk .sidebar-nav-item span {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    font-size: 0.6rem !important;
    font-weight: 600;
    line-height: normal;
    text-align: center;
    width: 100% !important;
    white-space: nowrap;
}

/* Submenu in shrunk mode */
body.sidebar-shrunk .submenu {
    padding-left: 0 !important;
    margin-left: 0 !important;
    border-left: none !important;
    background-color: rgba(37, 99, 235, 0.05);
    /* Very light blue background */
}

body.sidebar-shrunk .submenu.open {
    display: flex !important;
    flex-direction: column !important;
    max-height: 500px !important;
    opacity: 1 !important;
}

body.sidebar-shrunk .submenu a {
    padding: 0.5rem 0.25rem !important;
    justify-content: center !important;
    text-align: center !important;
    font-size: 0.55rem !important;
    margin: 0 !important;
}

/* Hide separators when shrunk */
body.sidebar-shrunk #sidebar .px-3>p {
    display: none !important;
}

#sidebar-toggle {
    cursor: pointer;
    transition: all 0.3s ease;
}

/* Adjust padding */
body.sidebar-shrunk #sidebar .px-6,
body.sidebar-shrunk #sidebar .px-3 {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

body.sidebar-shrunk #sidebar .mb-10 {
    margin-bottom: 1rem;
}

#sidebar-toggle {
    cursor: pointer;
    transition: all 0.3s ease;
}

.sidebar-header {
    background-color: transparent !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

#sidebar .logo-text {
    color: #ffffff !important;
}

[data-theme="dark"] .sidebar-header {
    background: transparent !important;
}

.logo-wrapper {
    transition: all 0.3s ease;
    background-color: transparent !important;
    box-shadow: none !important;
}

[data-theme="dark"] .logo-wrapper {
    background-color: transparent !important;
    box-shadow: none !important;
}

body.sidebar-shrunk #sidebar-toggle {
    transform: rotate(180deg);
}

/* Card Styling */
.stats-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stats-card:hover {
    box-shadow: var(--card-shadow-hover);
}

.stats-card.teal {
    border-left: 4px solid var(--accent-teal);
}

.stats-card.blue {
    border-left: 4px solid var(--accent-blue);
}

.stats-card.red {
    border-left: 4px solid var(--accent-red);
}

.stats-card.amber {
    border-left: 4px solid var(--accent-amber);
}

/* Table Styling */
.modern-table-container {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: var(--card-shadow);
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
}

.modern-table th {
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    text-align: left;
    padding: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.modern-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

/* Utility Classes */
.text-teal {
    color: var(--accent-teal);
}

.bg-teal-soft {
    background-color: var(--accent-teal-soft);
}

.text-blue {
    color: var(--accent-blue);
}

.bg-blue-soft {
    background-color: var(--accent-blue-soft);
}

.text-red {
    color: var(--accent-red);
}

.bg-red-soft {
    background-color: var(--accent-red-soft);
}

.text-amber {
    color: var(--accent-amber);
}

.bg-amber-soft {
    background-color: var(--accent-amber-soft);
}

/* Submenu Styling */
.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.3s ease;
    opacity: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding-left: 1rem;
    /* Reduced from 3rem */
    border-left: 1px solid var(--border-color);
    margin-left: 1.25rem;
}

.submenu.open {
    max-height: 500px;
    /* Large enough to fit content */
    opacity: 1;
    margin-bottom: 0.5rem;
}

.chevron-icon {
    transition: transform 0.3s ease;
}

.chevron-rotate {
    transform: rotate(180deg);
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    #sidebar {
        transform: translateX(-100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 2000 !important;
        box-shadow: 15px 0 35px rgba(0, 0, 0, 0.3);
        height: 100vh;
        width: 280px !important;
    }

    #sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 1rem 0 !important;
        /* Edge to edge on mobile */
    }

    /* Mobile Backdrop */
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(5px);
        z-index: 1500 !important;
        opacity: 0;
        visibility: hidden;
        transition: all 0.4s ease;
    }

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Responsive Header Container */
    #header-container {
        position: sticky;
        top: 0;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        z-index: 100 !important;
        background: var(--bg-sidebar);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding: 0.75rem 1.25rem !important;
        margin: 0 !important;
        display: flex;
        align-items: center;
    }

    #header-container h1,
    #header-container p,
    #header-container .text-text-primary,
    #header-container .text-text-secondary {
        color: #ffffff !important;
    }

    #header-container button,
    #header-container .bg-bg-secondary {
        background-color: rgba(255, 255, 255, 0.1) !important;
        border-color: rgba(255, 255, 255, 0.1) !important;
        color: #f1f5f9 !important;
    }
}

/* Table Responsiveness Improvements */
@media (max-width: 768px) {
    .hide-on-mobile {
        display: none !important;
    }

    .table-responsive-compact td,
    .table-responsive-compact th {
        padding: 0.75rem 0.5rem !important;
    }

    .mobile-stack {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.25rem !important;
    }

    .mobile-row-card {
        padding: 1rem !important;
    }
}

/* Scrollbar styling for narrow tables */
.scrollbar-hide::-webkit-scrollbar {
    height: 4px;
}

.scrollbar-hide::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.scrollbar-hide::-webkit-scrollbar-track {
    background: transparent;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

/* Selected Row Styles */
.selected-row {
    background-color: rgba(47, 120, 196, 0.03) !important;
    border-left: 4px solid #2F78C4 !important;
}

.selected-row-checkbox {
    background-color: #2F78C4 !important;
    border-color: #2F78C4 !important;
}

/* Drag and Drop Styles */
.bulk-action-btn:active {
    cursor: grabbing !important;
}

.dragging {
    opacity: 0.5;
    border: 2px dashed #2F78C4 !important;
}

.drop-target {
    background-color: rgba(47, 120, 196, 0.1) !important;
    border: 2px solid #2F78C4 !important;
}