/* ============================================
   REGION PAGES CSS - CLASSIC BLUE THEME
   FOR: Asia, Arab World, Europe, Africa, 
   South America, North America, Oceania
============================================ */
:root {
  --primary: #0d47a1;
  --primary-light: #1565c0;
  --primary-dark: #0a2a6a;
  --primary-bg: #e3f2fd;
  --accent: #42a5f5;
  --accent-light: #90caf9;
  --text-dark: #1a1a2e;
  --text-muted: #555577;
  --bg-white: #FFFFFF;
  --bg-gray: #f4f6fa;
  --shadow: 0 4px 20px rgba(13, 71, 161, 0.08);
  --shadow-hover: 0 8px 30px rgba(13, 71, 161, 0.15);
  --border-radius: 12px;
  --transition: all 0.3s ease;
  --max-width: 1400px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-white);
  color: var(--text-dark);
  line-height: 1.6;
}

a {
  text-decoration: none;
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

/* ============================================
   HEADER
============================================ */
.main-header {
  background: var(--bg-white);
  border-bottom: 1px solid #e8ecf0;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(13, 71, 161, 0.04);
}

.header-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.brand-name {
  font-family: 'Source Serif 4', serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
}

/* ============================================
   NAVIGATION
============================================ */
.nav-list {
  display: flex;
  list-style: none;
  gap: 8px;
  align-items: center;
}

.nav-list li a {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dark);
  border-radius: 8px;
  transition: var(--transition);
  white-space: nowrap;
}

.nav-list li a:hover {
  background: var(--primary-bg);
  color: var(--primary);
}

.nav-list li a.active {
  background: var(--primary);
  color: white;
}

.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.menu-toggle span {
  display: block;
  width: 25px;
  height: 2.5px;
  background: var(--text-dark);
  border-radius: 2px;
  transition: var(--transition);
}

.menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ============================================
   SUB-NAVIGATION
============================================ */
.sub-nav-wrapper {
  background: var(--bg-gray);
  border-bottom: 1px solid #e8ecf0;
  position: relative;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 50px;
}

.sub-nav-scroll {
  display: flex;
  overflow-x: auto;
  scroll-behavior: smooth;
  gap: 4px;
  padding: 10px 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.sub-nav-scroll::-webkit-scrollbar {
  display: none;
}

.sub-nav-scroll a {
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 20px;
  white-space: nowrap;
  transition: var(--transition);
  flex-shrink: 0;
}

.sub-nav-scroll a:hover {
  background: white;
  color: var(--primary);
}

.sub-nav-scroll a.active {
  background: var(--primary);
  color: white;
}

.scroll-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #ddd;
  background: white;
  color: var(--text-dark);
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.scroll-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.scroll-left { left: 8px; }
.scroll-right { right: 8px; }

/* ============================================
   REGION HERO
============================================ */
.region-hero {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 24px 20px;
}

.hero-content {
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
}

.hero-content h1 {
  font-family: 'Source Serif 4', serif;
  font-size: 38px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 16px;
  line-height: 1.2;
}

.hero-content p {
  font-size: 17px;
  color: var(--text-muted);
  line-height: 1.7;
}

/* ============================================
   STATS BANNER
============================================ */
.stats-banner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px 20px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-item {
  background: var(--bg-gray);
  border-radius: var(--border-radius);
  padding: 16px 20px;
  text-align: center;
  border: 1px solid #e8ecf0;
  transition: var(--transition);
}

.stat-item:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow);
}

.stat-number {
  display: block;
  font-family: 'Source Serif 4', serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ============================================
   FILTERS
============================================ */
.filter-wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px 16px;
}

.filter-card {
  background: var(--bg-gray);
  border-radius: var(--border-radius);
  padding: 20px 24px;
  border: 1px solid #e8ecf0;
}

.filter-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 0.7fr 0.8fr;
  gap: 16px;
  align-items: end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-group input,
