/* ===== الخطوط ===== */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700&display=swap');

/* ===== متغيرات CSS ===== */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --light-color: #ecf0f1;
    --dark-color: #2c3e50;
    --text-color: #333;
    --border-color: #ddd;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 5px 15px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s ease;
    --border-radius: 8px;
    --border-radius-sm: 4px;
    --container-padding: 15px;
}

/* ===== إعادة تعيين عامة ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: #f5f5f5;
    color: var(--text-color);
    line-height: 1.6;
    direction: rtl;
    overflow-x: hidden;
    min-height: 100vh;
    scroll-behavior: smooth;
    font-size: 16px;
}

a {
    text-decoration: none;
    color: var(--secondary-color);
}

ul {
    list-style: none;
}

/* ===== الحاويات ===== */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--container-padding);
    position: relative;
}

/* ===== الرأس ===== */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem 0;
    box-shadow: var(--shadow-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: var(--transition);
}

.logo h1 {
    font-size: 1.5rem;
    margin: 0;
    padding: 0 1rem;
}

nav ul {
    display: flex;
    flex-wrap: wrap;
}

nav ul li {
    margin: 0 0.5rem;
}

nav ul li a {
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    display: block;
    font-weight: 500;
}

nav ul li a:hover, nav ul li a.active {
    background-color: var(--secondary-color);
}

.user-info {
    display: flex;
    align-items: center;
    padding: 0 1rem;
}

.logout-btn {
    margin-right: 1rem;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1rem;
}

/* ===== الأقسام الرئيسية ===== */
main {
    padding: 2rem 0;
    min-height: calc(100vh - 70px);
}

.section {
    display: none;
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 2rem;
    transition: var(--transition);
    animation: fadeIn 0.5s ease;
}

.section.active {
    display: block;
}

.section h2 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

/* ===== لوحة التحكم ===== */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
    animation: slideUp 0.5s ease;
}

.stat-card {
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    transition: var(--transition);
    border-right: 4px solid var(--secondary-color);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    font-size: 2rem;
    margin-left: 1rem;
    color: var(--secondary-color);
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(52, 152, 219, 0.1);
    border-radius: 50%;
}

.stat-info h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.stat-info p {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.quick-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ===== الأزرار ===== */
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
    text-transform: none;
}

.btn i {
    margin-left: 0.5rem;
}

.primary-btn {
    background-color: var(--secondary-color);
    color: white;
}

.primary-btn:hover {
    background-color: #2980b9;
}

.secondary-btn {
    background-color: var(--primary-color);
    color: white;
}

.secondary-btn:hover {
    background-color: #1a252f;
}

.info-btn {
    background-color: #3498db;
    color: white;
}

.info-btn:hover {
    background-color: #2980b9;
}

.danger-btn {
    background-color: var(--danger-color);
    color: white;
}

.danger-btn:hover {
    background-color: #c0392b;
}

.cancel-btn {
    background-color: #95a5a6;
    color: white;
}

.cancel-btn:hover {
    background-color: #7f8c8d;
}

/* ===== شريط الإجراءات ===== */
.actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.search-container {
    display: flex;
    align-items: center;
}

.search-container input {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px 0 0 4px;
    font-family: 'Cairo', sans-serif;
}

.search-btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
}

.filter-container {
    display: flex;
    align-items: center;
}

.filter-container label {
    margin-left: 0.5rem;
}

.filter-container input[type="date"] {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: 'Cairo', sans-serif;
}

/* ===== الجداول ===== */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
}

table th, table td {
    padding: 0.75rem;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: var(--primary-color);
}

table tbody tr:hover {
    background-color: #f8f9fa;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    margin: 0 0.25rem;
    color: var(--secondary-color);
}

.action-btn.edit {
    color: var(--warning-color);
}

.action-btn.delete {
    color: var(--danger-color);
}

/* ===== النوافذ المنبثقة ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
    padding: 2rem 0;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
    width: 90%;
    max-width: 500px;
    margin: 0 auto;
    animation: modalFadeIn 0.3s;
}

.modal-lg {
    max-width: 800px;
}

.modal-sm {
    max-width: 400px;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-50px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: var(--primary-color);
}

.close-modal {
    font-size: 1.5rem;
    cursor: pointer;
    color: #aaa;
    transition: color 0.3s;
}

.close-modal:hover {
    color: var(--danger-color);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* ===== النماذج ===== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: 'Cairo', sans-serif;
    font-size: 1rem;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* ===== تفاصيل العميل ===== */
