@import './tokens.css';

/* Layout Container */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar (RTL: right side) */
.app-sidebar {
  width: 260px;
  background-color: var(--centrly-white);
  border-left: 1px solid var(--centrly-line);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  z-index: 40;
  overflow: hidden;
  overscroll-behavior: contain;
}

.sidebar-header {
  padding: 1.25rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--centrly-line);
  flex-shrink: 0;
}

.brand-logo-badge {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--centrly-blue-700), var(--centrly-blue-900));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--centrly-white);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.brand-name {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--centrly-ink);
  line-height: 1.2;
}

.brand-tagline {
  font-size: 0.75rem;
  color: var(--centrly-text);
}

.sidebar-nav {
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto !important;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  flex: 1 1 0% !important;
  min-height: 0 !important;
}

.sidebar-footer {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--centrly-line);
  flex-shrink: 0;
  background: var(--centrly-white);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.48rem 0.7rem;
  border-radius: 6px;
  color: #334155 !important;
  background-color: transparent !important;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.82rem;
  transition: all 0.12s ease;
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: right;
}

.nav-link .nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #64748b !important;
  flex-shrink: 0;
}

.nav-link .nav-title {
  color: #334155 !important;
  font-weight: 600;
}

.nav-link svg {
  stroke: #64748b !important;
}

.nav-link:hover:not(.active) {
  background-color: #f1f5f9 !important;
  color: #0f172a !important;
}

.nav-link:hover:not(.active) .nav-icon,
.nav-link:hover:not(.active) .nav-title {
  color: #0f172a !important;
}

.nav-link:hover:not(.active) svg {
  stroke: #0f172a !important;
}

.nav-link.active {
  background-color: #0f172a !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.nav-link.active .nav-icon,
.nav-link.active .nav-title,
.nav-link.active span {
  color: #ffffff !important;
  font-weight: 700 !important;
}

.nav-link.active svg {
  stroke: #ffffff !important;
}

/* Responsive Platform Builder Student Tracking */
.desktop-tracking-table {
  display: block;
  width: 100%;
  overflow-x: auto;
}
.mobile-tracking-cards {
  display: none;
}

@media (max-width: 768px) {
  .desktop-tracking-table {
    display: none !important;
  }
  .mobile-tracking-cards {
    display: flex !important;
    flex-direction: column;
    gap: 0.65rem;
    padding: 0.75rem;
  }
}

/* Main Content Area */
.app-main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: var(--centrly-surface);
}

/* Top Navbar */
.app-topbar {
  height: 52px;
  background-color: var(--centrly-white);
  border-bottom: 1px solid var(--centrly-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.content-body {
  padding: 1rem 1.25rem;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
}

/* Card Component */
.card {
  background-color: var(--centrly-white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--centrly-line);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  padding: 0.85rem 1.15rem;
  margin-bottom: 0.75rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--centrly-line);
  margin-bottom: 0.75rem;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--centrly-ink);
  margin: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0 0.75rem;
  min-height: 32px;
  height: auto;
  white-space: nowrap;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.76rem;
  line-height: 1.4;
  cursor: pointer;
  transition: all 0.12s ease;
  border: 1px solid transparent;
  text-decoration: none;
  font-family: var(--font-family-arabic);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background-color: #0f172a;
  color: #ffffff;
  border: 1px solid #0f172a;
  box-shadow: none;
}

.btn-primary:hover {
  background-color: #1e293b;
  border-color: #1e293b;
  box-shadow: none;
}

.btn-secondary {
  background-color: #ffffff;
  border-color: var(--centrly-line);
  color: #334155;
  box-shadow: none;
}

.btn-secondary:hover {
  background-color: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

.btn-success {
  background-color: #166534 !important;
  color: #ffffff !important;
  border: 1px solid #166534 !important;
  box-shadow: none;
}

.btn-success:hover {
  background-color: #14532d !important;
  border-color: #14532d !important;
}

.btn-danger {
  background-color: #991b1b;
  color: #ffffff;
  border: 1px solid #991b1b;
  box-shadow: none;
}

.btn-danger:hover {
  background-color: #7f1d1d;
}

.btn-warning {
  background-color: #b45309 !important;
  color: #ffffff !important;
  border: 1px solid #b45309 !important;
  box-shadow: none;
}

.btn-warning:hover {
  background-color: #92400e !important;
}

.btn-sm {
  min-height: 28px;
  height: auto;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  white-space: nowrap;
  line-height: 1.3;
}

/* Form Controls */
.form-group {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--centrly-ink);
}

