/* Emanovate Modern UI Design System & Global Stylesheet */

:root {
  /* Light Theme Color Palette */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --accent-color: #06b6d4;
  --accent-hover: #0891b2;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition-speed: 0.3s;
}

[data-theme="dark"] {
  /* Dark Theme Color Palette */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-sidebar: #020617;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --primary-color: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #1e3a8a;
  --accent-color: #22d3ee;
  --accent-hover: #67e8f9;
  --success-color: #34d399;
  --warning-color: #fbbf24;
  --danger-color: #f87171;
  --border-color: #334155;
  --border-hover: #475569;
  --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);
}

/* Base resets & typography */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  direction: rtl;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  transition: background-color var(--transition-speed), color var(--transition-speed);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary-hover);
}

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

ul {
  list-style: none;
}

input[type="number"] {
  text-align: right;
  direction: ltr;
}
/* Alert Message */
.popup-container {
  left: 50%;
  top: 20%;
  padding: 20px;
  overflow: auto;
  position: fixed;
  max-height: 70%;
  z-index: 1000000;
  max-width: 1000px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
  transform: translate(-50%, 20px);
  border: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
}
.popup-close-button {
  top: 10px;
  right: 15px;
  font-size: 25px;
  cursor: pointer;
  user-select: none;
  position: absolute;
}
.popup-title {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 10px;
}
.popup-message {
  font-size: 16px;
  margin-bottom: 20px;
}
.popup-action-button {
  background-color: #4CAF50;
  color: #fff;
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
.popup-action-button:hover {
  background-color: #3e8e41;
}

/* Header & Navigation Bar */
header {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 1;
}

header main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  gap: 5px;
  align-items: center;
  justify-content: space-between;
}

header .brand {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

nav ul {
  gap: 5px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

nav ul li a {
  color: var(--text-secondary);
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-speed);
}

nav ul li a:hover, nav ul li a.active {
  color: var(--primary-color);
  background-color: var(--primary-light);
}

/* Dark Mode Toggle Button */
.theme-toggle-btn {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  transition: all var(--transition-speed);
}
.theme-toggle-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* Global Loading Screen Overlay */
#global-loader {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#global-loader.active {
  opacity: 1;
  pointer-events: auto;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-left-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Layout Containers & Sections */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex: 1;
}

.mainTitle {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 2rem;
  position: relative;
}
.mainTitle::after {
  content: '';
  display: block;
  width: 60px;
  height: 4px;
  background: var(--primary-color);
  margin: 0.5rem auto 0;
  border-radius: 2px;
}

/* Modern Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-speed), box-shadow var(--transition-speed), border-color var(--transition-speed);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-color);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 1.25rem;
}

/* Buttons System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition-speed);
  text-align: center;
}

.btn-primary {
  background-color: var(--primary-color);
  color: #ffffff !important;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.btn-danger {
  background-color: var(--danger-color);
  color: #ffffff !important;
}
.btn-success {
  background-color: var(--success-color);
  color: #ffffff !important;
}

/* Form Controls */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  user-select: none;
  cursor: pointer;
}

.form-control:not(input[type="checkbox"]) {
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.form-control:focus:not(input[type="checkbox"]) {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Sidebar-Header-Main Management Dashboard Layout */
.dashboard-layout {
  display: flex;
  min-height: calc(100vh - 65px);
}

.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  color: #f8fafc;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-color);
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: #94a3b8;
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: all var(--transition-speed);
  cursor: pointer;
}

.sidebar-link:hover, .sidebar-link.active {
  background-color: rgb(255 255 255 / 5%);
  color: #ffffff;
}

.dashboard-main {
  flex: 1;
  padding: 2rem;
  background-color: var(--bg-primary);
  overflow-y: auto;
}

/* Management Real-time Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.metric-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.metric-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-md);
  background-color: var(--primary-light);
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.metric-val {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-lbl {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
/* uploadModal */
#uploadModal {
  top: 0;
  left: 0;
  z-index: 5000;
  width: 100%;
  height: 100%;
  display: flex;
  position: fixed;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
}
#uploadModal #modal-content {
  display: flex;
  padding: 20px;
  max-width: 90%;
  min-width: 300px;
  background: #fff;
  border-radius: 8px;
  position: relative;
  flex-direction: column;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}
