/* ============================================================
   صفحة الأقسام — CSS كامل ومنظّم
   ============================================================ */

/* ============================================================
   1. المتغيرات
   ============================================================ */
:root {
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --primary-blue: #1a73e8;
    --trend-up: #137333;
    --trend-up-bg: #e6f4ea;
    --trend-down: #c5221f;
    --trend-down-bg: #fce8e6;
    --sidebar-width: 250px;

    /* ألوان الكليات */
    --college-medicine:    #4a7bb5;
    --college-dentistry:   #5a9d6e;
    --college-pharmacy:    #c9a24a;
    --college-engineering: #7e6ba8;
    --college-computing:   #4a8fa3;
    --college-admin:       #b85c5c;
    --college-humanities:  #7a5e4a;
}

/* ============================================================
   2. إعادة الضبط
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    direction: rtl;
    line-height: 1.5;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================================================
   3. القائمة الجانبية
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    background-color: #ffffff;
    color: #475569;
    position: fixed;
    height: 100vh;
    right: 0;
    top: 0;
    z-index: 100;
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border-left: 1px solid var(--border-color);
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.04);
    transform: translateX(100%);
}

.sidebar.active {
    transform: translateX(0);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
}

.logo-container {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border-color);
    height: 72px;
    flex-shrink: 0;
}

.logo-container .brand-logo {
    width: 140px !important;
    height: 40px !important;
    object-fit: contain;
    display: block;
}

.nav-menu {
    padding: 15px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: #64748b;
    font-size: 0.88rem;
    border-radius: 6px;
    transition: all 0.15s ease;
    font-weight: 500;
}

.nav-item:hover { background-color: #f1f5f9; color: #1e293b; }
.nav-item.active { background-color: #e8f0fe; color: var(--primary-blue); font-weight: 600; }

/* ============================================================
   4. المحتوى الرئيسي
   ============================================================ */
