:root {
  --er-primary: #1e407a;
  --er-accent: #ffc53a;
  --er-soft: #cdd4fb;
  --er-chip-bg: #b7d8ef;
  --er-text-main: #292929;
  --er-text-muted: #545454;
  --er-border-soft: #cdd4fb;
  --er-page-bg: #ffffff;
  --er-card-bg: #ffffff;
  --er-radius-lg: 22px;
  --er-radius-md: 14px;
  --er-shadow-soft: 0 22px 55px rgba(15, 23, 42, 0.14);
}

/* Hide theme headers */
.post-type-archive-exam_result .page-header,
.post-type-archive-exam_result .page-title,
.post-type-archive-exam_result .entry-title,
.post-type-archive-exam_result #sub-header,
.post-type-archive-exam_result .elementor-page-title {
  display: none !important;
}

body.post-type-archive-exam_result {
  background: var(--er-page-bg);
  color: var(--er-text-main);
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
}

/* OVERFLOW FIX FOR PARENT CONTAINERS */
.limit-wrapper,
.vamtam-box-outer-padding {
  overflow: visible !important;
}

/* 1. HERO SECTION */
.er-hero-wrapper {
  position: relative !important;
  width: 100vw !important;
  max-width: none !important;
  margin-left: calc(50% - 50vw) !important;
  margin-top: 0 !important;
  height: 480px;
  background-size: cover;
  background-position: center;
  background-color: var(--er-primary);
  display: flex;
  align-items: flex-end;
  margin-bottom: 0;
  /* Flush with header bar */
}

/* Overlay Box */
.er-hero-overlay-box {
  background: var(--er-primary);
  color: #ffffff;
  padding: 3rem 3.5rem;
  width: 85%;
  max-width: 650px;
  margin-left: 10%;
  margin-bottom: -3rem;
  /* Overlap effect */
  position: relative;
  z-index: 10;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  border-top-left-radius: var(--er-radius-lg);
  border-top-right-radius: var(--er-radius-lg);
}

.er-hero-title {
  margin: 0 0 1rem;
  font-size: 2.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #ffffff !important;
  line-height: 1.1;
}

.er-hero-subtitle {
  font-size: 1.05rem;
  line-height: 1.6;
  opacity: 0.9;
  margin: 0;
  max-width: 90%;
}

/* RTL Hero */
html[dir="rtl"] .er-hero-wrapper {
  margin-right: calc(50% - 50vw) !important;
  margin-left: 0 !important;
  right: 0;
  left: auto;
}

html[dir="rtl"] .er-hero-overlay-box {
  margin-left: 0;
  margin-right: 10%;
  text-align: right;
  direction: rtl;
}

/* 2. ARCHIVE PAGE WRAPPER */
.er-archive-page {
  padding: 60px 0 80px;
}

.er-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* 3. HEADER BAR */
.er-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 40px;
  margin-top: 20px;
  flex-wrap: wrap;
  gap: 20px;
}

.er-header-label {
  display: block;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--er-text-muted);
  margin-bottom: 4px;
}

.er-header-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--er-primary);
  margin: 0;
  line-height: 1.2;
}

/* Stat Card */
.er-stat-card {
  min-width: 240px;
  background: linear-gradient(135deg, var(--er-primary), #164885);
  color: #ffffff;
  padding: 16px 24px;
  border-radius: var(--er-radius-md);
  box-shadow: 0 10px 25px rgba(22, 72, 133, 0.25);
  position: relative;
  overflow: hidden;
}

.er-stat-content {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.er-stat-value {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1;
}

.er-stat-label {
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0.9;
}

.er-stat-note {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-top: 4px;
}

/* 4. FILTERS */
.er-filters {
  background: #f8f9fc;
  border: 1px solid #eef2f6;
  border-radius: var(--er-radius-lg);
  padding: 24px;
  margin-bottom: 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.er-filter-group {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.er-filter-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--er-text-muted);
  margin-left: 8px;
}

html[dir="rtl"] .er-filter-label {
  margin-left: 0;
  margin-right: 8px;
}

.er-select,
.er-input {
  width: 100%;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--er-border-soft);
  background: #ffffff;
  font-size: 0.9rem;
  color: var(--er-text-main);
  transition: all 0.2s ease;
  appearance: none;
  /* hide default arrow */
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231e407a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 16px;
}

html[dir="rtl"] .er-select {
  background-position: left 1rem center;
}

.er-select:focus,
.er-input:focus {
  outline: none;
  border-color: var(--er-primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 122, 0.1);
}

.er-filter-search {
  flex-basis: 100%;
  /* Full width search usually better? or keep inline? */
  max-width: 400px;
}

.er-input {
  background-image: none;
  /* No arrow for text input */
}


/* 5. PREMIUM CARD GRID (Academic Style) */
.er-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 30px;
}

.er-card {
  position: relative;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
  /* Soft academic shadow */
  transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
  border: 1px solid #e1e8f0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* File Folder Tab Effect */
.er-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(90deg, #1e407a 0%, #3b5d96 100%);
  /* University Blue */
}

.er-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 13px 27px -5px rgba(50, 50, 93, 0.25), 0 8px 16px -8px rgba(0, 0, 0, 0.3);
  border-color: #b7c2d0;
}