.form-input, .form-select, .form-control {
  display: block;
  padding: 0 0.65rem;
  height: 32px;
  border-radius: var(--radius-sm, 4px);
  border: 1px solid #cbd5e1;
  background-color: var(--centrly-white, #ffffff);
  color: var(--centrly-ink, #0f172a);
  font-family: var(--font-family-arabic, 'Cairo', sans-serif);
  font-size: 0.78rem;
  font-weight: 600;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea,
textarea.form-input,
textarea.form-control,
.form-textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  height: auto !important;
  min-height: 85px;
  padding: 0.65rem 0.75rem !important;
  border-radius: var(--radius-sm, 4px);
  border: 1px solid #cbd5e1;
  background-color: var(--centrly-white, #ffffff);
  color: var(--centrly-ink, #0f172a);
  font-family: var(--font-family-arabic, 'Cairo', sans-serif);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus, .form-control:focus, select:focus {
  outline: none;
  border-color: #0f172a;
  box-shadow: 0 0 0 1px #0f172a;
}

/* Password Visibility Toggle Button - Locked Dead-Center */
.password-toggle-btn,
button.password-toggle-btn {
  position: absolute !important;
  left: 8px !important;
  top: 0 !important;
  bottom: 0 !important;
  margin-top: auto !important;
  margin-bottom: auto !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  width: 32px !important;
  height: 32px !important;
  transform: none !important;
  background: transparent !important;
  border: none !important;
  border-width: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  filter: none !important;
  -webkit-appearance: none !important;
  appearance: none !important;
  cursor: pointer;
  color: var(--centrly-text);
  padding: 0 !important;
  border-radius: 6px;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
  z-index: 10 !important;
  transition: color 0.15s ease, background-color 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.password-toggle-btn:hover,
button.password-toggle-btn:hover {
  color: var(--centrly-blue-700);
  background-color: rgba(70, 101, 211, 0.08) !important;
  transform: none !important;
  filter: none !important;
}

.password-toggle-btn:focus,
.password-toggle-btn:focus-visible,
.password-toggle-btn:active,
button.password-toggle-btn:focus,
button.password-toggle-btn:focus-visible,
button.password-toggle-btn:active {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
  filter: none !important;
  transform: none !important;
  background-color: rgba(70, 101, 211, 0.12) !important;
}

.password-toggle-btn svg {
  display: block;
  margin: auto;
  pointer-events: none;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.3;
}

.badge-success {
  background-color: var(--centrly-success-light);
  color: var(--centrly-success);
}

.badge-warning {
  background-color: var(--centrly-warning-light);
  color: var(--centrly-warning);
}

.badge-danger {
  background-color: var(--centrly-danger-light);
  color: var(--centrly-danger);
}

.badge-blue {
  background-color: var(--centrly-blue-100);
  color: var(--centrly-blue-700);
}

/* Data Table Styles - Clean Spacing & Non-stick Cells */
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.82rem;
  background-color: var(--centrly-white);
  border-radius: var(--radius-md);
}

.data-table th {
  background-color: #f8fafc;
  color: #64748b;
  font-weight: 700;
  font-size: 0.76rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--centrly-line);
  white-space: nowrap;
}

.data-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  color: var(--centrly-ink);
  vertical-align: middle;
  line-height: 1.45;
}

.data-table tbody tr:hover {
  background-color: #f8fafc;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* Table Actions Spacing */
.data-table td .btn {
  margin: 0.15rem 0.25rem;
}

/* Students Table Responsive Horizontal Scrollbar Controls */
#studentsTableContainer {
  scrollbar-width: none; /* Hide default scrollbar so there is no duplicate */
  -ms-overflow-style: none;
}
#studentsTableContainer::-webkit-scrollbar {
  display: none;
}

#studentsStickyScrollTrack {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f8fafc;
}

#studentsStickyScrollTrack::-webkit-scrollbar {
  height: 12px;
}

#studentsStickyScrollTrack::-webkit-scrollbar-track {
  background: #f8fafc;
  border-radius: 6px;
}

#studentsStickyScrollTrack::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 6px;
  border: 2px solid #f8fafc;
}

#studentsStickyScrollTrack::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ==========================================================================
   Modal Dialogs & Responsive Scrolling System
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 1rem;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}