.filter-group select {
  padding: 10px 14px;
  border: 1px solid #dde1e6;
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  background: var(--bg-white);
  transition: var(--transition);
  width: 100%;
  color: var(--text-dark);
}

.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 71, 161, 0.1);
}

.filter-actions {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary);
  color: white;
}

/* ============================================
   SORT INFO
============================================ */
.sort-info {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 8px 24px;
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--text-muted);
}

.sort-info strong {
  color: var(--primary);
}

/* ============================================
   TABLE
============================================ */
.table-wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.rankings-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  background: var(--bg-white);
  border-radius: var(--border-radius);
  overflow: hidden;
  border: 1px solid #e8ecf0;
  font-size: 14px;
}

.rankings-table thead {
  background: var(--primary);
  color: white;
}

.rankings-table thead th {
  padding: 14px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  user-select: none;
}

.rankings-table thead th:hover {
  background: var(--primary-light);
}

.rankings-table thead th::after {
  content: ' ⇅';
  opacity: 0.5;
  font-size: 11px;
}

.rankings-table thead th.sorted-asc::after {
  content: ' ↑';
  opacity: 1;
}

.rankings-table thead th.sorted-desc::after {
  content: ' ↓';
  opacity: 1;
}

.rankings-table tbody tr {
  border-bottom: 1px solid #f0f2f5;
  transition: var(--transition);
}

.rankings-table tbody tr:hover {
  background: var(--primary-bg);
}

.rankings-table tbody tr:last-child {
  border-bottom: none;
}

.rankings-table tbody td {
  padding: 12px 16px;
  vertical-align: middle;
}

/* ============================================
   COLUMN WIDTHS
============================================ */
.col-rank { 
  width: 70px; 
  text-align: center; 
}

.col-institution { 
  min-width: 220px; 
}

.col-country { 
  min-width: 150px; 
}

.col-world-rank { 
  width: 110px; 
  text-align: center; 
}

.col-country-rank { 
  width: 120px; 
  text-align: center; 
}

.col-website { 
  width: 110px; 
  text-align: center; 
}

/* ============================================
   RANK BADGE
============================================ */
.rank-badge {
  display: inline-block;
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 20px;
  min-width: 40px;
  text-align: center;
}

.rank-badge.top-10 {
  background: #FFD700;
  color: #1a1a2e;
}

.rank-badge.top-50 {
  background: #C0C0C0;
  color: #1a1a2e;
}

.rank-badge.top-100 {
  background: #CD7F32;
  color: white;
}

.institution-name {
  font-weight: 600;
  color: var(--text-dark);
}

.institution-name a {
  color: inherit;
  transition: var(--transition);
}

.institution-name a:hover {
  color: var(--primary);
}

.country-flag {
  display: inline-block;
  margin-right: 6px;
}

.website-link {
  display: inline-block;
  padding: 4px 14px;
  background: var(--bg-gray);
  color: var(--text-muted);
  border-radius: 6px;
  font-size: 12px;
  transition: var(--transition);
}

.website-link:hover {
  background: var(--primary);
  color: white;
}

.loading-cell {
  text-align: center;
  padding: 40px !important;
  color: var(--text-muted);
}

/* ============================================
   PAGINATION
============================================ */
.pagination-wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px 40px;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pagination button {
  padding: 8px 16px;
  border: 1px solid #dde1e6;
  border-radius: 8px;
  background: var(--bg-white);
  color: var(--text-dark);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
  min-width: 40px;
}

.pagination button:hover:not(:disabled) {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.pagination button.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================
   FOOTER
============================================ */
.main-footer {
  background: var(--bg-gray);
  border-top: 1px solid #e8ecf0;
  margin-top: 20px;
}

.footer-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 24px 24px;
  text-align: center;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px 28px;
  margin-bottom: 20px;
}

.footer-links a {
  font-size: 14px;
  color: var(--text-muted);
  transition: var(--transition);
}

