/* ═══════════════════════════════════════════════════════════════════
   نظام الصادر والوارد — تصميم عربي RTL احترافي
   ═══════════════════════════════════════════════════════════════════ */

:root {
    --clr-primary:    #1a568d;
    --clr-primary-lt: #e8f0f9;
    --clr-success:    #198754;
    --clr-success-lt: #d1e7dd;
    --clr-danger:     #dc3545;
    --clr-danger-lt:  #f8d7da;
    --clr-warning:    #fd7e14;
    --clr-warning-lt: #fff3cd;
    --clr-info:       #0dcaf0;
    --clr-purple:     #6f42c1;
    --clr-purple-lt:  #e9e5f8;
    --clr-sidebar:    #0f2744;
    --clr-sidebar-hover: #1a3d6b;
    --clr-text:       #212529;
    --clr-muted:      #6c757d;
    --radius:         0.5rem;
    --shadow:         0 1px 4px rgba(0,0,0,.1);
    --shadow-md:      0 4px 12px rgba(0,0,0,.12);
}

/* ─── Base ──────────────────────────────────────────────────────── */
html, body {
    font-family: 'Segoe UI', Tahoma, 'Arial', sans-serif;
    font-size: 14px;
    background: #f4f6f9;
    color: var(--clr-text);
    direction: rtl;
}

a { color: var(--clr-primary); text-decoration: none; }
a:hover { color: #0d3d6e; }

/* ─── Layout ─────────────────────────────────────────────────────── */
.page { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    min-height: 100vh;
    background: var(--clr-sidebar);
    position: fixed;
    top: 0; right: 0;
    z-index: 1000;
    overflow-y: auto;
    transition: width .25s;
}

.main-content {
    margin-right: 250px;
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-bar {
    background: #fff;
    border-bottom: 1px solid #e0e6ee;
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: var(--shadow);
}

.page-body { padding: 1.5rem; flex: 1; }

/* ─── Sidebar ────────────────────────────────────────────────────── */
.sidebar-brand {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
    text-align: center;
}

.sidebar-brand h5 {
    color: #fff;
    font-weight: 700;
    margin: 0;
    font-size: 1rem;
}

.sidebar-brand span {
    color: rgba(255,255,255,.6);
    font-size: .75rem;
}

.nav-sidebar { padding: .5rem 0; }

.nav-sidebar .nav-item .nav-link {
    color: rgba(255,255,255,.75);
    padding: .65rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .6rem;
    border-radius: 0;
    transition: all .2s;
    font-size: .875rem;
    border-right: 3px solid transparent;
}

.nav-sidebar .nav-item .nav-link:hover,
.nav-sidebar .nav-item .nav-link.active {
    background: var(--clr-sidebar-hover);
    color: #fff;
    border-right-color: #4da8ff;
}

.nav-sidebar .nav-item .nav-link i {
    width: 18px;
    text-align: center;
    font-size: 1rem;
}

.nav-section-title {
    color: rgba(255,255,255,.4);
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: .75rem 1.25rem .25rem;
}

/* ─── KPI Cards ──────────────────────────────────────────────────── */
.kpi-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid #e8edf3;
    transition: transform .2s, box-shadow .2s;
    position: relative;
    overflow: hidden;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi-card .kpi-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.kpi-card .kpi-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    color: var(--clr-text);
}

.kpi-card .kpi-label {
    font-size: .8rem;
    color: var(--clr-muted);
    margin-top: .2rem;
}

.kpi-card .kpi-rate {
    font-size: .8rem;
    font-weight: 600;
    margin-top: .4rem;
}

.kpi-primary   .kpi-icon { background: var(--clr-primary-lt); color: var(--clr-primary); }
.kpi-success   .kpi-icon { background: var(--clr-success-lt); color: var(--clr-success); }
.kpi-danger    .kpi-icon { background: var(--clr-danger-lt);  color: var(--clr-danger); }
.kpi-warning   .kpi-icon { background: var(--clr-warning-lt); color: var(--clr-warning); }
.kpi-purple    .kpi-icon { background: var(--clr-purple-lt);  color: var(--clr-purple); }

/* ─── Page Card ──────────────────────────────────────────────────── */
.page-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid #e8edf3;
}

.page-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e8edf3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.page-card-body { padding: 1.25rem; }

/* ─── Table ──────────────────────────────────────────────────────── */
.table-rtl {
    font-size: .85rem;
}

