/* ================================================================
   WayFlow Learning LMS - Complete Theme
   Modern, mobile-first, premium design
   ================================================================ */

/* ── Google Font ── */
@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@400;500;600;700&display=swap');

/* ── CSS Variables ── */
:root {
  /* Background */
  --bg-main: #FFFAF4;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-input: #ffffff;
  --bg-hover: #f8f8f8;
  --bg-overlay: rgba(0,0,0,0.4);

  /* Primary (Green) */
  --primary: #12A41C;
  --primary-hover: #0e8a16;
  --primary-light: #e6f7e8;
  --primary-dark: #0a6e12;
  --primary-gradient: linear-gradient(135deg, #12A41C 0%, #0e8a16 100%);

  /* Status Colors */
  --success: #12A41C;
  --warning: #ff9800;
  --danger: #e53935;
  --info: #2196f3;
  --success-light: #e6f7e8;
  --warning-light: #fff3e0;
  --danger-light: #ffebee;
  --info-light: #e3f2fd;

  /* Text */
  --text-main: #1a1a1a;
  --text-secondary: #555555;
  --text-muted: #888888;
  --text-white: #ffffff;
  --text-link: #12A41C;

  /* Neutral */
  --grey-dark: #2e2e2e;
  --grey-medium: #666666;
  --grey-light: #f5f5f5;
  --grey-lighter: #f1f5f9;

  /* Borders */
  --border: #e8e8e8;
  --border-light: #f0f0f0;
  --border-focus: #12A41C;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 15px 35px rgba(0,0,0,0.12);
  --transition: all 0.3s ease;
  --transition-fast: all 0.2s ease;
}

/* ── CORE RESPONSIVE HARDENING ── */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 0px; /* Hide on small screens by default */
  }
  .main-content {
    margin-left: 0 !important;
  }
  .sidebar {
    transform: translateX(-100%);
    width: 280px !important;
  }
  .sidebar.active {
    transform: translateX(0);
    box-shadow: 20px 0 50px rgba(0,0,0,0.2);
  }
}

@media (max-width: 767px) {
  .page-content {
    padding: 15px !important;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }
  .stat-card {
    padding: 15px !important;
    flex-direction: column !important;
    text-align: center !important;
    gap: 10px !important;
  }
  .stat-icon {
    margin: 0 auto !important;
  }
  .d-flex.justify-between:not(.no-stack) {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 15px !important;
  }
  .mobile-only { display: flex !important; }
  .hide-mobile { display: none !important; }
  
  /* Touch Optimization */
  .btn, .sidebar-link, .header-icon-btn, input, select, textarea {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .sidebar-link { justify-content: flex-start; }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr !important;
  }
  .page-title {
    font-size: 1.1rem !important;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ── PREMIUM GLASSMORPHISM & ELEVATION ── */
.card, .stat-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
}

.card:hover, .stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.12);
  border-color: var(--primary-light);
}

/* ── SMOOTH TRANSITIONS ── */
.sidebar, .sidebar-overlay, .btn, .card, .stat-card, .sidebar-link {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* ── TABLET REFINEMENTS (768px to 1024px) ── */
@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    --sidebar-width: 240px;
  }
  
  .sidebar-link {
    padding: 12px 15px;
    font-size: 0.85rem;
  }
}

:root {
  --shadow-card: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-hover: 0 6px 20px rgba(0,0,0,0.1);

  /* Font */
  --font-main: 'Quicksand', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 50%;

  /* Sidebar */
  --sidebar-width: 260px;
  --header-height: 64px;

  /* Transitions */
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
}

/* ── RESET ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: none; /* iOS 10+ fix */
  touch-action: manipulation;
  overflow-x: hidden;
}

body {
  background: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-main);
  font-weight: 500;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-touch-callout: none;
  touch-action: manipulation; /* Prevents double-tap zoom for faster feel */
  user-select: none;
  overflow-x: hidden;
  width: 100%;
}

/* ── PWA Adjustments ── */
@media (display-mode: standalone) {
  body {
    -webkit-user-select: none;
    user-select: none;
  }
  input, textarea {
    -webkit-user-select: text;
    user-select: text;
  }
}

body.modal-open {
  overflow: hidden !important;
  padding-right: 0px; /* Optional: adjust for scrollbar shift if needed */
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: var(--transition-fast);
}
a:hover {
  color: var(--primary-hover);
}

img {
  max-width: 100%;
  height: auto;
}

