/* ==============================================
   نظام إدارة قطع الغيار - الأنماط
   ============================================== */

: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;
}

body.lang-en {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ============ شاشة التحميل الأولى (Boot splash) ============ */
.boot-splash {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(1200px 600px at 50% -10%, rgba(37, 99, 235, 0.12) 0%, rgba(241, 245, 249, 1) 55%);
}
.boot-splash.d-none {
    display: none !important;
}
.boot-splash-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(203, 213, 225, 0.75);
    backdrop-filter: blur(8px);
}
.boot-splash-spinner {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(37, 99, 235, 0.25);
    border-top-color: rgba(37, 99, 235, 0.95);
    animation: bootspin 0.9s linear infinite;
}
.boot-splash-title {
    font-weight: 700;
    color: var(--gray-700);
}
@keyframes bootspin {
    to { transform: rotate(360deg); }
}

/* English (LTR): sidebar fixed on the left, main content to the right */
body.lang-en .sidebar {
    right: auto;
    left: 0;
}
body.lang-en .main-content {
    margin-right: 0;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease, margin-right 0.3s ease;
}
body.lang-en .sidebar.collapsed ~ .main-content {
    margin-right: 0;
    margin-left: var(--sidebar-collapsed);
}
body.lang-en .nav-item {
    border-right: none;
    border-left: 3px solid transparent;
}
body.lang-en .nav-item.active {
    border-right-color: transparent;
    border-left-color: var(--primary);
}
body.lang-en .topbar-actions {
    margin-right: 0;
    margin-left: auto;
}
body.lang-en .topbar-search .input-group-text {
    border-right: none;
    border-left: 1px solid var(--gray-200);
}
body.lang-en .topbar-search .form-control {
    border-left: none;
    border-right: 1px solid var(--gray-200);
}
body.lang-en .ts-wrapper,
body.lang-en .ts-dropdown,
body.lang-en .ts-control {
    direction: ltr;
    text-align: left;
}
body.lang-en .notifications-menu-body,
body.lang-en .notifications-item-row {
    text-align: left;
}
body.lang-en .user-menu i {
    margin-left: 0;
    margin-right: 8px;
}

/* ============ صفحة تسجيل الدخول ============ */
.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);
}

/* تحسين تباين أزرار اللغة في صفحة الدخول */
.locale-switch-login .btn.btn-outline-light {
    color: var(--gray-900);
    border-color: var(--gray-300);
    background: rgba(248, 250, 252, 0.9);
}
.locale-switch-login .btn.btn-outline-light:hover {
    color: var(--gray-900);
    border-color: var(--gray-300);
    background: rgba(241, 245, 249, 1);
}
.locale-switch-login .btn.btn-outline-light:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.25);
    outline-offset: 2px;
}

/* ============ الشريط الجانبي ============ */
.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;
    justify-content: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    min-height: 60px;
    position: relative;
}

.sidebar-header::before {
    content: '';
    position: absolute;
    width: 230px;
    height: 110px;
    border-radius: 999px;
    background: radial-gradient(closest-side, rgba(249, 115, 22, 1), rgba(249, 115, 22, 0) 74%);
    filter: blur(22px);
    opacity: 1;
    pointer-events: none;
    z-index: 0;
    box-shadow:
        0 0 40px rgba(249, 115, 22, 0.55),
        0 0 90px rgba(249, 115, 22, 0.35);
}

.sidebar-logo {
    height: 44px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    position: relative;
    z-index: 1;
}

.sidebar-header .sidebar-logo {
    background: transparent;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    /* تحسين الوضوح على الخلفية الداكنة بدون صندوق أبيض */
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.35));
}

.sidebar.collapsed .sidebar-logo {
    height: 34px;
    margin: 0 auto;
}

.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;
}

.pending-requests-bell {
    color: var(--gray-700);
    font-size: 18px;
    padding: 6px 10px;
    position: relative;
    text-decoration: none;
}

.pending-requests-bell:hover {
    color: var(--primary);
}