.footer-links a:hover {
  color: var(--primary);
}

.footer-copyright {
  font-size: 13px;
  color: var(--text-muted);
}

/* ============================================
   RESPONSIVE
============================================ */

/* Tablets */
@media (max-width: 1200px) {
  .filter-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .filter-actions {
    grid-column: span 2;
    justify-content: flex-start;
  }
}

@media (max-width: 992px) {
  .hero-content h1 {
    font-size: 30px;
  }
  
  .stats-banner {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .rankings-table {
    font-size: 13px;
    min-width: 850px;
  }
  
  .rankings-table thead th,
  .rankings-table tbody td {
    padding: 10px 12px;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .menu-toggle {
    display: flex;
  }
  
  .main-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-white);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }
  
  .main-nav.open {
    max-height: 500px;
    overflow-y: auto;
  }
  
  .nav-list {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 20px;
    gap: 0;
  }
  
  .nav-list li a {
    padding: 12px 16px;
    border-radius: 0;
    border-bottom: 1px solid #f0f0f0;
  }
  
  .nav-list li:last-child a {
    border-bottom: none;
  }
  
  .hero-content h1 {
    font-size: 24px;
  }
  
  .hero-content p {
    font-size: 15px;
  }
  
  .stats-banner {
    grid-template-columns: 1fr 1fr;
  }
  
  .stat-number {
    font-size: 24px;
  }
  
  .filter-grid {
    grid-template-columns: 1fr;
  }
  
  .filter-actions {
    grid-column: span 1;
    flex-direction: row;
  }
  
  .filter-actions .btn {
    flex: 1;
  }
  
  .sub-nav-wrapper {
    padding: 0 38px;
  }
  
  .scroll-btn {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }
  
  .rankings-table {
    font-size: 12px;
    min-width: 750px;
  }
  
  .rankings-table thead th,
  .rankings-table tbody td {
    padding: 8px 10px;
  }
  
  .sort-info {
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
  }
}

/* Small Mobile */
@media (max-width: 480px) {
  .header-container {
    padding: 10px 16px;
  }
  
  .brand-name {
    font-size: 20px;
  }
  
  .brand-logo {
    width: 32px;
    height: 32px;
  }
  
  .region-hero {
    padding: 24px 16px 12px;
  }
  
  .hero-content h1 {
    font-size: 20px;
  }
  
  .stats-banner {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 0 16px 16px;
  }
  
  .stat-item {
    padding: 12px 16px;
  }
  
  .stat-number {
    font-size: 20px;
  }
  
  .filter-wrapper {
    padding: 0 16px 12px;
  }
  
  .filter-card {
    padding: 16px;
  }
  
  .table-wrapper {
    padding: 0 16px 12px;
  }
  
  .rankings-table {
    font-size: 11px;
    min-width: 650px;
  }
  
  .rankings-table thead th,
  .rankings-table tbody td {
    padding: 6px 8px;
  }
  
  .col-rank { width: 50px; }
  .col-institution { min-width: 140px; }
  .col-country { min-width: 110px; }
  .col-world-rank { width: 90px; }
  .col-country-rank { width: 90px; }
  .col-website { width: 80px; }
  
  .rank-badge {
    font-size: 11px;
    padding: 2px 8px;
    min-width: 30px;
  }
  
  .website-link {
    font-size: 10px;
    padding: 2px 10px;
  }
  
  .pagination-wrapper {
    padding: 0 16px 24px;
  }
  
  .pagination button {
    padding: 6px 12px;
    font-size: 12px;
    min-width: 32px;
  }
  
  .footer-links {
    gap: 10px 16px;
  }
  
  .footer-links a {
    font-size: 12px;
  }
}