.table-rtl th {
    background: #f8fafc;
    font-weight: 600;
    color: #4a5568;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    padding: .65rem .75rem;
}

.table-rtl td {
    padding: .6rem .75rem;
    vertical-align: middle;
    border-color: #f0f4f8;
}

.table-rtl tbody tr:hover { background: #f8fafc; }

/* ─── Badges ─────────────────────────────────────────────────────── */
.badge-on-track  { background: var(--clr-success-lt); color: var(--clr-success); }
.badge-late      { background: var(--clr-danger-lt);  color: var(--clr-danger); }
.badge-compliant { background: var(--clr-success-lt); color: var(--clr-success); }
.badge-non-compliant { background: var(--clr-danger-lt); color: var(--clr-danger); }
.badge-pending   { background: var(--clr-warning-lt); color: var(--clr-warning); }
.badge-completed { background: var(--clr-success-lt); color: var(--clr-success); }
.badge-not-completed { background: var(--clr-warning-lt); color: var(--clr-warning); }

.badge-custom {
    padding: .3em .65em;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: .25em;
}

/* Row highlights */
.row-late td { background: #fff5f5 !important; }
.row-error td { background: #fff8e1 !important; }

/* ─── Filters Panel ──────────────────────────────────────────────── */
.filters-panel {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

/* ─── Skeleton Loading ───────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, #f0f4f8 25%, #e2e8f0 50%, #f0f4f8 75%);
    background-size: 400% 100%;
    animation: skeleton-loading 1.4s ease infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─── Empty State ────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--clr-muted);
}

.empty-state i { font-size: 3rem; margin-bottom: 1rem; display: block; }
.empty-state h6 { font-weight: 600; margin-bottom: .25rem; }

/* ─── Upload Zone ────────────────────────────────────────────────── */
.upload-zone {
    border: 2px dashed #c8d6e5;
    border-radius: var(--radius);
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    background: #f8fafc;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--clr-primary);
    background: var(--clr-primary-lt);
}

.upload-zone i { font-size: 2.5rem; color: var(--clr-primary); margin-bottom: .75rem; }

/* ─── Import Result ──────────────────────────────────────────────── */
.import-stat {
    background: #fff;
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow);
    text-align: center;
}

.import-stat .stat-value { font-size: 2.5rem; font-weight: 700; }
.import-stat .stat-label { font-size: .8rem; color: var(--clr-muted); }

/* ─── Utilities ──────────────────────────────────────────────────── */
.text-primary-dark { color: var(--clr-primary); }
.bg-primary-dark   { background: var(--clr-primary); }
.fw-600  { font-weight: 600 !important; }
.fw-700  { font-weight: 700 !important; }
.cursor-pointer { cursor: pointer; }
.border-radius  { border-radius: var(--radius); }
.fs-tiny { font-size: .7rem; }
.gap-xs  { gap: .25rem; }

/* ─── Print ──────────────────────────────────────────────────────── */
@media print {
    .sidebar, .top-bar, .no-print { display: none !important; }
    .main-content { margin-right: 0 !important; }
    .page-card { box-shadow: none; border: 1px solid #ddd; }
    body { font-size: 12px; }
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        width: 0;
        overflow: hidden;
        transition: width .25s;
    }
    .sidebar.open {
        width: 250px;
        box-shadow: -4px 0 20px rgba(0,0,0,.3);
    }
    .main-content { margin-right: 0; }
}

/* ─── Blazor ─────────────────────────────────────────────────────── */
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--clr-success); }
.invalid { outline: 1px solid var(--clr-danger); }
.validation-message { color: var(--clr-danger); font-size: .8rem; margin-top: .25rem; }

.blazor-error-boundary {
    padding: 1rem; color: white;
    background: var(--clr-danger);
    border-radius: var(--radius);
}

/* ─── Sortable Table Header ──────────────────────────────────────── */
.table-rtl th.cursor-pointer:hover {
    background: #edf2f7;
    color: var(--clr-primary);
}

/* ─── Sidebar Overlay (Mobile) ───────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 999;
}
.sidebar-overlay.active { display: block; }

/* ─── Bar Chart (CSS-only) ───────────────────────────────────────── */
.bar-chart-container {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 140px;
    padding: 0 4px;
}
.bar-chart-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    height: 100%;
}
.bar-chart-bar-wrap {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: flex-end;
}
.bar-chart-bar {
    width: 100%;
    min-height: 2px;
    border-radius: 4px 4px 0 0;
    transition: height .3s ease;
}
.bar-chart-label {
    font-size: .65rem;
    color: var(--clr-muted);
    margin-top: 4px;
    text-align: center;
    white-space: nowrap;
}
.bar-chart-value {
    font-size: .65rem;
    font-weight: 600;
    color: var(--clr-text);
    min-height: 14px;
}

