@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Coptic:wght@400;700&family=Tajawal:wght@300;400;500;700;800;900&family=Alexandria:wght@400;600;700;800&display=swap');

@font-face {
  font-family: 'Noto Sans Coptic';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/NotoSansCoptic-Regular.ttf') format('truetype'),
       url('https://fonts.gstatic.com/s/notosanscoptic/v22/iJWfBWmUZi_OHPqn4wq6kgqumOEd78s.ttf') format('truetype');
}

.coptic-font, .coptic-text {
  font-family: 'Noto Sans Coptic', 'Avva Shenouda', 'Coptic Unicode', 'Antinoou', 'Segoe UI Historic', Arial, sans-serif !important;
  letter-spacing: 0.5px;
}

:root {
  --primary-color: #0A2A4F;
  --primary-dark: #071f3a;
  --primary-light: #164070;
  --secondary-color: #444cf7;
  --accent-gold: #c99326;
  --accent-gold-light: #f7e0a3;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 14px rgba(10, 42, 79, 0.08);
  --shadow-lg: 0 10px 25px rgba(10, 42, 79, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  box-sizing: border-box;
  max-width: 100%;
}

*, *:before, *:after {
  box-sizing: inherit;
}

body {
  font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #f8fafc;
  color: var(--text-main);
  direction: rtl;
  min-height: 100vh;
  text-align: right;
  width: 100%;
  max-width: 100%;
  overflow-x: clip; /* Fixes RTL horizontal crop without breaking touch scroll */
}

/* ================== NAVBAR ================== */
.app-navbar {
  height: 70px;
  background: linear-gradient(135deg, rgba(10, 42, 79, 0.98) 0%, rgba(15, 47, 84, 0.98) 100%);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 1000;
  color: white;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: white;
}

.brand-logo-img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  background: white;
  border-radius: 50%;
  padding: 3px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.brand-titles h1 {
  font-size: 1.1rem;
  font-weight: 800;
  margin: 0;
  color: #ffffff;
}

.brand-titles small {
  font-size: 0.78rem;
  color: var(--accent-gold-light);
  display: block;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.12);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.88rem;
  color: white;
}

.user-badge i {
  color: var(--accent-gold);
}

/* ================== MAIN LAYOUT ================== */
.app-wrapper {
  display: flex;
  min-height: calc(100vh - 70px);
  width: 100%;
  max-width: 100vw;
  overflow-x: clip;
}

/* Mobile toggle button */
.mobile-toggle-btn {
  display: none;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: white;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.15rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.mobile-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 42, 79, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1400;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-backdrop.show {
  display: block;
  opacity: 1;
}

.mobile-sidebar-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 12px;
}

.sidebar-close-btn {
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  transition: all 0.2s ease;
}

.sidebar-close-btn:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* Sidebar */
.app-sidebar {
  width: 260px;
  background: #ffffff;
  border-left: 1px solid var(--border-color);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  box-shadow: -2px 0 10px rgba(0,0,0,0.02);
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.sidebar-menu {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-menu-header {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 14px 4px;
  letter-spacing: 0.5px;
}

.sidebar-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  color: var(--text-main);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.92rem;
  transition: all 0.2s ease;
}

.sidebar-item a i {
  font-size: 1.1rem;
  color: var(--primary-light);
  width: 22px;
  text-align: center;
  transition: transform 0.2s ease;
}

.sidebar-item a:hover {
  background: rgba(68, 76, 247, 0.08);
  color: var(--secondary-color);
}

.sidebar-item a:hover i {
  transform: scale(1.15);
  color: var(--secondary-color);
}

.sidebar-item.active a {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(10, 42, 79, 0.25);
}

.sidebar-item.active a i {
  color: var(--accent-gold);
}

/* Content Area */
.app-content {
  flex: 1;
  padding: 28px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  min-width: 0; /* CRITICAL: prevents flex item from overflowing viewport in flex parent */
}

/* ================== CARDS & STATS ================== */
.stat-card {
  background: white;
  border-radius: var(--radius-md);
  padding: 22px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 18px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}

.stat-icon.primary { background: rgba(10, 42, 79, 0.1); color: var(--primary-color); }
.stat-icon.success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.stat-icon.warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.stat-icon.info { background: rgba(59, 130, 246, 0.1); color: var(--info); }
.stat-icon.gold { background: rgba(201, 147, 38, 0.15); color: var(--accent-gold); }

.stat-details h3 {
  font-size: 1.7rem;
  font-weight: 800;
  margin: 0 0 2px;
  color: var(--text-main);
}

.stat-details p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0;
  font-weight: 500;
}