/* Extra Small */
@media (max-width: 380px) {
  .rankings-table {
    min-width: 550px;
    font-size: 10px;
  }
  
  .rankings-table thead th,
  .rankings-table tbody td {
    padding: 4px 6px;
  }
  
  .col-rank { width: 40px; }
  .col-institution { min-width: 120px; }
  .col-country { min-width: 90px; }
  .col-world-rank { width: 70px; }
  .col-country-rank { width: 70px; }
  .col-website { width: 65px; }
}

/* ============================================
   REGION NEWS SECTION
============================================ */
#regionNews {
  padding-top: 20px;
}

#regionNews .news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  margin-top: 16px;
}

#regionNews .news-card {
  background: var(--bg-white);
  border: 1px solid #e8ecf0;
  border-radius: var(--border-radius);
  overflow: hidden;
  transition: var(--transition);
}

#regionNews .news-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-4px);
  border-color: var(--primary-light);
}

#regionNews .news-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

#regionNews .news-card-body {
  padding: 16px 20px 20px;
}

#regionNews .news-card-body h4 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.4;
}

#regionNews .news-card-body h4 a {
  color: var(--text-dark);
  transition: var(--transition);
}

#regionNews .news-card-body h4 a:hover {
  color: var(--primary);
}

#regionNews .news-card-body .news-meta {
  font-size: 13px;
  color: var(--text-muted);
}

#regionNews .loading-spinner {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  grid-column: 1 / -1;
}

@media (max-width: 768px) {
  #regionNews .news-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
  }
}

@media (max-width: 480px) {
  #regionNews .news-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  
  #regionNews .news-card img {
    height: 150px;
  }
  
  #regionNews .news-card-body h4 {
    font-size: 15px;
  }
}
/* ============================================
   FIX: HEADER NAVIGATION ALIGNMENT & SCROLL
============================================ */
.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-right: 24px;
}

.main-nav {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  scrollbar-width: thin;
}

.main-nav::-webkit-scrollbar {
  height: 4px;
}

.main-nav::-webkit-scrollbar-thumb {
  background: var(--primary-light);
  border-radius: 4px;
}

.nav-list {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: nowrap;
}

.nav-list li a {
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--text-dark);
  border-radius: 6px;
  transition: var(--transition);
}

.nav-list li a:hover {
  background: var(--primary-bg);
  color: var(--primary);
}

.nav-list li a.active {
  background: var(--primary);
  color: white;
  padding: 4px 10px;
  font-size: 13px;
  border-radius: 6px;
}

.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}

.menu-toggle span {
  display: block;
  width: 25px;
  height: 2.5px;
  background: var(--text-dark);
  border-radius: 2px;
  transition: var(--transition);
}

.menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

@media (min-width: 769px) {
  .header-container {
    flex-wrap: nowrap;
  }
  
  .main-nav {
    flex: 0 1 auto;
  }
}

@media (max-width: 768px) {
  .brand {
    margin-right: 0;
  }
  
  .menu-toggle {
    display: flex;
  }
  
  .main-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-white);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    overflow-y: auto;
    flex: none;
    width: 100%;
  }
  
  .main-nav.open {
    max-height: 500px;
  }
  
  .nav-list {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 20px;
    gap: 0;
    flex-wrap: wrap;
  }
  
  .nav-list li a {
    padding: 12px 16px;
    font-size: 14px;
    border-radius: 0;
    border-bottom: 1px solid #f0f0f0;
    white-space: normal;
  }
  
  .nav-list li a.active {
    padding: 8px 12px;
    border-radius: 0;
  }
  
  .nav-list li:last-child a {
    border-bottom: none;
  }
}

/* ============================================
   SOCIAL LINKS
============================================ */
.footer-social {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;  
}

.social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-gray);
  color: var(--text-muted);
  transition: var(--transition);
}

.social-link:hover {
  transform: translateY(-3px);
}

.social-link:hover .social-x {
  color: #000000;
}

.social-link:hover .social-linkedin {
  color: #0A66C2;
}

.social-link:hover .social-facebook {
  color: #1877F2;
}