:root {
  --quran-primary: #176b57;
  --quran-primary-dark: #0f4f41;
  --quran-accent: #c99a3d;
  --quran-ink: #17221f;
  --quran-surface: #fbfaf6;
}

html[dir="rtl"] body {
  direction: rtl;
  font-family: "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  text-align: right;
}

html[dir="rtl"] .layout-menu {
  right: 0;
  left: auto;
}

/* The original dashboard theme is LTR-first. Without these overrides it keeps
   reserving the menu space on the left while drawing the Arabic menu on the
   right, so the menu and page overlap at normal browser zoom. */
@media (min-width: 1200px) {
  html[dir="rtl"].layout-menu-fixed:not(.layout-menu-collapsed) .layout-page,
  html[dir="rtl"].layout-menu-fixed-offcanvas:not(.layout-menu-collapsed) .layout-page {
    padding-right: 16.25rem !important;
    padding-left: 0 !important;
  }

  html[dir="rtl"].layout-menu-collapsed .layout-page {
    padding-right: 5.25rem !important;
    padding-left: 0 !important;
  }
}

@media (max-width: 1199.98px) {
  html[dir="rtl"] .layout-menu {
    right: 0 !important;
    left: auto !important;
    transform: translate3d(100%, 0, 0) !important;
  }

  html[dir="rtl"].layout-menu-expanded .layout-menu {
    transform: translate3d(0, 0, 0) !important;
  }
}

.layout-page,
.content-wrapper {
  min-width: 0;
  overflow-x: hidden;
}

.layout-overlay {
  z-index: 1085;
  padding: 0;
  border: 0;
}

/* System feedback must never be hidden behind the fixed Arabic sidebar. */
div:where(.swal2-container) {
  z-index: 2000 !important;
}

body.swal2-toast-shown .swal2-container.swal2-bottom-start {
  inset: auto auto 1rem 1rem;
}

.swal2-popup.swal2-toast {
  border: 1px solid #e1e9e5;
  border-radius: 14px;
  box-shadow: 0 14px 38px rgba(20, 50, 42, 0.18);
}

.connection-status {
  position: fixed;
  z-index: 1200;
  right: 50%;
  bottom: 1rem;
  display: flex;
  max-width: calc(100vw - 2rem);
  align-items: center;
  gap: 0.55rem;
  padding: 0.75rem 1rem;
  transform: translateX(50%);
  border-radius: 12px;
  color: #fff;
  background: #9f3a38;
  box-shadow: 0 8px 24px rgba(47, 23, 23, 0.2);
  font-weight: 700;
}

.connection-status[hidden] {
  display: none;
}

.layout-menu {
  z-index: 1090;
  border-left: 1px solid #e3ebe7;
  box-shadow: -8px 0 28px rgba(23, 34, 31, 0.06);
}

html[dir="rtl"] .menu-inner-shadow {
  right: auto;
  left: 0;
}

html[dir="rtl"] .dropdown-menu {
  text-align: right;
}

.bg-menu-theme .menu-item.active > .menu-link:not(.menu-toggle) {
  color: #fff;
  background: linear-gradient(135deg, var(--quran-primary), var(--quran-primary-dark));
  box-shadow: 0 7px 16px rgba(23, 107, 87, 0.2);
}

.bg-menu-theme .menu-item.active > .menu-link:not(.menu-toggle)::before {
  display: none;
}

.layout-wrapper:not(.layout-horizontal) .bg-menu-theme .menu-inner > .menu-item.active::before {
  display: none;
}

.layout-menu .app-brand {
  height: auto;
  min-height: 72px;
  margin: 0 0.75rem 0.35rem;
  padding: 0.9rem 0.35rem;
  border-bottom: 1px solid #e8efec;
}