/* ── TYPOGRAPHY ── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-main);
}
h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }
p { font-weight: 500; color: var(--text-secondary); }

.text-primary { color: var(--primary) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 0.85rem; }
.text-lg { font-size: 1.15rem; }

.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* ── LOGIN PAGE ── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #FFFAF4 0%, #e6f7e8 50%, #FFFAF4 100%);
  padding: var(--space-md);
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2xl) var(--space-xl);
  padding-bottom: calc(var(--space-2xl) + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 420px;
  text-align: center;
  animation: slideUp 0.5s ease-out;
}

.top-header {
  height: calc(var(--header-height) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: var(--space-lg);
  padding-right: var(--space-lg);
  position: sticky;
  top: 0;
  z-index: 50;
}

.sidebar {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.login-logo {
  width: 72px;
  height: 72px;
  background: var(--primary-gradient);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-lg);
  color: white;
  box-shadow: 0 4px 15px rgba(18,164,28,0.3);
}

.login-logo i {
  font-size: 2.2rem;
}

/* ── LANDING PAGE ── */
.landing-hero {
  min-height: 80vh;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 20px;
  background: linear-gradient(rgba(0,0,0,0.65), rgba(0,0,0,0.65)), url('/assets/images/landing_hero_lms.png');
  background-size: cover;
  background-position: center;
  color: white;
  overflow: hidden;
}

.hero-content {
  max-width: 900px;
  z-index: 2;
  animation: fadeIn 1s ease-out;
}

.hero-content h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  margin-bottom: 20px;
  color: white;
  line-height: 1.1;
  font-weight: 800;
}

.hero-content p {
  font-size: clamp(1rem, 2vw, 1.25rem);
  margin-bottom: 40px;
  color: rgba(255,255,255,0.9);
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
  font-weight: 500;
}

.landing-section {
  padding: 80px 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.section-header {
  text-align: center;
  margin-bottom: 60px;
}

.section-header h2 {
  font-size: 2.2rem;
  margin-bottom: 15px;
  color: var(--grey-dark);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
}

.feature-item {
  background: white;
  padding: 40px;
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  text-align: center;
  border: 1px solid var(--border-light);
}

.feature-item:hover {
  transform: translateY(-10px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}

.feature-icon {
  font-size: 2.5rem;
  color: var(--primary);
  margin-bottom: 25px;
}

.feature-item h3 {
  margin-bottom: 15px;
  color: var(--grey-dark);
}

.portal-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 25px;
  margin-top: 40px;
}

.portal-card {
  background: white;
  padding: 40px 30px;
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  text-align: center;
  transition: var(--transition);
  text-decoration: none;
  display: block;
}

.portal-card:hover { 
  border-color: var(--primary); 
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
}

.portal-card i { 
  font-size: 2.5rem; 
  color: var(--primary); 
  margin-bottom: 20px; 
  display: block;
}

.portal-card h3 {
  color: var(--grey-dark);
  margin-bottom: 10px;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.login-card h1 {
  font-size: 1.5rem;
  margin-bottom: var(--space-xs);
}

.login-card .subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: var(--space-xl);
}

/* ── LAYOUT: SIDEBAR + MAIN ── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar-brand {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sidebar-brand-icon {
  width: 40px;
  height: 40px;
  background: var(--primary-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.sidebar-brand h2 {
  font-size: 1.1rem;
  color: var(--primary);
  white-space: nowrap;
}

.sidebar-brand small {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-md) 0;
}

.sidebar-section {
  padding: var(--space-sm) var(--space-lg);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-top: var(--space-md);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px var(--space-lg);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition-fast);
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.sidebar-link.active {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
  border-left-color: var(--primary);
}

.sidebar-link .icon {
  font-size: 1.15rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-light);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.sidebar-user-info {
  overflow: hidden;
}

.sidebar-user-info .name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.sidebar-user-info .role {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

/* ── MAIN CONTENT ── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── TOP HEADER ── */
/* Merged with main definition above */

.top-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.top-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-main);
  padding: var(--space-xs);
}

.page-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.header-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--grey-light);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-secondary);
  position: relative;
  transition: var(--transition-fast);
}

.header-icon-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  background: var(--danger);
  color: white;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* ── PAGE CONTENT ── */
.page-content {
  flex: 1;
  padding: var(--space-lg);
}

/* ── CARDS ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-light);
}

.card-header h3 {
  font-size: 1.05rem;
}

.card-body { padding: 0; }

/* ── STAT CARDS (Dashboard) ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  transition: var(--transition);
  cursor: default;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.blue { background: var(--info-light); color: var(--info); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }

.stat-info h4 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-info .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.stat-info .stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

.btn-primary {
  background: var(--primary-gradient);
  color: white;
  box-shadow: 0 2px 8px rgba(18,164,28,0.25);
}
.btn-primary:hover {
  background: var(--primary-hover);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(18,164,28,0.35);
}

.btn-secondary {
  background: var(--grey-light);
  color: var(--text-main);
}
.btn-secondary:hover { background: var(--border); color: var(--text-main); }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #c62828; color: white; }

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover {
  background: var(--primary);
  color: white;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.btn-group {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* ── FORMS ── */
.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: var(--space-xs);
}

