/* ==============================================
   نظام إدارة قطع الغيار - الأنماط
   ============================================== */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --topbar-height: 60px;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --info: #0ea5e9;
    --dark: #1e293b;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-500: #64748b;
    --gray-700: #334155;
    --gray-900: #0f172a;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    min-height: 100vh;
}

/* ============ صفحة تسجيل الدخول ============ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #1e40af 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
    top: -100px;
    left: -100px;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
    bottom: -80px;
    right: -80px;
}

.login-container {
    z-index: 1;
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 40px 35px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-icon {
    font-size: 48px;
    color: var(--primary);
    margin-bottom: 15px;
}

.login-header h2 {
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 5px;
}

.login-header p {
    color: var(--gray-500);
}

/* ============ الشريط الجانبي ============ */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: white;
    z-index: 1000;
    transition: width 0.3s ease;
    overflow-x: hidden;
    overflow-y: auto;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    min-height: 60px;
}

.sidebar-header i {
    font-size: 24px;
    color: var(--primary);
    min-width: 30px;
    text-align: center;
}

.sidebar-title {
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
}

.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-section {
    display: none;
}

.sidebar-nav {
    padding: 10px 0;
}

.nav-section {
    padding: 15px 20px 5px;
    font-size: 11px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.4);
    font-weight: 700;
    letter-spacing: 1px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.2s;
    border-right: 3px solid transparent;
    white-space: nowrap;
}

.nav-item:hover {
    color: white;
    background: rgba(255,255,255,0.08);
}

.nav-item.active {
    color: white;
    background: rgba(37, 99, 235, 0.2);
    border-right-color: var(--primary);
}

.nav-item i {
    width: 22px;
    text-align: center;
    font-size: 15px;
    min-width: 22px;
}

/* ============ المحتوى الرئيسي ============ */
.main-content {
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-right 0.3s ease;
}

.sidebar.collapsed ~ .main-content {
    margin-right: var(--sidebar-collapsed);
}

/* ============ الشريط العلوي ============ */
.topbar {
    height: var(--topbar-height);
    background: white;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    padding: 0 25px;
    gap: 15px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.sidebar-toggle {
    color: var(--gray-700);
    font-size: 20px;
    padding: 5px;
}

.topbar-search {
    flex: 1;
    max-width: 400px;
}

.topbar-search .input-group {
    border-radius: var(--radius);
    overflow: hidden;
}

.topbar-search .input-group-text {
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-left: none;
}

.topbar-search .form-control {
    border: 1px solid var(--gray-200);
    border-right: none;
    background: var(--gray-100);
}

.topbar-actions {
    margin-right: auto;
}

.user-menu {
    color: var(--gray-700);
    text-decoration: none;
    font-size: 14px;
}

.user-menu i {
    font-size: 22px;
    margin-left: 8px;
}

/* ============ منطقة المحتوى ============ */
.content-area {
    padding: 25px;
}

/* ============ البطاقات ============ */
.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--gray-200);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card .stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 12px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--dark);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 4px;
}

