:root {
  --primary: #2D6A4F;
  --secondary: #40916C;
  --accent: #D4A017;
  --dark: #1B4332;
  --light: #F1F8F3;
  --bg: #FAFAF7;
  --text: #1A1A1A;
  --text-light: #555555;
  --card-bg: #FFFFFF;
  --border: #E0E0E0;
  --error: #D32F2F;
  --success: #388E3C;
  --info: #1976D2;
  --warning: #F57C00;
  
  --font-ar: 'Cairo', sans-serif;
  --font-en: 'Inter', sans-serif;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 20px rgba(0,0,0,0.15);
  
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --transition: all 0.3s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

html.lang-ar body {
  font-family: var(--font-ar);
}

html.lang-en body {
  font-family: var(--font-en);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--secondary);
}

button {
  cursor: pointer;
  font-family: inherit;
}

ul {
  list-style: none;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--dark);
  margin-bottom: 1rem;
  font-weight: 700;
}

/* Loading */
#loading {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.loading-spinner {
  text-align: center;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Navbar */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 70px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
  z-index: 1000;
  display: flex;
  align-items: center;
}

.navbar-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--dark);
}

.logo i {
  color: var(--primary);
  font-size: 1.5rem;
}

.nav-menu {
  display: flex;
  gap: 1.5rem;
}

.nav-link {
  color: var(--text);
  font-weight: 600;
  padding: 0.5rem;
  position: relative;
}

.nav-link.active {
  color: var(--primary);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--primary);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.lang-switch {
  background: var(--light);
  border: 1px solid var(--border);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 600;
}

.btn {
  padding: 0.5rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--dark);
  color: white;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
}

.btn-outline:hover {
  background: var(--primary);
  color: white;
}

.nav-user {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.notification-bell {
  position: relative;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-light);
}

.badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--error);
  color: white;
  font-size: 0.65rem;
  padding: 2px 5px;
  border-radius: var(--radius-full);
  min-width: 15px;
  text-align: center;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  cursor: pointer;
  user-select: none;
}

.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  overflow: hidden;
  z-index: 1010;
}

html.lang-ar .user-dropdown {
  right: auto;
  left: 0;
}

.dropdown-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.role-badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  display: inline-block;
  align-self: flex-start;
}

.role-owner, .role-admin { background: var(--dark); color: white; }
.role-moderator { background: var(--primary); color: white; }
.role-student { background: var(--secondary); color: white; }

.dropdown-item {
  width: 100%;
  padding: 0.75rem 1rem;
  text-align: right;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.875rem;
}

html.lang-en .dropdown-item {
  text-align: left;
}

.dropdown-item:hover {
  background: var(--light);
}

.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--dark);
}

.mobile-menu {
  display: none;
  position: absolute;
  top: 70px;
  left: 0;
  right: 0;
  background: white;
  box-shadow: var(--shadow-md);
  padding: 1rem;
}

.mobile-menu.active {
  display: block;
}

.mobile-nav-links {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Page Content */
.page-content {
  flex: 1;
  margin-top: 70px;
  min-height: calc(100vh - 70px - 80px); /* 80px footer */
}

/* Footer */
.site-footer {
  background: var(--dark);
  color: white;
  padding: 2rem 1rem;
  text-align: center;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.footer-logo {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--accent);
}

/* Home Page */
.hero {
  background: linear-gradient(135deg, var(--dark), var(--primary));
  color: white;
  padding: 6rem 1rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  opacity: 0.1;
  background-image: url('data:image/svg+xml;utf8,<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><path d="M50 0c27.6 0 50 22.4 50 50s-22.4 50-50 50S0 77.6 0 50 22.4 0 50 0zm0 10c-22.1 0-40 17.9-40 40s17.9 40 40 40 40-17.9 40-40-17.9-40-40-40z" fill="white"/></svg>');
}

.hero-content {
  position: relative;
  max-width: 800px;
  margin: 0 auto;
  animation: slideUp 0.8s ease-out;
}

.hero-title {
  font-size: 3rem;
  color: white;
  margin-bottom: 1rem;
}

.hero-subtitle {
  font-size: 1.5rem;
  color: var(--accent);
  margin-bottom: 2rem;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.btn-accent {
  background: var(--accent);
  color: var(--dark);
  font-weight: 700;
}

.btn-accent:hover {
  background: #E5B220;
}

/* Stats Section */
.stats-section {
  padding: 4rem 1rem;
  background: white;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
}

.stat-card {
  background: var(--light);
  padding: 2rem;
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  font-size: 3rem;
  color: var(--primary);
  margin-bottom: 1rem;
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--dark);
}

.stat-label {
  font-size: 1.125rem;
  color: var(--text-light);
}

/* Section Headers */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border);
}