/* iOS Safari Auto-Zoom Fix */
@media screen and (max-width: 767px) {
  input, select, textarea, .form-control {
    font-size: 16px !important; /* Forces 16px to prevent iOS auto-zoom */
  }
}

.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 16px; /* Lock to 16px to prevent iOS auto-zoom on field focus */
  font-weight: 500;
  color: var(--text-main);
  background: var(--bg-input);
  transition: var(--transition-fast);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(18,164,28,0.1);
}

.form-control::placeholder {
  color: var(--text-muted);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23555' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  font-size: 16px;
}

textarea.form-control {
  min-height: 100px;
  resize: vertical;
  font-size: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
}

.form-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
}

/* ── RESPONSIVE TABLES & GRIDS ── */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: var(--space-md);
  border-radius: var(--radius-lg);
  /* Scrollbar Shadow Indicator */
  background: 
    linear-gradient(to right, white 30%, rgba(255,255,255,0)),
    linear-gradient(to right, rgba(255,255,255,0), white 70%) 0 100%,
    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,0.1), rgba(0,0,0,0)),
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,0.1), rgba(0,0,0,0)) 0 100%;
  background-repeat: no-repeat;
  background-color: white;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}

.table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

.table th, .table td {
  padding: 14px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.table th {
  background: var(--grey-lighter);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.table .actions {
  display: flex;
  gap: var(--space-xs);
}

/* Mobile Optimizations for Tables */
@media (max-width: 767px) {
  .table th, .table td {
    padding: 12px 15px;
    font-size: 0.85rem;
  }
  
  /* Attendance Status Buttons on Mobile */
  .attendance-status-group {
    flex-wrap: wrap !important;
    gap: 5px !important;
  }
  
  .option-item {
    padding: 6px 10px !important;
    font-size: 0.75rem !important;
  }
}

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: #e65100; }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }

/* ── ALERTS ── */
.alert {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  animation: slideDown 0.3s ease;
}

.alert-success { background: var(--success-light); color: #1b5e20; border-left: 4px solid var(--success); }
.alert-danger { background: var(--danger-light); color: #b71c1c; border-left: 4px solid var(--danger); }
.alert-warning { background: var(--warning-light); color: #e65100; border-left: 4px solid var(--warning); }
.alert-info { background: var(--info-light); color: #0d47a1; border-left: 4px solid var(--info); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-overlay);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.9) translateY(20px);
  transition: var(--transition);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
  font-size: 1.1rem;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--grey-light);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.modal-close:hover {
  background: var(--danger-light);
  color: var(--danger);
}

.modal-body {
  padding: var(--space-lg);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-light);
}

/* ── PAGINATION ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-lg) 0;
}

.page-btn {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: var(--transition-fast);
}

.page-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.page-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ── TABS ── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: var(--space-lg);
  overflow-x: auto;
}

.tab-btn {
  padding: 10px 20px;
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-fast);
}

.tab-btn:hover {
  color: var(--primary);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* ── PAYMENT CARD ── */
.payment-card {
  background: linear-gradient(135deg, #f0fff0 0%, #FFFAF4 100%);
  border: 2px dashed var(--primary);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  text-align: center;
}

.payment-card .upi-id {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  background: white;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  display: inline-block;
  margin: var(--space-md) 0;
  letter-spacing: 0.5px;
}

.payment-card .amount {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-main);
}

.payment-card .note-field {
  background: var(--warning-light);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: #e65100;
  margin: var(--space-md) 0;
}

.copy-btn {
  background: var(--grey-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  font-family: var(--font-main);
}

.copy-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* ── EXAM TIMER ── */
.exam-timer {
  position: sticky;
  top: var(--header-height);
  z-index: 40;
  background: white;
  border-bottom: 1px solid var(--border);
  padding: var(--space-sm) var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.timer-display {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.timer-display.warning { color: var(--warning); }
.timer-display.danger { color: var(--danger); animation: pulse 1s infinite; }

/* ── QUESTION CARD ── */
.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
}

.question-card .q-number {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
}

.question-card .q-text {
  font-size: 1rem;
  font-weight: 600;
  margin: var(--space-sm) 0 var(--space-md);
}

.option-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.option-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.option-item.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: var(--space-2xl);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.4;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ── GRID LAYOUTS ── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-md);
}

@media (max-width: 600px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-md);
}

/* ── COURSE CARD ── */
.course-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition);
}

.course-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.course-card-thumb {
  height: 160px;
  background: linear-gradient(135deg, var(--primary-light), #c8e6c9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--primary);
}

.course-card-body {
  padding: var(--space-md);
}

.course-card-body h4 {
  font-size: 1rem;
  margin-bottom: var(--space-xs);
}

.course-card-body .meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.course-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid var(--border-light);
}

.course-card-footer .price {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}

/* ── PROGRESS BAR ── */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--grey-light);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* ── SYLLABUS BUILDER ── */
.module-item {
  border: 2px solid var(--border);
  margin: 0 20px 20px;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  transition: var(--transition);
}