.icon-primary { background: var(--primary-light); color: var(--primary); }
.icon-success { background: #dcfce7; color: var(--success); }
.icon-danger { background: #fee2e2; color: var(--danger); }
.icon-warning { background: #fef3c7; color: var(--warning); }
.icon-info { background: #e0f2fe; color: var(--info); }

/* ============ الجداول ============ */
.table-container {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    border-bottom: 1px solid var(--gray-200);
    flex-wrap: wrap;
    gap: 10px;
}

.table-header h5 {
    font-weight: 700;
    margin: 0;
}

.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    margin: 0;
}

.data-table thead th {
    background: var(--gray-50);
    font-weight: 700;
    font-size: 13px;
    color: var(--gray-700);
    padding: 12px 15px;
    white-space: nowrap;
    border-bottom: 2px solid var(--gray-200);
}

.data-table tbody td {
    padding: 10px 15px;
    vertical-align: middle;
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.data-table .actions-cell {
    white-space: nowrap;
}

.data-table .actions-cell .btn {
    padding: 3px 8px;
    font-size: 13px;
    margin: 0 2px;
}

/* ============ الشارات ============ */
.badge-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-low-stock {
    background: #fee2e2;
    color: #991b1b;
}

.badge-ok-stock {
    background: #dcfce7;
    color: #166534;
}

/* ============ النوافذ المنبثقة ============ */
.modal-header {
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-maximize {
    border: none;
}

.modal.maximized .modal-dialog {
    max-width: 100%;
    width: 100%;
    height: 100vh;
    margin: 0;
}

.modal.maximized .modal-content {
    height: 100vh;
    border-radius: 0;
}

.modal.maximized .modal-body {
    overflow-y: auto;
    max-height: calc(100vh - 130px);
}

.modal.maximized #modalMaximize i {
    transform: rotate(45deg);
}

.modal-title {
    font-weight: 700;
}

/* ============ صفحة عنوان ============ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.page-header h4 {
    font-weight: 700;
    color: var(--dark);
    margin: 0;
}

.page-header .breadcrumb {
    margin: 0;
    font-size: 13px;
}

/* ============ فلاتر ============ */
.filters-bar {
    background: white;
    border-radius: var(--radius);
    padding: 15px 20px;
    margin-bottom: 15px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
    border: 1px solid var(--gray-200);
}

.filters-bar .form-group {
    flex: 1;
    min-width: 150px;
}

.filters-bar label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    margin-bottom: 4px;
    display: block;
}

/* ============ لوحة التحكم ============ */
.dashboard-chart {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.chart-header h6 {
    font-weight: 700;
    margin: 0;
}

/* ============ قوائم ============ */
.list-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100);
}

.list-item:last-child {
    border-bottom: none;
}

.list-item-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 12px;
    font-size: 14px;
}

.list-item-content {
    flex: 1;
}

.list-item-title {
    font-weight: 600;
    font-size: 14px;
}

.list-item-subtitle {
    font-size: 12px;
    color: var(--gray-500);
}

.list-item-value {
    font-weight: 700;
    font-size: 14px;
}

/* ============ شريط التقدم ============ */
.progress-bar-custom {
    height: 8px;
    border-radius: 4px;
    background: var(--gray-200);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* ============ أنماط الطباعة ============ */
@media print {
    .sidebar, .topbar, .no-print {
        display: none !important;
    }
    .main-content {
        margin: 0 !important;
    }
    .content-area {
        padding: 10px !important;
    }
}

/* ============ التجاوب ============ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
        width: var(--sidebar-width);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .main-content {
        margin-right: 0;
    }
    .topbar-search {
        display: none;
    }
    .stat-card .stat-value {
        font-size: 22px;
    }
    .filters-bar {
        flex-direction: column;
    }
    .filters-bar .form-group {
        width: 100%;
    }
}

/* ============ تمرير مخصص ============ */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

/* ============ انيميشن ============ */
.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============ الإشعارات ============ */
.alert-float {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    min-width: 300px;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translate(-50%, -20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============ خلفية رمادية للـ overlay ============ */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 999;
}

@media (max-width: 768px) {
    .sidebar.mobile-open ~ .sidebar-overlay {
        display: block;
    }
}

/* ============ التقارير ============ */
.report-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 25px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid var(--gray-200);
}

.report-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}

.report-card i {
    font-size: 40px;
    margin-bottom: 12px;
}

.report-card h6 {
    font-weight: 700;
}

.report-card p {
    font-size: 13px;
    color: var(--gray-500);
    margin: 0;
}

/* ============ Tabs ============ */
.custom-tabs .nav-link {
    color: var(--gray-500);
    font-weight: 600;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 8px 20px;
}

.custom-tabs .nav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: transparent;
}

/* ============ Empty State ============ */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--gray-500);
}

.empty-state i {
    font-size: 60px;
    margin-bottom: 15px;
    opacity: 0.3;
}

.empty-state h5 {
    font-weight: 700;
    margin-bottom: 5px;
}

/* ============ SweetAlert2 فوق Bootstrap Modal ============ */
.swal2-container {
    z-index: 99999 !important;
}

.swal2-container .swal2-popup {
    z-index: 99999 !important;
}

/* ============ Pagination ============ */
.pagination-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid var(--gray-200);
    font-size: 13px;
    color: var(--gray-500);
}
