/* ========================================
   نظام الألوان والمتغيرات
   ======================================== */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700&display=swap');

:root {
    /* الألوان الرئيسية */
    --primary-color: #27ae60;
    --primary-dark: #219653;
    --primary-gradient: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    --secondary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    
    /* ألوان الخلفية */
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-bg: rgba(255, 255, 255, 0.95);
    --card-border: rgba(255, 255, 255, 0.2);
    
    /* ألوان النصوص */
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --text-light: #ecf0f1;
    
    /* ألوان الحالة */
    --success-color: #2ecc71;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --info-color: #3498db;
    
    /* الظلال والتأثيرات */
    --shadow-sm: 0 2px 5px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.15);
    
    /* الحدود */
    --border-radius: 8px;
    --border-radius-lg: 16px;
    --border-color: #dce0e5;
}

/* ========================================
   الإعدادات الأساسية
   ======================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Tajawal', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-gradient);
    min-height: 100vh;
    direction: rtl;
}

html {
    scroll-behavior: smooth;
}

/* ========================================
   Typography
   ======================================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

/* ========================================
   الحاويات والشبكات
   ======================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

.main-container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 15px;
    position: relative;
    z-index: 1;
}

/* ========================================
   البطاقات (Cards)
   ======================================== */
.app-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--card-border);
    margin-bottom: 20px;
    padding: 25px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.app-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-gradient);
}

.app-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--text-light);
}

.card-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary-color);
}

/* ========================================
   شريط التنقل (Navbar)
   ======================================== */
.navbar {
    background: var(--primary-gradient);
    padding: 15px 20px;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.navbar-brand {
    color: white;
    font-weight: 700;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.nav-link {
    color: white !important;
    opacity: 0.9;
    transition: all 0.2s ease;
    font-weight: 500;
    text-decoration: none;
    padding: 0.5rem 1rem;
}

.nav-link:hover,
.nav-link.active {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
}

/* ========================================
   الأزرار (Buttons)
   ======================================== */
.btn {
    font-size: 14px;
    padding: 10px 18px;
    border-radius: var(--border-radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: var(--primary-dark);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-warning {
    background-color: var(--warning-color);
    color: white;
}

.btn-info {
    background-color: var(--info-color);
    color: white;
}

.btn-outline-secondary {
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background-color: var(--text-light);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
}

.w-100 {
    width: 100%;
}

/* ========================================
   النماذج (Forms)
   ======================================== */
.form-control {
    font-size: 14px;
    padding: 10px 12px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    width: 100%;
    transition: all 0.3s ease;
    font-family: 'Tajawal', sans-serif;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.1);
}

.form-control[readonly] {
    background-color: var(--text-light);
    opacity: 0.8;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-select {
    font-size: 14px;
    padding: 10px 12px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    width: 100%;
    background-color: white;
    cursor: pointer;
}

.form-check {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
}

.form-check-input {
    margin-left: 0.5rem;
    cursor: pointer;
}

.form-check-label {
    cursor: pointer;
}

/* ========================================
   الجداول (Tables)
   ======================================== */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 15px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.table {
    width: 100%;
    margin-bottom: 0;
    border-collapse: collapse;
}

.table thead th {
    background-color: var(--text-light);
    font-weight: 600;
    border: none;
    color: var(--text-primary);
    padding: 12px;
    text-align: center;
}

.table tbody td {
    padding: 12px;
    vertical-align: middle;
    border-bottom: 1px solid var(--text-light);
    text-align: center;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* ========================================
   النتائج والإحصائيات
   ======================================== */
.result-section {
    background: #fff;
    padding: 15px;
    border-radius: var(--border-radius-lg);
    margin-top: 15px;
    box-shadow: var(--shadow-sm);
}

.result-item {
    margin-bottom: 12px;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--text-light);
}

.result-item:last-child {
    border-bottom: none;
}

.result-label {
    color: var(--text-secondary);
}

.result-value {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.positive {
    color: var(--success-color);
}

.negative {
    color: var(--danger-color);
}

/* ========================================
   Utility Classes
   ======================================== */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.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; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }

.d-flex {
    display: flex;
}

.align-items-center {
    align-items: center;
}

.justify-content-between {
    justify-content: space-between;
}

.justify-content-center {
    justify-content: center;
}

.gap-2 {
    gap: 1rem;
}

.gap-3 {
    gap: 1.5rem;
}

/* ========================================
   الإشعارات (Toasts)
   ======================================== */
.toast-container {
    position: fixed;
    top: 80px;
    left: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    min-width: 250px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
}

.toast.success {
    border-right: 4px solid var(--success-color);
}

.toast.danger,
.toast.error {
    border-right: 4px solid var(--danger-color);
}

.toast.warning {
    border-right: 4px solid var(--warning-color);
}

.toast.info {
    border-right: 4px solid var(--info-color);
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ========================================
   التذييل (Footer)
   ======================================== */
.footer {
    text-align: center;
    padding: 30px 20px;
    margin-top: 50px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer a:hover {
    color: var(--primary-color);
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 992px) {
    .container,
    .main-container {
        padding: 0 10px;
    }
}

@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
    
    .app-card {
        padding: 15px;
    }
    
    .btn {
        padding: 8px 14px;
        font-size: 13px;
    }
}

@media (max-width: 576px) {
    .form-control {
        padding: 8px;
        font-size: 13px;
    }
    
    .table thead th,
    .table tbody td {
        padding: 8px 6px;
        font-size: 13px;
    }
    
    .btn-sm {
        padding: 4px 8px;
        font-size: 12px;
    }
    
    .toast-container {
        left: 10px;
        right: 10px;
        top: 70px;
    }
    
    .toast {
        min-width: auto;
        width: 100%;
    }
}

/* ========================================
   Loading Spinner
   ======================================== */
.loading-spinner {
    border: 3px solid var(--text-light);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