.layout-menu .app-brand-text {
  max-width: 165px;
  overflow: hidden;
  color: var(--quran-ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layout-menu .menu-inner {
  padding-inline: 0.75rem !important;
}

.layout-menu .menu-header {
  margin: 1.1rem 0 0.3rem;
  padding: 0 0.75rem;
  color: #7c8c86;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0;
}

.layout-menu .menu-header::before {
  display: none;
}

.layout-menu .menu-item .menu-link {
  min-height: 44px;
  margin-block: 2px;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  color: #4d5c57;
  font-weight: 600;
}

.layout-menu .menu-item .menu-link:hover {
  color: var(--quran-primary);
  background: rgba(23, 107, 87, 0.07);
}

.layout-menu .menu-item .menu-icon {
  display: inline-grid;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  margin-inline-end: 0.65rem;
  place-items: center;
  border-radius: 9px;
  color: var(--quran-primary);
  background: rgba(23, 107, 87, 0.08);
}

.layout-menu .menu-item.active > .menu-link .menu-icon {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
}

/* Keep each record on one readable row. On small screens the table scrolls
   horizontally instead of stacking names, emails and actions on top of each other. */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-responsive .table,
.dataTables_wrapper .table,
.dt-container .table {
  min-width: 760px;
  margin-bottom: 0 !important;
}

.table > :not(caption) > * > * {
  padding: 0.9rem 1rem;
  vertical-align: middle;
  text-align: start !important;
  white-space: nowrap;
  border-bottom-color: #edf1ef;
}

.table thead th {
  color: #52615c;
  background: #f5f8f6;
  font-size: 0.75rem;
  font-weight: 800;
}

/* DataTables is LTR-first: it reserves space for its ordering arrows on the
   right, which visually pushes Arabic headings into the previous column. */
html[dir="rtl"] table.dataTable thead > tr > th.dt-orderable-asc,
html[dir="rtl"] table.dataTable thead > tr > th.dt-orderable-desc,
html[dir="rtl"] table.dataTable thead > tr > th.dt-ordering-asc,
html[dir="rtl"] table.dataTable thead > tr > th.dt-ordering-desc {
  padding-right: 1rem !important;
  padding-left: 2rem !important;
  text-align: right !important;
}

html[dir="rtl"] table.dataTable thead span.dt-column-order {
  right: auto !important;
  left: 0.75rem !important;
}

.table thead th:first-child,
.table tbody td:first-child,
.table thead th:last-child,
.table tbody td:last-child {
  text-align: center !important;
}

.table thead th + th,
.table tbody td + td {
  border-inline-start: 1px solid rgba(226, 234, 230, 0.65);
}

.table tbody tr:hover > * {
  background: rgba(23, 107, 87, 0.035);
}

.email-cell,
.phone-cell {
  display: inline-block;
  direction: ltr;
  text-align: left;
  unicode-bidi: plaintext;
}

.announcement-guide {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(23, 107, 87, 0.16);
  border-radius: 12px;
  color: #245a4d;
  background: #eef7f3;
}

.announcement-guide i {
  flex: 0 0 auto;
  color: var(--quran-primary);
}

.student-record-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--quran-ink);
  font-weight: 700;
}

.student-record-link:hover {
  color: var(--quran-primary);
}

.student-record-link small {
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  color: var(--quran-primary);
  background: rgba(23, 107, 87, 0.1);
  font-size: 0.68rem;
  font-weight: 800;
}

.student-profile-card {
  border-top: 3px solid var(--quran-primary);
}

.guardian-contact-card {
  border: 1px solid #e4ece8;
}

.guardian-contact-icon {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  color: var(--quran-primary);
  background: rgba(23, 107, 87, 0.09);
  font-size: 1.35rem;
}

.guardian-contact-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.guardian-contact-item {
  min-width: 0;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: #f7f9f8;
}

.guardian-contact-item > span {
  display: block;
  margin-bottom: 0.35rem;
  color: #75847f;
  font-size: 0.75rem;
  font-weight: 700;
}

.guardian-contact-item strong,
.guardian-contact-value {
  color: var(--quran-ink);
  font-weight: 700;
}

