:root {
  scroll-behavior: smooth;
  --top-bar-height: 0px;
  --footer-height: 73px;
  --rail-width: 88px;
  --drawer-width: 300px;
}

@media (max-width: 1023.9px) {
  :root {
    --top-bar-height: 64px;
    --footer-height: 75px;
  }
}

/* Global Scrollbar Styling (Cross-browser) */
* {
  /* Firefox */
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--mdui-color-primary), 0.3) transparent;
}

/* Chrome, Edge, Safari */
*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(var(--mdui-color-primary), 0.2);
  border-radius: 10px;
  border: 1px solid transparent;
  /* Padding around thumb */
  background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--mdui-color-primary), 0.5);
  background-clip: content-box;
}


/* Search Dialog Styling */
#search-dialog {
  --mdui-dialog-max-width: 500px;
}

#search-results {
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
}

#results-list mdui-list-item {
  cursor: pointer;
  transition: background-color 0.2s ease;
}

#results-list mdui-list-item:hover {
  background-color: rgba(var(--mdui-color-primary), 0.1);
}


#search-fab {
  margin-bottom: 8px;
}

mdui-text-field::part(label),
mdui-select::part(label),
mdui-select::part(text-field__label) {
  left: auto !important;
  right: 0.75rem !important;
  transform-origin: right top !important;
}

mdui-text-field[icon]::part(label),
mdui-select[icon]::part(text-field__label) {
  right: 2.75rem !important;
}

mdui-circular-progress,
mdui-linear-progress,
mdui-button::part(loading) {
  direction: ltr !important;
}

* {
  box-sizing: border-box;
}

mdui-dialog {
  --z-index: 999999999;
}

/*--------------------------------------------------------------
# Navigation Rail
--------------------------------------------------------------*/

mdui-layout {
  min-height: 100vh;
}


/* RAIL (Desktop Only) */
mdui-navigation-rail {
  background-color: rgb(var(--mdui-color-surface-container-low), 1);
  z-index: 10000;
  border-inline-end: 1px solid rgba(var(--mdui-color-outline-variant), 0.2);
}

/* Desktop Mode: Always Modal/Overlay as requested */
@media (min-width: 1024px) {
  mdui-navigation-drawer {
    /* Remove 'push' logic - act as overlay */
    position: fixed !important;
    inset-inline-start: var(--rail-width);
    /* Align next to rail */
    height: 100vh !important;
    box-shadow: var(--mdui-shadow-3);
    /* Add shadow for overlay depth */
    border-inline-end: 1px solid rgba(var(--mdui-color-outline-variant), 0.2);
  }

  /* Make overlay transparent on desktop so it looks like a flyout but keeps modal closing logic */
  mdui-navigation-drawer::part(scrim),
  mdui-navigation-drawer::part(overlay) {
    background-color: rgba(var(--mdui-color-primary), 0.1);
    backdrop-filter: blur(1px);
  }
}

/* MENU STACK ARCHITECTURE */

/* تحديد طول القوائم وتفعيل التمرير الداخلي */
mdui-select::part(menu) {
  max-height: 300px;
  overflow-y: auto;
}

.menu-stack {
  position: relative;
  width: 100%;
  height: 100%;
  /* Ensure it fills the drawer */
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.menu-layer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  background-color: inherit;
  padding: 8px;
  display: none;
  /* Hidden by default */
  flex-direction: column;
  z-index: 1;
}