.modal-dialog {
  background-color: var(--centrly-white);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  max-width: 520px;
  width: 100%;
  max-height: calc(100vh - 2rem) !important;
  max-height: calc(100dvh - 2rem) !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  margin: auto !important;
  animation: modalIn 0.2s ease-out;
  border: 1px solid var(--centrly-line);
  position: relative;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--centrly-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: #ffffff;
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  flex: 1 1 auto !important;
  min-height: 0 !important;
}

/* Custom smooth scrollbar for modal-body */
.modal-body::-webkit-scrollbar {
  width: 6px;
}
.modal-body::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}
.modal-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--centrly-line);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-shrink: 0;
  background-color: #fafbfc;
}

/* Responsive Modal Form Grids & Overflow Control */
.modal-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  width: 100%;
  box-sizing: border-box;
}

.modal-dialog {
  overflow-x: hidden !important;
  box-sizing: border-box;
}

.modal-body {
  overflow-x: hidden !important;
  box-sizing: border-box;
}

.modal-body input,
.modal-body select,
.modal-body textarea {
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

@media (max-width: 540px) {
  .modal-form-grid {
    grid-template-columns: 1fr !important;
    gap: 0.65rem;
  }
}

/* Live Session Topbar Badge */
.nav-live-session-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: #fef2f2;
  color: #b91c1c;
  border: 1.5px solid #f87171;
  border-radius: 9999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  animation: centrlyPulse 2s infinite;
  white-space: nowrap;
}

.nav-live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ef4444;
  display: inline-block;
  flex-shrink: 0;
}

.nav-live-text-desktop {
  display: inline;
}

.nav-live-text-mobile {
  display: none;
}

#sidebarToggle {
  display: none;
}

#appSidebarBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  touch-action: none;
  will-change: opacity;
}

#appSidebarBackdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Responsive Drawer & Comprehensive Mobile Optimizations */
@media (max-width: 768px) {
  /* Prevent background screen from scrolling when mobile sidebar is open */
  body.sidebar-open,
  html.sidebar-open {
    overflow: hidden !important;
    overscroll-behavior: none !important;
    touch-action: none !important;
  }

  #sidebarToggle {
    display: inline-flex !important;
    flex-shrink: 0 !important;
    z-index: 10;
  }
  .app-sidebar {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(295px, 85vw);
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    z-index: 1000;
    transform: translate3d(105%, 0, 0);
    will-change: transform;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: -4px 0 25px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    visibility: hidden;
    pointer-events: none;
  }
  .app-sidebar.open {
    transform: translate3d(0, 0, 0);
    visibility: visible;
    pointer-events: auto;
  }
  .app-sidebar .mobile-close-btn {
    display: inline-flex !important;
  }
  .app-sidebar .sidebar-nav {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    padding-bottom: 2rem !important;
  }

  /* Prevent iOS Safari from automatically zooming into inputs on focus */
  input, select, textarea, .form-input, .form-select, .form-textarea, .filter-select {
    font-size: 16px !important;
  }

  /* Rapid touch response without 300ms tap delay */
  button, a, .btn, .nav-link, input, select, label {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  /* Mobile container padding & clean card spacing */
  .content-body {
  padding: 1rem 1.25rem;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
}
  .app-topbar {
  height: 52px;
  background-color: var(--centrly-white);
  border-bottom: 1px solid var(--centrly-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 30;
}
  .topbar-start {
    gap: 0.4rem !important;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
  }
  .nav-live-text-desktop {
    display: none !important;
  }
  .nav-live-text-mobile {
    display: inline !important;
  }
  .nav-live-session-btn {
    padding: 0.25rem 0.55rem !important;
    font-size: 0.75rem !important;
    gap: 0.3rem !important;
    max-width: 135px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
  }
  .topbar-user-role {
    display: none !important;
  }
  .topbar-user-name {
    max-width: 85px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.78rem !important;
  }
  .topbar-actions {
    gap: 0.45rem !important;
    flex-shrink: 0 !important;
  }
  .topbar-admin-badge {
    display: none !important;
  }
  .card {
  background-color: var(--centrly-white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--centrly-line);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  padding: 0.85rem 1.15rem;
  margin-bottom: 0.75rem;
}

  /* Table horizontal scrolling without breaking mobile layout */
  .card:has(table), .card:has(.data-table), .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Modals full-width & max-height control on mobile */
  .modal-overlay {
    padding: 0.4rem !important;
    overflow-x: hidden !important;
  }
  .modal-dialog {
    max-height: calc(100dvh - 0.8rem) !important;
    width: 100% !important;
    margin: auto 0 !important;
    border-radius: 12px !important;
    overflow-x: hidden !important;
  }
  .modal-header {
    padding: 0.85rem 1rem !important;
  }
  .modal-body {
    padding: 0.9rem 0.85rem !important;
    overflow-x: hidden !important;
  }
  .modal-footer {
    padding: 0.75rem 0.85rem !important;
    flex-wrap: wrap !important;
  }
  .modal-footer .btn {
    flex: 1 1 auto;
    justify-content: center;
  }
}

/* Scanner Laser Line Animation */
@keyframes centrlyLaserScan {
  0% { top: 6%; opacity: 0.6; }
  50% { top: 92%; opacity: 1; }
  100% { top: 6%; opacity: 0.6; }
}

.scanner-laser-line {
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2.5px;
  background: linear-gradient(90deg, transparent, #10b981, #34d399, #10b981, transparent);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.9);
  animation: centrlyLaserScan 2s infinite ease-in-out;
  pointer-events: none;
  z-index: 10;
}

/* Sleek Top Progress Bar for Instant Page Feedback */
.top-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, #1d4ed8, #38bdf8, #2563eb);
  background-size: 200% 100%;
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.7);
}

