/* =====================================================
   نظام الفواتير - الأنماط الرئيسية
   Invoice System - Main Styles
===================================================== */

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

html, body {
    height: 100%;
    font-family: 'Segoe UI', Tahoma, Arial, 'Cairo', sans-serif;
    direction: rtl;
    background: #f5f7fa;
    color: #333;
    font-size: 14px;
    line-height: 1.6;
}

/* ===== التخطيط الرئيسي ===== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ===== الشريط الجانبي ===== */
.sidebar {
    width: 250px;
    background: linear-gradient(180deg, #2c3e50 0%, #1a252f 100%);
    color: white;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    padding: 10px 0;
}

.sidebar-nav a {
    display: block;
    padding: 12px 20px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    transition: all 0.2s;
    border-right: 3px solid transparent;
    font-size: 14px;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.sidebar-nav a.active {
    background: rgba(102, 126, 234, 0.2);
    color: white;
    border-right-color: #667eea;
}

.sidebar-divider {
    border: none;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin: 10px 20px;
}

.sidebar-section {
    padding: 10px 20px;
    font-size: 11px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.4);
    letter-spacing: 1px;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
}

.user-role {
    font-size: 11px;
    color: rgba(255,255,255,0.6);
}

.btn-logout {
    display: block;
    text-align: center;
    padding: 8px;
    background: rgba(231, 76, 60, 0.2);
    color: #ff6b6b;
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: rgba(231, 76, 60, 0.3);
}

/* ===== المحتوى الرئيسي ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.page-header {
    background: white;
    padding: 20px 30px;
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 600;
    color: #2c3e50;
}

.page-content {
    flex: 1;
    padding: 25px 30px;
}

/* ===== البطاقات ===== */
.card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 18px 22px;
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.card-body {
    padding: 22px;
}

/* ===== الإحصائيات ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 25px;
}

.stat-card {
    background: white;
    border-radius: 10px;
    padding: 22px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border-right: 4px solid #667eea;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.stat-card.success { border-right-color: #2ecc71; }
.stat-card.warning { border-right-color: #f39c12; }
.stat-card.danger { border-right-color: #e74c3c; }
.stat-card.info { border-right-color: #3498db; }

.stat-icon {
    font-size: 28px;
    margin-bottom: 10px;
}

.stat-label {
    color: #7f8c8d;
    font-size: 13px;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: #2c3e50;
}

.stat-change {
    font-size: 12px;
    margin-top: 6px;
    color: #95a5a6;
}

/* ===== الأزرار ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-success { background: #2ecc71; color: white; }
.btn-success:hover { background: #27ae60; }

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

.btn-warning { background: #f39c12; color: white; }
.btn-warning:hover { background: #d68910; }

.btn-secondary { background: #95a5a6; color: white; }
.btn-secondary:hover { background: #7f8c8d; }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }

.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ===== الجداول ===== */
.table-wrapper {
    overflow-x: auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: #f8f9fa;
}

.data-table th {
    padding: 12px 16px;
    text-align: right;
    font-weight: 600;
    color: #2c3e50;
    font-size: 13px;
    border-bottom: 2px solid #e1e5e9;
    white-space: nowrap;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f2f5;
    color: #4a5568;
}

.data-table tbody tr {
    transition: background 0.15s;
}

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

.data-table tbody tr:last-child td {
    border-bottom: none;
}

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

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 13px;
}

.form-group label .required { color: #e74c3c; }

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-control[disabled],
.form-control[readonly] {
    background: #f5f7fa;
    color: #7f8c8d;
}

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

select.form-control {
    cursor: pointer;
    background: white;
}

/* ===== الإشعارات ===== */
#toast-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    padding: 14px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border-right: 4px solid #667eea;
    min-width: 280px;
    animation: slideIn 0.3s ease;
}

.toast.success { border-right-color: #2ecc71; }
.toast.error { border-right-color: #e74c3c; }
.toast.warning { border-right-color: #f39c12; }

@keyframes slideIn {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== الشارات (Badges) ===== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-secondary { background: #e2e3e5; color: #383d41; }

/* ===== النوافذ المنبثقة (Modal) ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    padding: 18px 22px;
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    color: #2c3e50;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #95a5a6;
}

.modal-body { padding: 22px; }

.modal-footer {
    padding: 15px 22px;
    border-top: 1px solid #e1e5e9;
    display: flex;
    gap: 10px;
    justify-content: flex-start;
}

/* ===== رسائل التنبيه ===== */
.alert {
    padding: 12px 18px;
    border-radius: 6px;
    margin-bottom: 18px;
    border-right: 4px solid;
}

.alert-success { background: #d4edda; color: #155724; border-color: #28a745; }
.alert-danger { background: #f8d7da; color: #721c24; border-color: #dc3545; }
.alert-warning { background: #fff3cd; color: #856404; border-color: #ffc107; }
.alert-info { background: #d1ecf1; color: #0c5460; border-color: #17a2b8; }

/* ===== شريط البحث ===== */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    align-items: center;
    flex-wrap: wrap;
}

.search-bar .form-control {
    flex: 1;
    min-width: 200px;
}

/* ===== الترقيم (Pagination) ===== */
.pagination {
    display: flex;
    gap: 5px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pagination a, .pagination span {
    padding: 8px 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #4a5568;
    text-decoration: none;
    font-size: 14px;
}

.pagination a:hover { background: #f5f7fa; }
.pagination .current { background: #667eea; color: white; border-color: #667eea; }

/* ===== الاستجابة للموبايل ===== */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
        position: fixed;
        z-index: 100;
    }
    
    .sidebar-header h2,
    .sidebar-nav a,
    .sidebar-section,
    .user-name,
    .user-role,
    .btn-logout {
        display: none;
    }
    
    .main-content {
        margin-right: 60px;
    }
    
    .page-header,
    .page-content {
        padding: 15px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== أدوات مساعدة ===== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-muted { color: #95a5a6; }
.text-success { color: #27ae60; }
.text-danger { color: #c0392b; }
.text-warning { color: #d68910; }

.mt-1 { margin-top: 5px; } .mt-2 { margin-top: 10px; } .mt-3 { margin-top: 15px; }
.mb-1 { margin-bottom: 5px; } .mb-2 { margin-bottom: 10px; } .mb-3 { margin-bottom: 15px; }

.d-flex { display: flex; }
.gap-1 { gap: 5px; } .gap-2 { gap: 10px; } .gap-3 { gap: 15px; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }

.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: #95a5a6;
}

.empty-state .icon { font-size: 48px; margin-bottom: 15px; }