.section-title {
  font-size: 2rem;
  color: var(--dark);
  margin: 0;
  position: relative;
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: -18px;
  left: 0;
  width: 60px;
  height: 4px;
  background: var(--accent);
  border-radius: 2px;
}
html.lang-ar .section-title::after {
  left: auto;
  right: 0;
}

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
}

.card-img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: var(--light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 3rem;
}

.card-content {
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-meta {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
}

.card-title {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.card-text {
  color: var(--text-light);
  margin-bottom: 1.5rem;
  flex: 1;
}

/* Auth Forms */
.auth-container {
  min-height: calc(100vh - 150px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  overflow: hidden;
  position: relative;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 10px;
  background: var(--primary);
}
html.lang-ar .auth-card::before {
  left: auto;
  right: 0;
}

.auth-header {
  padding: 2rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  text-align: center;
  padding: 1rem;
  cursor: pointer;
  background: var(--light);
  font-weight: 600;
  border-bottom: 2px solid transparent;
}

.auth-tab.active {
  background: white;
  border-bottom-color: var(--primary);
  color: var(--primary);
}

.auth-body {
  padding: 2rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 1rem;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.1);
}

.btn-block {
  width: 100%;
}

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
}

/* Chat Interface */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 70px);
  background: white;
  max-width: 1000px;
  margin: 0 auto;
  box-shadow: var(--shadow-sm);
}

.chat-header {
  padding: 1rem;
  background: var(--light);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.chat-messages {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message {
  max-width: 70%;
  display: flex;
  flex-direction: column;
}

.message.sent {
  align-self: flex-end;
}

.message.received {
  align-self: flex-start;
}

.message-meta {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-bottom: 0.25rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.message-bubble {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-lg);
  position: relative;
  line-height: 1.4;
}

.message.sent .message-bubble {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 0;
}
html.lang-ar .message.sent .message-bubble {
  border-bottom-right-radius: var(--radius-lg);
  border-bottom-left-radius: 0;
}

.message.received .message-bubble {
  background: var(--light);
  color: var(--text);
  border-bottom-left-radius: 0;
}
html.lang-ar .message.received .message-bubble {
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: 0;
}

.chat-input-area {
  padding: 1rem;
  border-top: 1px solid var(--border);
  background: white;
}

.chat-form {
  display: flex;
  gap: 0.5rem;
}

.chat-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-family: inherit;
  resize: none;
}

.chat-input:focus {
  outline: none;
  border-color: var(--primary);
}

.btn-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* Dashboard Sidebar Layout */
.dashboard-layout {
  display: flex;
  min-height: calc(100vh - 70px);
}

.sidebar {
  width: 250px;
  background: var(--dark);
  color: white;
  padding: 1.5rem 0;
  transition: var(--transition);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
}

.sidebar-link {
  padding: 1rem 1.5rem;
  color: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  gap: 1rem;
  border-left: 4px solid transparent;
}
html.lang-ar .sidebar-link {
  border-left: none;
  border-right: 4px solid transparent;
}

.sidebar-link:hover, .sidebar-link.active {
  background: rgba(255,255,255,0.1);
  color: white;
  border-color: var(--accent);
}

.dashboard-content {
  flex: 1;
  padding: 2rem;
  background: var(--bg);
  overflow-y: auto;
}

/* Upload Dropzone */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 3rem;
  text-align: center;
  background: var(--light);
  cursor: pointer;
  transition: var(--transition);
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: #E8F5E9;
}

.dropzone i {
  font-size: 3rem;
  color: var(--primary);
  margin-bottom: 1rem;
}