.guardian-contact-value {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.guardian-contact-value:hover {
  color: var(--quran-primary);
}

.guardian-contact-address {
  grid-column: 1 / -1;
}

@media (max-width: 991.98px) {
  .guardian-contact-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 575.98px) {
  .guardian-contact-grid {
    grid-template-columns: 1fr;
  }
}

.student-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.student-meta-grid span,
.guardian-compact-details > span,
.guardian-compact-details > a {
  display: grid;
  min-width: 0;
  grid-template-columns: auto 1fr;
  column-gap: 0.45rem;
  align-items: center;
  color: #52615c;
  font-size: 0.82rem;
}

.student-meta-grid i,
.guardian-compact-details i {
  grid-row: 1 / span 2;
  color: var(--quran-primary);
  font-size: 1.1rem;
}

.student-meta-grid b,
.guardian-compact-details b {
  color: #7a8984;
  font-size: 0.7rem;
  font-weight: 700;
}

.student-meta-grid span > :last-child,
.guardian-compact-details em {
  overflow: hidden;
  color: var(--quran-ink);
  font-style: normal;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guardian-compact-card {
  border: 1px solid rgba(23, 107, 87, 0.18);
  background: linear-gradient(135deg, #fff 0%, #f7fbf9 100%);
}

.guardian-compact-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1rem;
}

.guardian-compact-details .guardian-address {
  grid-column: 1 / -1;
}

.guardian-call-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.guardian-call-button strong {
  padding-inline-start: 0.5rem;
  border-inline-start: 1px solid currentColor;
}

.guardian-phone-missing {
  padding: 0.65rem 0.8rem;
  border-radius: 9px;
  color: #7b6650;
  background: #fff6eb;
  font-size: 0.8rem;
}

.record-navigation-card {
  position: sticky;
  z-index: 10;
  top: 0.75rem;
  border: 1px solid #e3ebe7;
  box-shadow: 0 7px 22px rgba(24, 57, 49, 0.08);
}

.record-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.record-tabs .nav-link {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 10px;
  color: #52635e;
  font-weight: 800;
}

.record-tabs .nav-link:hover {
  color: var(--quran-primary);
  background: #f1f7f4;
}

.record-tabs .nav-link.active {
  color: #fff;
  background: var(--quran-primary);
  box-shadow: 0 5px 13px rgba(23, 107, 87, 0.18);
}

.record-tabs .nav-link b {
  min-width: 23px;
  padding: 0.1rem 0.38rem;
  border-radius: 999px;
  background: rgba(23, 107, 87, 0.1);
  font-size: 0.7rem;
}

.record-tabs .nav-link.active b {
  background: rgba(255, 255, 255, 0.18);
}

.record-overview-stat {
  border: 1px solid #e5ece9;
  border-top: 3px solid var(--quran-primary);
}

.record-overview-stat.stat-success { border-top-color: #2e9d68; }
.record-overview-stat.stat-danger { border-top-color: #d95656; }
.record-overview-stat.stat-warning { border-top-color: #d29a32; }
.record-overview-stat.stat-info { border-top-color: #418ca6; }

.record-overview-stat .card-body {
  display: flex;
  min-height: 125px;
  flex-direction: column;
  justify-content: center;
}

.record-overview-stat span,
.record-overview-stat small {
  color: #74837e;
  font-size: 0.78rem;
  font-weight: 700;
}

.record-overview-stat strong {
  margin-block: 0.2rem;
  color: var(--quran-ink);
  font-size: 1.8rem;
}

.record-section-link {
  display: flex;
  min-height: 94px;
  flex-direction: row;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid #e2ebe7;
  color: var(--quran-ink);
  background: #fff;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.record-section-link:hover {
  transform: translateY(-2px);
  border-color: rgba(23, 107, 87, 0.35);
  box-shadow: 0 9px 22px rgba(23, 107, 87, 0.08);
}

.record-section-link strong,
.record-section-link small {
  display: block;
}

.record-section-link small {
  margin-top: 0.25rem;
  color: #76847f;
}

.record-section-icon {
  display: inline-grid;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 13px;
  font-size: 1.45rem;
}

@media (max-width: 767.98px) {
  .student-meta-grid,
  .guardian-compact-details {
    grid-template-columns: 1fr;
  }

  .record-navigation-card {
    top: 0.4rem;
  }

  .record-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.25rem;
  }

  .record-tabs .nav-link {
    min-height: 52px;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.4rem 0.2rem;
    font-size: 0.72rem;
    line-height: 1.2;
  }

  .record-tabs .nav-link b {
    display: none;
  }

  .guardian-call-button {
    justify-content: flex-start;
  }
}

.stat-card {
  border: 1px solid #e8eeeb;
  box-shadow: 0 4px 14px rgba(23, 34, 31, 0.04);
}

.stat-card .card-body {
  display: flex;
  min-height: 112px;
  flex-direction: column;
  justify-content: center;
}

.stat-card .stat-label {
  margin-bottom: 0.35rem;
  color: #70807a;
  font-size: 0.78rem;
  font-weight: 700;
}

.stat-card strong {
  color: var(--quran-ink);
  font-size: 1.75rem;
  line-height: 1.15;
}

.stat-card small {
  margin-top: 0.25rem;
  color: #7c8c86;
}

.stat-card.stat-success { border-top: 3px solid #2e9d68; }
.stat-card.stat-danger { border-top: 3px solid #d95656; }
.stat-card.stat-warning { border-top: 3px solid #d29a32; }
.stat-card.stat-info { border-top: 3px solid #418ca6; }

.date-cell {
  display: inline-block;
  direction: ltr;
  unicode-bidi: isolate;
}

.date-with-day {
  display: inline-block;
  direction: rtl;
  unicode-bidi: isolate;
  white-space: nowrap;
}

.student-progress-table {
  min-width: 1050px !important;
}

.child-summary-card {
  border: 1px solid #e4ece8;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.child-summary-card:hover {
  transform: translateY(-2px);
  border-color: rgba(23, 107, 87, 0.3);
  box-shadow: 0 10px 24px rgba(23, 107, 87, 0.09);
}

.child-summary-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.55rem;
  border-radius: 8px;
  color: #52615c;
  background: #f3f7f5;
}

.dashboard-welcome {
  padding: 0.25rem 0;
}

.dashboard-welcome h3 {
  color: var(--quran-ink);
  font-weight: 800;
}

.setup-guide {
  overflow: hidden;
  border: 1px solid rgba(23, 107, 87, 0.2);
  background: linear-gradient(145deg, #fff 0%, #f3faf7 100%);
}

.setup-guide-kicker,
.setup-guide-progress {
  display: inline-flex;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  color: var(--quran-primary);
  background: rgba(23, 107, 87, 0.1);
  font-size: 0.75rem;
  font-weight: 800;
}

.setup-guide-kicker {
  margin-bottom: 0.55rem;
}

.setup-guide-bar {
  height: 7px;
  background: rgba(23, 107, 87, 0.1);
}

.setup-guide-bar .progress-bar {
  background: var(--quran-primary);
}

.setup-guide-steps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.setup-guide-step {
  display: grid;
  min-width: 0;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.7rem;
  align-items: center;
  padding: 0.8rem;
  border: 1px solid #deebe6;
  border-radius: 11px;
  color: var(--quran-ink);
  background: #fff;
}

.setup-guide-step:hover {
  border-color: rgba(23, 107, 87, 0.4);
  color: var(--quran-primary);
}

.setup-guide-step.is-complete {
  opacity: 0.72;
  background: #f4f7f6;
}

.setup-guide-number {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: var(--quran-primary);
}

.setup-guide-step small,
.setup-guide-step b {
  display: block;
}

.setup-guide-step small {
  margin-top: 0.15rem;
  color: #74837e;
  font-size: 0.73rem;
  line-height: 1.55;
}

.form-section-heading {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e7eeeb;
}

.form-section-heading > span {
  display: inline-grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: var(--quran-primary);
  font-weight: 800;
}

.form-section-heading h5,
.form-section-heading p {
  margin: 0;
}

.form-section-heading p {
  margin-top: 0.18rem;
  color: #74837e;
  font-size: 0.78rem;
  line-height: 1.55;
}

.weekly-schedule-note {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  color: var(--quran-primary);
  background: rgba(23, 107, 87, 0.09);
  font-size: 0.76rem;
  font-weight: 800;
}

.weekly-schedule-card {
  overflow: hidden;
  border: 1px solid #e1eae6;
  box-shadow: 0 5px 18px rgba(23, 58, 49, 0.045);
}

.weekly-schedule-card::before {
  display: block;
  height: 3px;
  background: var(--quran-primary);
  content: '';
}

.weekly-schedule-icon {
  display: inline-grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  color: var(--quran-primary);
  background: rgba(23, 107, 87, 0.09);
  font-size: 1.25rem;
}

.weekly-schedule-members {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  padding: 0.55rem 0.65rem;
  border-radius: 9px;
  color: #4f625c;
  background: #f4f8f6;
  font-size: 0.78rem;
  font-weight: 700;
}

.weekly-schedule-times {
  display: grid;
  gap: 0.5rem;
}

.weekly-schedule-time {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid #e7eeeb;
  border-radius: 10px;
  background: #fbfcfc;
}

.weekly-schedule-time span {
  color: #53635e;
  font-weight: 700;
}

.weekly-schedule-time span b {
  margin-inline-start: 0.35rem;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  color: #fff;
  background: var(--quran-primary);
  font-size: 0.65rem;
}

.weekly-schedule-time strong {
  color: var(--quran-ink);
  font-size: 0.92rem;
}

.weekly-schedule-time.is-today {
  border-color: rgba(23, 107, 87, 0.35);
  background: #eef8f4;
}

.weekly-schedule-empty {
  padding: 0.8rem;
  border-radius: 10px;
  color: #7b6650;
  background: #fff7ed;
  font-size: 0.8rem;
}

.action-card,
.halaqa-action-card {
  border: 1px solid #e4ece8;
  box-shadow: 0 5px 18px rgba(23, 58, 49, 0.045);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.action-card:hover,
.halaqa-action-card:hover {
  transform: translateY(-2px);
  border-color: rgba(23, 107, 87, 0.3);
  box-shadow: 0 12px 26px rgba(23, 107, 87, 0.09);
}

.action-card-icon {
  display: inline-grid;
  flex: 0 0 54px;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 15px;
  font-size: 1.6rem;
}

.halaqa-count {
  height: fit-content;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  color: var(--quran-primary);
  background: rgba(23, 107, 87, 0.09);
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

.stat-card-simple {
  border: 0;
  border-inline-start: 4px solid var(--quran-primary);
}

.stat-card-simple .card-body {
  display: flex;
  min-height: 105px;
  flex-direction: column;
  justify-content: center;
}

.stat-card-simple strong {
  display: block;
  margin-top: 0.3rem;
  color: var(--quran-ink);
  font-size: 1.65rem;
}

.announcement-row:hover strong {
  color: var(--quran-primary);
}

@media (max-width: 767.98px) {
  .dashboard-welcome h3 {
    font-size: 1.35rem;
  }

  .action-card .card-body {
    padding: 1rem;
  }

  .action-card-icon {
    flex-basis: 46px;
    width: 46px;
    height: 46px;
  }

  .halaqa-action-card .btn {
    min-height: 44px;
  }
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate,
.dt-container .dt-length,
.dt-container .dt-search,
.dt-container .dt-info,
.dt-container .dt-paging {
  padding-block: 0.25rem;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select,
.dt-container .dt-search input,
.dt-container .dt-length select {
  min-height: 38px;
  border: 1px solid #dfe7e3;
  border-radius: 9px;
}

@media (max-width: 767.98px) {
  .dataTables_wrapper > .row {
    gap: 0.65rem;
  }

  .dt-container > .row {
    gap: 0.65rem;
  }

  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate {
    text-align: right !important;
  }

  .dt-container .dt-length,
  .dt-container .dt-search,
  .dt-container .dt-info,
  .dt-container .dt-paging {
    text-align: right !important;
  }
}

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

.btn-primary:hover,
.btn-primary:focus {
  border-color: var(--quran-primary-dark);
  background-color: var(--quran-primary-dark);
}

.btn-outline-primary {
  color: var(--quran-primary);
  border-color: var(--quran-primary);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
  color: #fff;
  border-color: var(--quran-primary);
  background-color: var(--quran-primary);
}

.text-primary {
  color: var(--quran-primary) !important;
}

a {
  color: var(--quran-primary);
}

.bg-label-primary {
  color: var(--quran-primary) !important;
  background: #eaf6f2 !important;
}

.form-check-input:checked,
.form-check-input[type="checkbox"]:indeterminate {
  border-color: var(--quran-primary) !important;
  background-color: var(--quran-primary) !important;
  box-shadow: 0 2px 4px rgba(23, 107, 87, 0.22) !important;
}

.attendance-status-choice {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.attendance-status-choice:has(input[value="present"]:checked) {
  --attendance-status-color: #168451;
  --attendance-status-background: #e9f8f0;
}

.attendance-status-choice:has(input[value="absent"]:checked) {
  --attendance-status-color: #c83f49;
  --attendance-status-background: #fff0f1;
}

.attendance-status-choice input:checked {
  border-color: var(--attendance-status-color, var(--quran-primary)) !important;
  background-color: var(--attendance-status-color, var(--quran-primary)) !important;
  box-shadow: 0 2px 5px color-mix(in srgb, var(--attendance-status-color, var(--quran-primary)) 28%, transparent) !important;
}

.attendance-status-choice span {
  display: none;
}

.attendance-save-bar {
  border-top: 1px solid #e6ece9;
  background: #fbfcfc;
}

.progress-student-choice {
  border: 1px solid #e0e9e5;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.progress-student-choice:hover {
  transform: translateY(-2px);
  border-color: var(--quran-primary);
  box-shadow: 0 10px 24px rgba(23, 107, 87, 0.09);
}

.progress-student-choice.is-complete {
  border-color: rgba(40, 167, 69, 0.35);
  background: #f5fbf7;
}

.competition-steps {
  display: flex;
  max-width: 620px;
  align-items: center;
  margin-inline: auto;
}

.competition-step-indicator {
  display: grid;
  min-width: 84px;
  gap: 0.25rem;
  place-items: center;
  border: 0;
  color: #71817c;
  background: transparent;
}

.competition-step-indicator span {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 2px solid #dbe5e1;
  border-radius: 50%;
  background: #fff;
  font-weight: 800;
}

.competition-step-indicator small {
  font-weight: 700;
}

.competition-step-indicator.is-active,
.competition-step-indicator.is-complete {
  color: var(--quran-primary);
}

.competition-step-indicator.is-active span,
.competition-step-indicator.is-complete span {
  border-color: var(--quran-primary);
  color: #fff;
  background: var(--quran-primary);
}

.competition-step-line {
  flex: 1;
  height: 2px;
  margin-bottom: 1.3rem;
  background: #dbe5e1;
}

.competition-halaqa-card {
  transition: border-color 0.18s ease, background 0.18s ease;
}

.competition-halaqa-card:has(input:checked) {
  border-color: var(--quran-primary) !important;
  background: #eef8f4;
}

/* الهاتف ليس نسخة مصغرة من الحاسوب: تتحول قوائم الإدارة إلى بطاقات قابلة
   للمس، بينما تبقى الجداول التقليدية كما هي على الشاشات الكبيرة. */
@media (max-width: 767.98px) {
  body {
    font-size: 0.94rem;
  }

  html[dir="rtl"] .layout-menu,
  html[dir="rtl"] .menu-vertical,
  html[dir="rtl"] .menu-vertical .menu-block,
  html[dir="rtl"] .menu-vertical .menu-inner > .menu-item,
  html[dir="rtl"] .menu-vertical .menu-inner > .menu-header {
    width: min(15rem, 82vw);
  }

  .layout-menu .app-brand {
    min-height: 60px;
    margin: 0 0.5rem 0.2rem;
    padding: 0.65rem 0.25rem;
  }

  .layout-menu .app-brand-logo {
    width: 30px !important;
    height: 30px !important;
  }

  .layout-menu .app-brand-text {
    max-width: 132px;
    font-size: 0.95rem !important;
  }

  .layout-menu .menu-inner {
    padding-inline: 0.45rem !important;
    padding-bottom: max(1rem, env(safe-area-inset-bottom)) !important;
  }

  .layout-menu .menu-header {
    margin: 0.7rem 0 0.15rem;
    padding-inline: 0.6rem;
    font-size: 0.65rem;
  }

  .layout-menu .menu-item .menu-link {
    min-height: 40px;
    margin-block: 1px;
    padding: 0.4rem 0.55rem;
    border-radius: 10px;
    font-size: 0.85rem;
  }

  .layout-menu .menu-item .menu-icon {
    flex-basis: 28px;
    width: 28px;
    height: 28px;
    margin-inline-end: 0.45rem;
    border-radius: 8px;
  }

  .layout-overlay {
    background: rgba(15, 35, 30, 0.58);
    opacity: 1;
    backdrop-filter: blur(2px);
  }

  body.swal2-toast-shown .swal2-container {
    width: calc(100% - 1rem);
    max-width: none;
  }

  body.swal2-toast-shown .swal2-container.swal2-bottom-start {
    inset: auto 0.5rem max(0.5rem, env(safe-area-inset-bottom)) 0.5rem;
  }

  .swal2-popup.swal2-toast {
    width: 100%;
    font-size: 0.9rem;
  }

  .container-xxl.container-p-y {
    padding-block: 1rem 1.5rem !important;
    padding-inline: 1rem !important;
  }

  #layout-navbar {
    min-height: 64px;
    margin-block: 0.75rem 0.25rem;
    margin-inline: 1rem !important;
    padding-inline: 0.75rem;
  }

  #layout-navbar .nav-link,
  #layout-navbar .layout-menu-toggle a {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
  }

  .dashboard-welcome {
    max-width: 100%;
    margin-bottom: 1.25rem !important;
    overflow: visible;
  }

  .dashboard-welcome > div {
    min-width: 0;
    max-width: 100%;
  }

  .dashboard-welcome h3 {
    max-width: 100%;
    font-size: clamp(1.2rem, 6vw, 1.45rem);
    line-height: 1.55;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .dashboard-welcome p {
    line-height: 1.75;
  }

  .dashboard-primary-actions {
    display: grid !important;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .setup-guide-steps {
    grid-template-columns: 1fr;
  }

  .dashboard-primary-actions .btn {
    min-width: 0;
    padding-inline: 0.5rem;
  }

  .container-p-y > .d-flex.justify-content-between.align-items-center {
    align-items: stretch !important;
    flex-direction: column;
    gap: 0.75rem;
  }

  .container-p-y > .d-flex.justify-content-between.align-items-center h4 {
    padding-block: 0 !important;
  }

  .container-p-y > .d-flex.justify-content-between.align-items-center .btn {
    width: 100%;
  }

  .card {
    border-radius: 12px;
  }

  .card-header,
  .card-body {
    padding: 1rem;
  }

  .card-header .form-control,
  .card-header .form-select,
  .card-header .select2-selection,
  .card-header .btn,
  form .form-control,
  form .form-select,
  form .select2-selection,
  form .btn {
    min-height: 44px;
  }

  button:not(.btn-close),
  .btn {
    min-height: 44px;
  }

  .attendance-register {
    display: block;
    min-width: 0 !important;
  }

  .attendance-register thead {
    display: none;
  }

  .attendance-register tbody {
    display: grid;
    gap: 0.8rem;
    padding: 0.8rem;
  }

  .attendance-register .attendance-student-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    padding: 0.85rem;
    border: 1px solid #e0e9e5;
    border-inline-start: 3px solid var(--quran-primary);
    border-radius: 12px;
    background: #fff;
  }

  .attendance-register .attendance-student-row > td {
    display: block;
    padding: 0 !important;
    border: 0 !important;
  }

  .attendance-register .attendance-number {
    display: none !important;
  }

  .attendance-register .attendance-student,
  .attendance-register .attendance-note,
  .attendance-register .attendance-justified {
    grid-column: 1 / -1;
  }

  .attendance-register .attendance-student {
    margin-bottom: 0.15rem;
    padding-bottom: 0.7rem !important;
    border-bottom: 1px solid #edf2ef !important;
  }

  .attendance-status-choice {
    width: 100%;
    gap: 0.45rem;
    padding: 0.55rem 0.45rem;
    border: 1px solid #dfe8e4;
    border-radius: 9px;
    background: #fafcfb;
  }

  .attendance-status-choice:has(input:checked) {
    border-color: var(--attendance-status-color, var(--quran-primary));
    color: var(--attendance-status-color, var(--quran-primary));
    background: var(--attendance-status-background, #edf8f4);
    font-weight: 800;
  }

  .attendance-status-choice span {
    display: inline;
  }

  .attendance-register .attendance-note {
    display: none;
    margin-top: 0.15rem;
  }

  .attendance-register .attendance-note.attendance-note-visible,
  .attendance-register .attendance-justified + .attendance-note {
    display: block;
  }

  .attendance-save-bar {
    position: sticky;
    z-index: 5;
    bottom: 0;
    box-shadow: 0 -8px 24px rgba(27, 63, 53, 0.08);
  }

  .attendance-save-bar .btn {
    width: 100%;
  }

  .competition-steps {
    margin-inline: -0.4rem;
  }

  .competition-step-indicator {
    min-width: 68px;
    padding-inline: 0.2rem;
  }

  .competition-wizard-actions .btn,
  .competition-wizard-actions a {
    flex: 1 1 calc(50% - 0.5rem);
  }

  .dataTables_wrapper .dataTables_length,
  .dt-container .dt-length {
    display: none;
  }

  .table-responsive:has(.mobile-card-table) {
    overflow: visible;
    padding-bottom: 0 !important;
  }

  table.mobile-card-table,
  .dataTables_wrapper table.mobile-card-table,
  .dt-container table.mobile-card-table {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
    border: 0;
  }

  .mobile-card-table thead {
    display: none;
  }

  .mobile-card-table tbody {
    display: grid;
    gap: 0.75rem;
    padding: 0.75rem;
  }

  .mobile-card-table tbody tr {
    display: grid;
    overflow: hidden;
    border: 1px solid #e0e9e5;
    border-inline-start: 3px solid var(--quran-primary);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 4px 13px rgba(23, 58, 49, 0.05);
  }

  .mobile-card-table tbody td {
    display: grid;
    min-width: 0;
    grid-template-columns: minmax(88px, 38%) minmax(0, 1fr);
    gap: 0.65rem;
    align-items: center;
    padding: 0.65rem 0.75rem !important;
    text-align: start !important;
    white-space: normal !important;
    border: 0 !important;
    border-bottom: 1px solid #edf2ef !important;
    overflow-wrap: anywhere;
  }

  .mobile-card-table tbody td:last-child {
    border-bottom: 0 !important;
  }

  .mobile-card-table tbody td::before {
    color: #74837e;
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 800;
  }

  .mobile-card-table tbody td[colspan] {
    display: block;
    padding-block: 1.5rem !important;
    text-align: center !important;
  }

  .mobile-card-table tbody td[colspan]::before {
    display: none;
  }

  .mobile-card-table tbody td img {
    width: 42px;
    height: 42px;
    object-fit: cover;
  }

  .mobile-card-table tbody td .dropdown {
    justify-self: start;
  }

  .mobile-card-table tbody td a,
  .mobile-card-table tbody td button {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
  }

  .mobile-card-table tbody td .student-record-link {
    width: fit-content;
  }

  .student-list-table tbody tr {
    grid-template-columns: 52px minmax(0, 1fr) auto;
    gap: 0.25rem 0.65rem;
    padding: 0.75rem;
  }

  .student-list-table tbody td {
    display: block;
    padding: 0.15rem 0 !important;
    border-bottom: 0 !important;
  }

  .student-list-table tbody td::before {
    display: none;
  }

  .student-list-table .student-cell-image {
    grid-column: 1;
    grid-row: 1 / span 2;
  }

  .student-list-table .student-cell-name {
    grid-column: 2;
    grid-row: 1;
    align-self: end;
    color: #243b35;
    font-weight: 800;
  }

  .student-list-table .student-cell-id {
    grid-column: 2;
    grid-row: 2;
    color: #74837e;
    font-size: 0.78rem;
  }

  .student-list-table .student-cell-status,
  .student-list-table .student-cell-gender {
    grid-column: 3;
    font-size: 0.75rem;
    text-align: end !important;
  }

  .student-list-table .student-cell-status { grid-row: 1; }
  .student-list-table .student-cell-gender { grid-row: 2; }

  .student-list-table .student-cell-record {
    grid-column: 1 / span 2;
    grid-row: 3;
    padding-top: 0.55rem !important;
    border-top: 1px solid #edf2ef !important;
  }

  .student-list-table .student-cell-action {
    grid-column: 3;
    grid-row: 3;
    padding-top: 0.55rem !important;
    border-top: 1px solid #edf2ef !important;
  }

  .dataTables_wrapper > .row,
  .dt-container > .row {
    margin-inline: 0 !important;
    padding-inline: 0.75rem !important;
  }

  .dataTables_wrapper .dataTables_filter input,
  .dt-container .dt-search input {
    width: 100% !important;
    margin: 0.35rem 0 0 !important;
  }

  .dataTables_wrapper .dataTables_filter label,
  .dt-container .dt-search label {
    display: block;
    width: 100%;
  }

  .dataTables_wrapper .pagination,
  .dt-container .pagination {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.2rem;
  }

  .dataTables_wrapper .page-link,
  .dt-container .page-link {
    display: inline-flex;
    min-width: 40px;
    min-height: 40px;
    align-items: center;
    justify-content: center;
  }

  .announcement-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.45rem !important;
  }

  .announcement-row .date-with-day {
    white-space: normal;
  }

  .weekly-schedule-time {
    gap: 0.5rem;
  }
}

@media (max-width: 374.98px) {
  .container-xxl.container-p-y {
    padding-inline: 0.75rem !important;
  }

  #layout-navbar {
    margin-inline: 0.75rem !important;
  }

  .dashboard-primary-actions {
    grid-template-columns: 1fr;
  }

  .mobile-card-table tbody {
    padding-inline: 0.5rem;
  }

  .mobile-card-table tbody td {
    grid-template-columns: minmax(78px, 36%) minmax(0, 1fr);
    padding-inline: 0.6rem !important;
  }

  .record-tabs .nav-link {
    font-size: 0.68rem;
  }
}
