:root {
    /* Light Mode Variables */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #10b981;
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --glass-bg: rgba(255, 255, 255, 0.8);
    --danger: #ef4444;
    --warning: #f59e0b;
}

[data-theme="dark"] {
    /* Dark Mode Variables */
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --secondary: #34d399;
    --bg-body: #111827;
    --bg-card: #1f2937;
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --border: #374151;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --glass-bg: rgba(31, 41, 55, 0.8);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Base UI Elements */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-family: 'Tajawal', sans-serif;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--primary);
    color: #fff;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-block {
    width: 100%;
}

.input-group {
    margin-bottom: 1.25rem;
    text-align: right;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-muted);
}

.input-group input,
.input-group select,
.input-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--bg-card);
    color: var(--text-main);
    font-family: 'Tajawal', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    animation: fadeIn 0.4s ease forwards;
}

/* Login specific */
#login-container {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-body) 0%, var(--bg-card) 100%);
}

.login-box {
    background: var(--bg-card);
    padding: 3rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
    width: 400px;
    max-width: 90%;
    text-align: center;
    border: 1px solid var(--border);
}

.login-header h2 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.error-msg {
    color: var(--danger);
    margin-top: 1rem;
    font-size: 0.9rem;
}

/* Layout */
#app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    background-color: var(--bg-card);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    color: var(--primary);
}

.nav-links {
    list-style: none;
    padding: 1rem 0;
    flex: 1;
    overflow-y: auto;
}

.nav-links li a {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    border-right: 4px solid transparent;
}

.nav-links li a i {
    margin-left: 1rem;
    font-size: 1.2rem;
    width: 20px;
    text-align: center;
}

.nav-links li a:hover,
.nav-links li a.active {
    background-color: rgba(37, 99, 235, 0.05);
    color: var(--primary);
    border-right-color: var(--primary);
}

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    height: 70px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    z-index: 10;
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.icon-btn:hover {
    color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-info span {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-info small {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* Responsive */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }

    .sidebar {
        position: fixed;
        right: -280px;
        height: 100vh;
    }

    .sidebar.open {
        right: 0;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    }

    .topbar {
        padding: 0 1rem;
    }

    .user-info {
        display: none;
    }
}

/* Utilities */
.mb-4 {
    margin-bottom: 1.5rem;
}

.text-primary {
    color: var(--primary);
}

/* Grid System for Dashboard */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-cols-1 {
    grid-template-columns: repeat(1, 1fr);
}

.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1024px) {
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {

    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }
}

/* Stat Card */
.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: white;
}

.bg-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.bg-success {
    background: linear-gradient(135deg, #34d399, #10b981);
}

.bg-warning {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

.bg-danger {
    background: linear-gradient(135deg, #f87171, #ef4444);
}

.stat-info h3 {
    font-size: 1.8rem;
    margin: 0;
}

.stat-info p {
    color: var(--text-muted);
    margin: 0;
    font-size: 0.9rem;
}

/* Flex utilities */
.flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.align-center {
    align-items: center;
}

.gap-1 {
    gap: 1rem;
}

/* Status Badges */
.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--secondary);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.badge-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
}

/* Table Styles */
.table-responsive {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
}

.table th,
.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.table th {
    background-color: var(--bg-body);
    color: var(--text-muted);
    font-weight: 600;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover {
    background-color: rgba(37, 99, 235, 0.02);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    width: 600px;
    max-width: 95%;
    border-radius: 16px;
    box-shadow: var(--shadow);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Print Styles */
@media print {

    body,
    * {
        background: white !important;
        color: black !important;
    }

    .sidebar,
    .topbar,
    .print-btn,
    #theme-toggle {
        display: none !important;
    }

    #app-container,
    .main-wrapper,
    .content {
        height: auto !important;
        overflow: visible !important;
        display: block !important;
    }

    .card {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        break-inside: avoid;
        margin-bottom: 2rem;
    }

    .grid {
        display: block;
    }

    .grid>div {
        margin-bottom: 1.5rem;
    }
}