/* Tom Select — اتجاه عربي */
.ts-wrapper,
.ts-dropdown,
.ts-control {
    direction: rtl;
    text-align: right;
}

/* قوائم Tom Select فوق محتوى المودال */
.ts-dropdown,
.ts-dropdown-content {
    z-index: 10050 !important;
}

/*
 * مودال التطبيق: محتوى طويل (نماذج صرف، إلخ) يُمرَّر داخل الجسم مع بقاء الرأس والتذييل ظاهرين.
 * z-index لقوائم Tom Select يبقى فوق المودال (انظر أدناه).
 */
#appModal.modal {
    overflow-x: hidden;
    overflow-y: auto;
}

#appModal.modal:not(.maximized) .modal-dialog {
    max-height: calc(100vh - 1rem);
    margin: 0.5rem auto;
    display: flex;
    align-items: stretch;
}

#appModal.modal:not(.maximized) .modal-content {
    max-height: calc(100vh - 1rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1 1 auto;
    min-height: 0;
}

#appModal.modal .modal-header,
#appModal.modal .modal-footer {
    flex-shrink: 0;
}

#appModal.modal .modal-body {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.pending-requests-bell .pending-requests-badge {
    position: absolute;
    top: 2px;
    inset-inline-end: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 1.15rem;
    line-height: 1.1;
    padding: 0.2em 0.42em;
}

.pending-requests-bell.dropdown-toggle-no-caret::after {
    display: none;
}

.notifications-dropdown {
    min-width: min(360px, 92vw);
    max-height: 70vh;
    overflow-y: auto;
}

.notifications-menu-body {
    text-align: right;
    max-height: 65vh;
    overflow-y: auto;
}

.notifications-section-title {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--gray-800);
}

.notifications-item-row {
    border-bottom: 1px solid var(--gray-100);
    padding: 0.35rem 0.25rem;
    text-align: right;
}

.notifications-item-row:last-child {
    border-bottom: none;
}

.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;
    display: flex;
    align-items: stretch;
}

.modal.maximized .modal-content {
    flex: 1 1 auto;
    min-height: 0;
    height: 100vh;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal.maximized .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: none;
}

.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;
}