.main-content {
    flex: 1;
    padding: 25px 30px;
    width: 100%;
    min-width: 0;
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ============================================================
   5. شريط الرأس
   ============================================================ */
.top-header {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.hamburger-btn {
    display: block;
    color: var(--text-primary);
    padding: 4px;
    border-radius: 4px;
    flex-shrink: 0;
    cursor: pointer;
}

.hamburger-btn:hover { background: var(--bg-surface); }

.header-logo {
    width: 140px;
    height: 40px;
    object-fit: contain;
    flex-shrink: 0;
}

/* ============================================================
   6. Top Nav
   ============================================================ */
.top-nav {
    display: flex;
    gap: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.top-nav::-webkit-scrollbar { display: none; }

.top-nav__link {
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: 6px;
    transition: all 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.top-nav__link:hover { background: #f1f5f9; color: var(--text-primary); }
.top-nav__link.active { background: var(--primary-blue); color: #ffffff; font-weight: 600; }

/* ============================================================
   7. شريط الفلاتر
   ============================================================ */
.filter-bar {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.filter-group label {
    font-weight: 500;
    white-space: nowrap;
}

.form-select {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    color: var(--text-primary);
    background: #fff;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease;
    min-width: 200px;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

/* ============================================================
   8. شريط الاختيار (Dropdowns)
   ============================================================ */
.selector-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    flex-wrap: wrap;
}

.selector-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex: 1;
    min-width: 200px;
}

.selector-group label {
    font-weight: 600;
    white-space: nowrap;
    color: var(--text-primary);
}

.selector-group select {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--text-primary);
    background: #fff;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.selector-group select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

/* ============================================================
   9. التبويبات (Tabs)
   ============================================================ */
.departments-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.departments-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
    padding: 8px 18px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: 6px;
    transition: all 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.tab-btn:hover {
    background: #f1f5f9;
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--primary-blue);
    color: #ffffff;
    font-weight: 600;
}

/* ============================================================
   10. شبكة KPIs
   ============================================================ */
..kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
    min-width: 0;
}

.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: box-shadow 0.15s ease;
}

.kpi-title {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.kpi-value-container {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin: 6px 0 0 0;
    flex-wrap: wrap;
}

.kpi-value {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================================
   11. مؤشرات النمو (Trend)
   ============================================================ */
.trend {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    display: inline-block;
}

.trend.positive { color: #137333; background-color: #e6f4ea; }
.trend.negative { color: #c5221f; background-color: #fce8e6; }
.trend.neutral  { color: #1a73e8; background-color: #e8f0fe; }

/* ============================================================
   12. البطاقات العامة
   ============================================================ */
.chart-card,
.table-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    min-width: 0;
    overflow: hidden;
    margin-bottom: 20px;
}

.chart-card--wide { width: 100%; }

.card-header {
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ============================================================
   13. حاويات الرسوم
   ============================================================ */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    overflow: hidden;
}

.chart-container--tall { height: 450px; }
.chart-container--small { height: 250px; }

/* رسوم Bar الستة (أقصر) */
.chart-container:has(#barWorks),
.chart-container:has(#barCitations),
.chart-container:has(#barImpact),
.chart-container:has(#barQuality),
.chart-container:has(#barCollab),
.chart-container:has(#barHIndex) {
    height: 250px;
}

/* ============================================================
   14. تبويبات الرسم (Chart Tabs)
   ============================================================ */
.chart-tabs {
    display: flex;
    gap: 4px;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 6px;
}

.chart-tab {
    padding: 5px 12px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: all 0.15s ease;
    cursor: pointer;
}

.chart-tab:hover { color: var(--text-primary); }

.chart-tab.active {
    background: #ffffff;
    color: var(--primary-blue);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    font-weight: 600;
}

/* ============================================================
   15. الشبكات
   ============================================================ */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    min-width: 0;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    min-width: 0;
}

/* ============================================================
   16. Heatmap (Fields × الكليات)
   ============================================================ */
.heatmap-wrapper {
    overflow-x: auto;
    width: 100%;
}

.heatmap-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.heatmap-table th {
    padding: 10px 6px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.72rem;
    text-align: center;
    white-space: nowrap;
    border-bottom: 2px solid var(--border-color);
}

.heatmap-table th:first-child {
    text-align: right;
    position: sticky;
    right: 0;
    background: var(--bg-surface);
    z-index: 2;
}

.heatmap-table td {
    padding: 8px 6px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    font-weight: 500;
    transition: transform 0.15s ease;
}

.heatmap-table td:first-child {
    text-align: right;
    font-weight: 600;
    color: var(--text-primary);
    position: sticky;
    right: 0;
    background: var(--bg-surface);
    z-index: 2;
    white-space: nowrap;
    padding-left: 15px;
}

.heatmap-table td:not(:first-child):hover {
    transform: scale(1.05);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

/* ============================================================
   17. Leaderboard
   ============================================================ */
.leaderboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.leaderboard-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
}

.leaderboard-card h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}

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

.leaderboard-rank {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    background: #f1f5f9;
    flex-shrink: 0;
}

.leaderboard-rank.rank-1 {
    background: #1a73e8;
    color: #ffffff;
}

.leaderboard-rank.rank-2,
.leaderboard-rank.rank-3 {
    background: #e2e8f0;
    color: #475569;
}

.leaderboard-name {
    flex: 1;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
}

.leaderboard-value {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--primary-blue);
}

/* ============================================================
   18. الجداول
   ============================================================ */
.table-wrapper {
    overflow-x: auto;
    width: 100%;
    border-radius: 6px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: right;
}

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

.data-table th {
    color: var(--text-secondary);
    font-weight: 600;
    padding: 12px 10px;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    font-size: 0.82rem;
    text-align: right;
}

.data-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table td strong { font-weight: 600; }

/* ============================================================
   19. جدول Fields التفصيلي
   ============================================================ */
.fields-detailed-table {
    width: 100%;
}

.fields-detailed-table th {
    text-align: right;
}

.fields-detailed-table th:nth-child(3),
.fields-detailed-table th:nth-child(4),
.fields-detailed-table th:nth-child(5) {
    text-align: center;
}

.fields-detailed-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
}

.fields-detailed-table td.field-name-cell {
    background: #f8fafc;
    border-right: 3px solid var(--primary-blue);
    vertical-align: middle;
    font-size: 0.85rem;
}

.fields-detailed-table tbody tr:hover {
    background: #f1f5f9;
}

.fields-detailed-table tbody tr:hover td.field-name-cell {
    background: #e2e8f0;
}

/* ============================================================
   20. جدول Fields السنوي
   ============================================================ */
.fields-yearly-table {
    width: 100%;
}

.fields-yearly-table th {
    text-align: center;
    font-size: 0.8rem;
    padding: 10px 8px;
}

.fields-yearly-table th:first-child {
    text-align: right;
}

.fields-yearly-table td {
    text-align: center;
    padding: 10px 8px;
    font-size: 0.85rem;
}

.fields-yearly-table td.field-name {
    text-align: right;
    font-weight: 600;
    color: var(--text-primary);
    border-right: 3px solid var(--primary-blue);
    background: #f8fafc;
    padding-right: 12px;
    vertical-align: middle;
    font-size: 0.85rem;
}

.fields-yearly-table td.field-name-sub {
    text-align: right;
    background: #f8fafc;
    border-right: 3px solid var(--primary-blue);
    padding: 0;
    height: 4px;
}

.fields-yearly-table tr.row-works td:not(.field-name) {
    background: #ffffff;
    font-weight: 600;
    color: var(--text-primary);
}

.fields-yearly-table tr.row-cites td:not(.field-name-sub) {
    background: #f8fafc;
    font-weight: 400;
    color: #64748b;
}

.fields-yearly-table tr.row-total-works {
    border-top: 2px solid var(--border-color);
}

.fields-yearly-table tr.row-total-works td {
    font-weight: 700;
    color: var(--text-primary);
    background: #e2e8f0;
}

.fields-yearly-table tr.row-total-cites td:not(.field-name-sub) {
    font-weight: 600;
    color: #475569;
    background: #f1f5f9;
}

.fields-yearly-table tr.row-total-cites td.field-name-sub {
    background: #e2e8f0;
}

.fields-yearly-table tr.row-cites td {
    border-bottom: 1px solid var(--border-color);
}

/* ============================================================
   21. عنوان الكلية/التخصص
   ============================================================ */
.college-title-header {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px 25px;
    border-right: 4px solid var(--primary-blue);
    margin-bottom: 20px;
}

.college-title-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.college-title-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ============================================================
   22. Empty State
   ============================================================ */
.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px dashed var(--border-color);
}

/* ============================================================
   23. Sidebar Overlay
   ============================================================ */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    z-index: 99;
    cursor: pointer;
}

.sidebar-overlay.active { opacity: 1; visibility: visible; }

/* ============================================================
   24. Responsive
   ============================================================ */
@media (max-width: 1024px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .main-content { padding: 15px; gap: 15px; }
    .chart-container { height: 240px; }
    .chart-container--tall { height: 380px; }
    .chart-container--small { height: 220px; }
    .filter-bar { padding: 10px 15px; gap: 12px; }
    .filter-group { flex: 1; min-width: 140px; }
    .form-select { width: 100%; min-width: 0; }
    .data-table { font-size: 0.8rem; }
    .data-table th, .data-table td { padding: 8px 6px; }
    .tab-btn { padding: 6px 14px; font-size: 0.8rem; }
    .selector-bar { padding: 10px 12px; }
    .selector-group { min-width: 100%; }
}

@media (max-width: 600px) {
    .kpi-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .main-content { padding: 10px; }
    .kpi-grid { grid-template-columns: 1fr; }
    .kpi-value { font-size: 1.4rem; }
    .chart-container { height: 200px; }
    .chart-container--tall { height: 320px; }
    .chart-container--small { height: 200px; }
}