/* Active State: FORCE VISIBILITY */
.menu-layer.active {
  display: flex !important;
  z-index: 10;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateX(10px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Desktop Adjustments */
@media (min-width: 1024px) {
  .root-layer {
    display: none !important;
  }
}

/* Main Content Wrapper */
#main {
  padding: 1rem;
  z-index: 1;
}

.main-wrapper {
  box-sizing: border-box;
  overflow: auto;
  width: 100%;
  height: calc(100dvh - var(--top-bar-height) - var(--footer-height) - 1rem);
  background-color: rgb(var(--mdui-color-surface-bright), 1);
  border-radius: var(--mdui-shape-corner-extra-large);
  box-shadow: var(--mdui-shadow-1);
  position: relative;
  z-index: 2;
}

@media (max-width: 1023.9px) {
  .main-wrapper {
    height: calc(100dvh - var(--top-bar-height) - var(--footer-height) - 1rem);
    border-radius: var(--mdui-shape-corner-large);
  }
}

footer#footer {
  background-color: rgb(var(--mdui-color-surface-bright), 1);
  border-radius: var(--mdui-shape-corner-extra-large) var(--mdui-shape-corner-extra-large) 0 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* COMPACT TABLES & UNIFICATION */
.compact-table th,
.compact-table td,
.table-sm th,
.table-sm td {
  padding: 0.5rem 0.75rem !important;
  font-size: 0.85rem !important;
  vertical-align: middle !important;
}

.mdui-table table,
.mdui-table.table {
  width: 100% !important;
  border-collapse: collapse !important;
}

.mdui-table thead th {
  background-color: rgb(var(--mdui-color-surface-container-low));
  color: rgb(var(--mdui-color-primary));
  font-weight: 700 !important;
  text-transform: none !important;
  border-bottom: 2px solid rgb(var(--mdui-color-primary-container)) !important;
  height: 40px !important;
  padding: 8px 12px !important;
  font-size: 0.9rem !important;
}

.mdui-table tbody td {
  height: 48px !important;
  padding: 8px 12px !important;
  border-bottom: 1px solid rgba(var(--mdui-color-outline-variant), 0.3) !important;
  font-size: 0.875rem !important;
}

.mdui-table tr:hover {
  background-color: rgba(var(--mdui-color-primary), 0.04) !important;
}

mdui-snackbar {
  z-index: 99999999999;
}

/* Status Chip Refinement */
.status-chip {
  height: 24px !important;
  font-size: 0.75rem !important;
  border-radius: 6px !important;
  padding: 0 8px !important;
  min-height: 24px !important;
  --mdui-shape-corner: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* DataTables Advanced Filters */
.dt-filter-dropdown mdui-button-icon {
  opacity: 0.3;
  transition: opacity 0.3s, color 0.3s;
}

th:hover .dt-filter-dropdown mdui-button-icon,
.dt-filter-dropdown[open] mdui-button-icon {
  opacity: 1;
}

.export-btn mdui-button {
  font-family: 'ElMessiri', sans-serif !important;
}

/* DataTable Toolbar */
.dt-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: .75rem;
  margin-bottom: 1rem;
  background: rgba(var(--mdui-color-surface-container-high), 0.5);
  border-radius: 12px;
  border: 1px solid rgba(var(--mdui-color-outline-variant), 0.2);
}

/* Ensure DataTable elements are properly positioned */
.dt-container .dt-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dt-container .dt-search {
  margin-bottom: 0;
  display: flex;
  justify-content: flex-end;
  min-width: 250px;
}

.dt-container .dt-paging {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2px;
  margin-top: 1rem;
  padding: 12px;
  background: rgba(var(--mdui-color-surface-container), 0.3);
  border-radius: 12px;
}

/* Fix DataTable layout issues */
.table-responsive .dt-toolbar {
  margin-bottom: 1rem;
}

.dt-container {
  position: relative;
}

/* Hide default DataTable info if needed */
.dt-container .dt-info {
  margin-top: 0.5rem;
  text-align: center;
  color: rgb(var(--mdui-color-on-surface-variant));
}

.dt-container .dt-search {
  margin-bottom: 0;
  display: flex;
  justify-content: flex-end;
}

.dt-container .dt-paging {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2px;
  margin-top: .5rem;
  padding: 12px;
  background: rgba(var(--mdui-color-surface-container), 0.3);
  border-radius: 12px;
}

.dt-container .dt-paging-button {
  padding: 4px 10px !important;
  border: none !important;
  background: transparent !important;
  margin: 0 2px !important;
  font-size: 0.9rem !important;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 6px !important;
  color: rgb(var(--mdui-color-on-surface)) !important;
}

.dt-paging-button.current {
  background: #6c4900 !important;
  /* Theme primary */
  color: #ffffff !important;
  font-weight: bold;
  box-shadow: var(--mdui-elevation-level1);
}

.dt-paging-button:hover:not(.disabled):not(.current) {
  background: rgba(var(--mdui-color-primary), 0.15) !important;
}

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

.dt-buttons {
  margin-bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
}

.dt-search {
  margin-bottom: 12px;
}

/* Hide default DataTables sorting icons since we have custom menu */
table.dataTable thead th.dt-orderable-asc::before,
table.dataTable thead th.dt-orderable-asc::after,
table.dataTable thead th.dt-orderable-desc::before,
table.dataTable thead th.dt-orderable-desc::after {
  display: none !important;
}

table.dataTable thead th {
  cursor: default !important;
  padding-right: 8px !important;
}

.status-chip::part(container) {
  height: 24px !important;
  padding-left: 8px !important;
  padding-right: 8px !important;
}

.status-chip::part(label) {
  padding: 0 !important;
}

html,
body {
  font-family: "ElMessiri", sans-serif;
  margin: 0;
  background-color: rgb(var(--mdui-color-surface-container));
}

@media print {
  @page {
    margin: 0.5cm;
  }

  /* Universal Hide & Reset */
  .no-print,
  #header,
  #sidebar,
  #footer,
  .pagetitle,
  .breadcrumb,
  .back-to-top,
  mdui-navigation-rail,
  mdui-navigation-drawer,
  mdui-fab {
    display: none !important;
  }

  /* Main Layout Reset */
  body,
  html,
  #main,
  .main-wrapper {
    background-color: white !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Force RTL Layout to fix Arabic text reversal */
  body,
  html,
  .mdui-table,
  p,
  div,
  span,
  td,
  th,
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    direction: rtl !important;
    text-align: right;
  }

  /* High Contrast for Printing */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  /* Table Styling for Print */
  .mdui-table table,
  .table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 12px;
  }

  thead th {
    background-color: #f0f0f0 !important;
    color: #000000 !important;
    font-weight: bold !important;
    border: 1px solid #000 !important;
    text-align: center !important;
  }

  td {
    border: 1px solid #ddd !important;
    color: #000 !important;
    padding: 6px !important;
  }

  /* Text Alignment Utilities Adjustment for RTL */
  .text-center {
    text-align: center !important;
  }

  .text-end {
    text-align: left !important;
  }

  .text-start {
    text-align: right !important;
  }

  /* Element Cleanup */
  .card,
  mdui-card {
    border: none !important;
    box-shadow: none !important;
    background: white !important;
  }

  .card-body,
  mdui-card>div {
    padding: 0 !important;
  }

  .table-responsive {
    overflow: visible !important;
    display: block !important;
  }

  /* Links */
  a {
    text-decoration: none !important;
    color: #000 !important;
  }
}

