/* ============================================================
   المتغيرات (نفس university.css)
   ============================================================ */
: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:    #1a73e8;
    --college-dentistry:   #129e59;
    --college-pharmacy:    #f9ab00;
    --college-engineering: #a142f4;
    --college-computing:   #00acc1;
    --college-admin:       #ea4335;
    --college-humanities:  #6d4c41;
}

/* ============================================================
   إعادة الضبط
   ============================================================ */
*, *::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; }

/* ============================================================
   القائمة الجانبية
   ============================================================ */
.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;
    max-width: 140px !important;
    max-height: 40px !important;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
}

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

/* ============================================================
   المحتوى الرئيسي
   ============================================================ */
.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;
}

/* ============================================================
   شريط الرأس
   ============================================================ */
.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;
    background: none;
    border: none;
}

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

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

/* ============================================================
   شريط الفلتر
   ============================================================ */
.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);
}

/* ============================================================
   التبويبات (Tabs)
   ============================================================ */
.colleges-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);
}

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

/* ============================================================
   شبكة KPIs — 2 بطاقات في كل سطر
   ============================================================ */
/* ============================================================
   شبكة 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);
}

/* ============================================================
   شبكة KPIs — بطابتين في كل سطر مع مسافة سفلية
   ============================================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
    min-width: 0;
    margin-bottom: 24px; /* مسافة حافة للأسفل لعدم الالتصاق */
}



/* Responsive */
@media (max-width: 600px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
}
/* ============================================================
   البطاقات العامة
   ============================================================ */
.chart-card,
.table-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    min-width: 0;
    overflow: hidden;
}

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

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    overflow: hidden;
}

.chart-container--tall { height: 400px; }

/* ============================================================
   Heatmap (كلية × Field)
   ============================================================ */
.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;
}

/* ============================================================
   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: #fff;
    flex-shrink: 0;
}

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

/* ============================================================
   الجداول
   ============================================================ */
.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; }
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--primary-blue); }

/* ============================================================
   Insights
   ============================================================ */
.insights-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.insight-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    background: #f8fafc;
    border-right: 4px solid var(--primary-blue);
    border-radius: 6px;
    font-size: 0.85rem;
    line-height: 1.6;
}

.insight-item--success { border-right-color: #129e59; }
.insight-item--warning { border-right-color: #f9ab00; }
.insight-item--info    { border-right-color: var(--primary-blue); }


}

/* ============================================================
   الشبكات
   ============================================================ */
.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;
}

/* ============================================================
   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;
    display: block;
    cursor: pointer;
}

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

/* ============================================================
   Top Nav (يأتي من university.css)
   ============================================================ */
.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;
    text-decoration: none;
}

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

/* ============================================================
   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; }
    .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; }
}

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


/* ============================================================
   عنوان الكلية
   ============================================================ */
.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);
}

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


/* ============================================================
   جدول 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;
}


/* ============================================================
   جدول 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;
    border-bottom: none;
}

.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 td.growth-cell {
    padding: 8px;
}

/* صف الأبحاث */
.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);
    background: #e2e8f0;
}

.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 التفصيلي
   ============================================================ */
.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;
}


/* ============================================================
   جدول 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);
}


/* ============================================================
   الرسوم التي بها 7 كليات (تحتاج ارتفاع أكبر)
   ============================================================ */
.chart-container--tall {
    height: 450px;
}

@media (max-width: 768px) {
    .chart-container--tall {
        height: 380px;
    }
}

@media (max-width: 480px) {
    .chart-container--tall {
        height: 320px;
    }
}



/* ============================================================
   مؤشرات النمو (▲ / ▼)
   ============================================================ */
.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;
}


/* ============================================================
   تبويبات الرسم (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;
    border: none;
    background: none;
    font-family: inherit;
}

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