/**
 * Al Huda Quran Academy - Standalone LMS Design System
 * Clean, Bright, Luminous & Modern (Default: Light Mode)
 * Ultra-Responsive & Subdomain-Ready
 */

/* ==========================================================================
   1. CSS CUSTOM PROPERTIES & THEME PALETTES
   ========================================================================== */
:root {
  /* Default Bright & Pristine Light Mode */
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-muted: #e2e8f0;

  --border-light: #e2e8f0;
  --border-subtle: #cbd5e1;
  --border-accent: rgba(5, 150, 105, 0.25);

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  /* Brand Colors: Vibrant Islamic Emerald & Radiant Gold */
  --color-emerald-50: #ecfdf5;
  --color-emerald-100: #d1fae5;
  --color-emerald-500: #10b981;
  --color-emerald-600: #059669;
  --color-emerald-700: #047857;
  --color-emerald-800: #065f46;

  --color-amber-50: #fffbeb;
  --color-amber-100: #fef3c7;
  --color-amber-500: #f59e0b;
  --color-amber-600: #d97706;
  --color-amber-700: #b45309;

  --color-sky-50: #f0f9ff;
  --color-sky-500: #0ea5e9;
  --color-sky-600: #0284c7;

  --color-rose-50: #fff1f2;
  --color-rose-500: #f43f5e;
  --color-rose-600: #e11d48;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.09), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-emerald: 0 10px 25px -5px rgba(5, 150, 105, 0.2);

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-arabic: 'Amiri', serif;
}

/* Dark Mode Palette (Triggered only when .dark class is added) */
html.dark {
  --bg-main: #0b1120;
  --bg-surface: #131c31;
  --bg-surface-elevated: #1e293b;
  --bg-subtle: #1a2438;
  --bg-muted: #334155;

  --border-light: #1e293b;
  --border-subtle: #334155;
  --border-accent: rgba(16, 185, 129, 0.3);

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;

  --color-emerald-50: rgba(6, 95, 70, 0.35);
  --color-emerald-100: rgba(5, 150, 105, 0.25);
  --color-amber-50: rgba(180, 83, 9, 0.25);
  --color-amber-100: rgba(217, 119, 6, 0.25);
  --color-sky-50: rgba(14, 165, 233, 0.2);
  --color-rose-50: rgba(225, 29, 72, 0.2);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
  --shadow-emerald: 0 10px 25px -5px rgba(16, 185, 129, 0.25);
}

/* ==========================================================================
   2. GLOBAL BASE STYLES & RESET
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  max-width: 100vw;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  position: relative;
  transition: background-color 0.25s ease, color 0.25s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#lms-app {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  min-height: 100vh;
}

.font-arabic {
  font-family: var(--font-arabic);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: var(--bg-subtle);
}
::-webkit-scrollbar-thumb {
  background: var(--color-emerald-600);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-emerald-700);
}

/* ==========================================================================
   3. CARD & SURFACE COMPONENTS
   ========================================================================== */
.lms-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 1rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.lms-card-hover:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-accent);
  transform: translateY(-2px);
}

.lms-surface-elevated {
  background-color: var(--bg-surface-elevated);
}

/* Header & Glassmorphism */
.lms-header-glass {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
}

html.dark .lms-header-glass {
  background: rgba(19, 28, 49, 0.88);
}

/* Badges */
.badge-role-owner {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: #ffffff;
}

.badge-role-teacher {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
}

.badge-role-student {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff;
}