.module-item:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-sm);
}

.topic-list {
  padding-left: 20px;
}

.topic-item {
  background: var(--grey-lighter);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  transition: var(--transition-fast);
}

.topic-item:hover {
  background: var(--primary-light);
  transform: translateX(4px);
}

@media (max-width: 600px) {
  .module-item {
    margin: 0 0 15px;
    padding: 15px;
  }
  
  .topic-list {
    padding-left: 10px;
  }
  
  .topic-item {
    padding: 10px;
  }
}

/* ── EXAM MODE ── */
.proctor-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  height: auto !important;
  min-height: 60px;
  padding: 10px 15px !important;
}

@media (max-width: 480px) {
  .proctor-bar {
    flex-direction: column;
    align-items: stretch !important;
    gap: 5px;
  }
  
  .proctor-bar > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  #examForm {
    margin-top: 130px !important;
  }
}

.question-card {
  padding: 15px !important;
  border-radius: 10px !important;
}

.question-card .q-text {
  font-size: 1rem !important;
}

.option-item {
  padding: 10px 14px !important;
  font-size: 0.9rem !important;
}

/* ── CHECKBOX LISTS ── */
.checkbox-list {
  background: var(--grey-lighter);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 8px;
  overflow-y: auto;
  max-height: 200px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.checkbox-item:hover {
  background: var(--primary-light);
}

.checkbox-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.checkbox-item label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-dark);
  cursor: pointer;
  margin-bottom: 0;
}

/* ── CHAT COMPOSER ── */
@media (max-width: 480px) {
  #chatForm .d-flex {
    flex-wrap: wrap;
    gap: 8px !important;
  }
  
  #chatInput {
    order: -1;
    width: 100% !important;
    flex: none !important;
  }
  
  #chatForm .btn-primary {
    flex: 1;
  }
}

/* ── ANIMATIONS ── */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── SIDEBAR OVERLAY (MOBILE) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-overlay);
  z-index: 99;
}

/* ── MODAL SCROLLING ── */
.modal-body.scrollable {
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 5px;
}
.modal-body.scrollable::-webkit-scrollbar { width: 4px; }
.modal-body.scrollable::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* ── CHECKBOX LIST ── */
.checkbox-list {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  max-height: 250px;
  overflow-y: auto;
  background: var(--grey-lighter);
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  cursor: pointer;
}
.checkbox-item:hover { background: var(--bg-card); }
.checkbox-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}
.checkbox-item label { margin: 0; cursor: pointer; flex: 1; font-size: 0.9rem; }

.search-wrapper { position: relative; margin-bottom: 10px; }
.search-wrapper i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-wrapper input { padding-left: 35px; }

/* ── UTILITY ── */
.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-md); }
.mt-3 { margin-top: var(--space-lg); }
.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space-md); }
.mb-3 { margin-bottom: var(--space-lg); }
.p-2 { padding: var(--space-md); }
.p-3 { padding: var(--space-lg); }
.gap-1 { gap: var(--space-sm); }
.gap-2 { gap: var(--space-md); }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

@media (max-width: 500px) {
  .justify-between.align-center:not(.no-stack) {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
  }
  .justify-between.align-center:not(.no-stack) > .text-right {
    text-align: left;
  }
}
.hidden { display: none !important; }

.search-box {
  position: relative;
}

.search-box input {
  padding-left: 38px;
}

.search-box .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── TOUCH TARGETS (MOBILE ACCESSIBILITY) ── */
.btn, .tab-btn, .page-btn, .header-icon-btn, .sidebar-link, .option-item {
  min-height: 44px;
}

.btn-sm {
  min-height: 36px;
}

/* ── EXAM PROCTORING STYLES ── */
.proctor-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  color: white;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.proctor-bar .violations {
  display: flex;
  align-items: center;
  gap: 6px;
}

.proctor-bar .violations .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  transition: background 0.3s;
}

.proctor-bar .violations .dot.warn { background: var(--warning); }
.proctor-bar .violations .dot.danger { background: var(--danger); }

.proctor-warning-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(229,57,53,0.95);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: white;
  font-family: var(--font-main);
}

.proctor-warning-overlay.active {
  display: flex;
}

.proctor-warning-overlay .warning-content {
  max-width: 400px;
}

.proctor-warning-overlay h2 {
  font-size: 1.8rem;
  margin-bottom: 10px;
}

.proctor-warning-overlay p {
  font-size: 1.1rem;
  opacity: 0.9;
  margin-bottom: 20px;
}

.proctor-warning-overlay button {
  padding: 12px 32px;
  background: white;
  color: var(--danger);
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-main);
}