/* ─── شارة الإشعارات في الشريط الجانبي ──────────────────────────── */
.nav-badge {
    margin-right: auto;
    margin-left: 0;
    background: var(--clr-danger);
    color: #fff;
    font-size: .6rem;
    font-weight: 700;
    border-radius: 999px;
    padding: 1px 6px;
    min-width: 18px;
    text-align: center;
    line-height: 1.6;
}

/* ─── صفوف المتأخرات (Alerts page) ──────────────────────────────── */
.urgency-critical-row  { background: rgba(220,53,69,.07) !important; }
.urgency-warning-row   { background: rgba(253,126,20,.06) !important; }
.urgency-caution-row   { background: rgba(255,193,7,.05) !important; }

.urgency-critical {
    background: rgba(220,53,69,.15);
    color: #b02a37;
    border: 1px solid rgba(220,53,69,.3);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: .75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.urgency-warning {
    background: rgba(253,126,20,.13);
    color: #b35900;
    border: 1px solid rgba(253,126,20,.3);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: .75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.urgency-caution {
    background: rgba(255,193,7,.18);
    color: #856404;
    border: 1px solid rgba(255,193,7,.4);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: .75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ─── صفحة الأداء — أفاتار الموظف ──────────────────────────────── */
.perf-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--clr-primary-lt);
    color: var(--clr-primary);
    font-weight: 700;
    font-size: .8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.perf-avatar-dept {
    background: var(--clr-success-lt);
    color: var(--clr-success);
    font-size: .7rem;
}

/* ══════════════════════════════════════════════════════════════
   التقرير التنفيذي الملخص
══════════════════════════════════════════════════════════════ */
.report-document {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: .75rem;
    padding: 2rem;
    max-width: 900px;
    margin: 0 auto;
}
.report-header h3 { font-size: 1.4rem; }
.section-title {
    font-size: .9rem;
    font-weight: 700;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: .35rem;
    margin-bottom: 1rem;
}
/* KPI cards */
.kpi-card {
    border-radius: .6rem;
    padding: 1rem .75rem;
    text-align: center;
    border: 1px solid transparent;
}
.kpi-incoming  { background: #eff6ff; border-color: #bfdbfe; }
.kpi-outgoing  { background: #ecfdf5; border-color: #a7f3d0; }
.kpi-completed { background: #f0fdf4; border-color: #86efac; }
.kpi-late      { background: #fff1f2; border-color: #fecdd3; }
.kpi-value { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.kpi-incoming  .kpi-value { color: #2563eb; }
.kpi-outgoing  .kpi-value { color: #059669; }
.kpi-completed .kpi-value { color: #16a34a; }
.kpi-late      .kpi-value { color: #dc2626; }
.kpi-label { font-size: .75rem; color: #6b7280; margin-top: .25rem; }
/* Rate circles */
.rate-card { text-align: center; padding: .5rem; }
.rate-circle {
    display: inline-flex;
    align-items: baseline;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: .35rem;
}
.rate-unit { font-size: 1rem; margin-right: .1rem; }
.rate-good { color: #16a34a; }
.rate-warn { color: #d97706; }
.rate-bad  { color: #dc2626; }
.rate-label { font-size: .75rem; color: #6b7280; }
/* Quarterly bar */
.quarterly-row { display: flex; align-items: center; gap: .75rem; }
.quarterly-label { width: 6rem; font-size: .8rem; font-weight: 600; color: #374151; flex-shrink: 0; text-align: left; }
.quarterly-bar-wrap { flex: 1; background: #f1f5f9; border-radius: 99px; height: 18px; overflow: hidden; }
.quarterly-bar { background: var(--clr-primary); height: 100%; border-radius: 99px; min-width: 4px; transition: width .4s ease; }
.quarterly-value { width: 2.5rem; text-align: center; font-size: .85rem; font-weight: 700; color: #374151; flex-shrink: 0; }
/* Report table */
.report-table th, .report-table td { font-size: .82rem; }
/* Print */
@media print {
    .no-print { display: none !important; }
    .report-document { border: none; padding: .5rem; }
    .sidebar, nav { display: none !important; }
}
