:root {
    --primary-color: #4361ee;
    --secondary-color: #3f37c9;
    --sidebar-bg: #212529;
    --sidebar-text: #ffffff;
    --sidebar-active-bg: rgba(255, 255, 255, 0.15);
    --body-bg: #f3f4f6;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --border-radius: 1rem;
    --text-main: #333;
    --text-muted: #6b7280;
}

/* Global Table Styles - No Wrap */
.table th, .table td,
.glass-table th, .glass-table td {
    white-space: nowrap !important;
    vertical-align: middle;
}
.btn {
    white-space: nowrap;
}

body {
    background-color: var(--body-bg);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    overflow-x: hidden;
    color: var(--text-main);
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    width: 260px;
    padding: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px 0 rgba(0,0,0,0.05);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    height: 80px;
    padding: 20px 1.5rem 0 1.5rem;
    background: transparent;
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.sidebar-header h3 {
    font-size: 24px;
    margin: 0;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.5px;
    line-height: 45px;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.75rem;
}

.nav-link {
    color: rgba(255, 255, 255, 0.85);
    padding: 0.85rem 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.nav-link:hover {
    color: #fff;
    background-color: rgba(255,255,255,0.1);
    transform: translateX(4px);
}

.nav-link.active {
    color: #fff;
    background-color: var(--sidebar-active-bg);
    font-weight: 600;
    box-shadow: none;
}

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

.sidebar-footer {
    padding: 1.5rem;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.6);
    text-align: center;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* Main Content */
.main-content {
    margin-left: 260px;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

.top-navbar {
    background: #fff;
    padding: 0.8rem 1.5rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 72px;
    position: sticky;
    top: 0;
    z-index: 99;
    transition: all 0.3s ease;
}

/* Custom Toggle Buttons */
.btn-toggle-menu {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
}
.btn-toggle-menu:hover {
    background-color: var(--secondary-color);
    color: white;
}

.btn-logout {
    width: 40px; /* Icon only on mobile/compact */
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ef4444;
    color: white;
    border: none;
    border-radius: 0.5rem;
    text-decoration: none;
    transition: background-color 0.2s;
}
.btn-logout:hover {
    background-color: #dc2626;
    color: white;
}
.btn-logout span {
    display: none; /* Hidden by default */
}

/* Page Content */
.page-content {
    padding: 1.5rem;
    flex: 1;
}

/* Cards */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    background: #fff;
    margin-bottom: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #f3f4f6;
    padding: 1.25rem 1.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: #111827;
    border-top-left-radius: var(--border-radius) !important;
    border-top-right-radius: var(--border-radius) !important;
}

.card-body {
    padding: 1.5rem;
}

/* Stats Card Redesign */
.stats-card {
    background: #fff;
    border: none;
    border-left: 5px solid var(--primary-color); /* Default */
    border-radius: 0.75rem;
    padding: 1.25rem;
    height: 100%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stats-card h6 {
    color: #6b7280;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.stats-card h2 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    color: #111827;
}

.stats-card .sub-text {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 0.25rem;
}

/* Quick Action Buttons (Solid Color) */
.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    border-radius: 0.75rem;
    color: white;
    text-decoration: none;
    height: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.quick-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px rgba(0,0,0,0.15);
    color: white;
}
.quick-action-btn i {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}
.quick-action-btn span {
    font-weight: 600;
    font-size: 0.9rem;
}
.btn-bg-primary { background-color: #4361ee; }
.btn-bg-success { background-color: #10b981; }
.btn-bg-info { background-color: #3b82f6; } /* Adjusted info color */
.btn-bg-warning { background-color: #f59e0b; }
.btn-bg-danger { background-color: #ef4444; }
.btn-bg-secondary { background-color: #6b7280; }
.btn-bg-dark { background-color: #374151; }

/* Mobile Responsiveness */
@media (max-width: 768px) {
    /* Mobile Sidebar - Horizontal Bar */
    .sidebar {
        position: fixed !important;
        transform: none !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        height: auto !important; /* Allow height to adjust */
        min-height: 60px !important;
        flex-direction: row !important;
        z-index: 1030 !important; /* Lowered from 9990 to be below modals (1055) */
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1) !important;
        padding: 0 !important;
        overflow: visible !important; /* Allow child scroll */
        margin: 0 !important;
        background: #ffffff !important; /* White background */
        border-top: 1px solid #e5e7eb !important;
    }
    
    .sidebar.show {
        transform: none !important;
    }

    .sidebar-header, .sidebar-footer {
        display: none !important;
    }
    
    .sidebar-menu {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        width: 100% !important;
        padding: 0 !important;
        overflow-x: auto !important; /* Enable horizontal scroll */
        overflow-y: hidden !important;
        margin: 0 !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
    }
    
    .sidebar-menu::-webkit-scrollbar {
        display: none;
    }
    
    .sidebar .nav-link {
        flex-direction: column;
        justify-content: center;
        padding: 8px 4px !important;
        margin: 0 !important;
        border-radius: 0;
        text-align: center;
        height: 100%;
        min-width: auto !important;
        width: auto !important;
        flex: 1 1 0 !important; /* Average distribution */
        background: transparent !important; 
        color: #6b7280 !important; /* Gray text */
    }
    
    .sidebar .nav-link:hover {
        transform: none;
        background: rgba(0,0,0,0.02) !important;
        color: var(--primary-color) !important;
    }
    
    .sidebar .nav-link span {
        display: block !important; /* Show text */
        font-size: 10px !important;
        line-height: 1.2;
        margin-top: 4px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .sidebar .nav-link i {
        font-size: 1.25rem;
        margin: 0;
        color: inherit;
    }
    
    /* Active state for bottom bar */
    .sidebar .nav-link.active {
        color: var(--primary-color) !important;
        background: transparent !important;
        box-shadow: none;
        position: relative;
    }
    .sidebar .nav-link.active::after {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 30px;
        height: 3px;
        background: var(--primary-color);
        border-radius: 0 0 4px 4px;
    }

    /* Adjust main content padding */
    .main-content {
        padding-bottom: 100px !important; /* Increased padding */
        margin-left: 0 !important;
    }
    
    /* Hide the top toggle button */
    .btn-toggle-menu {
        display: none !important;
    }
    
    .page-content {
        padding: 1rem;
    }
    
    .top-navbar {
        padding: 0.8rem 1rem;
    }

    .btn-logout {
        width: auto;
        padding: 0 1rem;
    }
    .btn-logout i {
        margin-right: 0.5rem;
    }
    .btn-logout span {
        display: inline;
        font-weight: 600;
    }
    
    /* Overlay no longer needed */
    /* .sidebar-overlay {
        display: none !important;
    } */

    /* Disable complex animations on mobile for better performance and layout stability */
    .animate-fade-in-up,
    .animate-fade-in-up.delay-100,
    .animate-fade-in-up.delay-200,
    .animate-fade-in-up.delay-300 {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

@media (min-width: 768px) {
    .w-md-auto {
        width: auto !important;
    }
}

/* Table Animation: Float up from bottom */
@keyframes floatUpTable {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body:not(.page-index):not(.page-login) table tbody tr {
    animation: floatUpTable 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0; /* Start invisible */
    transform: translateY(20px);
    position: relative; /* Ensure z-index works */
    transition: z-index 0s; /* Instant z-index change */
}

/* Ensure hovered row or row with focus (e.g. open dropdown) stays on top */
body:not(.page-index):not(.page-login) table tbody tr:hover,
body:not(.page-index):not(.page-login) table tbody tr:focus-within {
    z-index: 100;
}

/* Staggered delay for first 40 rows */
body:not(.page-index):not(.page-login) table tbody tr:nth-child(1) { animation-delay: 0.05s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(2) { animation-delay: 0.1s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(3) { animation-delay: 0.15s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(4) { animation-delay: 0.2s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(5) { animation-delay: 0.25s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(6) { animation-delay: 0.3s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(7) { animation-delay: 0.35s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(8) { animation-delay: 0.4s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(9) { animation-delay: 0.45s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(10) { animation-delay: 0.5s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(11) { animation-delay: 0.55s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(12) { animation-delay: 0.6s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(13) { animation-delay: 0.65s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(14) { animation-delay: 0.7s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(15) { animation-delay: 0.75s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(16) { animation-delay: 0.8s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(17) { animation-delay: 0.85s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(18) { animation-delay: 0.9s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(19) { animation-delay: 0.95s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(20) { animation-delay: 1.0s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(21) { animation-delay: 1.05s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(22) { animation-delay: 1.1s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(23) { animation-delay: 1.15s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(24) { animation-delay: 1.2s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(25) { animation-delay: 1.25s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(26) { animation-delay: 1.3s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(27) { animation-delay: 1.35s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(28) { animation-delay: 1.4s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(29) { animation-delay: 1.45s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(30) { animation-delay: 1.5s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(31) { animation-delay: 1.55s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(32) { animation-delay: 1.6s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(33) { animation-delay: 1.65s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(34) { animation-delay: 1.7s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(35) { animation-delay: 1.75s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(36) { animation-delay: 1.8s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(37) { animation-delay: 1.85s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(38) { animation-delay: 1.9s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(39) { animation-delay: 1.95s; }
body:not(.page-index):not(.page-login) table tbody tr:nth-child(40) { animation-delay: 2.0s; }