.content-card {
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
}

.content-card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafbfc;
}

.content-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--primary-color);
}

.content-card-body {
  padding: 24px;
}

/* ================== TABLES ================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.app-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.92rem;
}

.app-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 700;
  padding: 13px 16px;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.app-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.app-table tbody tr:hover {
  background-color: rgba(68, 76, 247, 0.02);
}

/* ================== BADGES & BUTTONS ================== */
.badge-appraisal {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}

.badge-excellent { background: #dcfce7; color: #15803d; }
.badge-verygood { background: #e0f2fe; color: #0369a1; }
.badge-good { background: #fef3c7; color: #b45309; }
.badge-pass { background: #f1f5f9; color: #475569; }
.badge-retake { background: #fee2e2; color: #b91c1c; }

.btn-church {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(10, 42, 79, 0.2);
}

.btn-church:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(10, 42, 79, 0.3);
}

.btn-gold {
  background: linear-gradient(135deg, #d4af37 0%, #b8860b 100%);
  color: white;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(184, 134, 11, 0.25);
}

.btn-gold:hover {
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(184, 134, 11, 0.35);
}

.btn-outline-church {
  background: transparent;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-outline-church:hover {
  background: var(--primary-color);
  color: white;
}

/* ================== HEADER ACTIONS & MOBILE BARS ================== */
.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.mobile-sticky-save-bar {
  display: none;
}

/* ================== LOGIN PAGES ================== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 480px;
  background: white;
  border-radius: var(--radius-lg);
  padding: 38px 34px;
  box-shadow: 0 10px 35px rgba(10, 42, 79, 0.12);
  border: 1px solid rgba(68, 76, 247, 0.1);
  text-align: center;
}

.login-logos {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 22px;
}

.login-logos img {
  height: 72px;
  width: 72px;
  object-fit: contain;
}

.login-box h2 {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--primary-color);
  margin-bottom: 6px;
}

.login-box p.subtitle {
  color: var(--text-muted);
  font-size: 0.94rem;
  margin-bottom: 28px;
}

.form-group {
  margin-bottom: 18px;
  text-align: right;
}

.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--text-main);
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon i {
  position: absolute;
  right: 14px;
  color: var(--text-muted);
  font-size: 1rem;
}

.form-control-custom {
  width: 100%;
  padding: 12px 42px 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  background: #fbfcfe;
}

.form-control-custom:focus {
  outline: none;
  border-color: var(--secondary-color);
  box-shadow: 0 0 0 3px rgba(68, 76, 247, 0.12);
  background: #ffffff;
}

/* ================== STUDENT PORTAL ================== */
.student-hero {
  background: linear-gradient(135deg, #0A2A4F 0%, #153c6c 100%);
  border-radius: var(--radius-md);
  padding: 30px;
  color: white;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.student-hero::after {
  content: '⛪';
  position: absolute;
  left: 20px;
  bottom: -20px;
  font-size: 9rem;
  opacity: 0.06;
  pointer-events: none;
}

.student-hero h2 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: #ffffff;
}

.student-meta-tags {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.student-tag {
  background: rgba(255, 255, 255, 0.15);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.86rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.student-tag.gold {
  background: rgba(212, 175, 55, 0.25);
  color: var(--accent-gold-light);
  font-weight: 700;
}

/* ================== OFFICIAL CERTIFICATE / REPORT CARD ================== */
@media print {
  body {
    background: none !important;
    background-image: none !important;
  }
  .app-navbar, .app-sidebar, .no-print {
    display: none !important;
  }
  .app-content {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }
  .cert-container {
    box-shadow: none !important;
    border: none !important;
    margin: 0 !important;
    page-break-after: always;
  }
}

.cert-container {
  width: 100%;
  max-width: 820px;
  margin: 0 auto 30px;
  background: white;
  border: 2px solid #0A2A4F;
  border-radius: 8px;
  padding: 36px 40px;
  box-shadow: var(--shadow-md);
  position: relative;
}

.cert-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #0A2A4F;
  padding-bottom: 18px;
  margin-bottom: 24px;
}

.cert-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.cert-title-block {
  text-align: center;
}

.cert-title-block h2 {
  font-family: 'Alexandria', sans-serif;
  font-size: 1.45rem;
  font-weight: 800;
  color: #0A2A4F;
  margin: 0;
}

.cert-title-block h3 {
  font-size: 1.15rem;
  color: #334155;
  font-weight: 700;
  margin: 4px 0;
}

.cert-title-block p {
  font-size: 0.92rem;
  color: #64748b;
  margin: 0;
  font-weight: 600;
}

.cert-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  background: #f8fafc;
  padding: 14px 18px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  margin-bottom: 24px;
}

.cert-info-item span.label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.cert-info-item span.value {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary-color);
}

.cert-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.cert-table th, .cert-table td {
  border: 1px solid #cbd5e1;
  padding: 10px 14px;
  text-align: center;
  font-size: 0.95rem;
}

.cert-table th {
  background: #0A2A4F;
  color: white;
  font-weight: 700;
}

.cert-table td.subject-name {
  text-align: right;
  font-weight: 700;
}

.cert-table tr.total-row td {
  font-weight: 800;
  background: #f1f5f9;
  font-size: 1.05rem;
  color: #0A2A4F;
}

.cert-signatures {
  display: flex;
  justify-content: space-between;
  margin-top: 40px;
  padding-top: 20px;
}

.sig-block {
  text-align: center;
  width: 180px;
}

.sig-block p.role {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary-color);
  margin-bottom: 30px;
}

.sig-block div.line {
  border-bottom: 1px dashed #94a3b8;
  margin-top: 20px;
}

/* ================== FOOTER ================== */
.app-footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.86rem;
  border-top: 1px solid var(--border-color);
  background: white;
  margin-top: 40px;
}

/* ================== GLOBAL MODAL SYSTEM & BEAUTIFUL POPUPS ================== */
.modal-overlay,
div[id$="Modal"],
div[id*="Modal"] {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 42, 79, 0.7) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  z-index: 2000 !important;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  animation: modalOverlayFadeIn 0.25s ease forwards;
}

@keyframes modalOverlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalPopIn {
  0% {
    opacity: 0;
    transform: scale(0.92) translateY(18px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-box,
div[id$="Modal"] > .card,
div[id*="Modal"] > .card,
div[id$="Modal"] > div:not(.modal-box),
div[id*="Modal"] > div:not(.modal-box) {
  background: #ffffff !important;
  border-radius: 18px !important;
  border: 1.5px solid rgba(212, 175, 55, 0.35) !important;
  box-shadow: 0 25px 60px -15px rgba(10, 42, 79, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.6) inset !important;
  max-height: calc(100vh - 40px) !important;
  overflow-y: auto !important;
  width: 100% !important;
  animation: modalPopIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
  position: relative !important;
  padding: 0 !important;
  margin: 0 auto !important;
  overflow-x: hidden !important;
}

/* Custom scrollbar for modal boxes */
.modal-box::-webkit-scrollbar,
div[id*="Modal"] > .card::-webkit-scrollbar,
div[id*="Modal"] > div::-webkit-scrollbar {
  width: 6px;
}
.modal-box::-webkit-scrollbar-thumb,
div[id*="Modal"] > .card::-webkit-scrollbar-thumb,
div[id*="Modal"] > div::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* Modal Header styling */
.modal-header,
div[id*="Modal"] > .card > div:first-child:has(button),
div[id*="Modal"] > div > div:first-child:has(button) {
  padding: 18px 24px !important;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%) !important;
  border-bottom: 1.5px solid #e2e8f0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  border-radius: 18px 18px 0 0 !important;
  margin-bottom: 0 !important;
}

.modal-title,
div[id*="Modal"] h3 {
  margin: 0 !important;
  font-size: 1.22rem !important;
  font-weight: 800 !important;
  color: var(--primary-color) !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  font-family: 'Alexandria', 'Tajawal', sans-serif !important;
}

.modal-close-btn,
div[id*="Modal"] button:has-text("×"),
div[id*="Modal"] button[onclick*="style.display='none'"] {
  width: 36px !important;
  height: 36px !important;
  border-radius: 50% !important;
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  font-size: 1.35rem !important;
  color: #64748b !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.2s ease !important;
  line-height: 1 !important;
  flex-shrink: 0 !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06) !important;
}

.modal-close-btn:hover,
div[id*="Modal"] button[onclick*="style.display='none'"]:hover {
  background: #fee2e2 !important;
  color: #dc2626 !important;
  border-color: #fecaca !important;
  transform: rotate(90deg) scale(1.05) !important;
}

/* Modal Body / Form Container */
.modal-body,
div[id*="Modal"] form {
  padding: 24px !important;
  margin: 0 !important;
}

.modal-footer,
div[id*="Modal"] form > div:last-child:has(button) {
  padding: 16px 24px !important;
  margin-top: 20px !important;
  margin-left: -24px !important;
  margin-right: -24px !important;
  margin-bottom: -24px !important;
  border-top: 1px solid #e2e8f0 !important;
  background: #f8fafc !important;
  border-radius: 0 0 18px 18px !important;
  display: flex !important;
  justify-content: flex-end !important;
  gap: 12px !important;
  align-items: center !important;
}

/* ================== GLOBAL FORM & COMPONENT STYLING ================== */
.card {
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 14px rgba(10, 42, 79, 0.05);
  padding: 24px;
  margin-bottom: 24px;
  transition: box-shadow 0.2s ease;
}

.form-control,
.form-control-custom {
  width: 100%;
  padding: 11px 16px;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  color: #1e293b;
  background-color: #f8fafc;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.form-control:focus,
.form-control-custom:focus {
  outline: none;
  border-color: #444cf7;
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(68, 76, 247, 0.15);
}

select.form-control,
select.form-control-custom {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  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='%2364748b' 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: left 12px center;
  background-size: 16px;
  padding-left: 36px;
}

input[type="file"].form-control,
input[type="file"].form-control-custom {
  padding: 8px 12px;
  background: #ffffff;
  border: 1.5px dashed #94a3b8;
  border-radius: 10px;
  cursor: pointer;
}

.form-label,
label {
  display: block;
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 6px;
  color: #1e293b;
}

.form-group {
  margin-bottom: 18px;
  text-align: right;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.92rem;
}

.table th {
  background: #0A2A4F;
  color: white;
  font-weight: 700;
  padding: 12px 14px;
  border-bottom: 2px solid #071f3a;
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  vertical-align: middle;
}

.table tbody tr:hover {
  background-color: rgba(68, 76, 247, 0.03);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(10, 42, 79, 0.2);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(10, 42, 79, 0.3);
}

.btn-secondary {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-danger:hover {
  background: #b91c1c;
  color: white;
}

/* ================== RESPONSIVE DESIGN & MOBILE OPTIMIZATIONS ================== */

/* Ensure table container scrolls smoothly */
.table-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 20px;
}

.table-responsive > table,
.table-responsive > .table,
.table-responsive > .app-table,
div[style*="overflow-x: auto"] > table,
div[style*="overflow-x: auto"] > .table {
  min-width: 650px;
  width: 100%;
}

/* Tablet & Mobile Screens (<= 992px) */
@media (max-width: 992px) {
  .mobile-toggle-btn {
    display: inline-flex !important;
  }

  .app-sidebar {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 280px !important;
    max-width: 85vw !important;
    height: 100vh !important;
    z-index: 1500 !important;
    transform: translateX(100%) !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: -8px 0 25px rgba(0, 0, 0, 0.25) !important;
    overflow-y: auto !important;
    background: #ffffff !important;
    padding-top: 14px !important;
  }

  .app-sidebar.show {
    transform: translateX(0) !important;
  }

  .mobile-sidebar-header {
    display: flex !important;
  }

  .app-content {
    padding: 18px 14px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .content-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }

  .content-header > div {
    width: 100% !important;
  }

  .header-actions {
    width: 100% !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    align-items: center !important;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }
}

/* Mobile Screens (<= 768px) */
@media (max-width: 768px) {
  .app-navbar {
    padding: 0 12px !important;
    height: 62px !important;
  }

  .brand-logo-img {
    width: 36px !important;
    height: 36px !important;
  }

  .brand-titles h1 {
    font-size: 0.92rem !important;
  }

  .brand-titles small {
    display: none !important;
  }

  .nav-actions {
    gap: 6px !important;
  }

  .user-badge {
    padding: 4px 8px !important;
    font-size: 0.78rem !important;
  }

  .user-badge span:last-child {
    display: none !important;
  }

  .card {
    padding: 16px !important;
    border-radius: 12px !important;
    margin-bottom: 16px !important;
    max-width: 100% !important;
  }

  .stats-grid {
    grid-template-columns: 1fr !important;
  }

  .cert-info-grid {
    grid-template-columns: 1fr !important;
  }

  .student-hero {
    flex-direction: column !important;
    align-items: flex-start !important;
    padding: 18px !important;
  }

  .student-hero::after {
    display: none !important;
  }

  .modal-overlay {
    padding: 8px !important;
  }

  .modal-box,
  div[id$="Modal"] > .card,
  div[id*="Modal"] > .card,
  div[id$="Modal"] > div:not(.modal-box),
  div[id*="Modal"] > div:not(.modal-box) {
    width: 96% !important;
    max-width: 96% !important;
    border-radius: 14px !important;
    max-height: calc(100vh - 16px) !important;
  }

  .modal-header,
  div[id*="Modal"] > .card > div:first-child:has(button),
  div[id*="Modal"] > div > div:first-child:has(button) {
    padding: 14px 16px !important;
  }

  .modal-title,
  div[id*="Modal"] h3 {
    font-size: 1.05rem !important;
  }

  .modal-body,
  div[id*="Modal"] form {
    padding: 16px !important;
  }

  .modal-footer,
  div[id*="Modal"] form > div:last-child:has(button) {
    padding: 12px 16px !important;
    margin-left: -16px !important;
    margin-right: -16px !important;
    margin-bottom: -16px !important;
    flex-direction: column-reverse !important;
    gap: 8px !important;
  }

  .modal-footer button,
  .modal-footer a,
  div[id*="Modal"] form > div:last-child:has(button) button,
  div[id*="Modal"] form > div:last-child:has(button) a {
    width: 100% !important;
    justify-content: center !important;
  }

  .form-control,
  .form-control-custom {
    font-size: 0.9rem !important;
    padding: 9px 12px !important;
  }

  select.form-control,
  select.form-control-custom,
  .subject-picker-button {
    padding: 9px 12px 9px 40px !important;
  }

  /* Mobile Sticky Action Bar */
  .mobile-sticky-save-bar {
    display: block !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    background: rgba(255, 255, 255, 0.98) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border-top: 1px solid #e2e8f0 !important;
    box-shadow: 0 -4px 20px rgba(10, 42, 79, 0.12) !important;
    padding: 10px 16px !important;
    z-index: 1050 !important;
  }

  /* Safe bottom padding on mobile */
  body {
    padding-bottom: 68px !important;
  }

  .table-responsive {
    -webkit-overflow-scrolling: touch !important;
    border-radius: 10px !important;
  }

  /* Touch-friendly buttons on mobile */
  .btn-church, .btn-gold, .btn-outline-church {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* Small Phones (<= 480px) */
@media (max-width: 480px) {
  .app-content {
    padding: 12px 8px !important;
  }

  .card {
    padding: 14px 12px !important;
  }

  .btn-primary, .btn-secondary, .btn-gold, .btn-danger {
    padding: 8px 14px !important;
    font-size: 0.85rem !important;
  }
}

.scorecard {
  border: 2px solid #0A2A4F;
  border-radius: 12px;
  background: #fff;
  padding: 0;
  margin-bottom: 16px;
  overflow: hidden;
}
.scorecard-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0;
  padding: 12px 14px;
  background: #f8fafc;
  border-bottom: 2px solid #0A2A4F;
}
.scorecard-head h3, .scorecard-head h4 { margin: 0 0 4px; color: #0A2A4F; }
.scorecard-head p { margin: 0; color: #475569; line-height: 1.7; }
.door-pill {
  background: #fff;
  border: 1px solid #0A2A4F;
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 800;
  color: #0A2A4F;
}
.marksheet-wrap { overflow-x: auto; }
.marksheet {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}
.marksheet th, .marksheet td {
  border: 1px solid #64748b;
  padding: 10px 12px;
  text-align: center;
  vertical-align: middle;
}
.marksheet th {
  background: #0A2A4F;
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
}
.marksheet tr.mark-hymns td { background: #e7eef8; }
.marksheet tr.mark-rituals td { background: #e5f6f2; }
.marksheet tr.mark-coptic td { background: #eeeafc; }
.marksheet td.mark-subject {
  width: 118px;
  background: #0A2A4F !important;
  color: #fff;
  font-weight: 800;
}
.marksheet tr.mark-rituals td.mark-subject { background: #0f766e !important; }
.marksheet tr.mark-coptic td.mark-subject { background: #3730a3 !important; }
.mark-subject-name { font-size: 1.05rem; }
.mark-percent { margin-top: 6px; font-size: 1.25rem; font-weight: 900; color: #fde68a; }
.mark-examiner { margin-top: 8px; font-size: 0.78rem; font-weight: 700; line-height: 1.4; color: #e2e8f0; }
.marksheet td.mark-item { text-align: right; font-weight: 800; color: #0A2A4F; }
.marksheet td.mark-score { font-size: 1.2rem; font-weight: 900; }
.marksheet td.mark-max { font-weight: 800; color: #334155; }
.marksheet td.mark-score.high { background: #86efac !important; color: #14532d; }
.marksheet td.mark-score.mid { background: #fde68a !important; color: #78350f; }
.marksheet td.mark-score.low { background: #fca5a5 !important; color: #7f1d1d; }
.marksheet td.mark-score.empty { background: #f8fafc !important; color: #94a3b8; }
.marksheet td.mark-note {
  background: #fff7ed !important;
  color: #9a3412;
  text-align: right;
  font-weight: 700;
  line-height: 1.6;
}

.subject-picker-button,
.subject-picker-option {
  width: 100%;
  border: 0;
  background: transparent;
  color: #1e293b;
  font: inherit;
  font-weight: 700;
  text-align: right;
  line-height: 1.5;
  cursor: pointer;
}

.subject-picker-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 16px 11px 40px;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  background-color: #f8fafc;
  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='%2364748b' 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: left 12px center;
  background-size: 16px;
}

.subject-picker.is-open .subject-picker-button,
.subject-picker-button:focus {
  outline: none;
  border-color: #0A2A4F;
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(10, 42, 79, 0.12);
}

.subject-picker-button span {
  white-space: normal;
}

.subject-picker-caret {
  display: none;
}

.subject-picker-menu {
  margin-top: 6px;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(10, 42, 79, 0.08);
}

.subject-picker-option {
  display: block;
  padding: 11px 16px;
  border-bottom: 1px solid #e2e8f0;
}

.subject-picker-option:last-child {
  border-bottom: 0;
}

.subject-picker-option:hover {
  background: #f8fafc;
  color: #0A2A4F;
}

.subject-picker-option.is-selected,
.subject-picker-option.is-selected:hover {
  background: #0A2A4F;
  color: #ffffff;
}