.top-progress-bar.active {
  opacity: 1;
  animation: centrlyProgressPulse 1.2s infinite linear;
}

@keyframes centrlyProgressPulse {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Centrly Shimmer Skeleton Loaders */
@keyframes centrlyShimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton-box {
  display: inline-block;
  position: relative;
  overflow: hidden;
  background: #e2e8f0;
  background-image: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0,
    rgba(255, 255, 255, 0.65) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  background-size: 200% 100%;
  background-repeat: no-repeat;
  border-radius: 6px;
  animation: centrlyShimmer 1.4s infinite ease-in-out;
}

.skeleton-row td {
  padding: 1rem 1rem !important;
  vertical-align: middle;
}

.skeleton-card {
  background: var(--centrly-white);
  border: 1px solid var(--centrly-line);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
}

@keyframes centrlyPulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1.08); box-shadow: 0 0 0 7px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.centrly-spinner {
  display: inline-block;
  border-radius: 50%;
  border: 3px solid #e2e8f0;
  border-top-color: var(--centrly-blue-700);
  animation: spin 0.75s linear infinite;
}

.page-loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 1.5rem;
  text-align: center;
  background: var(--centrly-white);
  border: 1px solid var(--centrly-line);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
}

/* Modern Sleek Minimalist Route Loader */
.centrly-sleek-loader-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(70vh - 64px);
  min-height: calc(70dvh - 64px);
  width: 100%;
  padding: 2rem 1rem;
}

.centrly-sleek-spinner {
  width: 46px;
  height: 46px;
  animation: centrlyRotate 1.4s linear infinite;
  transform-origin: center center;
}

.centrly-sleek-spinner .spinner-track {
  stroke: rgba(30, 58, 138, 0.08);
}

.centrly-sleek-spinner .spinner-head {
  stroke-dasharray: 90, 150;
  stroke-dashoffset: 0;
  stroke-linecap: round;
  animation: centrlyDash 1.4s ease-in-out infinite;
}

@keyframes centrlyRotate {
  100% {
    transform: rotate(360deg);
  }
}

@keyframes centrlyDash {
  0% {
    stroke-dasharray: 1, 150;
    stroke-dashoffset: 0;
  }
  50% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -35;
  }
  100% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -124;
  }
}

/* ========================================================
   Low-End Mobile & Legacy Browser Performance Optimizations
   ======================================================== */
@media (max-width: 768px) {
  html, body {
    text-rendering: optimizeSpeed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
  }

  /* GPU acceleration for mobile scroll containers */
  #mainContent,
  #studentsTableContainer,
  .modal-overlay {
    -webkit-overflow-scrolling: touch;
    transform: translateZ(0);
  }

  /* Contain layout reflows to boost scrolling speed on budget Android CPUs */
  .card, .stat-card {
    contain: content;
    will-change: auto;
  }
}

/* ========================================================
   Print Media Styles for Exams and Bubble Sheets
   ======================================================== */
