@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800&family=Tajawal:wght@400;500;700;800&display=swap');

:root {
  /* Bright Modern SaaS Theme */
  --bg-color: #f8fafc; /* Light Slate */
  --bg-secondary: #ffffff; /* White */
  
  --primary-color: #2563eb; /* Blue 600 */
  --primary-glow: rgba(37, 99, 235, 0.2);
  
  --secondary-color: #f97316; /* Orange 500 */
  --accent-color: #22c55e; /* Green 500 */
  
  --text-main: #0f172a; /* Slate 900 */
  --text-muted: #64748b; /* Slate 500 */
  
  --glass-bg: rgba(255, 255, 255, 0.9);
  --glass-border: rgba(0, 0, 0, 0.08); /* Light subtle border */
  --blur: 15px;
  
  --transition-speed: 0.3s;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Tajawal', 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: hidden;
  background-image: radial-gradient(circle at top right, rgba(37, 99, 235, 0.05), transparent 40%),
                    radial-gradient(circle at bottom left, rgba(249, 115, 22, 0.05), transparent 40%);
  background-attachment: fixed;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Cairo', 'Outfit', sans-serif;
  font-weight: 800;
  margin-bottom: 1rem;
  color: var(--text-main);
}

a {
  text-decoration: none;
  color: inherit;
  transition: color var(--transition-speed);
}

.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03); /* Lighter shadow */
  transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.glass-panel:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08), 0 0 15px var(--primary-glow);
  border-color: rgba(37, 99, 235, 0.1); /* Primary slight border on hover */
}

.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-speed);
  border: none;
  font-family: 'Tajawal', sans-serif;
  letter-spacing: 0.5px;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
  box-shadow: 0 4px 10px var(--primary-glow);
}

.btn-primary:hover {
  background: #1d4ed8; /* Blue 700 */
  transform: scale(1.02);
  box-shadow: 0 6px 15px rgba(29, 78, 216, 0.3);
}

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

.btn-outline:hover {
  background: var(--primary-color);
  color: white;
}

/* Header & Nav */
header {
  padding: 1.5rem 5%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(15px);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.logo {
  font-family: 'Cairo', sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary-color);
}

nav ul {
  display: flex;
  list-style: none;
  gap: 2rem;
}

nav a {
  font-weight: 600;
  color: var(--text-main);
}

nav a:hover {
  color: var(--primary-color);
}

/* Hero Section */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5%;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-content {
  max-width: 800px;
  z-index: 2;
}

.hero-title {
  font-size: 4rem;
  line-height: 1.2;
  margin-bottom: 1.5rem;
  color: var(--text-main);
  animation: float 6s ease-in-out infinite;
}

.hero-title span {
  color: var(--primary-color);
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
}

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

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

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

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text-main);
  font-family: 'Tajawal', sans-serif;
  font-weight: 500;
  transition: all var(--transition-speed);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  background: #ffffff;
}

/* Dashboard Layout */
.dashboard-container {
  display: flex;
  min-height: 100vh;
  padding-top: 80px; /* Header offset */
}

.sidebar {
  width: 280px;
  background: var(--glass-bg);
  border-right: 1px solid var(--glass-border);
  padding: 2rem 1rem;
  position: fixed;
  height: calc(100vh - 80px);
  overflow-y: auto;
}

.sidebar-menu {
  list-style: none;
}

.sidebar-menu li {
  margin-bottom: 0.5rem;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 600;
  transition: all var(--transition-speed);
}

.sidebar-menu a:hover, .sidebar-menu a.active {
  background: rgba(37, 99, 235, 0.08);
  color: var(--primary-color);
  transform: translateX(5px);
}

.sidebar-menu i {
  margin-right: 10px;
  font-size: 1.2rem;
}

.main-content {
  flex: 1;
  margin-left: 280px;
  padding: 2rem 5%;
}

/* Gamification Elements */
.level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  font-weight: bold;
  font-size: 1.2rem;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.4);
}

.xp-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 10px;
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  width: 65%; /* Dynamic */
  border-radius: 4px;
}

/* Flashcards */
.flashcard-container {
  perspective: 1000px;
  width: 100%;
  max-width: 400px;
  height: 250px;
  margin: 0 auto 2rem;
  cursor: pointer;
}

.flashcard {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.flashcard-container.flipped .flashcard {
  transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border-radius: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
  font-size: 1.25rem;
}

.flashcard-front {
  color: var(--text-main);
}

.flashcard-back {
  background: var(--primary-color);
  color: #ffffff;
  border-color: var(--primary-color);
  transform: rotateY(180deg);
}

/* Quizzes */
.quiz-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 1rem;
  margin-bottom: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.quiz-option:hover {
  background: rgba(37, 99, 235, 0.02);
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.quiz-option.selected {
  background: rgba(37, 99, 235, 0.08);
  border-color: var(--primary-color);
}

/* Grid Layouts */
.grid {
  display: grid;
  gap: 2rem;
}

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

@media (max-width: 768px) {
  .hero-title { font-size: 2.5rem; }
  .grid-cols-2, .grid-cols-3 { grid-template-columns: 1fr; }
  .dashboard-container { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; border-right: none; border-bottom: 1px solid var(--glass-border); margin-bottom: 1rem; }
  .main-content { margin-left: 0; padding-top: 0; }
}

/* RTL Support */
[dir='rtl'] body {
    direction: rtl;
}

[dir='rtl'] .btn-outline {
    margin-right: 0 !important;
    margin-left: 10px;
}

[dir='rtl'] .sidebar-menu a i {
    margin-right: 0;
    margin-left: 10px;
}

[dir='rtl'] .main-content {
    margin-left: 0;
    margin-right: 280px;
}

@media (max-width: 768px) {
    [dir='rtl'] .main-content {
        margin-right: 0;
    }
}

/* Form Fixes */
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-muted);
    text-align: left;
}

[dir='rtl'] .form-group label {
    text-align: right;
}

[dir='rtl'] .form-group {
    text-align: right;
}

[dir='rtl'] .sidebar {
    right: 0;
    left: auto;
    border-right: none;
    border-left: 1px solid var(--glass-border);
}

[dir='rtl'] input, [dir='rtl'] textarea {
    text-align: right;
}

/* Section Text Alignment Fixes */
[dir='rtl'] section {
    direction: rtl;
}

[dir='rtl'] .hero-content, [dir='rtl'] .text-center {
    text-align: center !important;
}