/* Progress bar */
.progress-container {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 1rem;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.3s ease;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-md);
  overflow: hidden;
}

th, td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
html.lang-ar th, html.lang-ar td {
  text-align: right;
}

th {
  background: var(--light);
  font-weight: 600;
  color: var(--dark);
}

tbody tr:hover {
  background: #FAFAFA;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
html.lang-ar .toast-container {
  right: auto;
  left: 2rem;
}

.toast {
  background: white;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  transform: translateX(100%);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  border-left: 4px solid var(--primary);
}
html.lang-ar .toast {
  transform: translateX(-100%);
  border-left: none;
  border-right: 4px solid var(--primary);
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast-error { border-color: var(--error); }
.toast-success { border-color: var(--success); }
.toast-info { border-color: var(--info); }

.toast button {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-light);
}

/* Empty States */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
}

.empty-state i {
  font-size: 4rem;
  color: var(--border);
  margin-bottom: 1rem;
}

.empty-state p {
  color: var(--text-light);
  font-size: 1.25rem;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1050;
  padding: 1rem;
}

.modal-content {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 1.5rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-light);
}

/* Animations */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Filters */
.filter-bar {
  background: white;
  padding: 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.filter-bar select, .filter-bar input {
  flex: 1;
  min-width: 200px;
}

/* Responsive */
@media (max-width: 768px) {
  .nav-menu, .auth-section-desktop {
    display: none;
  }
  
  .hamburger {
    display: block;
  }
  
  .dashboard-layout {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
  }
  
  .hero-title {
    font-size: 2rem;
  }
  
  .chat-container {
    height: calc(100vh - 70px - 80px);
  }
}

/* Print Styles */
@media print {
  .navbar, .site-footer, .sidebar, .filter-bar {
    display: none !important;
  }
  .page-content, .dashboard-content {
    margin: 0 !important;
    padding: 0 !important;
  }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: #C1C1C1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--secondary);
}

/* Modern Animations & Enhancements */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.fade-in-up {
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animated-bg {
  background: linear-gradient(-45deg, #f1f8f3, #e2f1e8, #cce3d6, #e8f5ec) !important;
  background-size: 400% 400% !important;
  animation: gradientBG 15s ease infinite !important;
}

.auth-container {
  min-height: calc(100vh - 70px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-card.card {
  border: none;
  border-top: 5px solid var(--primary);
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.08);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(15px);
  max-width: 450px;
  width: 100%;
  padding: 2.5rem;
}

.auth-card .form-control {
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(0,0,0,0.1);
  transition: all 0.3s ease;
}

.auth-card .form-control:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.1);
  transform: translateY(-2px);
}

.btn {
  transition: all 0.3s ease;
}
.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.auth-title {
  text-align: center;
  margin-bottom: 2rem;
  font-weight: 800;
  color: var(--dark);
}

/* Responsive Layout Improvements */
@media (max-width: 1024px) {
  .dashboard-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    min-height: auto;
    border-right: none;
    border-bottom: 1px solid rgba(0,0,0,0.1);
  }
  .sidebar-nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 0.5rem;
  }
  .sidebar-link {
    white-space: nowrap;
  }
}

@media (max-width: 768px) {
  .navbar-container {
    padding: 0.5rem 1rem;
  }
  .nav-menu {
    display: none; /* Hidden by default on mobile, shown in mobile-menu */
  }
  .hamburger {
    display: block !important;
  }
  .hero-content {
    padding: 2rem 1.5rem !important;
  }
  .hero-title {
    font-size: 2rem !important;
  }
  .card-grid, .stats-grid {
    grid-template-columns: 1fr !important; /* Stack vertically on small screens */
  }
  .chat-container {
    margin: 1rem;
    height: calc(100vh - 120px);
  }
  .auth-card.card {
    padding: 1.5rem;
  }
}

@media (min-width: 769px) {
  .hamburger {
    display: none !important;
  }
  .card-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
  }
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
  }
}