/* ============ أنماط الطباعة ============ */
/* ============ الطباعة (Global) ============ */
@media print {
    @page { size: A4; margin: 12mm 10mm; }

    html, body {
        background: #fff !important;
        color: #000 !important;
        font-size: 11pt !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    * {
        box-shadow: none !important;
        text-shadow: none !important;
        animation: none !important;
        transition: none !important;
    }

    /* إخفاء عناصر الواجهة غير المطلوبة في الطباعة */
    .sidebar,
    .topbar,
    .no-print,
    .btn,
    button,
    .modal-header-actions,
    .modal-footer,
    .filters-bar,
    .pagination,
    .dropdown-menu,
    .card-actions,
    .tom-select .ts-control > .clear-button,
    .swal2-container {
        display: none !important;
    }

    /* إعادة ضبط الهيكل العام */
    .app-container,
    .main-content,
    main.main-content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .content-area {
        padding: 0 !important;
        overflow: visible !important;
    }

    /* روابط بلا تزيين */
    a, a:visited {
        color: #000 !important;
        text-decoration: none !important;
    }

    /* تفعيل الألوان في البطاقات والشارات والتدرّجات */
    .stat-card,
    .card,
    .alert,
    .badge,
    .bg-primary, .bg-success, .bg-danger, .bg-warning, .bg-info, .bg-secondary, .bg-light, .bg-dark,
    .text-primary, .text-success, .text-danger, .text-warning, .text-info, .text-secondary, .text-muted,
    [style*="background"] {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* إبقاء ظل/حدود البطاقات لطيفة عند الطباعة */
    .card, .stat-card {
        border: 1px solid #cbd5e1 !important;
        border-radius: 6px !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    /* الجداول */
    table {
        width: 100% !important;
        border-collapse: collapse !important;
        page-break-inside: auto;
    }
    thead { display: table-header-group; }
    tfoot { display: table-footer-group; }
    tr {
        page-break-inside: avoid !important;
        page-break-after: auto;
    }
    th, td {
        border: 1px solid #475569 !important;
        padding: 4px 6px !important;
        font-size: 10pt !important;
        vertical-align: middle !important;
    }
    thead th {
        background: #e2e8f0 !important;
        color: #0f172a !important;
        font-weight: 700 !important;
    }
    .table-striped > tbody > tr:nth-of-type(odd) > * {
        background: #f8fafc !important;
    }

    /* التحكم في حجم الخط داخل الجداول المتراصّة */
    .table-sm th, .table-sm td { font-size: 9.5pt !important; padding: 3px 5px !important; }

    /* ===== المودال (التقارير/التفاصيل) ===== */
    body.modal-open { overflow: visible !important; height: auto !important; }
    .modal-backdrop { display: none !important; }

    /* عند وجود مودال مفتوح — اطبع المودال فقط */
    body.modal-open > *:not(.modal):not(script):not(style):not(link) {
        display: none !important;
    }

    .modal {
        position: static !important;
        inset: auto !important;
        display: block !important;
        background: #fff !important;
        overflow: visible !important;
        padding: 0 !important;
    }
    .modal-dialog {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        transform: none !important;
    }
    .modal-content {
        border: none !important;
        box-shadow: none !important;
        background: #fff !important;
    }
    .modal-header {
        padding: 0 0 8px 0 !important;
        border: 0 !important;
        border-bottom: 2px solid #0f172a !important;
        margin-bottom: 10px !important;
    }
    .modal-header .modal-title {
        font-size: 14pt !important;
        font-weight: 700 !important;
        color: #0f172a !important;
    }
    .modal-body {
        padding: 0 !important;
        overflow: visible !important;
        max-height: none !important;
    }

    /* إزالة ارتفاعات ثابتة وحاويات تمرير داخل المودال */
    .modal .table-responsive {
        overflow: visible !important;
        max-height: none !important;
    }

    /* تبويبات: إظهار كل المحتوى دائمًا عند الطباعة */
    .tab-content > .tab-pane {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    .nav-tabs, .custom-tabs { display: none !important; }
    .tab-content > .tab-pane[data-title]::before {
        content: attr(data-title);
        display: block;
        font-weight: 700;
        margin: 10px 0 6px;
        padding-bottom: 4px;
        border-bottom: 1px solid #cbd5e1;
    }

    /* الحقول تظهر كنص هادئ */
    .form-control, .form-select {
        border: 1px solid #94a3b8 !important;
        background: #fff !important;
    }

    /* شرائط التقدم (تقرير العمر الإنتاجي) */
    .lc-progress {
        border: 1px solid #cbd5e1 !important;
        background: #fff !important;
    }
    .lc-progress > span {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* عدم كسر الفقرات الصغيرة */
    h1, h2, h3, h4, h5, h6, caption {
        page-break-after: avoid;
    }
    img, svg { max-width: 100% !important; page-break-inside: avoid; }

    /* ترويسة وتذييل الطباعة الموحّدة (تُضاف ديناميكياً عبر printDocument) */
    .app-print-header {
        display: block !important;
        padding: 0 0 8px;
        margin: 0 0 10px;
        border-bottom: 2px solid #0f172a;
    }
    .app-print-header .app-print-title {
        font-size: 14pt;
        font-weight: 700;
        color: #0f172a;
    }
    .app-print-header .app-print-meta {
        font-size: 9.5pt;
        color: #475569;
        margin-top: 4px;
        display: flex;
        justify-content: space-between;
        gap: 8px;
    }
    .app-print-footer {
        display: block !important;
        margin-top: 14px;
        padding-top: 6px;
        border-top: 1px solid #cbd5e1;
        font-size: 9pt;
        color: #64748b;
        text-align: center;
    }
}

/* إخفاء عناصر الطباعة في العرض العادي */
.app-print-header, .app-print-footer { display: none; }

/* ============ التجاوب (موبايل وتابلت عمودي) ============ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(100%);
        width: min(var(--sidebar-width), 88vw);
        height: 100dvh;
        max-height: -webkit-fill-available;
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.25);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .main-content {
        margin-right: 0;
        min-height: 100dvh;
        max-height: none;
    }
    body.lang-en .sidebar {
        transform: translateX(-100%);
    }
    body.lang-en .sidebar.mobile-open {
        transform: translateX(0);
    }
    body.lang-en .main-content {
        margin-left: 0;
    }
    .topbar {
        padding: 0 10px 0 12px;
        padding-inline-start: max(10px, env(safe-area-inset-left, 0px));
        padding-inline-end: max(10px, env(safe-area-inset-right, 0px));
        padding-top: max(4px, env(safe-area-inset-top, 0px));
        gap: 8px;
        min-height: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
    }
    .topbar-search {
        display: none;
    }
    .topbar-actions {
        margin-inline-start: auto;
        flex-shrink: 0;
        gap: 2px;
    }
    .user-menu {
        font-size: 13px;
        max-width: 42vw;
    }
    .user-menu span {
        display: inline-block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        vertical-align: middle;
    }
    .stat-card .stat-value {
        font-size: 22px;
    }
    .content-area {
        padding: 14px 12px;
        padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
    }
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }
    .page-header > .d-flex.flex-wrap {
        width: 100%;
        justify-content: flex-start;
    }
    .filters-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 14px;
    }
    .filters-bar .form-group {
        width: 100%;
        min-width: 0;
        flex: none;
    }
    .table-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .pagination-container {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        text-align: center;
    }
    .data-table thead th,
    .data-table tbody td {
        padding: 9px 10px;
        font-size: 13px;
    }
    .data-table .actions-cell .btn {
        padding: 6px 9px;
        min-height: 36px;
        min-width: 36px;
    }
    /* مودال التطبيق: عرض شبه كامل على الشاشات الصغيرة */
    #appModal.modal:not(.maximized) .modal-dialog.app-modal-dialog {
        max-width: calc(100vw - 0.75rem);
        width: calc(100vw - 0.75rem);
        margin: 0.35rem auto;
        max-height: calc(100dvh - 0.7rem);
    }
    #appModal.modal:not(.maximized) .modal-content {
        max-height: calc(100dvh - 0.7rem);
    }
    #appModal .modal-header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 12px;
    }
    #appModal .modal-title {
        font-size: 1rem;
        flex: 1 1 auto;
        min-width: 0;
        line-height: 1.35;
    }
    #appModal .modal-body {
        padding: 12px;
    }
    #appModal .modal-footer {
        padding: 10px 12px;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }
    #appModal .modal-footer .btn {
        min-height: 44px;
        padding-inline: 14px;
    }
    #appModal .input-group {
        flex-wrap: nowrap;
        min-width: 0;
    }
    #appModal .input-group > .form-control,
    #appModal .input-group > .form-select {
        min-width: 0;
    }
    #appModal .row.g-3 > [class*="col-"] {
        min-width: 0;
    }
}

@media (max-width: 575.98px) {
    .content-area {
        padding: 10px 8px;
    }
    .login-container {
        padding: 12px;
    }
    .login-card {
        padding: 28px 20px;
    }
    .login-header h2 {
        font-size: 1.25rem;
    }
    .user-menu span {
        display: none;
    }
    .user-menu i {
        margin-inline-start: 0;
    }
    .stat-card {
        padding: 16px;
    }
    .dashboard-chart {
        padding: 14px;
    }
    .alert-float {
        left: 50%;
        right: auto;
        width: min(360px, calc(100vw - 16px));
        min-width: 0;
        max-width: calc(100vw - 16px);
        transform: translateX(-50%);
        padding-inline: env(safe-area-inset-left, 0px);
    }
}

/* ============ تمرير مخصص ============ */
.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;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.45);
    z-index: 999;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 991.98px) {
    .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);
}

/* ============ صور الأصناف ============ */
.part-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    vertical-align: middle;
}
.part-image-preview {
    max-height: 120px;
    max-width: 100%;
    object-fit: contain;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}