#modal-content #close-btn {
  top: 10px;
  right: 15px;
  font-size: 22px;
  cursor: pointer;
  position: absolute;
}
#modal-content #modal-title {
  margin: 0 20px;
}
#loadingBtn {
  cursor: wait;
  height: 40px;
  margin: 10px 0;
  border-radius: 5px;
  background-color: var(--main-color);
}
#loadingBtn #loading {
  margin: 0;
  height: 100%;
}
#loadingBtn span {
  background-color: aliceblue;
}
/* Loading Section */
#loading {
  height: 50px;
  display: flex;
  margin: 50px auto;
  align-items: center;
  justify-content: center;
}
#loading span {
  opacity: 0;
  width: 30px;
  height: 30px;
  margin: 0 5px;
  border-radius: 50%;
  background-color: #00d7cb;
  animation: dot-pulse 1.2s cubic-bezier(0.65, 0.05, 0.36, 1) infinite;
}
#loading span:nth-child(1) {
  animation-delay: 0s;
}
#loading span:nth-child(2) {
  animation-delay: 0.15s;
}
#loading span:nth-child(3) {
  animation-delay: 0.3s;
}
#loading span:nth-child(4) {
  animation-delay: 0.45s;
}
#loading span:nth-child(5) {
  animation-delay: 0.6s;
}
@keyframes dot-pulse {
  0%, 100% {
    opacity: 0;
    transform: scale(0.5);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}
/* Floating Management Button */
#managementBtn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background-color: var(--primary-color);
  color: #ffffff !important;
  padding: 0.85rem 1.5rem;
  border-radius: 30px;
  box-shadow: var(--shadow-lg);
  font-weight: 600;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform var(--transition-speed), background-color var(--transition-speed);
}
#managementBtn:hover {
  transform: scale(1.05);
  background-color: var(--primary-hover);
}

/* Floating Subjects Button */
#subjectsBtn {
  position: fixed;
  top: 8rem;
  right: 50%;
  transform: translateX(50%);

  background-color: var(--primary-color);
  color: #fff !important;

  padding: 2.85rem 3.5rem;
  border-radius: 30px;

  box-shadow: var(--shadow-lg);
  font-weight: 600;

  display: flex;
  align-items: center;
  gap: 0.5rem;

  z-index: 900;
  isolation: isolate;

  transition:
    transform var(--transition-speed),
    background-color var(--transition-speed),
    opacity var(--transition-speed) ease;

}

/* Blur background behind button */
#subjectsBtn::before {
  content: "";
  position: absolute;
  top: -100px;
  right: -100px;
  bottom: -100px;
  left: -100px;
  border-radius: 60px;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  background: rgba(255, 255, 255, 0.12);
  z-index: -1;
  pointer-events: none;
}
/* Soft glow */
#subjectsBtn::after {
  content: "";
  position: absolute;
  top: -20px;
  right: -20px;
  bottom: -20px;
  left: -20px;
  border-radius: 50px;
  background: var(--primary-color);
  filter: blur(24px);
  opacity: 0.35;
  z-index: -2;
  pointer-events: none;
}

#subjectsBtn:hover {
  transform: translateX(50%) scale(1.05);
  background-color: var(--primary-hover);
}

/* Tables */
.table-container {
  overflow-x: auto;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
}

th, td {
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

th {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-weight: 600;
}

tr:hover {
  background-color: var(--primary-light);
}

/* Footer */
footer {
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-secondary);
  margin-top: auto;
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
  header main {
    flex-direction: column;
    gap: 1rem;
  }
  .dashboard-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
  }
}