/* Ensure mobile menu works */
.mobile-menu {
  display: none;
  background: white;
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  z-index: 100;
}
.mobile-menu.active {
  display: block;
}
.mobile-nav-links {
  list-style: none;
  padding: 0;
  margin: 0;
}
.mobile-nav-links li {
  border-bottom: 1px solid #eee;
}
.mobile-nav-links li a {
  display: block;
  padding: 1rem;
  color: var(--dark);
  text-decoration: none;
}


[data-theme="dark"] {
  --bg: #121212;
  --card-bg: #1E1E1E;
  --text: #F5F5F5;
  --text-light: #AAAAAA;
  --border: #333333;
  --light: #2A2A2A;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.6);
  --shadow-lg: 0 10px 20px rgba(0,0,0,0.7);
  --primary: #40916C;
  --dark: #2D6A4F;
}

[data-theme="dark"] .navbar-container {
  background: rgba(30, 30, 30, 0.9);
  border-bottom: 1px solid var(--border);
}

[data-theme="dark"] .card, [data-theme="dark"] .modal-content, [data-theme="dark"] .user-dropdown {
  background-color: var(--card-bg);
  color: var(--text);
  border-color: var(--border);
}

[data-theme="dark"] .form-control {
  background-color: #2C2C2C;
  color: var(--text);
  border-color: var(--border);
}

[data-theme="dark"] .form-control:focus {
  background-color: #333333;
}

[data-theme="dark"] table th, [data-theme="dark"] table td {
  border-bottom-color: var(--border);
}

[data-theme="dark"] .sidebar {
  background: #1A1A1A;
  border-right-color: var(--border);
}

[data-theme="dark"] .message-received {
  background: #2C2C2C;
  color: #fff;
}

[data-theme="dark"] .hero-content {
  background: rgba(0, 0, 0, 0.3) !important;
}

.theme-switch {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  margin-right: 1rem;
  margin-left: 1rem;
  transition: color 0.3s;
}
.theme-switch:hover {
  color: var(--primary);
}


/* =============================================
   COMPREHENSIVE MOBILE RESPONSIVE FIX
   ============================================= */

/* Base fixes */
html, body {
  overflow-x: hidden !important;
  width: 100% !important;
}

/* Navbar mobile */
@media (max-width: 768px) {
  .navbar-container {
    padding: 0.5rem 1rem !important;
    flex-wrap: wrap !important;
    position: relative !important;
  }
  
  .nav-logo {
    font-size: 0.95rem !important;
  }

  .nav-menu {
    display: none !important;
  }
  .nav-menu.open {
    display: flex !important;
    flex-direction: column !important;
    position: absolute !important;
    top: 60px !important;
    right: 0 !important;
    left: 0 !important;
    background: white !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15) !important;
    z-index: 1000 !important;
    padding: 1rem !important;
    gap: 0 !important;
  }
  [data-theme="dark"] .nav-menu.open {
    background: #1E1E1E !important;
  }
  .nav-menu.open .nav-link {
    padding: 0.9rem 1rem !important;
    border-bottom: 1px solid var(--border) !important;
    font-size: 1rem !important;
  }
  .nav-actions {
    gap: 0.5rem !important;
  }
  .hamburger {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text);
  }
  
  /* Hero section */
  .hero-section {
    min-height: 60vh !important;
  }
  .hero-content {
    padding: 2rem 1.2rem !important;
  }
  .hero-title {
    font-size: 1.6rem !important;
    line-height: 1.4 !important;
  }
  .hero-subtitle {
    font-size: 1rem !important;
  }
  .hero-actions {
    flex-direction: column !important;
    gap: 0.8rem !important;
    align-items: stretch !important;
  }
  .hero-actions .btn {
    width: 100% !important;
    text-align: center !important;
  }
  
  /* Stats grid */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.8rem !important;
  }
  
  /* Cards grid */
  .card-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
  
  /* Auth pages */
  .auth-container {
    padding: 1rem !important;
    min-height: 100vh !important;
    display: flex !important;
    align-items: flex-start !important;
    padding-top: 2rem !important;
  }
  .auth-card.card {
    padding: 1.5rem 1.2rem !important;
    width: 100% !important;
    margin: 0 !important;
    box-shadow: none !important;
  }
  .auth-title {
    font-size: 1.4rem !important;
  }
  
  /* Dashboard */
  .dashboard-layout {
    flex-direction: column !important;
  }
  .sidebar {
    width: 100% !important;
    min-height: auto !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border) !important;
    padding: 0.5rem !important;
  }
  .sidebar-nav {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 0.3rem !important;
    padding: 0.5rem !important;
  }
  .sidebar-link {
    white-space: nowrap !important;
    padding: 0.5rem 0.8rem !important;
    font-size: 0.85rem !important;
    border-radius: var(--radius-sm) !important;
  }
  .sidebar-link i {
    margin: 0 0.3rem !important;
  }
  .dashboard-content {
    padding: 1rem !important;
  }
  
  /* Chat */
  .chat-container {
    margin: 0 !important;
    border-radius: 0 !important;
    height: calc(100vh - 65px) !important;
  }
  .chat-input-area {
    padding: 0.5rem !important;
  }
  .chat-form {
    gap: 0.4rem !important;
  }
  .chat-input {
    font-size: 0.9rem !important;
  }
  
  /* Tables */
  .table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  table {
    min-width: 600px !important;
  }
  
  /* Page container */
  .container {
    padding: 1rem !important;
  }
  
  /* Forms */
  .form-control {
    font-size: 16px !important; /* prevent iOS zoom */
  }
  
  /* Section titles */
  .section-title {
    font-size: 1.3rem !important;
  }
  
  /* Footer */
  .site-footer {
    padding: 1rem !important;
    text-align: center !important;
  }
  
  /* Buttons in cards */
  .card-content .btn {
    width: 100% !important;
  }
  
  /* User dropdown */
  .user-dropdown {
    right: 0 !important;
    left: auto !important;
    min-width: 200px !important;
  }
  
  /* Emoji picker */
  #emoji-picker {
    right: 0.5rem !important;
    left: 0.5rem !important;
    width: auto !important;
  }
  
  /* Video/Lecture cards */
  .card-img {
    height: 160px !important;
  }
  
  /* News modal */
  #news-modal .modal-content {
    padding: 1rem !important;
    margin: 0.5rem !important;
  }
  #modal-news-title {
    font-size: 1.2rem !important;
  }
}

