/* =============================================
   منظومة مصنع الرخام - التنسيقات
   Marble Factory System - Styles
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-sidebar: #1a1a2e;
    --bg-sidebar-hover: #16213e;
    --bg-sidebar-active: #0f3460;
    --text-primary: #2d2d2d;
    --text-secondary: #6b6b6b;
    --text-sidebar: #c4c4c4;
    --text-sidebar-active: #ffffff;
    --border-color: #e0e0e0;
    --border-light: #eeeeee;
    --accent: #3a3a3a;
    --accent-light: #555555;
    --success: #4a7c59;
    --danger: #8b3a3a;
    --warning: #8b7a3a;
    --info: #3a5a7c;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.1);
    --radius: 6px;
    --sidebar-width: 250px;
    --header-height: 56px;
    --transition: all 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    direction: rtl;
    font-size: 14px;
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: inherit;
}

/* =============================================
   الشريط الجانبي
   ============================================= */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    z-index: 1000;
    overflow-y: auto;
    transition: var(--transition);
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header .logo-icon {
    font-size: 28px;
    color: #fff;
}

.sidebar-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}

.sidebar-header small {
    display: block;
    font-size: 11px;
    color: var(--text-sidebar);
    font-weight: 300;
}

.sidebar-nav {
    padding: 10px 0;
}

.sidebar-nav .nav-section {
    padding: 8px 20px 4px;
    font-size: 11px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.3);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-sidebar);
    font-size: 13px;
    font-weight: 400;
    transition: var(--transition);
    border-right: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: var(--bg-sidebar-hover);
    color: #fff;
}

.sidebar-nav a.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
    border-right-color: #fff;
    font-weight: 500;
}

.sidebar-nav a .material-icons-outlined {
    font-size: 20px;
    width: 20px;
    text-align: center;
}

/* =============================================
   الرأس العلوي
   ============================================= */
.main-content {
    margin-right: var(--sidebar-width);
    min-height: 100vh;
}

.top-header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-header .page-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.top-header .header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.top-header .user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.top-header .user-info .material-icons-outlined {
    font-size: 20px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-primary);
}

/* =============================================
   المحتوى الرئيسي
   ============================================= */
.page-content {
    padding: 20px 24px;
}

/* =============================================
   البطاقات الإحصائية
   ============================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
}

.stat-card .stat-icon .material-icons-outlined {
    font-size: 22px;
    color: var(--text-secondary);
}

.stat-card .stat-info h4 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-card .stat-info span {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* =============================================
   الجداول
   ============================================= */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header h3 .material-icons-outlined {
    font-size: 20px;
    color: var(--text-secondary);
}

.card-body {
    padding: 16px 20px;
}

.card-body.no-padding {
    padding: 0;
}

.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

table thead th {
    background: var(--bg-primary);
    padding: 10px 14px;
    text-align: right;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

table tbody tr:hover {
    background: #fafafa;
}

table tbody tr:last-child td {
    border-bottom: none;
}

/* =============================================
   الأزرار
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: 'Cairo', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn:hover {
    background: var(--bg-primary);
    border-color: #ccc;
}

.btn .material-icons-outlined {
    font-size: 18px;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-sm .material-icons-outlined {
    font-size: 16px;
}

.btn-dark {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-dark:hover {
    background: var(--accent-light);
    border-color: var(--accent-light);
    color: #fff;
}

.btn-danger-outline {
    color: var(--danger);
    border-color: var(--danger);
}

.btn-danger-outline:hover {
    background: var(--danger);
    color: #fff;
}

/* =============================================
   النماذج
   ============================================= */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: 'Cairo', sans-serif;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-secondary);
    transition: var(--transition);
    direction: rtl;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(58,58,58,0.1);
}

.form-control::placeholder {
    color: #bbb;
}

select.form-control {
    appearance: auto;
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.form-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* =============================================
   النافذة المنبثقة (Modal)
   ============================================= */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 2000;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 20px;
    overflow-y: auto;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    width: 100%;
    max-width: 600px;
    box-shadow: var(--shadow-md);
    animation: modalIn 0.2s ease;
}

.modal-lg {
    max-width: 900px;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-start;
    gap: 8px;
}

/* =============================================
   التنبيهات
   ============================================= */
.alert {
    padding: 10px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid;
}

.alert-success {
    background: #f0f7f0;
    color: var(--success);
    border-color: #d4e8d4;
}

.alert-danger {
    background: #f7f0f0;
    color: var(--danger);
    border-color: #e8d4d4;
}