.er-card-header {
  padding: 24px 24px 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

/* Pills */
.er-card-pill {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.er-pill-faculty {
  background: #eef2fa;
  color: #1e407a;
  border: 1px solid #dae1e7;
}

.er-pill-year {
  background: #fff7e6;
  color: #bfa15f;
  /* Gold-ish */
  border: 1px solid #faeacc;
}

.er-card-body {
  padding: 10px 24px 20px;
  flex-grow: 1;
}

/* Font Override as requested */
.er-card-title {
  margin: 0 0 16px;
  font-size: 1.3rem !important;
  /* Force academic size */
  font-weight: 800 !important;
  color: #2d3748 !important;
  line-height: 1.3;
  font-family: 'Inter', system-ui, sans-serif !important;
}

/* Info Grid */
.er-card-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  border-top: 1px solid #f1f5f9;
  padding-top: 16px;
}

.er-info-item {
  display: flex;
  flex-direction: column;
}

.er-info-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: #718096;
  font-weight: 600;
  margin-bottom: 2px;
}

.er-info-val {
  font-size: 0.9rem;
  font-weight: 500;
  color: #4a5568;
}

.er-card-footer {
  padding: 16px 24px;
  background: #f8fafc;
  border-top: 1px solid #edf2f7;
}

/* Action Button: Eye Icon style */
.er-btn-action {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #fff;
  border: 1px solid #1e407a;
  color: #1e407a;
  border-radius: 6px;
  font-weight: 600;
  transition: all 0.2s ease;
  cursor: pointer;
  gap: 12px;
}

.er-btn-action:hover {
  background: var(--er-accent);
  /* Gold */
  color: #1e407a;
  /* Dark Blue Text */
  border-color: var(--er-accent);
}

.er-btn-text {
  font-size: 0.85rem;
  line-height: 1;
}

.er-no-file-msg {
  display: block;
  text-align: center;
  font-size: 0.85rem;
  font-style: italic;
  color: #a0aec0;
}

/* 6. MODAL (Z-Index Fix) */
.er-pdf-modal {
  position: fixed !important;
  inset: 0 !important;
  /* Top/Left/Right/Bottom 0 */
  width: 100vw !important;
  height: 100vh !important;
  z-index: 2147483647 !important;
  /* Max Z-Index */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.er-pdf-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.er-pdf-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  /* Darker backdrop */
  backdrop-filter: blur(5px);
}

.er-pdf-dialog {
  position: relative;
  width: 90%;
  max-width: 1000px;
  height: 85vh;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 50px 100px -20px rgba(0, 0, 0, 0.6);
  /* Heavy shadow */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 2147483648;
  /* One higher */
  transform: translateY(20px) scale(0.98);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.er-pdf-modal.is-open .er-pdf-dialog {
  transform: translateY(0) scale(1);
}

.er-pdf-header {
  padding: 12px 20px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.er-pdf-title {
  font-weight: 600;
  color: #334155;
}

.er-pdf-close {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
}

.er-pdf-body {
  flex: 1;
  background: #333;
}

.er-pdf-frame {
  width: 100%;
  height: 100%;
  border: none;
}

/* RTL Support */
html[dir="rtl"] .er-grid {
  direction: rtl;
}

html[dir="rtl"] .er-card-header {
  flex-direction: row-reverse;
  /* If needed? Or keep specific flow? */
}

/* Usually header is pills, keep standard row */

html[dir="rtl"] .er-card-title {
  text-align: right;
  font-family: 'Tajawal', system-ui, sans-serif !important;
  /* Arabic Font preference */
}

html[dir="rtl"] .er-btn-action {
  flex-direction: row-reverse;
}

/* 7. PAGINATION */
.er-pagination {
  margin-top: 40px;
  display: flex;
  justify-content: center;
}

.er-pagination .page-numbers {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  margin: 0 4px;
  padding: 0 12px;
  background: #ffffff;
  border: 1px solid var(--er-border-soft);
  border-radius: 999px;
  color: var(--er-primary);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
}

.er-pagination .page-numbers.current,
.er-pagination .page-numbers:hover {
  background: var(--er-primary);
  color: #ffffff;
  border-color: var(--er-primary);
}

/* 8. NO RESULTS STATE */
.er-no-results {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 30px;
  background: linear-gradient(135deg, #f8fafc 0%, #eef2f7 100%);
  border: 2px dashed #cbd5e1;
  border-radius: var(--er-radius-lg);
  text-align: center;
}

.er-no-results::before {
  content: '📋';
  font-size: 3.5rem;
  margin-bottom: 16px;
  opacity: 0.7;
}

.er-no-results h3 {
  margin: 0 0 8px;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--er-primary);
}

.er-no-results p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--er-text-muted);
  max-width: 320px;
}

/* RTL No Results */
html[dir="rtl"] .er-no-results {
  direction: rtl;
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .er-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .er-stat-card {
    width: 100%;
  }

  .er-filters {
    flex-direction: column;
  }

  .er-filter-group {
    width: 100%;
  }
}