/* Enhanced CSS Variables */
:root {
  /* Brand colors */
  --primary: #00488d;
  --secondary: #004a73;
  --accent: #660000;
  
  /* Background system */
  --bg: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  --card-bg: #ffffff;
  
  /* Text colors */
  --text: #333;
  --text-light: #777;
  --text-muted: #999;
  
  /* Borders */
  --border: #ddd;
  --border-light: #e9ecef;
  
  /* Shadows */
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.15);
  --shadow-hover: 0 12px 48px rgba(0,0,0,0.2);
  
  /* Border radius */
  --border-radius: 8px;
  --border-radius-lg: 12px;
  
  /* Spacing scale */
  --spacing-xs: 0.25rem;   /* 4px */
  --spacing-sm: 0.5rem;    /* 8px */
  --spacing-md: 1rem;      /* 16px */
  --spacing-lg: 1.5rem;    /* 24px */
  --spacing-xl: 2rem;      /* 32px */
  --spacing-2xl: 3rem;     /* 48px */
  
  /* Typography scale */
  --font-xs: 0.75rem;      /* 12px */
  --font-sm: 0.875rem;     /* 14px */
  --font-base: 1rem;       /* 16px */
  --font-lg: 1.125rem;     /* 18px */
  --font-xl: 1.25rem;      /* 20px */
  --font-2xl: 1.5rem;      /* 24px */
  --font-3xl: 1.875rem;    /* 30px */
  
  /* Animation */
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Layout */
  --nav-height: 64px;
  --nav-bg: var(--primary);
  --nav-fg: #fff;
  
  /* Status colors */
  --info: #17a2b8;
  --success: #28a745;
  --warning: #ffc107;
  --error: #dc3545;
  
  /* Typography */
  --font-primary: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Out-of-class count styling for escalating severity levels */
.outofclass-count {
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.outofclass-count-normal {
  color: var(--text-muted);
}

.outofclass-count-yellow {
  color: #856404;
  background-color: #fff3cd;
  border: 1px solid #ffeaa7;
}

.outofclass-count-orange {
  color: #d63384;
  background-color: #ffebd7;
  border: 1px solid #ffb74d;
  font-weight: 600;
}

.outofclass-count-red {
  color: #dc3545;
  background-color: #f8d7da;
  border: 1px solid #f1aeb5;
  font-weight: 600;
}

.outofclass-count-bold-red {
  color: #ffffff;
  background-color: #dc3545;
  border: 1px solid #b02a37;
  font-weight: 700;
  text-shadow: 1px 1px 1px rgba(0,0,0,0.3);
}

.outofclass-count-severe {
  color: #ffffff;
  background-color: #dc143c;
  border: 1px solid #8b0000;
  font-weight: 700;
  text-shadow: 1px 1px 1px rgba(0,0,0,0.5);
  animation: glow 2s ease-in-out infinite alternate;
}

.outofclass-count-critical {
  color: #ffffff;
  background-color: #8b0000;
  border: 1px solid #4b0000;
  font-weight: 700;
  text-shadow: 1px 1px 1px rgba(0,0,0,0.7);
  animation: pulse 1.5s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(139, 0, 0, 0.6);
}

/* Row styling for high count students */
.row-critical {
  background-color: rgba(139, 0, 0, 0.03) !important;
}

.row-severe {
  background-color: rgba(220, 20, 60, 0.03) !important;
}

/* Enhanced Animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 2px 4px rgba(102, 0, 0, 0.3); }
  50% { box-shadow: 0 4px 12px rgba(102, 0, 0, 0.5); }
}

/* Enhanced Global Styles */
* { 
  margin: 0; 
  padding: 0; 
  box-sizing: border-box; 
}

body { 
  font-family: var(--font-primary);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  overflow-x: hidden;
}

/* Skip Links for Accessibility */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--accent);
  color: white;
  padding: 8px;
  text-decoration: none;
  border-radius: 4px;
  z-index: 10000;
  transition: top 0.3s;
}

.skip-link:focus {
  top: 6px;
}

.skip-links a:focus {
  top: 6px;
}

/* Enhanced Navigation Bar */
.nav-bar { 
  background: var(--nav-bg);
  color: var(--nav-fg);
  padding: 12px 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--nav-height);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.nav-logo { 
  height: 40px;
  margin-right: 12px;
  transition: var(--transition);
}

