/**
 * ================================================================
 * أكاديمية جدير - الزر العائم وبوابة العمليات السريعة (Jadeer Quick Hub)
 * Floating Action Hub & Visual Navigation Cockpit
 * ================================================================
 */

/* 1. The Floating Action Trigger Button (FAB) */
#jadeerFloatingHubBtn {
  position: fixed;
  z-index: 2147483646 !important;
  bottom: 22px;
  left: 22px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #059669 0%, #0d9488 45%, #0284c7 100%);
  border: 2px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 6px 18px rgba(5, 150, 105, 0.4), 0 2px 6px rgba(0, 0, 0, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s ease, background 0.3s ease;
}

#jadeerFloatingHubBtn:active {
  cursor: grabbing;
  transform: scale(0.92);
}

#jadeerFloatingHubBtn:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 8px 24px rgba(5, 150, 105, 0.5), 0 3px 8px rgba(0, 0, 0, 0.2);
}

#jadeerFloatingHubBtn.hub-open {
  background: linear-gradient(135deg, #e11d48 0%, #be123c 100%);
  box-shadow: 0 6px 18px rgba(225, 29, 72, 0.4), 0 2px 6px rgba(0, 0, 0, 0.2);
}

#jadeerFloatingHubBtn .hub-fab-icon {
  font-size: 1.15rem;
  line-height: 1;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

#jadeerFloatingHubBtn.hub-open .hub-fab-icon {
  transform: rotate(90deg) scale(1.1);
}

/* Pulsing Status Dot */
#jadeerFloatingHubBtn .hub-fab-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 9px;
  height: 9px;
  background: #10b981;
  border: 1.5px solid #ffffff;
  border-radius: 50%;
  pointer-events: none;
}

#jadeerFloatingHubBtn .hub-fab-badge::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  border: 2px solid #10b981;
  animation: jadeerFabPulse 2s infinite ease-out;
}

@keyframes jadeerFabPulse {
  0% { transform: scale(0.9); opacity: 0.9; }
  60% { transform: scale(1.8); opacity: 0; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* Tooltip on Hover */
.hub-fab-tooltip {
  position: absolute;
  right: calc(100% + 12px);
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-family: 'Cairo', sans-serif;
}

#jadeerFloatingHubBtn:hover .hub-fab-tooltip {
  opacity: 1;
  transform: translateX(0);
}

/* 2. Floating Action Hub Menu Backdrop / Shield */
#jadeerFloatingHubBackdrop {
  position: fixed;
  inset: 0;
  z-index: 2147483640 !important;
  background: rgba(15, 23, 42, 0.25);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

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

/* 3. The Action Hub Cockpit Container */
#jadeerFloatingHubMenu {
  position: fixed;
  z-index: 2147483645 !important;
  width: 395px;
  max-width: calc(100vw - 20px);
  max-height: calc(100vh - 80px);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.38), 0 6px 20px rgba(0, 0, 0, 0.18);
  font-family: 'Cairo', sans-serif;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92) translateY(12px);
  transform-origin: bottom left;
  transition: opacity 0.16s ease, transform 0.16s ease;
  direction: rtl;
  will-change: transform, opacity;
  contain: layout style;
}

#jadeerFloatingHubMenu.hub-active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1) translateY(0);
}

/* Light Theme Styling */
:root,
[data-theme="light"] #jadeerFloatingHubMenu {
  background: #ffffff;
  border: 1px solid rgba(203, 213, 225, 0.95);
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.06);
  color: #0f172a;
}

/* Dark Theme Styling */
[data-theme="dark"] #jadeerFloatingHubMenu {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55), 0 4px 12px rgba(0, 0, 0, 0.3);
  color: #f8fafc;
}

/* Hub Header (Draggable) */
.hub-header {
  padding: 8px 12px 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.02);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.hub-header:active {
  cursor: grabbing;
}

[data-theme="dark"] .hub-header {
  background: rgba(255, 255, 255, 0.03);
}

.hub-title-box {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.hub-title-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #059669, #0284c7);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  box-shadow: 0 3px 8px rgba(5, 150, 105, 0.3);
}

.hub-title-text h3 {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 5px;
}

.hub-title-text span {
  font-size: 0.67rem;
  color: var(--text-muted);
}

.hub-header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.hub-btn-icon {
  width: 25px;
  height: 25px;
  border-radius: 7px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.15s ease;
}

.hub-btn-icon:hover {
  background: var(--bg-hover);
  color: var(--accent-rose);
  border-color: var(--accent-rose);
}