/* Fullscreen exam body */
body.exam-mode {
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

body.exam-mode .sidebar,
body.exam-mode .sidebar-overlay,
body.exam-mode .top-header {
  display: none !important;
}

body.exam-mode .main-content {
  margin-left: 0;
}

body.exam-mode .page-content {
  padding-top: 60px;
}

/* ── RESPONSIVE: Large Desktop (1280px+) ── */
@media (min-width: 1280px) {
  .page-content {
    max-width: 1200px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ── RESPONSIVE: Small Desktop / Large Tablet (1024px) ── */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── RESPONSIVE: Tablet (768px) ── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.active {
    transform: translateX(0) !important;
  }
  
  .sidebar-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 95;
    display: none;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }

  .sidebar-overlay.active {
    display: block;
  }

  .main-content {
    margin-left: 0;
  }

  .menu-toggle {
    display: block;
  }

  .page-content {
    padding: var(--space-md);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-card {
    padding: var(--space-md);
  }

  .stat-info .stat-value {
    font-size: 1.4rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }

  .card {
    padding: var(--space-md);
    border-radius: var(--radius-md);
  }

  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.15rem; }
  h3 { font-size: 1.05rem; }

  /* Table → Card on mobile */
  .table-mobile-cards thead {
    display: none;
  }

  .table-mobile-cards tbody tr {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
  }

  .table-mobile-cards tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.85rem;
  }

  .table-mobile-cards tbody td:last-child {
    border-bottom: none;
  }

  .table-mobile-cards tbody td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-right: 12px;
  }

  .table th, .table td {
    padding: 10px 8px;
    font-size: 0.82rem;
  }

  .modal {
    max-width: 100%;
    max-height: 90vh; /* Keep some space for overlay click */
    margin: 20px auto;
    border-radius: var(--radius-lg);
    overflow-y: auto; /* Scroll the modal, not the background */
  }

  .modal-body {
    max-height: calc(90vh - 120px); /* Adjust for header/footer */
    overflow-y: auto;
  }

  .btn-group {
    flex-direction: column;
  }

  .btn-block-mobile {
    width: 100% !important;
  }

  .login-card {
    padding: var(--space-lg);
  }

  .tabs {
    gap: 0;
    -webkit-overflow-scrolling: touch;
  }

  .tab-btn {
    padding: 10px 14px;
    font-size: 0.82rem;
  }

  .exam-timer {
    flex-direction: column;
    gap: 4px;
    text-align: center;
  }

  .course-card-thumb {
    height: 120px;
  }

  .payment-card .upi-id {
    font-size: 1rem;
    word-break: break-all;
  }

  .proctor-bar {
    font-size: 0.78rem;
    padding: 6px 12px;
  }
}

/* ── RESPONSIVE: Large Mobile (481px–768px) ── */
@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    flex-direction: row;
    gap: var(--space-md);
  }

  .d-flex.justify-between {
    flex-direction: column;
    align-items: flex-start !important;
    gap: var(--space-sm);
  }

  .d-flex.justify-between > .d-flex {
    width: 100%;
  }

  .actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ── RESPONSIVE: Small Phone (≤480px) ── */
@media (max-width: 480px) {
  :root {
    --space-lg: 14px;
    --space-xl: 20px;
  }

  .top-header {
    padding: 0 var(--space-md);
    height: 52px;
  }

  .page-title {
    font-size: 0.95rem;
  }

  .page-content {
    padding: var(--space-sm);
  }

  h1 { font-size: 1.2rem; }

  .card {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .btn {
    padding: 10px 16px;
    font-size: 0.85rem;
  }

  .btn-lg {
    padding: 12px 20px;
    font-size: 0.95rem;
  }

  .form-control {
    padding: 10px 12px;
    font-size: 0.88rem;
  }

  .payment-card {
    padding: var(--space-md);
  }

  .payment-card .amount {
    font-size: 1.5rem;
  }

  .question-card {
    padding: var(--space-md);
  }

  .option-item {
    padding: 10px 12px;
    font-size: 0.88rem;
  }

  .login-card {
    padding: var(--space-md);
  }

  .login-card h1 {
    font-size: 1.3rem;
  }

  .empty-state {
    padding: var(--space-lg);
  }

  .empty-state .icon {
    font-size: 2.2rem;
  }

  .pagination {
    flex-wrap: wrap;
  }

  .page-btn {
    padding: 8px 10px;
    font-size: 0.8rem;
  }

  .badge {
    font-size: 0.68rem;
    padding: 2px 8px;
  }

  .sidebar-brand h2 {
    font-size: 1rem;
  }

  .timer-display {
    font-size: 1.2rem;
  }
}

/* ── iOS PWA SAFE AREA ── */
@supports (padding-top: env(safe-area-inset-top)) {
  .top-header {
    padding-top: env(safe-area-inset-top);
  }

  .sidebar {
    padding-top: env(safe-area-inset-top);
  }

  .proctor-bar {
    padding-top: env(safe-area-inset-top);
  }

  body.exam-mode .page-content {
    padding-top: calc(60px + env(safe-area-inset-top));
  }

  .page-content {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ── iOS INPUT ZOOM FIX ── */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
  select.form-control,
  textarea.form-control,
  input.form-control {
    font-size: 16px;
  }
}

/* ── OVERFLOW SAFETY ── */
html {
  overflow-x: hidden;
}

.table-responsive {
  -webkit-overflow-scrolling: touch;
}

img, video, iframe {
  max-width: 100%;
  height: auto;
}

/* ── HOVER EFFECTS (DESKTOP ONLY) ── */
@media (hover: hover) and (pointer: fine) {
  .stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
  }

  .course-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
  }

  .sidebar-link:hover {
    background: var(--primary-light);
    color: var(--primary);
  }
}