.alert-warning {
    background: #f7f5f0;
    color: var(--warning);
    border-color: #e8e0d4;
}

.alert-info {
    background: #f0f3f7;
    color: var(--info);
    border-color: #d4dce8;
}

/* =============================================
   الشارات
   ============================================= */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.badge-success { background: #e8f5e9; color: var(--success); }
.badge-danger { background: #fce4ec; color: var(--danger); }
.badge-warning { background: #fff8e1; color: var(--warning); }
.badge-info { background: #e3f2fd; color: var(--info); }
.badge-default { background: #f5f5f5; color: var(--text-secondary); }

/* =============================================
   صفحة تسجيل الدخول
   ============================================= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    padding: 20px;
}

.login-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
}

.login-box .login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-box .login-header .material-icons-outlined {
    font-size: 48px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.login-box .login-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.login-box .login-header p {
    font-size: 13px;
    color: var(--text-secondary);
}

.login-box .form-group {
    margin-bottom: 16px;
}

.login-box .btn {
    width: 100%;
    justify-content: center;
    padding: 10px;
    font-size: 14px;
}

/* =============================================
   الصفحة الفارغة
   ============================================= */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state .material-icons-outlined {
    font-size: 48px;
    margin-bottom: 10px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 14px;
}

/* =============================================
   الترقيم
   ============================================= */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px;
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-secondary);
    transition: var(--transition);
}

.pagination a:hover {
    background: var(--bg-primary);
}

.pagination span.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* =============================================
   طباعة الفاتورة
   ============================================= */
.invoice-print {
    max-width: 800px;
    margin: 0 auto;
    background: #fff;
    padding: 30px;
}

.invoice-print .invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 20px;
    border-bottom: 2px solid #333;
    margin-bottom: 20px;
}

.invoice-print .invoice-header .factory-info h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.invoice-print .invoice-header .factory-info p {
    font-size: 12px;
    color: var(--text-secondary);
}

.invoice-print .invoice-meta {
    text-align: left;
}

.invoice-print .invoice-meta .meta-item {
    font-size: 12px;
    margin-bottom: 4px;
}

.invoice-print .invoice-meta .meta-item strong {
    display: inline-block;
    min-width: 80px;
}

.invoice-print .invoice-title {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    padding: 10px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    margin-bottom: 20px;
}

.invoice-print .customer-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
    padding: 12px;
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 4px;
}

.invoice-print .customer-info .info-item {
    font-size: 13px;
}

.invoice-print .customer-info .info-item strong {
    color: var(--text-secondary);
}

.invoice-print table {
    border: 1px solid #ddd;
    margin-bottom: 20px;
}

.invoice-print table th {
    background: #f0f0f0;
    border: 1px solid #ddd;
    padding: 8px 10px;
    font-size: 12px;
}

.invoice-print table td {
    border: 1px solid #eee;
    padding: 8px 10px;
    font-size: 12px;
}

.invoice-print .invoice-totals {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 20px;
}

.invoice-print .totals-table {
    width: 280px;
}

.invoice-print .totals-table .total-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px solid #eee;
}

.invoice-print .totals-table .total-row.grand-total {
    font-weight: 700;
    font-size: 15px;
    border-bottom: 2px solid #333;
    border-top: 2px solid #333;
    padding: 8px 0;
}

.invoice-print .invoice-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.invoice-print .signatures {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
}

.invoice-print .signature-box {
    text-align: center;
    width: 200px;
}

.invoice-print .signature-box .line {
    border-top: 1px solid #999;
    margin-top: 40px;
    padding-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.invoice-print .invoice-notes {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 10px;
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 4px;
}

/* =============================================
   البحث والفلاتر
   ============================================= */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filters-bar .form-control {
    max-width: 220px;
}

.search-box {
    position: relative;
}

.search-box .form-control {
    padding-right: 36px;
}

.search-box .search-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--text-secondary);
}

/* =============================================
   متجاوب
   ============================================= */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-right: 0;
    }
    
    .menu-toggle {
        display: block;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .invoice-print .invoice-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .invoice-print .customer-info {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* =============================================
   طباعة
   ============================================= */
@media print {
    body {
        background: #fff;
    }
    
    .sidebar, .top-header, .no-print, .btn {
        display: none !important;
    }
    
    .main-content {
        margin: 0;
    }
    
    .page-content {
        padding: 0;
    }
    
    .invoice-print {
        padding: 0;
        max-width: 100%;
    }
}

/* =============================================
   عنصر التحميل
   ============================================= */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.loading .spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =============================================
   أدوات مساعدة
   ============================================= */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
