:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    --secondary: #f59e0b;
    --accent: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #1e293b;
    --bg-hover: rgba(255, 255, 255, 0.1);
    
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --text-white: #ffffff;
    
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    direction: rtl;
    text-align: right;
}

.app-container {
    display: flex;
    min-height: 100vh;
    flex-direction: row-reverse;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    padding: 2rem 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}

.logo {
    text-align: center;
    padding: 0 1.5rem 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 2rem;
}

.logo-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-white);
    letter-spacing: -0.5px;
}

.nav-menu {
    flex: 1;
    padding: 0 1rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1.125rem;
    margin-bottom: 0.375rem;
    color: var(--text-light);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    font-weight: 600;
    font-size: 0.9375rem;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-white);
    transform: translateX(4px);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: var(--text-white);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.nav-icon {
    font-size: 1.375rem;
    width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-left: 280px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-header {
    background: var(--bg-card);
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border-color);
}

.page-title {
    font-size: 1.625rem;
    font-weight: 800;
    color: var(--text-primary);
    position: relative;
    padding-right: 1rem;
}

.page-title::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 65%;
    background: linear-gradient(180deg, var(--primary), var(--secondary));
    border-radius: 2px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.date-time {
    padding: 0.5rem 1rem;
    background: var(--bg-main);
    border-radius: var(--radius-sm);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 1rem;
    background: var(--bg-main);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-menu:hover {
    background: var(--primary);
    color: var(--text-white);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.user-avatar {
    font-size: 1.375rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    border-radius: 50%;
}

.user-name {
    font-weight: 700;
    font-size: 0.9375rem;
}

.content-area {
    padding: 2rem;
    flex: 1;
}

/* ===== STATS CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    background: currentColor;
    opacity: 0.05;
    border-radius: 50%;
    transform: translate(25%, -25%);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: currentColor;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.stat-icon {
    font-size: 2.25rem;
    opacity: 0.9;
}

.stat-value {
    font-size: 1.875rem;
    font-weight: 900;
    line-height: 1.2;
    margin-bottom: 0.25rem;
    direction: ltr;
    text-align: left;
}

.stat-label {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-top: 0.375rem;
}

.stat-card.primary { color: var(--primary); }
.stat-card.success { color: var(--success); }
.stat-card.warning { color: var(--warning); }
.stat-card.danger { color: var(--danger); }
.stat-card.info { color: var(--info); }
.stat-card.secondary { color: var(--secondary); }

/* ===== TABLES ===== */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.table-header {
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-main);
}

.table-title {
    font-size: 1.125rem;
    font-weight: 800;
    color: var(--text-primary);
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

thead {
    background: var(--bg-main);
}

th {
    padding: 1rem 1.25rem;
    text-align: right;
    font-weight: 800;
    color: var(--text-primary);
    font-size: 0.875rem;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
}

tbody tr {
    transition: all 0.15s ease;
}

tbody tr:hover {
    background: var(--bg-main);
}

/* ===== BUTTONS ===== */
.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Cairo', sans-serif;
    font-size: 0.9375rem;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: var(--text-white);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
}

.btn-success {
    background: linear-gradient(135deg, #34d399, var(--success));
    color: var(--text-white);
}

.btn-warning {
    background: linear-gradient(135deg, #fbbf24, var(--warning));
    color: var(--text-white);
}

.btn-danger {
    background: linear-gradient(135deg, #f87171, var(--danger));
    color: var(--text-white);
}

.btn-sm {
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
}

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-lg);
    font-size: 0.8125rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-secondary {
    background: rgba(100, 116, 139, 0.15);
    color: #64748b;
    border: 1px solid rgba(100, 116, 139, 0.3);
}

/* ===== FORMS ===== */
.form-container {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: 'Cairo', sans-serif;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
    background: var(--bg-card);
    color: var(--text-primary);
    font-weight: 500;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* ===== NUMBERS ===== */
.format-number, .format-currency {
    font-weight: 700;
    direction: ltr;
    display: inline-block;
    text-align: left;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.empty-title {
    font-size: 1.375rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
    
    .main-content {
        margin-left: 240px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        left: auto;
        right: 0;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .top-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    table {
        font-size: 0.8125rem;
    }
    
    th, td {
        padding: 0.75rem 0.875rem;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.content-area > * {
    animation: fadeIn 0.4s ease-out;
}

/* ===== UTILITIES ===== */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.text-center { text-align: center; }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