/* Disable hover transforms on touch */
@media (hover: none) {
  .stat-card:hover,
  .course-card:hover {
    transform: none;
  }
}

/* ── UI PRINT SYSTEM v1.0 ── */
@media print {
  /* Hide all non-essential UI */
  .sidebar, .top-header, .menu-toggle, .btn, .pagination,
  .proctor-bar, .sidebar-overlay, .modal-close, #pwaRefreshBtn, 
  #wfInstallBtn, .no-print {
    display: none !important;
  }

  /* Force premium output appearance */
  html, body {
    background: #fff !important;
    color: #000 !important;
    height: auto !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Expand main content to full width */
  .app-layout { display: block !important; }
  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }
  .page-content { padding: 0 !important; }

  /* Perfect Card Printing */
  .card, .certificate, .id-card {
    box-shadow: none !important;
    border: none !important;
    margin: 0 auto !important;
    page-break-inside: avoid;
  }

  /* Hiding Browser Headers (Best effort via @page) */
  @page {
    margin: 0.5cm;
    size: auto;
  }
}
/* ── PREMIUM MODAL & PERFECT UI ── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-overlay);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  padding: 20px;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg-card);
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: var(--space-lg);
  background: linear-gradient(to right, #ffffff, var(--primary-light));
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-tabs {
  display: flex;
  background: var(--grey-lighter);
  padding: 5px;
  border-bottom: 1px solid var(--border);
}

.modal-tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  transition: var(--transition-fast);
}

.modal-tab.active {
  background: white;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.modal-body {
  padding: var(--space-lg);
  overflow-y: auto;
  flex: 1;
  max-height: calc(90vh - 120px); /* Internal scrolling for long content */
}

.modal-section { display: none; }
.modal-section.active { display: block; }

/* Perfect UI - Custom File Upload Zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  background: var(--grey-lighter);
}

.upload-zone:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-zone input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-zone i {
  font-size: 2.5rem;
  color: var(--primary);
  margin-bottom: 15px;
  display: block;
}

.upload-zone .zone-label {
  font-weight: 700;
  display: block;
  margin-bottom: 5px;
}

.upload-zone .zone-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Syllabus Builder UI */
.syllabus-builder {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}

.module-item {
  background: var(--grey-lighter);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  padding: var(--space-md);
}

.topic-item {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: var(--space-sm);
  padding: 10px;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
/* ── SECURE UPLOAD MODAL ── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 450px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
  overflow: hidden;
  animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.modal-header h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  margin: 0;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body {
  padding: 25px;
}

.upload-area {
  border: 2px dashed rgba(18, 164, 28, 0.3);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: rgba(18, 164, 28, 0.02);
}

.upload-area:hover {
  background: rgba(18, 164, 28, 0.05);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.upload-area i {
  color: var(--primary);
  margin-bottom: 10px;
}

.upload-area p {
  font-size: 0.9rem;
  font-weight: 600;
}

.upload-area span {
  color: var(--primary);
  text-decoration: underline;
}

/* ── PROGRESS BAR ── */
.progress-bar-wrap {
  height: 8px;
  background: var(--grey-lighter);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 5px;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--primary-gradient);
  border-radius: 4px;
  transition: width 0.3s ease;
  position: relative;
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0.3) 50%,
    rgba(255,255,255,0) 100%
  );
  animation: progressPulse 1.5s infinite;
}