.customer-info {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

.customer-info p {
    margin-bottom: 0.5rem;
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    font-weight: 500;
    color: var(--text-color);
}

.tab-btn.active {
    border-bottom-color: var(--secondary-color);
    color: var(--secondary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ===== نافذة تسجيل الدخول ===== */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-container {
    background-color: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
    width: 90%;
    max-width: 400px;
    padding: 2rem;
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.login-container h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.input-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.input-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: 'Cairo', sans-serif;
    font-size: 1rem;
}

.toggle-password {
    position: absolute;
    left: 10px;
    top: 35px;
    cursor: pointer;
    color: #aaa;
}

/* ===== التكيف مع الشاشات المختلفة ===== */
@media (max-width: 992px) {
    .container {
        max-width: 100%;
        padding: 0 10px;
    }
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        padding: 1rem;
    }
    
    .logo, nav, .user-info {
        width: 100%;
        margin-bottom: 1rem;
        text-align: center;
    }
    
    nav ul {
        justify-content: center;
    }
    
    .user-info {
        justify-content: center;
    }
    
    .stats-container {
        grid-template-columns: 1fr;
    }
    
    .actions-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-container, .filter-container {
        width: 100%;
    }
    
    .search-container input {
        width: 100%;
    }
    
    .modal-content {
        width: 95%;
        margin: 0 auto;
    }
}

/* ===== الرسائل ===== */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

/* ===== الترقيم ===== */
.pagination {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}

.pagination-btn {
    padding: 0.5rem 1rem;
    margin: 0 0.25rem;
    border: 1px solid var(--border-color);
    background-color: white;
    cursor: pointer;
    border-radius: 4px;
    font-family: 'Cairo', sans-serif;
}

.pagination-btn.active {
    background-color: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

/* ===== التحميل ===== */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--secondary-color);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== تحسينات إضافية ===== */

/* تأثيرات الحركة */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* تحسين الجداول للأجهزة الصغيرة */
@media (max-width: 600px) {
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table th, table td {
        white-space: nowrap;
    }
}

/* تحسين تجربة المستخدم */
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

/* تحسين أزرار الإجراءات */
.action-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.action-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.action-btn.edit:hover {
    background-color: rgba(243, 156, 18, 0.1);
}

.action-btn.delete:hover {
    background-color: rgba(231, 76, 60, 0.1);
}

/* تحسين النوافذ المنبثقة */
.modal-content {
    transform: translateY(0);
    transition: transform 0.3s ease;
}

/* تحسين الأزرار */
.btn:active {
    transform: translateY(2px);
}

/* تحسين الشريط العلوي */
header.scrolled {
    padding: 0.5rem 0;
    background-color: rgba(44, 62, 80, 0.95);
    backdrop-filter: blur(10px);
}

/* تحسين عرض الأقسام */
.section.active {
    animation: fadeIn 0.3s ease;
}

/* تحسين نموذج تسجيل الدخول */
.login-container {
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255,255,255,0.1);
}

/* تحسين الإدخال */
.input-group input:focus + .toggle-password {
    color: var(--secondary-color);
}

/* تحسين الجداول */
table tbody tr {
    transition: var(--transition);
}

table tbody tr:nth-child(even) {
    background-color: rgba(0,0,0,0.02);
}

/* تحسين الرسائل */
.alert {
    border-right: 4px solid transparent;
    animation: slideUp 0.3s ease;
}

.alert-success {
    border-right-color: var(--success-color);
}

.alert-danger {
    border-right-color: var(--danger-color);
}

.alert-warning {
    border-right-color: var(--warning-color);
}

/* تحسين الأزرار الرئيسية */
.primary-btn, .secondary-btn, .info-btn, .danger-btn {
    position: relative;
    overflow: hidden;
}

.primary-btn::after, .secondary-btn::after, .info-btn::after, .danger-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background-color: rgba(255,255,255,0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s;
    z-index: 0;
}

.primary-btn:active::after, .secondary-btn:active::after, .info-btn:active::after, .danger-btn:active::after {
    width: 300px;
    height: 300px;
}

.btn i, .btn span {
    position: relative;
    z-index: 1;
}