/* Small phones (< 400px) */
@media (max-width: 400px) {
  .hero-title {
    font-size: 1.3rem !important;
  }
  .stats-grid {
    grid-template-columns: 1fr !important;
  }
  .nav-logo span {
    display: none !important;
  }
}

/* Tablet (768px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .stats-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  .sidebar {
    width: 200px !important;
    min-width: 200px !important;
  }
  .hamburger {
    display: none !important;
  }
}

/* Desktop */
@media (min-width: 1025px) {
  .hamburger {
    display: none !important;
  }
  .nav-menu {
    display: flex !important;
  }
}

/* ====== NAVBAR MOBILE MENU FIX ====== */
@media (max-width: 768px) {
  ul.nav-menu { display: none !important; }
  .hamburger { display: flex !important; align-items: center; justify-content: center; width: 38px; height: 38px; background: transparent; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: 1.1rem; color: var(--text); }
  .mobile-menu { display: none; position: fixed; top: 60px; right: 0; left: 0; background: var(--card-bg); box-shadow: 0 4px 20px rgba(0,0,0,0.15); z-index: 999; border-bottom: 2px solid var(--primary); }
  .mobile-menu.active { display: block; }
  .mobile-nav-links { list-style: none; padding: 0.5rem 0; margin: 0; }
  .mobile-nav-links li { border-bottom: 1px solid var(--border); }
  .mobile-nav-links li:last-child { border-bottom: none; }
  .mobile-nav-links li a, .mobile-nav-links li button { display: flex; align-items: center; gap: 0.7rem; padding: 0.9rem 1.5rem; color: var(--text); text-decoration: none; font-size: 1rem; background: transparent; border: none; width: 100%; cursor: pointer; font-family: var(--font-ar); }
  .mobile-nav-links li a:hover, .mobile-nav-links li button:hover { background: var(--light); }
  .menu-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.3); z-index: 998; }
  .menu-overlay.active { display: block; }
}
@media (min-width: 769px) {
  .hamburger { display: none !important; }
  .mobile-menu { display: none !important; }
}
