/* ==========================================================================
   EduCenter Pro - Modern Management System
   Main Stylesheet & Design System (RTL First)
   ========================================================================== */

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

:root {
  /* Color Palette - Modern Indigo & Emerald Theme (Dark Mode Default) */
  --bg-app: #090d16;
  --bg-surface: #111827;
  --bg-surface-elevated: #1a2234;
  --bg-surface-glass: rgba(17, 24, 39, 0.85);
  --bg-hover: rgba(255, 255, 255, 0.05);
  --bg-active: rgba(99, 102, 241, 0.15);
  
  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.14);
  --border-glow: rgba(99, 102, 241, 0.35);

  /* Primary & Accent Colors */
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.25);
  
  --secondary: #06b6d4;
  --secondary-glow: rgba(6, 182, 212, 0.25);

  /* Status Colors */
  --success: #10b981;
  --success-light: #34d399;
  --success-bg: rgba(16, 185, 129, 0.12);
  --success-border: rgba(16, 185, 129, 0.3);

  --warning: #f59e0b;
  --warning-light: #fbbf24;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --warning-border: rgba(245, 158, 11, 0.3);

  --danger: #ef4444;
  --danger-light: #f87171;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --danger-border: rgba(239, 68, 68, 0.3);

  --info: #3b82f6;
  --info-light: #60a5fa;
  --info-bg: rgba(59, 130, 246, 0.12);
  --info-border: rgba(59, 130, 246, 0.3);

  --whatsapp: #25d366;
  --whatsapp-hover: #22bf5b;
  --whatsapp-bg: rgba(37, 211, 102, 0.15);

  /* Text Colors */
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --text-inverted: #0f172a;

  /* Typography */
  --font-ar: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-en: 'Plus Jakarta Sans', sans-serif;

  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 20px var(--primary-glow);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 9999px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout */
  --sidebar-width: 270px;
  --header-height: 72px;
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-app: #f4f6fb;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f8fafc;
  --bg-surface-glass: rgba(255, 255, 255, 0.85);
  --bg-hover: rgba(0, 0, 0, 0.04);
  --bg-active: rgba(99, 102, 241, 0.08);

  --border-subtle: #e5e7eb;
  --border-medium: #d1d5db;
  --border-glow: rgba(99, 102, 241, 0.2);

  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --text-inverted: #ffffff;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.09);
  --shadow-glow: 0 4px 20px rgba(99, 102, 241, 0.15);
}

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

html {
  font-size: 15px;
  direction: rtl;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-ar);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.06) 0%, transparent 40%);
  background-attachment: fixed;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* Typography Helpers */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-ar);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

p, span, label, td, th {
  font-family: var(--font-ar);
}

.num-font {
  font-family: var(--font-en), var(--font-ar);
  direction: ltr;
  display: inline-block;
}

/* App Container Layout */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
  margin: 0;
  padding: 0;
}

.app-layout {
  display: flex;
  min-height: 100vh;
  max-width: 100vw;
  width: 100%;
  overflow-x: hidden;
  position: relative;
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #182234 0%, #0d131f 100%);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  transition: transform var(--transition-normal);
  backdrop-filter: blur(16px);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.35);
}

.sidebar-header {
  padding: 1.5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary) 0%, #a855f7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-info h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  background: linear-gradient(120deg, #ffffff, var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-info span {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 600;
  display: block;
  margin-top: 0.15rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1.25rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.98rem;
  transition: all var(--transition-fast);
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  transform: translateX(-3px);
}

.nav-link.active {
  background: rgba(99, 102, 241, 0.24);
  color: #ffffff;
  border: 1px solid rgba(99, 102, 241, 0.45);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.28);
  font-weight: 700;
}

.nav-link i, .nav-link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-badge {
  margin-right: auto;
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-pill);
}

.sidebar-footer {
  padding: 1.2rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-snippet {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
}

.user-meta h4 {
  font-size: 0.88rem;
  font-weight: 700;
}

.user-meta span {
  font-size: 0.72rem;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.user-meta span::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 6px var(--success);
}

/* Main Content Area */
.main-content {
  flex: 1;
  margin-right: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-right var(--transition-normal);
}

/* Header / Topbar */
.topbar {
  height: var(--header-height);
  background: var(--bg-surface-glass);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.menu-toggle-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.4rem;
  cursor: pointer;
}

.quick-search-box {
  position: relative;
  width: 360px;
}

.quick-search-box input {
  width: 100%;
  padding: 0.65rem 2.6rem 0.65rem 1rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  color: var(--text-primary);
  font-family: var(--font-ar);
  font-size: 0.9rem;
  outline: none;
  transition: all var(--transition-fast);
}

.quick-search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--bg-surface);
}

.quick-search-box .search-icon {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.quick-search-box .search-shortcut {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: var(--border-medium);
  color: var(--text-muted);
  font-size: 0.68rem;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  direction: ltr;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.header-action-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-md);
  font-family: var(--font-ar);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.header-action-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-medium);
}

.header-action-btn.primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border: none;
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.header-action-btn.primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.theme-toggle-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.theme-toggle-btn:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

/* Page Body Container */
.page-container {
  flex: 1;
  padding: 2rem;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

/* View Sections Switcher */
.view-section {
  display: none;
  animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.view-section.active {
  display: block;
}

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

/* Page Header Title */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-title-group h2 {
  font-size: 1.65rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.page-title-group p {
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 240px;
  }
  .page-container {
    padding: 1.5rem;
  }
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    right: -320px;
    width: 280px;
    max-width: 85vw;
    bottom: 0;
    z-index: 1000;
    transform: none !important;
    box-shadow: none;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.open {
    right: 0 !important;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.75);
  }

  .main-content {
    margin-right: 0 !important;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .menu-toggle-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 998;
  }

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

  .quick-search-box {
    width: 180px;
  }

  .topbar {
    padding: 0 1rem;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 0.75rem;
    height: 60px;
  }

  .topbar-right {
    gap: 0.5rem;
  }

  .quick-search-box {
    display: none; /* Hide top search bar on small mobile screens */
  }

  .topbar-left {
    gap: 0.35rem;
  }

  .header-action-btn {
    padding: 0.45rem 0.6rem;
    font-size: 0.8rem;
    gap: 0.3rem;
  }

  .header-action-btn span {
    display: none; /* Show only icons on phones for clean fit */
  }

  .header-action-btn i, .header-action-btn svg {
    width: 18px;
    height: 18px;
    margin: 0;
  }

  .theme-toggle-btn {
    width: 36px;
    height: 36px;
  }

  .page-container {
    padding: 1rem 0.75rem;
  }

  .page-header {
    margin-bottom: 1.25rem;
    gap: 0.6rem;
  }

  .page-title-group h2 {
    font-size: 1.3rem;
  }

  .page-title-group p {
    font-size: 0.8rem;
  }

  .grid-stats {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

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