@keyframes progressPulse {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ── MEDIA ICON DECORATORS ── */
.topic-item .topic-icon.pdf { color: #f44336; }
.topic-item .topic-icon.video { color: #2196f3; }
.topic-item .topic-icon.zip { color: #ffc107; }
.topic-item .topic-icon.image { color: #4caf50; }
.topic-item .topic-icon.quiz { color: #9c27b0; }

/* ── Assignment UI v13 (Premium) ── */
.card-assignment {
    transition: transform 0.2s, box-shadow 0.2s;
    background: var(--card-bg);
    overflow: hidden;
}
.card-assignment:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.08);
}
.assignment-details {
    border: 1px solid var(--border-light);
}
.instructions-content {
    white-space: pre-wrap;
    color: var(--text-dark);
}

/* Mobile Assignment Refinements */
@media (max-width: 600px) {
  .card .d-flex.justify-between.align-center.flex-wrap {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }
  
  .card .d-flex.gap-1.align-center {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  
  .card .btn-sm {
    flex-grow: 1;
    text-align: center;
  }
}

.uploader-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}
@media (max-width: 600px) { .uploader-grid { grid-template-columns: 1fr; } }

.custom-file-input {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}
.custom-file-input input[type="file"] {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}
.file-trigger {
    display: block;
    padding: 12px;
    background: rgba(18, 164, 28, 0.1);
    color: var(--primary);
    border: 2px dashed var(--primary);
    border-radius: 10px;
    text-align: center;
    font-weight: 700;
    transition: all 0.2s;
}
.file-trigger.variant-images {
    background: rgba(30, 60, 255, 0.05);
    color: #1e3cff;
    border-color: #1e3cff;
}
.file-trigger:hover {
    background: var(--primary);
    color: #fff;
}
.file-trigger.variant-images:hover {
    background: #1e3cff;
    color: #fff;
}

.gallery-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 10px;
}
.gallery-preview-item {
    aspect-ratio: 1/1;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border-light);
    background: #000;
}
.gallery-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.feedback-box {
    border-left: 4px solid var(--success);
}

/* ── BIG SCREEN / ULTRA-WIDE OPTIMIZATIONS ── */
@media screen and (min-width: 1440px) {
    :root {
        --space-lg: 28px;
        --space-xl: 40px;
    }

    .main-content {
        max-width: 100%; /* Restore 100% width as default */
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        gap: var(--space-lg);
    }

    .grid-2 {
        gap: var(--space-xl);
    }

    .stat-card {
        padding: var(--space-xl);
    }

    .stat-info .stat-value {
        font-size: 2.1rem;
    }
}

@media screen and (min-width: 1800px) {
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    }
}

/* Fix for sidebar scrolling on smaller laptops while keeping it fixed */
@media screen and (max-height: 700px) {
    .sidebar-brand { padding: var(--space-md); }
    .sidebar-section { margin-top: var(--space-sm); }
    .sidebar-link { padding: 8px var(--space-lg); }
}

/* ── RESPONSIVE TABLE FIX FOR LOCKED MOBILE ZOOM ── */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y; /* Explicitly allow swipe physics */
    border-radius: var(--radius-md);
    background: transparent;
    position: relative;
    box-shadow: inset -10px 0 10px -10px rgba(0,0,0,0.1); /* Subtle right-side shadow */
}

.table-responsive table {
    width: 100%;
    min-width: 650px; /* Forces horizontal scroll on mobile bounds */
    margin-bottom: 0;
}

/* Add gradient fade mask indicator on mobile to hint at scrollability */
@media (max-width: 768px) {
    .table-responsive {
        /* CSS native scroll shadow hints */
        background: 
            linear-gradient(to right, white 30%, rgba(255,255,255,0)),
            linear-gradient(to right, rgba(255,255,255,0), white 70%) 100% 0,
            radial-gradient(farthest-side at 0 50%, rgba(0,0,0,0.06), rgba(0,0,0,0)),
            radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,0.06), rgba(0,0,0,0)) 100% 0;
        background-repeat: no-repeat;
        background-color: white;
        background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
        background-attachment: local, local, scroll, scroll;
    }
}

/* ── BATCH CHAT PREMIUM UI ── */
.chat-container { display: flex; flex-direction: column; gap: 12px; }
.chat-msg-wrapper { display: flex; flex-direction: column; width: 100%; transition: var(--transition); animation: chatFadeIn 0.3s ease-out; }
@keyframes chatFadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.chat-msg-item {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    position: relative;
    font-size: 0.95rem;
    line-height: 1.5;
    box-shadow: var(--shadow-sm);
    margin-bottom: 4px;
}