/*--------------------------------------------------------------
# Login Page
--------------------------------------------------------------*/

.login-page {
  display: flex !important;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at top left, rgba(var(--mdui-color-primary), 0.05), transparent),
    radial-gradient(circle at bottom right, rgba(var(--mdui-color-secondary), 0.05), transparent),
    rgb(var(--mdui-color-surface-container-lowest));
  padding: 20px;
}

.login-container {
  width: 100%;
  max-width: 440px;
  animation: loginAppear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes loginAppear {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-container mdui-card {
  padding: 3rem 2.5rem;
  border-radius: 28px;
  background-color: rgba(var(--mdui-color-surface-container-low), 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(var(--mdui-color-outline-variant), 0.3);
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo img {
  height: 80px;
  width: auto;
  margin-bottom: 1rem;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

.login-logo .school-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: rgb(var(--mdui-color-primary));
  letter-spacing: -0.5px;
}

.login-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.login-header h5 {
  font-size: 1.75rem;
  font-weight: 800;
  margin: 0 0 0.5rem 0;
  color: rgb(var(--mdui-color-on-surface));
}

.login-header p {
  color: rgb(var(--mdui-color-on-surface-variant));
  font-size: 1rem;
  margin: 0;
}

.login-form mdui-text-field {
  margin-bottom: 1.25rem;
}

.login-form mdui-button {
  margin-top: 1rem;
  height: 56px;
  --mdui-shape-corner: 16px;
  font-weight: 700;
  font-size: 1.1rem;
}

.error-message {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1rem;
  background-color: rgb(var(--mdui-color-error-container));
  color: rgb(var(--mdui-color-on-error-container));
  border-radius: 16px;
  margin-bottom: 2rem;
  font-weight: 600;
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  75% {
    transform: translateX(5px);
  }
}

.login-footer {
  text-align: center;
  margin-top: 2rem;
  color: rgb(var(--mdui-color-on-surface-variant));
  font-size: 0.9rem;
  opacity: 0.8;
}

.login-footer p {
  margin: 0;
}

/* RTL Adjustments for Material Icons in fields */
[dir="rtl"] mdui-text-field::part(icon) {
  margin-left: 12px;
  margin-right: 0;
}

/* ============================================
   Smooth Theme Transition (Dark/Light Mode)
   ============================================ */
html {
  transition: background-color 0.3s ease, color 0.3s ease;
}

body {
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Smooth transitions for all elements */
* {
  transition: background-color 0.3s ease,
    color 0.3s ease,
    border-color 0.3s ease,
    box-shadow 0.3s ease,
    fill 0.3s ease,
    stroke 0.3s ease;
}

/* Exclude certain elements from transitions for performance */
img,
svg,
video,
iframe,
canvas,
.mdui-circular-progress,
.mdui-linear-progress,
.progress-fill,
.loading-spinner * {
  transition: none !important;
}

/* Smooth transitions for MDUI components */
mdui-card,
mdui-button,
mdui-button-icon,
mdui-list-item,
mdui-chip,
mdui-badge,
mdui-fab,
mdui-text-field,
mdui-select,
mdui-dialog,
mdui-navigation-drawer,
mdui-navigation-rail,
mdui-top-app-bar {
  transition: background-color 0.3s ease,
    color 0.3s ease,
    border-color 0.3s ease,
    box-shadow 0.3s ease;
}

/* Smooth transition for icons */
mdui-icon {
  transition: color 0.3s ease, fill 0.3s ease;
  vertical-align: middle !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  position: relative;
  /* Adjusted further down for perfect baseline alignment */
}

/* Smooth transition for charts and visual elements */
#reportsChart,
#pieChart,
.apexcharts-canvas {
  transition: opacity 0.3s ease;
}

/* Background Shapes Animated */

@keyframes floatMove {

  0%,
  100% {
    transform: translateY(0px) translateX(0px) rotateZ(0deg);
  }

  25% {
    transform: translateY(-15px) translateX(10px) rotateZ(90deg);
  }

  50% {
    transform: translateY(-30px) translateX(-5px) rotateZ(180deg);
  }

  75% {
    transform: translateY(-15px) translateX(-10px) rotateZ(270deg);
  }
}

@keyframes revealShapes {
  0% {
    opacity: 0;
    transform: scale(0.3) rotateZ(-180deg);
  }

  50% {
    opacity: 0.7;
    transform: scale(1.1) rotateZ(-90deg);
  }

  100% {
    opacity: 0.4;
    transform: scale(1) rotateZ(0deg);
  }
}

@keyframes slowRotate {
  0% {
    transform: rotateZ(0deg);
  }

  100% {
    transform: rotateZ(360deg);
  }
}

@keyframes mediumRotate {
  0% {
    transform: rotateZ(0deg);
  }

  100% {
    transform: rotateZ(-360deg);
  }
}

@keyframes fastRotate {
  0% {
    transform: rotateZ(0deg);
  }

  100% {
    transform: rotateZ(360deg);
  }
}

.bg-shap {
  display: none;
  width: clamp(200px, 25vw, 350px);
  height: clamp(200px, 25vw, 350px);
  z-index: 0;
  position: fixed;
  will-change: transform;
  opacity: 0.8;
  pointer-events: none;
  animation: 60s linear infinite slowRotate;
}

.top_right_corner {
  background: url(https://pixelos.net/Images/Shapes/Monetp-y.png) center center / contain no-repeat;
  top: -100px;
  right: -100px;
  animation: 60s linear infinite slowRotate;
}

.top_left_corner {
  background: url(https://pixelos.net/Images/Shapes/Monetp-w.png) center center / contain no-repeat;
  top: -100px;
  left: -100px;
  animation: 45s linear infinite reverse mediumRotate;
}

.bottom_right_corner {
  background: url(https://pixelos.net/Images/Shapes/Monetp-b.png) center center / contain no-repeat;
  bottom: -100px;
  right: -100px;
  animation: 75s linear infinite fastRotate;
}

.bottom_left_corner {
  background: url(https://pixelos.net/Images/Shapes/Monetp-t.png) center center / contain no-repeat;
  bottom: -100px;
  left: -100px;
  animation: 90s linear infinite reverse slowRotate;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .bg-shap {
    width: clamp(100px, 15vw, 200px);
    height: clamp(100px, 15vw, 200px);
  }

  .top_right_corner {
    top: -20px;
    right: -20px;
  }

  .top_left_corner {
    top: -25px;
    left: -25px;
  }

  .bottom_right_corner {
    bottom: -20px;
    right: -20px;
  }

  .bottom_left_corner {
    bottom: -25px;
    left: -25px;
  }
}

@media (max-width: 480px) {
  .bg-shap {
    width: clamp(80px, 12vw, 150px);
    height: clamp(80px, 12vw, 150px);
    opacity: 0.3;
  }

  .top_right_corner {
    top: -15px;
    right: -15px;
  }

  .top_left_corner {
    top: -20px;
    left: -20px;
  }

  .bottom_right_corner {
    bottom: -15px;
    right: -15px;
  }

  .bottom_left_corner {
    bottom: -20px;
    left: -20px;
  }
}