@media print {
  .sidebar,
  .top-bar,
  .mobile-nav,
  .btn,
  #quizSubTabsNav,
  header,
  footer,
  #toastContainer {
    display: none !important;
  }

  body, html {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  #mainContent {
    padding: 0 !important;
    margin: 0 !important;
  }

  #centrlyPrintContainer {
    display: block !important;
    width: 100% !important;
  }

  .printable-exam-paper,
  .printable-bubble-sheet {
    box-shadow: none !important;
    border: 2px solid #000000 !important;
    width: 100% !important;
    max-width: 100% !important;
    page-break-after: always !important;
    break-after: page !important;
    margin: 0 !important;
    padding: 1cm !important;
  }
}



/* Keep select text visible with component-specific vertical padding. */
select.form-input, select.form-select, select.form-control {
  height: auto;
  min-height: 40px;
  line-height: 1.5;
}
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  input.form-input, input.form-control, select.form-select { min-height: 44px; }
}

.student-password { display: flex; flex-direction: column; gap: .35rem; margin-block: .35rem; max-width: 100%; }
.student-password-label { font-size: .75rem; font-weight: 600; color: var(--centrly-text); }
.student-password-controls { display: flex; align-items: center; gap: .5rem; max-width: 100%; width: 196px; }
.student-password-toggle, .student-password-copy { min-height: 44px; border: 1px solid var(--centrly-line); border-radius: 10px; background: var(--centrly-surface, #fff); color: var(--centrly-ink); cursor: pointer; }
.student-password-toggle { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex: 1; min-width: 0; padding: .5rem .65rem; }
.student-password-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 .85rem/1.5 monospace; letter-spacing: .06em; }
.student-password-icon, .student-password-copy { display: grid; place-items: center; flex-shrink: 0; }
.student-password-copy { width: 44px; padding: .5rem; }
.student-password-toggle:hover, .student-password-copy:hover { background: var(--centrly-bg, #f8fafc); }
.student-password-toggle:focus-visible, .student-password-copy:focus-visible { outline: 2px solid var(--centrly-blue-700); outline-offset: 2px; }

/* One roster and one set of controls: readable student cards on phones. */
@media (max-width: 640px) {
  #studentsTableCard { border: 0 !important; background: transparent; overflow: visible !important; }
  #studentsTableContainer { overflow: visible !important; }
  #studentsTable.students-responsive-table { display: block; width: 100%; min-width: 0 !important; border: 0; }
  #studentsTable thead { position: absolute; inline-size: 1px; block-size: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  #studentsTable tbody { display: grid; gap: 1rem; width: 100%; }
  #studentsTable tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; min-width: 0; padding: 1rem; border: 1px solid var(--centrly-line); border-radius: var(--radius-lg); background: var(--centrly-surface, #fff); box-shadow: 0 1px 2px #0f172a05; }
  #studentsTable tbody td { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: .3rem; min-width: 0; max-width: none !important; padding: 0; border: 0; white-space: normal; overflow-wrap: anywhere; font-size: .9rem !important; }
  #studentsTable tbody td[data-label]::before { content: attr(data-label); color: var(--centrly-text); font: 600 .7rem/1.6 Cairo, sans-serif; direction: rtl; }
  #studentsTable tbody .student-name { grid-column: 1 / -1; grid-row: 1; font-size: 1.05rem !important; color: var(--centrly-ink, #0f172a); }
  #studentsTable tbody .student-name::before { display: none; }
  #studentsTable .student-group .badge { max-width: 100% !important; white-space: normal !important; }
  #studentsTable .student-links, #studentsTable .student-actions, #studentsTable td[colspan] { grid-column: 1 / -1; width: 100%; }
  #studentsTable .student-links { padding-block-start: .75rem; border-block-start: 1px solid var(--centrly-line); }
  #studentsTable .student-links > div { width: 100%; min-width: 0 !important; }
  #studentsTable .student-links > div > div { flex-wrap: wrap; gap: .5rem !important; }
  #studentsTable .student-actions > div { display: flex; flex-wrap: wrap; gap: .5rem !important; width: 100%; }
  #studentsTable .btn, #studentsTable a.btn { min-height: 44px; min-width: 44px; padding: .45rem .6rem !important; font-size: .8rem !important; }
  #studentsTable .student-actions button:first-child { flex: 1; justify-content: center; }
  #studentsStickyScrollBar, #studentsStickyScrollTrack { display: none !important; }
}

.teacher-actions { padding: 1.25rem; border: 1px solid var(--centrly-line); border-radius: var(--radius-lg); background: var(--centrly-surface, #fff); min-width: 0; }
.teacher-actions-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.teacher-actions-heading span { font-size: .75rem; color: var(--centrly-text); }
.teacher-actions-heading h2 { margin: .15rem 0 0; font-size: 1.1rem; color: #0f172a; }
.teacher-actions-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.teacher-action { display: flex; align-items: center; gap: .75rem; min-width: 0; min-height: 96px; padding: 1rem; text-align: start; color: #0f172a; background: #f8fafc; border: 1px solid var(--centrly-line); border-radius: 10px; font: inherit; cursor: pointer; }
.teacher-action:hover:not(:disabled) { border-color: #94a3b8; background: #f1f5f9; }
.teacher-action:focus-visible { outline: 2px solid #1e3a8a; outline-offset: 3px; }
.teacher-action:disabled { opacity: .65; cursor: not-allowed; }
.teacher-action-icon { display: grid; place-items: center; flex-shrink: 0; color: #334155; }
.teacher-action-copy { flex: 1; min-width: 0; }
.teacher-action-copy strong { display: block; font-size: .85rem; }
.teacher-action-copy small { display: block; margin-top: .3rem; font-size: .72rem; line-height: 1.7; color: var(--centrly-text); }
.teacher-action-count { font-size: 1.5rem; font-weight: 800; }
.teacher-actions-error { font-size: .8rem; color: #9a3412; line-height: 1.8; }
@media (max-width: 640px) { .teacher-actions { padding: 1rem; } .teacher-actions-grid { grid-template-columns: 1fr; } }

.signup-stages { border: 1px solid var(--centrly-line); border-radius: 10px; padding: .75rem; margin: 0 0 1rem; min-width: 0; }
.signup-stages legend { padding-inline: .3rem; font-size: .85rem; font-weight: 700; }
.signup-stages p { color: var(--centrly-text); font-size: .75rem; margin: 0 0 .5rem; }
.signup-stage-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.signup-stage-options label { display: flex; gap: .5rem; align-items: center; min-height: 44px; border: 1px solid var(--centrly-line); border-radius: 8px; padding: .5rem; font-size: .85rem; cursor: pointer; }
.signup-stage-options label:has(input:checked) { border-color: #334155; background: #f1f5f9; }
#signupOtherStageField:not([hidden]) { margin-top: .75rem; }

.product-demo-section { max-width: 960px; margin: 0 auto; padding: 3rem 1.25rem; }
.product-demo-heading { text-align: center; margin-bottom: 1.5rem; }
.product-demo-heading > span, .walkthrough-label { color: var(--centrly-text); font-size: .8rem; }
.product-demo-heading h2 { font-size: clamp(1.3rem, 3vw, 1.9rem); line-height: 1.7; color: #172d70; margin: .3rem 0; }
.product-demo-heading p, .walkthrough-panel p { font-size: .85rem; line-height: 1.9; color: var(--centrly-text); }
#product-walkthrough { border: 1px solid var(--centrly-line); border-radius: 14px; background: #fff; overflow: hidden; }
.walkthrough-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: #f8fafc; border-bottom: 1px solid var(--centrly-line); }
.walkthrough-tabs button { min-height: 48px; background: transparent; border: 0; border-bottom: 2px solid transparent; font: 700 .9rem Cairo, sans-serif; color: #475569; cursor: pointer; }
.walkthrough-tabs button[aria-selected=true] { border-bottom-color: #172d70; color: #172d70; background: #fff; }
.walkthrough-tabs button:focus-visible { outline: 2px solid #2949ba; outline-offset: -4px; }
.walkthrough-panel { padding: 1.5rem; min-height: 260px; }
.walkthrough-panel h3 { font-size: 1.1rem; margin: .5rem 0 1rem; }
.walkthrough-student { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1rem; border: 1px solid var(--centrly-line); border-radius: 10px; }
.walkthrough-student button { min-height: 44px; }
.walkthrough-permissions { display: grid; gap: .75rem; }
.walkthrough-permissions span { display: flex; gap: .5rem; align-items: center; font-size: .85rem; }
.walkthrough-results { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.walkthrough-results > div { padding: .75rem; border: 1px solid var(--centrly-line); border-radius: 8px; min-width: 0; }
.walkthrough-results dt { font-size: .75rem; color: #64748b; }.walkthrough-results dd { margin: .4rem 0 0; font-size: .85rem; font-weight: 700; }
@media (max-width: 640px) { .walkthrough-panel { padding: 1rem; }.walkthrough-results { grid-template-columns: 1fr; }.walkthrough-student button { width: 100%; }.product-demo-section { padding: 2rem .75rem; } }