/* Others (Left) */
.chat-msg-wrapper.chat-other { align-items: flex-start; }
.chat-msg-wrapper.chat-other .chat-msg-item {
    background: #ffffff;
    color: var(--text-main);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

/* Me (Right) */
.chat-msg-wrapper.chat-own { align-items: flex-end; }
.chat-msg-wrapper.chat-own .chat-msg-item {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(18, 164, 28, 0.2);
}
.chat-msg-wrapper.chat-own .chat-link { color: #dcfce7; }
.chat-msg-wrapper.chat-own .text-muted { color: rgba(255,255,255,0.7) !important; }

.chat-meta { font-size: 0.72rem; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; font-weight: 600; }
.chat-other .chat-meta { color: var(--text-muted); padding-left: 4px; }
.chat-own .chat-meta { color: var(--text-muted); flex-direction: row-reverse; padding-right: 4px; }

.chat-teacher-badge {
    background: var(--primary);
    color: white;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
}
.chat-own .chat-teacher-badge { background: white; color: var(--primary); }

.chat-scroll-indicator {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    padding: 6px 14px;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 700;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}
.chat-scroll-indicator.active { opacity: 1; pointer-events: auto; bottom: 90px; }

.chat-img-preview { cursor: pointer; transition: var(--transition); }
.chat-img-preview:hover { filter: brightness(0.9); }

/* ── REPLY UI ── */
#replyBar {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: var(--grey-lighter);
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}
#replyBar.reply-bar-active {
    display: flex;
}
#replyBar .reply-content {
    display: flex;
    flex-direction: column;
}
#replyBar .reply-content small {
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 700;
}
#replyBar .reply-text {
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}
#replyBar button {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
}
.msg-reply-preview {
    background: rgba(0,0,0,0.05);
    border-left: 3px solid var(--primary);
    padding: 6px 10px;
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 0.8rem;
    cursor: pointer;
}
.own .msg-reply-preview {
    background: rgba(255,255,255,0.2);
    border-left-color: white;
}
.msg-reply-preview .reply-sender {
    font-weight: 700;
    margin-bottom: 2px;
}
.own .msg-reply-preview .reply-sender {
    color: white;
}
.other .msg-reply-preview .reply-sender {
    color: var(--primary);
}
.msg-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    padding: 4px;
}
.msg-bubble-wrapper:hover .msg-action-btn {
    opacity: 1;
}
.msg-document {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 10px;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-main);
    transition: var(--transition);
}
.own .msg-document {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.3);
    color: white;
}
.msg-document:hover {
    background: var(--grey-light);
}
.own .msg-document:hover {
    background: rgba(255,255,255,0.2);
}
.msg-document div {
    flex: 1;
    line-height: 1.2;
}
.msg-document b {
    font-size: 0.9rem;
    word-break: break-all;
}
.msg-document small {
    font-size: 0.75rem;
    opacity: 0.8;
}
.msg-document .material-symbols-outlined {
    font-size: 24px;
}
.msg-video {
    max-width: 100%;
    border-radius: var(--radius-md);
    margin-top: 5px;
    background: #000;
}
.msg-image {
    max-width: 100%;
    border-radius: var(--radius-md);
    margin-top: 5px;
    cursor: pointer;
}
.msg-audio-custom {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    padding: 8px 16px 8px 12px;
    border-radius: 99px;
    margin-top: 5px;
    width: 260px;
}
.own .msg-audio-custom {
    background: rgba(255,255,255,0.1);
}
.msg-audio-custom .audio-play-btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}
.own .msg-audio-custom .audio-play-btn {
    background: white;
    color: var(--primary);
}
.msg-audio-custom .audio-play-btn:hover {
    transform: scale(1.05);
}
.msg-audio-custom .audio-track {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.msg-audio-custom .audio-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(0,0,0,0.1);
    border-radius: 2px;
    outline: none;
    margin: 8px 0;
    cursor: pointer;
    background-image: linear-gradient(var(--primary), var(--primary));
    background-size: 0% 100%;
    background-repeat: no-repeat;
}
.own .msg-audio-custom .audio-slider {
    background-color: rgba(255,255,255,0.3);
    background-image: linear-gradient(white, white);
}
.msg-audio-custom .audio-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.own .msg-audio-custom .audio-slider::-webkit-slider-thumb {
    background: white;
}
.msg-audio-custom .audio-time {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1;
}
.own .msg-audio-custom .audio-time {
    color: rgba(255,255,255,0.8);
}
.msg-audio-custom .audio-speed-btn {
    background: rgba(0,0,0,0.05);
    color: var(--text-color);
    border: none;
    border-radius: 12px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}
.own .msg-audio-custom .audio-speed-btn {
    background: rgba(255,255,255,0.2);
    color: white;
}
.msg-audio-custom .audio-speed-btn:hover {
    background: rgba(0,0,0,0.1);
}
.own .msg-audio-custom .audio-speed-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* ── TABLE RESPONSIVENESS ── */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
    color: var(--text-main);
}

.table th, .table td {
    padding: 12px 15px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
    white-space: nowrap;
}

.table thead th {
    background-color: var(--grey-light);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.table tbody tr:hover {
    background-color: #fafafa;
}

@media (max-width: 767px) {
    .table th, .table td {
        padding: 10px;
        font-size: 0.85rem;
    }
    
    .table-responsive {
        border-radius: var(--radius-md);
        box-shadow: inset -10px 0 10px -10px rgba(0,0,0,0.1);
    }
}

/* ── ADDITIONAL MOBILE OPTIMIZATIONS ── */
@media (max-width: 576px) {
    .container, .container-fluid {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    .card {
        border-radius: var(--radius-md);
    }
    
    .btn-sm {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    /* Avoid text overflow in flex items */
    .d-flex {
        min-width: 0;
    }
}