.nav-logo:hover {
  transform: scale(1.05);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  justify-content: flex-end;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

#staffName {
  color: white;
  font-weight: 500;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-title { 
  font-weight: 600;
  font-size: 1.2em;
  letter-spacing: -0.025em;
}

/* ===== FIXED DROPDOWN MENU ===== */
.dropdown {
  position: relative;
  display: inline-block;
}

.nav-links { 
  display: flex;
  align-items: center;
  gap: 16px;
}

#staffName { 
  font-weight: 500;
  padding: 8px 16px;
  background: rgba(255,255,255,0.1);
  border-radius: 20px;
  backdrop-filter: blur(10px);
}

.theme-btn { 
  background: rgba(255,255,255,0.1);
  border: none;
  color: var(--nav-fg);
  padding: 8px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 1.2em;
  transition: var(--transition);
  backdrop-filter: blur(10px);
}

.theme-btn:hover { 
  background: rgba(255,255,255,0.2);
  transform: translateY(-1px);
}

/* Enhanced Dropdown Menu */
.dropdown { 
  position: relative; 
  display: inline-block; 
}

.dropbtn { 
  background: rgba(255,255,255,0.1);
  color: var(--nav-fg);
  padding: 8px 16px;
  font-size: 1em;
  border: none;
  cursor: pointer;
  border-radius: 20px;
  transition: var(--transition);
  font-weight: 500;
  backdrop-filter: blur(10px);
}

.dropbtn:hover { 
  background: rgba(255,255,255,0.2);
  transform: translateY(-1px);
}

.dropdown-content {
  display: none;
  position: absolute;
  top: calc(100% + 5px);
  background-color: white;
  min-width: 200px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
  border-radius: 8px;
  z-index: 2000;
  overflow: hidden;
  
  /* Prevent clipping off screen */
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  
  /* Default positioning - will be adjusted by JavaScript */
  right: 0;
}

/* Force dropdown to stay within viewport bounds */
.dropdown-content.adjust-left {
  right: auto;
  left: 0;
}

.dropdown-content.adjust-center {
  right: auto;
  left: 50%;
  transform: translateX(-50%);
}

/* Ensure dropdown stays within viewport */
@media screen and (max-width: 480px) {
  .dropdown-content {
    right: -20px;
    left: auto;
    min-width: 180px;
  }
}

.dropdown-content a, 
.dropdown-content button {
  padding: 12px 20px;
  text-decoration: none; 
  display: block; 
  color: var(--nav-bg); 
  background: none; 
  border: none; 
  width: 100%; 
  text-align: left; 
  cursor: pointer;
  font-size: 0.95em;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.dropdown-content a::before,
.dropdown-content button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0,48,87,0.05), transparent);
  transition: left 0.3s ease;
}

.dropdown-content a:hover::before,
.dropdown-content button:hover::before {
  left: 100%;
}

.dropdown-content a:hover, 
.dropdown-content button:hover {
  background: rgba(0,48,87,0.08); 
  transform: translateX(4px);
}

.dropdown:hover .dropdown-content,
.dropdown:focus-within .dropdown-content {
  display: block; 
  animation: fadeInUp 0.2s ease;
}

.badge {
  background: var(--accent); 
  color: #fff; 
  border-radius: 50px; 
  padding: 4px 8px; 
  font-size: 0.75em; 
  margin-left: 8px;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
  animation: pulse 2s infinite, glow 2s infinite;
  box-shadow: 0 2px 4px rgba(102, 0, 0, 0.3);
}

/* Dark Mode Styles */
.dark-mode {
  --bg: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  --card-bg: #0f3460;
  --text: #e2e8f0;
  --text-light: #a0aec0;
  --text-muted: #718096;
  --border: #2d3748;
  --border-light: #4a5568;
  --nav-bg: #0a1428;
  --nav-fg: #fff;
}

/* Responsive Design */
@media (max-width: 768px) { 
  .nav-bar {
    padding: 10px 16px;
  }
  
  .nav-title {
    font-size: 1.1em;
  }
  
  #staffName {
    display: none;
  }
}

@media (max-width: 480px) {
  .nav-links {
    gap: 8px;
  }
  
  .dropdown-content {
    min-width: 180px;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles for keyboard navigation */
.dropbtn:focus,
.theme-btn:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}


/* Enhanced responsive navigation */
@media (max-width: 768px) {
  .nav-bar {
    padding: 8px 16px;
    flex-wrap: wrap;
  }

  .nav-title {
    font-size: 1em;
    order: 1;
  }

  .nav-links {
    gap: 8px;
    order: 3;
    flex-basis: 100%;
    justify-content: center;
    margin-top: 8px;
  }

  #staffName {
    display: none; /* Hide on mobile to save space */
  }
}

@media (max-width: 480px) {
  .nav-bar {
    min-height: 60px;
  }

  .nav-logo {
    height: 32px;
  }

  .dropdown-content {
    min-width: 160px;
    right: 0;
    left: auto;
  }
}
