:root {
    --primary-color: #4361ee;
    --primary-hover: #3a56d4;
    --secondary-color: #3f37c9;
    --success-color: #4cc9f0;
    --danger-color: #f72585;
    --warning-color: #fca311;
    --dark-color: #2b2d42;
    --light-color: #f8f9fa;
    --body-bg: #f0f2f5;
    --sidebar-bg: #1a1c23;
    --sidebar-width: 260px;
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    --card-radius: 16px;
    --transition: all 0.3s ease;
}

body {
    background-color: var(--body-bg);
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #495057;
    overflow-x: hidden;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    /* LTR Default */
    z-index: 1000;
    padding: 1.5rem 1rem;
    transition: var(--transition);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    color: #fff;
    font-weight: 700;
    font-size: 1.5rem;
    margin-bottom: 2rem;
    text-align: center;
    letter-spacing: 1px;
}

.sidebar .nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 1rem;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
}

/* Custom Scrollbar for Sidebar */
.sidebar .nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar .nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar .nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.sidebar .nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.7);
    padding: 0.8rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 10px;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background: var(--primary-color);
    color: #fff;
    transform: translateX(5px);
}

[dir="rtl"] .sidebar .nav-link:hover,
[dir="rtl"] .sidebar .nav-link.active {
    transform: translateX(-5px);
}

.sidebar .nav-link i {
    width: 24px;
    margin-right: 15px;
    /* LTR */
    text-align: center;
}

[dir="rtl"] .sidebar .nav-link i {
    margin-right: 0;
    margin-left: 15px;
}

/* --- Main Content --- */
.main-wrapper {
    margin-left: var(--sidebar-width);
    /* LTR */
    min-height: 100vh;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

[dir="rtl"] .main-wrapper {
    margin-left: 0;
    margin-right: var(--sidebar-width);
}

.top-navbar {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 900;
}

.page-content {
    padding: 2rem;
    flex: 1;
}

/* --- Mobile Toggle --- */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
    opacity: 0;
    opacity: 0;
    transition: opacity 0.3s;
}

/* Desktop Sidebar Toggle */
body.sidebar-closed .sidebar {
    transform: translateX(-100%);
}

body.sidebar-closed .main-wrapper {
    margin-left: 0 !important;
}

[dir="rtl"] body.sidebar-closed .sidebar {
    transform: translateX(100%);
}

[dir="rtl"] body.sidebar-closed .main-wrapper {
    margin-right: 0 !important;
}

.sidebar.open {
    transform: translateX(0);
}

/* Mobile: Sidebar Hidden by default */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    [dir="rtl"] .sidebar {
        transform: translateX(100%);
    }

    .main-wrapper {
        margin-left: 0;
        margin-right: 0;
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }
}

/* --- Components --- */
.card {
    border: none;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    background: #fff;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.stats-card {
    position: relative;
    overflow: hidden;
}

.stats-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20px;
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: rotate(45deg);
}

.btn {
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.4);
}

.table thead th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    color: #6c757d;
    padding: 1rem;
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
}

/* --- Inputs --- */
.form-control,
.form-select {
    border-radius: 8px;
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

/* --- Animations --- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

/* --- Utils --- */
.cursor-pointer {
    cursor: pointer;
}

.text-xs {
    font-size: 0.75rem;
}

/* --- Mobile Improvements --- */
@media (max-width: 768px) {
    .page-content {
        padding: 1rem;
        /* Reduce padding on mobile */
    }

    .card {
        border-radius: 12px;
        margin-bottom: 1rem;
    }

    .table-responsive {
        border-radius: 8px;
        border: 1px solid #e9ecef;
    }

    .top-navbar {
        padding: 0.8rem 1rem;
    }

    .navbar-text {
        display: none;
        /* Hide welcome text if present */
    }

    h3 {
        font-size: 1.5rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        /* Smaller buttons */
    }
}