/* Premium Design System - Modern & Beautiful */
:root {
  /* Enhanced Premium Color Palette */
  --primary-50: #f0f9ff;
  --primary-100: #e0f2fe;
  --primary-200: #bae6fd;
  --primary-300: #7dd3fc;
  --primary-400: #38bdf8;
  --primary-500: #0ea5e9;
  --primary-600: #0284c7;
  --primary-700: #0369a1;
  --primary-800: #075985;
  --primary-900: #0c4a6e;
  
  /* Neutral Colors */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  
  /* Enhanced Accent Colors */
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #8b5cf6;
  --accent-indigo: #6366f1;
  --accent-pink: #ec4899;
  --accent-orange: #f97316;
  --accent-cyan: #06b6d4;
  
  /* Legacy Accent Colors (for compatibility) */
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --purple-500: #8b5cf6;
  --rose-500: #f43f5e;
  
  /* Enhanced Gradients */
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --gradient-accent: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --gradient-dark: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --gradient-error: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  --gradient-info: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  --gradient-glass: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
  
  /* Typography */
  --font-display: 'Playfair Display', serif;
  --font-sans: 'Inter', sans-serif;
  --font-arabic: 'Cairo', 'Tajawal', 'Noto Sans Arabic', 'Amiri', 'Scheherazade New', 'Noto Naskh Arabic', serif;
  --font-arabic-heading: 'Cairo', 'Tajawal', 'Noto Sans Arabic', 'Amiri', 'Scheherazade New', 'Noto Naskh Arabic', serif;
  --font-arabic-body: 'Cairo', 'Tajawal', 'Noto Sans Arabic', 'Amiri', 'Scheherazade New', 'Noto Naskh Arabic', serif;
  --font-mono: 'Space Grotesk', monospace;
  
  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  
  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-3xl: 2rem;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  --shadow-glow: 0 0 20px rgb(59 130 246 / 0.3);
  
  /* Transitions */
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Dark Mode Variables */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --glass-bg: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.2);
}

/* Dark Mode Theme */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #475569;
  --glass-bg: rgba(0, 0, 0, 0.1);
  --glass-border: rgba(255, 255, 255, 0.1);
}

/* Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 100px; /* Account for fixed header */
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  line-height: 1.6;
  color: var(--gray-900);
}

/* Enhanced Arabic Typography */
[dir="rtl"], .arabic-text {
  font-family: var(--font-arabic);
  direction: rtl;
  text-align: right;
  line-height: 1.8;
  letter-spacing: 0.025em;
  font-feature-settings: "liga" 1, "kern" 1;
  text-rendering: optimizeLegibility;
}

.arabic-text h1, .arabic-text h2, .arabic-text h3, 
.arabic-text h4, .arabic-text h5, .arabic-text h6 {
  font-family: var(--font-arabic-heading);
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.025em;
}

.arabic-text p, .arabic-text span, .arabic-text div {
  font-family: var(--font-arabic-body);
  line-height: 1.7;
  letter-spacing: 0.025em;
}

/* Arabic Headers */
h1[dir="rtl"], h2[dir="rtl"], h3[dir="rtl"], h4[dir="rtl"], h5[dir="rtl"], h6[dir="rtl"],
.arabic-text h1, .arabic-text h2, .arabic-text h3, .arabic-text h4, .arabic-text h5, .arabic-text h6 {
  font-family: var(--font-arabic-heading);
  font-weight: 700;
  line-height: 1.4;
}

/* Arabic Body Text */
p[dir="rtl"], span[dir="rtl"], div[dir="rtl"], li[dir="rtl"],
.arabic-text p, .arabic-text span, .arabic-text div, .arabic-text li {
  font-family: var(--font-arabic-body);
  font-weight: 400;
  line-height: 1.7;
}

/* Arabic Buttons and UI Elements */
button[dir="rtl"], .btn[dir="rtl"], input[dir="rtl"], textarea[dir="rtl"], select[dir="rtl"],
.arabic-text button, .arabic-text .btn, .arabic-text input, .arabic-text textarea, .arabic-text select {
  font-family: var(--font-arabic);
  font-weight: 500;
}

body {
  background: var(--gray-50);
  font-size: 1rem;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* RTL Support */
[dir="rtl"] {
  font-family: var(--font-arabic);
}

[dir="rtl"] .container {
  text-align: right;
}

/* Typography Scale */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--space-4);
  letter-spacing: -0.025em;
  text-rendering: optimizeLegibility;
  font-feature-settings: "liga" 1, "kern" 1;
  color: var(--gray-900);
}

h1 {
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
}

h2 {
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

h3 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

h4 {
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  font-weight: 600;
  letter-spacing: -0.015em;
}

h5 {
  font-size: clamp(1.125rem, 2.5vw, 1.25rem);
  font-weight: 600;
  letter-spacing: -0.01em;
}

h6 {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}

/* Modern Heading Variants */
.modern-heading {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.gradient-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-glow {
  text-shadow: 0 0 20px rgba(14, 165, 233, 0.5);
}

p {
  margin-bottom: var(--space-4);
  color: var(--gray-600);
  font-size: 1.125rem;
  line-height: 1.7;
  font-weight: 400;
}

/* Container */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

@media (min-width: 640px) {
  .container {
    padding: 0 var(--space-6);
  }
}

@media (min-width: 1024px) {
  .container {
    padding: 0 var(--space-8);
  }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border: none;
  border-radius: var(--radius-lg);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition-normal);
  white-space: nowrap;
  min-height: 48px;
  position: relative;
  overflow: hidden;
  letter-spacing: -0.01em;
}

.btn:focus {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: var(--shadow-xl), var(--shadow-glow);
  filter: brightness(1.1);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.9);
  color: var(--gray-700);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.btn-secondary::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 100%;
  background: var(--gradient-primary);
  transition: width 0.3s ease;
  z-index: -1;
}

