:root {
    --primary-color: #4361ee;
    --secondary-color: #3a0ca3;
    --accent-color: #4cc9f0;
    --sidebar-gradient: linear-gradient(180deg, #4361ee 0%, #3a0ca3 100%);
    --header-gradient: linear-gradient(135deg, #4361ee 0%, #3a0ca3 100%);
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --header-height: 70px;
    --mobile-nav-height: 60px;
    --border-radius: 12px;
    --box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background-color: #f8fafc;
    color: #334155;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Global Loading Overlay */
#globalLoadingOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--header-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 99999;
    transition: opacity 0.3s ease;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: app-layout-spin 1s ease-in-out infinite;
}

@keyframes app-layout-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Main Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-gradient);
    z-index: 1000;
    overflow-y: auto;
    transition: var(--transition);
    box-shadow: var(--box-shadow);
}

.sidebar-wrapper.collapsed {
    width: var(--sidebar-collapsed-width);
}

.main-content-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.main-content-wrapper.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

/* Desktop Main Header */
.main-header {
    background: var(--header-gradient);
    height: var(--header-height);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-left h1 {
    color: white;
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    position: relative;
    text-decoration: none;
}

.header-action-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-2px);
    color: white;
}

.header-action-btn .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 0.7rem;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.25rem;
    border-radius: 50px;
    transition: var(--transition);
    cursor: pointer;
}

.user-dropdown-toggle:hover {
    background: rgba(255,255,255,0.1);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.3);
}

.user-name {
    color: white;
    font-weight: 500;
    font-size: 0.9rem;
}

/* Mobile Navbar */
.mobile-navbar {
    transition: opacity 0.3s ease;
}

/* Content Area */
.main-content {
    flex: 1;
    padding: 1.5rem;
    background: #f8fafc;
}

/* Footer for Authenticated Users */
.auth-footer {
    background: white;
    border-top: 1px solid #e2e8f0;
    padding: 1.5rem;
    margin-top: auto;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: #64748b;
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: var(--primary-color);
}

.footer-copyright {
    color: #94a3b8;
    font-size: 0.875rem;
}

/* Notification Bell Animation */
@keyframes bell-ring {
    0% { transform: rotate(0); }
    10% { transform: rotate(-15deg); }
    20% { transform: rotate(15deg); }
    30% { transform: rotate(-10deg); }
    40% { transform: rotate(10deg); }
    50% { transform: rotate(-5deg); }
    60% { transform: rotate(5deg); }
    100% { transform: rotate(0); }
}

.has-notification i.bi-bell {
    animation: bell-ring 2s ease infinite;
}

/* Modern Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Card Hover Effects */
.card-hover {
    transition: var(--transition);
    border: 1px solid #e2e8f0;
}

.card-hover:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border-color: var(--accent-color);
}

/* Gradient Text */
.gradient-text {
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Mobile Menu Toggle Animation */
.navbar-toggler {
    transition: var(--transition);
    border: none;
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    background: transparent;
}

.navbar-toggler span {
    display: block;
    width: 20px;
    height: 2px;
    background: white;
    transition: var(--transition);
    border-radius: 2px;
}

.navbar-toggler[aria-expanded="true"] span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.navbar-toggler[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.navbar-toggler[aria-expanded="true"] span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Toast Notifications */
.toast-container {
    z-index: 9999;
}

.custom-toast {
    border-radius: var(--border-radius);
    border: none;
    box-shadow: var(--box-shadow);
    backdrop-filter: blur(10px);
    background: rgba(255,255,255,0.95);
}

/* Page Titles */
.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 1.5rem;
}

.page-subtitle {
    color: #64748b;
    font-size: 1rem;
    margin-bottom: 2rem;
}

/* Scroll to Top */
#scroll-top {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

/* Mobile Quick Action */
#mobileQuickAction {
    transition: transform 0.3s ease;
    transform: translateY(100px);
}

/* Responsive Layout */
@media (max-width: 767.98px) {
    .sidebar-wrapper {
        display: none;
    }

    .main-content-wrapper,
    .main-content-wrapper.sidebar-collapsed {
        margin-left: 0;
        padding-top: var(--mobile-nav-height);
    }

    .mobile-navbar {
        height: var(--mobile-nav-height);
        background: var(--header-gradient);
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
    }

    .mobile-navbar .navbar-brand {
        font-size: 1.1rem;
        font-weight: 600;
    }

    .mobile-navbar .btn {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: 1px solid rgba(255,255,255,0.2);
        background: rgba(255,255,255,0.1);
    }

    .main-header {
        display: none;
    }

    .main-content {
        padding: 1rem;
    }

    .auth-footer {
        display: none;
    }
}

@media (min-width: 768px) {
    .mobile-navbar {
        display: none;
    }
}