/* Status Badges */
.badge-active {
  background-color: var(--color-emerald-50);
  color: var(--color-emerald-700);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-pending {
  background-color: var(--color-amber-50);
  color: var(--color-amber-700);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-danger {
  background-color: var(--color-rose-50);
  color: var(--color-rose-600);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

/* ==========================================================================
   4. INTERACTIVE BUTTONS & FORM ELEMENTS
   ========================================================================== */
.lms-btn-primary {
  background: linear-gradient(135deg, var(--color-emerald-600) 0%, var(--color-emerald-700) 100%);
  color: #ffffff;
  font-weight: 600;
  border-radius: 0.75rem;
  padding: 0.625rem 1.25rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(5, 150, 105, 0.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  cursor: pointer;
}

.lms-btn-primary:hover {
  background: linear-gradient(135deg, #047857 0%, #065f46 100%);
  box-shadow: var(--shadow-emerald);
  transform: translateY(-1px);
}

.lms-btn-primary:active {
  transform: translateY(0);
}

.lms-btn-secondary {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  font-weight: 600;
  border-radius: 0.75rem;
  padding: 0.625rem 1.25rem;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
}

.lms-btn-secondary:hover {
  background-color: var(--bg-subtle);
  border-color: var(--border-subtle);
}

.lms-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border-light);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: all 0.2s ease;
  outline: none;
}

.lms-input:focus {
  border-color: var(--color-emerald-600);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

html.dark .lms-input {
  background-color: #172238;
}

/* ==========================================================================
   5. PROGRESS BAR & METRIC CARDS
   ========================================================================== */
.lms-progress-bar {
  background-color: var(--bg-subtle);
  border-radius: 9999px;
  overflow: hidden;
  height: 0.5rem;
  width: 100%;
}

.lms-progress-fill {
  background: linear-gradient(90deg, #10b981 0%, #059669 100%);
  height: 100%;
  border-radius: 9999px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   6. CREDENTIAL SLIP & PRINT STYLES
   ========================================================================== */
.credential-slip {
  background: #ffffff;
  color: #0f172a;
  border: 2px dashed #059669;
  border-radius: 1rem;
  padding: 1.5rem;
  position: relative;
  box-shadow: 0 10px 25px rgba(5, 150, 105, 0.1);
}

.credential-slip-header {
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}

.credential-code-box {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

@media print {
  body * {
    visibility: hidden;
  }
  #printable-credential-modal, #printable-credential-modal * {
    visibility: visible;
  }
  #printable-credential-modal {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 20px;
    background: #ffffff !important;
    color: #000000 !important;
  }
  .no-print {
    display: none !important;
  }
}

/* ==========================================================================
   7. TOAST NOTIFICATIONS
   ========================================================================== */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast-msg {
  pointer-events: auto;
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--color-emerald-600);
  border-radius: 0.75rem;
  padding: 0.875rem 1.25rem;
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  max-width: 24rem;
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-msg.toast-error {
  border-left-color: var(--color-rose-500);
}

.toast-msg.toast-info {
  border-left-color: var(--color-sky-500);
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ==========================================================================
   8. RESPONSIVE UTILITIES & MOBILE OPTIMIZATIONS
   ========================================================================== */
.lms-table-responsive {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.lms-table-responsive table {
  min-width: 720px;
}

/* Hide scrollbar for clean horizontal tabs/scrolling on mobile */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Mobile Specific Optimizations */
@media (max-width: 640px) {
  /* Prevent iOS Safari auto-zooming on input focus by setting 16px font-size */
  .lms-input, 
  select.lms-input, 
  textarea.lms-input {
    font-size: 16px !important;
  }

  /* Full-width responsive toast container on mobile */
  #toast-container {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
    align-items: stretch;
  }
  
  .toast-msg {
    max-width: 100%;
    width: 100%;
    padding: 0.75rem 1rem;
  }

  .credential-slip {
    padding: 1rem;
  }

  /* Comfortable touch targets */
  .lms-btn-primary, 
  .lms-btn-secondary {
    min-height: 42px;
    padding: 0.625rem 1rem;
  }

  /* Break words in credential slips to avoid overflow on narrow screens */
  .credential-code-box,
  .credential-slip * {
    word-break: break-word;
    overflow-wrap: break-word;
  }
}

/* ==========================================================================
   9. CUSTOM POPUP MODALS & INPUT VALIDATION SUITE
   ========================================================================== */
@keyframes modalPopIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.lms-modal-card {
  animation: modalPopIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Modern Input Field Error & Feedback States */
.lms-input-error {
  border-color: #f43f5e !important;
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.15) !important;
}

.lms-input-success {
  border-color: #10b981 !important;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15) !important;
}

.lms-field-error {
  font-size: 0.75rem;
  font-weight: 600;
  color: #f43f5e;
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  animation: fadeIn 0.15s ease-in;
}

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

/* Quran Audio Player Widget */
.quran-audio-player {
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.08), rgba(217, 119, 6, 0.08));
  border: 1px solid var(--border-light);
  border-radius: 1rem;
  padding: 1rem 1.25rem;
}

html.dark .quran-audio-player {
  background: linear-gradient(135deg, rgba(6, 95, 70, 0.25), rgba(180, 83, 9, 0.15));
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

.animate-shake {
  animation: shake 0.35s ease-in-out;
}

/* Audio Player Waveform Animation */
.wave-active span {
  animation: wavePulse 1s ease-in-out infinite alternate;
}
.wave-active span:nth-child(2) {
  animation-delay: 0.2s;
}
.wave-active span:nth-child(3) {
  animation-delay: 0.4s;
}
.wave-active span:nth-child(4) {
  animation-delay: 0.6s;
}

@keyframes wavePulse {
  0% { height: 4px; }
  100% { height: 22px; }
}

/* Print Stylesheet for Official Academy Tuition Vouchers & Degree Certificates */
@media print {
  body * {
    visibility: hidden;
  }
  #printable-invoice, #printable-invoice *,
  #printable-certificate, #printable-certificate * {
    visibility: visible;
  }
  #printable-invoice, #printable-certificate {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 20px;
    background: #ffffff !important;
    color: #000000 !important;
    box-shadow: none !important;
  }
  #printable-invoice button, #printable-certificate button {
    display: none !important;
  }
}

/* Certificate Decorative Frame */
.cert-border-gold {
  border: 4px double #d97706;
  outline: 2px solid #059669;
  outline-offset: -10px;
}
.cert-seal {
  background: radial-gradient(circle, #fef3c7 0%, #fde68a 60%, #d97706 100%);
}
.quran-ayah-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-arabic);
  color: #059669;
  margin: 0 4px;
}

.quran-arabic-text {
  font-family: var(--font-arabic);
  direction: rtl;
  text-align: right;
  word-spacing: 2px;
}

.quran-urdu-text {
  font-family: 'Amiri', 'Jameel Noori Nastaleeq', 'Noto Nastaliq Urdu', 'Urdu Typesetting', serif;
  direction: rtl;
  text-align: right;
}

.quran-english-text {
  direction: ltr;
  text-align: left;
}

/* ==========================================================================
   10. MOBILE SIDEBAR DRAWER & ACCESSIBLE FONT SCALING
   ========================================================================== */
/* Typography Scale Suite for Student & Teacher Visualization */
html.ui-font-normal {
  font-size: 15px;
}

html.ui-font-large,
html:not(.ui-font-normal):not(.ui-font-xlarge) {
  font-size: 16.5px;
}

html.ui-font-xlarge {
  font-size: 18px;
}

@media (max-width: 768px) {
  html.ui-font-normal {
    font-size: 14.5px;
  }
  html.ui-font-large,
  html:not(.ui-font-normal):not(.ui-font-xlarge) {
    font-size: 16px;
  }
  html.ui-font-xlarge {
    font-size: 17.5px;
  }
}

/* Mobile Sidebar Drawer Animation & Backdrop */
#lms-mobile-sidebar {
  will-change: transform;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
}

#lms-mobile-sidebar-backdrop {
  will-change: opacity;
}

/* Enhanced Mobile Touch Targets & Inputs */
@media (max-width: 768px) {
  .lms-input,
  select.lms-input,
  textarea.lms-input {
    font-size: 16px !important; /* Prevents unwanted iOS Safari viewport auto-zoom */
  }

  .lms-card {
    border-radius: 0.875rem;
  }

  .lms-modal-card {
    max-height: 92vh !important;
    max-width: calc(100vw - 1.5rem) !important;
    padding: 1.25rem 1rem !important;
  }

  .cert-border-gold {
    padding: 1.25rem 0.875rem !important;
    border-width: 4px !important;
  }

  .credential-slip {
    padding: 1rem !important;
  }
}

/* Zero unwanted scrollbars on background decorative glow circles */
.lms-glow-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}