/* Hub Context Banner (Current Course) */
.hub-context-banner {
  padding: 5px 12px;
  background: rgba(5, 150, 105, 0.07);
  border-bottom: 1px solid rgba(5, 150, 105, 0.16);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.hub-context-info {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--accent-emerald);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hub-context-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.hub-context-pill {
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--bg-card);
  border: 1px solid rgba(5, 150, 105, 0.25);
  color: var(--accent-emerald);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.hub-context-pill:hover {
  background: var(--accent-emerald);
  color: #ffffff;
}

/* Hub Search & Quick Filters */
.hub-search-wrap {
  padding: 6px 12px 3px;
}

.hub-search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.hub-search-box input {
  width: 100%;
  height: 32px;
  padding: 0 30px 0 26px;
  border-radius: 8px;
  border: 1px solid var(--border-medium);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-family: 'Cairo', sans-serif;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hub-search-box input:focus {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 2px var(--accent-emerald-light);
}

.hub-search-icon-left {
  position: absolute;
  right: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  pointer-events: none;
}

.hub-search-clear {
  position: absolute;
  left: 6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: 0.68rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  visibility: hidden;
}

.hub-search-clear.visible {
  visibility: visible;
}

/* Hub Scrollable Content Stage */
.hub-content-stage {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: calc(100vh - 170px);
}

.hub-content-stage::-webkit-scrollbar {
  width: 4px;
}

.hub-content-stage::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 4px;
}

/* Section Titles inside Hub */
.hub-section-title {
  font-size: 0.67rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: 3px 2px 1px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hub-section-title-left {
  display: flex;
  align-items: center;
  gap: 5px;
}

.hub-section-count {
  font-size: 0.62rem;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  padding: 1px 5px;
  border-radius: 4px;
}

/* Grid of Action Cards */
.hub-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
}

.hub-action-card {
  padding: 6px 8px;
  border-radius: 9px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: all 0.14s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: right;
  position: relative;
  overflow: hidden;
}

.hub-action-card:hover {
  border-color: var(--accent-emerald);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  background: var(--bg-hover);
}

.hub-action-card:active {
  transform: translateY(0);
}

.hub-card-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
  transition: transform 0.14s ease;
}

.hub-action-card:hover .hub-card-icon {
  transform: scale(1.1);
}

.hub-card-text {
  flex: 1;
  min-width: 0;
}