.btn-secondary:hover::before {
  width: 100%;
}

.btn-secondary:hover {
  color: white;
  border-color: var(--primary-500);
  transform: translateY(-1px) scale(1.01);
  box-shadow: var(--shadow-md);
}

.btn-cta {
  background: var(--gradient-primary);
  color: white;
  padding: var(--space-4) var(--space-8);
  font-size: 1.125rem;
  font-weight: 700;
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-2xl);
  border: 1px solid rgba(255, 255, 255, 0.3);
  position: relative;
  overflow: hidden;
}

.btn-cta::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.btn-cta:hover::before {
  left: 100%;
}

.btn-cta:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: var(--shadow-2xl), var(--shadow-glow);
}

.btn-icon {
  transition: var(--transition-normal);
}

.btn:hover .btn-icon {
  transform: translateX(2px);
}

/* Modern Button Variants */
.btn-glass {
  background: var(--glass-bg);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-glass);
  position: relative;
  overflow: hidden;
}

.btn-glass:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl), var(--shadow-glass);
}

.btn-success {
  background: var(--gradient-success);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: var(--shadow-md);
}

.btn-success:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: var(--shadow-xl);
  filter: brightness(1.1);
}

.btn-warning {
  background: var(--gradient-warning);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: var(--shadow-md);
}

.btn-warning:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: var(--shadow-xl);
  filter: brightness(1.1);
}

.btn-error {
  background: var(--gradient-error);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: var(--shadow-md);
}

.btn-error:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: var(--shadow-xl);
  filter: brightness(1.1);
}

/* Form Elements */
.form-group {
  margin-bottom: var(--space-6);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 600;
  color: var(--gray-700);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-lg);
  font-size: 1rem;
  transition: var(--transition-normal);
  background-color: white;
  font-family: var(--font-sans);
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

.form-group input:invalid {
  border-color: var(--rose-500);
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }

.hidden { display: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

.animate-fade-in {
  animation: fadeIn 0.6s ease-out;
}

.animate-slide-in {
  animation: slideIn 0.6s ease-out;
}

/* Skeleton Loading States */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
}

.skeleton-text:last-child {
  width: 60%;
}

.skeleton-avatar {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
}

.skeleton-card {
  height: 12rem;
  border-radius: var(--radius-lg);
}

.skeleton-button {
  height: 2.5rem;
  width: 8rem;
  border-radius: var(--radius-md);
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Modern Spinner */
.modern-spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid rgba(14, 165, 233, 0.1);
  border-top: 3px solid var(--primary-500);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Pulse Animation */
.pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

/* Enhanced Responsive Design */
@media (max-width: 1024px) {
  .container {
    padding: 0 var(--space-6);
  }
  
  h1 {
    font-size: clamp(2rem, 6vw, 3rem);
  }
  
  h2 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
  }
}

@media (max-width: 768px) {
  .container {
    padding: 0 var(--space-4);
  }
  
  .btn {
    padding: var(--space-3) var(--space-5);
    font-size: 0.9rem;
  }
  
  .btn-cta {
    padding: var(--space-4) var(--space-6);
    font-size: 1rem;
  }
  
  /* Mobile-optimized spacing */
  .section-padding {
    padding: var(--space-8) 0;
  }
  
  /* Touch-friendly button sizes */
  .btn {
    min-height: 44px;
    min-width: 44px;
  }
}

@media (max-width: 640px) {
  .btn {
    padding: var(--space-2) var(--space-4);
    font-size: 0.875rem;
    min-height: 40px;
  }
  
  .btn-cta {
    padding: var(--space-3) var(--space-6);
    font-size: 1rem;
    min-height: 48px;
  }
  
  /* Mobile typography adjustments */
  h1 {
    font-size: clamp(1.75rem, 8vw, 2.5rem);
    line-height: 1.2;
  }
  
  h2 {
    font-size: clamp(1.5rem, 6vw, 2rem);
    line-height: 1.3;
  }
  
  h3 {
    font-size: clamp(1.25rem, 5vw, 1.75rem);
  }
  
  p {
    font-size: 1rem;
    line-height: 1.6;
  }
  
  /* Mobile-optimized cards */
  .course-card {
    margin-bottom: var(--space-4);
  }
  
  /* Mobile navigation improvements */
  .nav-link {
    padding: var(--space-3) var(--space-4);
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 var(--space-3);
  }
  
  /* Extra small screen optimizations */
  .btn {
    padding: var(--space-2) var(--space-3);
    font-size: 0.8rem;
    min-height: 36px;
  }
  
  .btn-cta {
    padding: var(--space-3) var(--space-5);
    font-size: 0.9rem;
    min-height: 44px;
  }
  
  /* Compact spacing for small screens */
  .section-padding {
    padding: var(--space-6) 0;
  }
  
  /* Mobile-first grid adjustments */
  .courses-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .btn:hover {
    transform: none;
  }
  
  .course-card:hover {
    transform: none;
  }
  
  /* Larger touch targets */
  .btn {
    min-height: 48px;
    min-width: 48px;
  }
  
  .nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

/* High DPI display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .course-image,
  .video-thumbnail {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Focus Management */
*:focus {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

button:focus,
input:focus,
a:focus {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  :root {
    --primary-500: #0000FF;
    --gray-900: #000000;
    --gray-600: #333333;
    --gray-200: #000000;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}