.hub-card-text .title {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hub-card-text .desc {
  font-size: 0.64rem;
  color: var(--text-muted);
  line-height: 1.15;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Icon Gradient Variants */
.icon-emerald { background: rgba(5, 150, 105, 0.12); color: #059669; }
.icon-blue { background: rgba(37, 99, 235, 0.12); color: #2563eb; }
.icon-amber { background: rgba(217, 119, 6, 0.12); color: #d97706; }
.icon-rose { background: rgba(225, 29, 72, 0.12); color: #e11d48; }
.icon-purple { background: rgba(124, 58, 237, 0.12); color: #7c3aed; }
.icon-cyan { background: rgba(8, 145, 178, 0.12); color: #0891b2; }

/* Filtered Search Results List */
.hub-search-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hub-result-item {
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.14s ease;
}

.hub-result-item:hover {
  background: var(--bg-hover);
  border-color: var(--accent-emerald);
  transform: translateX(-3px);
}

.hub-result-icon {
  font-size: 1.2rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hub-result-info {
  flex: 1;
  min-width: 0;
}

.hub-result-info .title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hub-result-info .desc {
  font-size: 0.69rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hub-result-badge {
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 700;
  white-space: nowrap;
}

/* Hub Footer */
.hub-footer {
  padding: 8px 14px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.02);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.71rem;
  color: var(--text-muted);
}

[data-theme="dark"] .hub-footer {
  background: rgba(255, 255, 255, 0.02);
}

.hub-footer-hint {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Responsive Constraints for Mobile */
@media (max-width: 768px) {
  #jadeerFloatingHubBtn {
    bottom: 16px;
    left: 16px;
    width: 38px;
    height: 38px;
  }

  #jadeerFloatingHubMenu {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 84px);
    border-radius: 16px;
  }

  .hub-actions-grid {
    grid-template-columns: 1fr;
  }
}

/* ================================================================
   JADEER UNIFIED COCKPIT WINDOW DESIGN SYSTEM (Standardized Windows)
   ================================================================ */

/* 1. Unified Window Overlay Backdrop (Ultra-Optimized, Zero-Lag) */
.modal-overlay,
.jadeer-window-overlay,
#speedGraderCockpitModal,
#courseConsole360Modal,
#studentProfile360Modal,
#teacherProfile360Modal {
  position: fixed !important;
  inset: 0 !important;
  background: rgba(15, 23, 42, 0.65) !important;
  display: none;
  align-items: center !important;
  justify-content: center !important;
  direction: rtl !important;
  z-index: 200050 !important;
  will-change: opacity;
  transform: translateZ(0);
}

.modal-overlay.active,
.jadeer-window-overlay.active,
#speedGraderCockpitModal.active,
#courseConsole360Modal.active,
#studentProfile360Modal.active,
#teacherProfile360Modal.active {
  display: flex !important;
}

/* 2. Unified Window Card Dimensions & Box Model (Standardized 95vw × 92vh) */
.jadeer-window-card,
.speed-grader-modal-card,
.course-console-box,
#courseConsole360Modal .course-console-box,
#studentProfile360Modal .student-profile-box,
#teacherProfile360Modal .teacher-cockpit-box,
#teacherProfile360Modal .teacher-profile-box,
.student-profile-box {
  width: 95vw !important;
  max-width: 1400px !important;
  height: 92vh !important;
  max-height: 92vh !important;
  background: var(--bg-card) !important;
  border-radius: 14px !important;
  border: 1px solid var(--border-medium) !important;
  box-shadow: 0 25px 65px rgba(0, 0, 0, 0.48), 0 5px 20px rgba(0, 0, 0, 0.22) !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  direction: rtl !important;
  font-family: 'Cairo', sans-serif !important;
  box-sizing: border-box !important;
  margin: auto !important;
  will-change: left, top;
  contain: layout style;
  transform: translateZ(0);
  transition: width 0.15s ease, height 0.15s ease, border-radius 0.15s ease !important;
}

/* 3. Unified Fullscreen Mode */
.jadeer-window-card.is-fullscreen,
.speed-grader-modal-card.is-fullscreen,
.course-console-box.is-fullscreen,
#courseConsole360Modal.is-fullscreen .course-console-box,
#studentProfile360Modal.is-fullscreen .student-profile-box,
#teacherProfile360Modal.is-fullscreen .teacher-cockpit-box {
  position: fixed !important;
  left: 0 !important;
  top: 0 !important;
  margin: 0 !important;
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  z-index: 2147483640 !important;
}

/* 4. Unified Window Header Styling & Colors */
.jadeer-window-header,
.speed-grader-modal-header,
.course-console-header {
  padding: 8px 16px !important;
  background: var(--bg-subtle) !important;
  border-bottom: 1px solid var(--border-subtle) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  flex-shrink: 0 !important;
  min-height: 52px !important;
  box-sizing: border-box !important;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.jadeer-window-header:active,
.speed-grader-modal-header:active,
.course-console-header:active {
  cursor: grabbing;
}

/* 5. Unified Header Identity Group (Right Side in RTL) */
.jadeer-win-identity {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  min-width: 0 !important;
}

.jadeer-win-icon {
  width: 32px !important;
  height: 32px !important;
  border-radius: 8px !important;
  background: linear-gradient(135deg, #059669 0%, #0284c7 100%) !important;
  color: #ffffff !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 1.05rem !important;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25) !important;
  flex-shrink: 0 !important;
}

.jadeer-win-title-box {
  display: flex !important;
  flex-direction: column !important;
  min-width: 0 !important;
}

.jadeer-win-title {
  margin: 0 !important;
  font-size: 0.92rem !important;
  font-weight: 800 !important;
  color: var(--text-primary) !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.jadeer-win-badge {
  background: rgba(5, 150, 105, 0.12) !important;
  color: var(--accent-emerald) !important;
  border: 1px solid rgba(5, 150, 105, 0.25) !important;
  font-size: 0.67rem !important;
  font-weight: 700 !important;
  padding: 1px 6px !important;
  border-radius: 4px !important;
}

.jadeer-win-desc {
  font-size: 0.70rem !important;
  color: var(--text-muted) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  margin-top: 1px !important;
}

/* 6. Unified Header Actions Group (Left Side in RTL) */
.jadeer-win-actions {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex-shrink: 0 !important;
}

/* Standardized Fullscreen Button */
.win-fullscreen-btn,
#speedGraderFullscreenBtn {
  font-size: 0.76rem !important;
  font-weight: 700 !important;
  font-family: 'Cairo', sans-serif !important;
  height: 30px !important;
  padding: 0 11px !important;
  border-radius: 7px !important;
  border: 1px solid var(--border-medium) !important;
  background: var(--bg-card) !important;
  color: var(--text-secondary) !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  transition: all 0.15s ease !important;
  white-space: nowrap !important;
}

.win-fullscreen-btn:hover,
#speedGraderFullscreenBtn:hover {
  background: var(--bg-hover) !important;
  color: var(--text-primary) !important;
  border-color: var(--accent-emerald) !important;
}

/* Standardized Close Button (30px × 30px with Rose/Red Hover) */
.jadeer-win-close {
  width: 30px !important;
  height: 30px !important;
  border-radius: 7px !important;
  border: 1px solid var(--border-subtle) !important;
  background: var(--bg-card) !important;
  color: var(--text-secondary) !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 0.95rem !important;
  font-weight: 700 !important;
  transition: all 0.15s ease !important;
  line-height: 1 !important;
  padding: 0 !important;
  margin: 0 !important;
}

.jadeer-win-close:hover {
  background: #e11d48 !important;
  color: #ffffff !important;
  border-color: #e11d48 !important;
  transform: scale(1.05) !important;
}

/* 7. Unified Window Body */
.jadeer-window-body,
.speed-grader-modal-body {
  flex: 1 !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  position: relative !important;
  background: var(--bg-main) !important;
}

.course-console-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  display: block !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  position: relative !important;
  background: var(--bg-main) !important;
  padding: 20px !important;
  box-sizing: border-box !important;
}

.jadeer-window-body .view-stage,
.speed-grader-modal-body #graderView {
  height: 100% !important;
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow-y: auto !important;
  padding: 10px !important;
}

/* Strict Safeguard: Force non-active stages in .main-stage to remain completely hidden (Never multi-column split) */
.main-stage > .view-stage:not(.active) {
  display: none !important;
}




