/* 
 * Teaching Management System - Scoped CSS Architecture
 * Design tokens remain global, component styles are scoped to .app-scope
 * This prevents CSS conflicts while maintaining consistent theming
 */

/* ========================================
   CSS CUSTOM PROPERTIES (DESIGN TOKENS)
   These remain global for consistency
   ======================================== */

:root {
  /* Brand Colors */
  --app-primary: #45b7d1;
  --app-primary-dark: #35a0ba;
  --app-secondary: #1a1a1a;
  --app-teal-gradient: linear-gradient(135deg, #4ecdc4 0%, #45b7d1 40%, #96ceb4 100%);

  /* Bootstrap primary override */
  --bs-primary: #45b7d1;
  --bs-primary-rgb: 69, 183, 209;

  /* Background Gradients */
  --app-bg-gradient: #f7f6f3;
  --app-navbar-gradient: var(--app-teal-gradient);
  --app-card-gradient: #ffffff;

  /* Typography */
  --app-font-family: 'Poppins', 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Shadows */
  --app-shadow-sm: 0 2px 8px rgba(0,0,0,0.1);
  --app-shadow-md: 0 4px 16px rgba(0,0,0,0.15);
  --app-shadow-lg: 0 8px 32px rgba(0,0,0,0.2);

  /* Border Radius */
  --app-radius: 12px;
  --app-radius-lg: 16px;
}

/* ── Colour Themes ──────────────────────────────────────────────────
   Theme blocks are defined at the END of this file (after body.dark-mode)
   so they win source-order specificity ties over body.dark-mode's generic
   overrides. See "COLOUR THEMES (END)" section below.
   ────────────────────────────────────────────────────────────────── */

/* ========================================
   BASE STYLES (MINIMAL GLOBAL OVERRIDES)
   ======================================== */

body {
  font-family: var(--app-font-family);
  background: var(--app-bg-gradient);
  line-height: 1.6;
}

/* Remove any text shadows or effects that might hide text */
* {
  text-shadow: none !important;
}

/* ========================================
   BOOTSTRAP PRIMARY COLOUR OVERRIDES
   Apply teal gradient to all bg-primary / btn-primary elements
   ======================================== */

.bg-primary {
  background: var(--app-teal-gradient) !important;
}

.btn-primary {
  background: var(--app-teal-gradient) !important;
  border-color: var(--app-primary) !important;
  color: #fff !important;
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
  background: linear-gradient(135deg, var(--app-primary-dark) 0%, var(--app-primary) 100%) !important;
  border-color: var(--app-primary-dark) !important;
}

.border-primary { border-color: var(--app-primary) !important; }
.text-primary { color: var(--app-primary-dark) !important; }

/* ========================================
   SCOPED APPLICATION STYLES
   All component styles are scoped to .app-scope
   ======================================== */

.app-scope .navbar,
.app-scope.navbar,
.app-navbar {
  background: var(--app-navbar-gradient) !important;
  border-bottom: none;
  padding: 0.5rem 0 !important;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  z-index: 1050;
  position: sticky !important;
  top: 0;
}

/* Beta Banner - Fixed under sticky navbar */
.beta-banner {
  position: sticky !important;
  top: auto !important;
  z-index: 1040 !important;
  background: rgba(13, 110, 253, 0.1) !important;
}

.app-scope .navbar-brand,
.app-navbar .navbar-brand {
  font-size: 1.25rem;
  font-weight: 600;
  color: white !important;
  text-decoration: none;
}

.app-scope .navbar-nav .nav-link,
.app-navbar .nav-link {
  color: rgba(255,255,255,0.95) !important;
  font-weight: 500;
  transition: all 0.2s ease;
  padding: 0.25rem 0.65rem !important;
  border-radius: 6px;
  font-size: 0.875rem;
}

.app-scope .navbar-nav .nav-link:hover,
.app-navbar .nav-link:hover {
  color: white !important;
  background: rgba(255,255,255,0.15);
  transform: none;
}

.app-scope .navbar-nav .nav-link:focus,
.app-navbar .nav-link:focus {
  color: white !important;
  outline: 2px solid rgba(255,255,255,0.5);
  outline-offset: 2px;
}

/* Dropdown menu visibility - Enhanced */
/* User profile dropdown — pinned to right edge, never overflows */
#userDropdown + .dropdown-menu,
ul[aria-labelledby="userDropdown"] {
  right: 0 !important;
  left: auto !important;
  min-width: 200px;
}

.app-scope .dropdown-menu {
  background-color: white;
  border: 1px solid #e9ecef;
  box-shadow: var(--app-shadow-md);
  border-radius: var(--app-radius);
}

.app-scope .dropdown-item {
  color: #212529 !important;
  font-weight: 400 !important;
  padding: 0.75rem 1.25rem;
}

.app-scope .dropdown-item:hover,
.app-scope .dropdown-item:focus {
  background-color: rgba(0,0,0,0.05) !important;
  color: #1a1a1a !important;
}

.app-scope .dropdown-item.active {
  background-color: rgba(212, 85, 10, 0.12) !important;
  color: #1a1a1a !important;
}

.app-scope .dropdown-divider {
  border-top: 1px solid #dee2e6;
}

/* Navbar toggler visibility */
.app-scope .navbar-toggler {
  border: 1px solid rgba(255,255,255,0.3);
  background-color: rgba(255,255,255,0.1);
}

.app-scope .navbar-toggler:focus {
  box-shadow: 0 0 0 0.2rem rgba(255,255,255,0.25);
}

.app-scope .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.95%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* App Cards */
.app-card {
  border-radius: var(--app-radius);
  border: none;
  box-shadow: var(--app-shadow-sm);
  transition: all 0.3s ease;
  background: white;
}

.app-card:hover {
  box-shadow: var(--app-shadow-md);
  transform: translateY(-2px);
}

.app-card .card-header {
  background: var(--app-card-gradient);
  border-bottom: 1px solid rgba(102, 126, 234, 0.15);
  border-radius: var(--app-radius-lg) var(--app-radius-lg) 0 0 !important;
  padding: 1.5rem 2rem;
  font-weight: 600;
  color: #212529 !important;
}

/* Class code card header - improved visibility */
#class-detail .card .card-header h5 {
  color: #212529 !important;
  font-weight: 700 !important;
}

#class-detail .card .card-header .btn-primary {
  background-color: #0d6efd !important;
  border-color: #0d6efd !important;
  color: white !important;
  font-weight: 600 !important;
}

#class-detail .card .card-header .btn-primary:hover {
  background-color: #0a58ca !important;
  border-color: #0a58ca !important;
}

/* Session notes - button styling for better visibility */
#add-note-form .btn-group .btn-outline-secondary {
  background-color: #6c757d !important;
  border-color: #6c757d !important;
  color: white !important;
  font-weight: 600 !important;
}

#add-note-form .btn-group .btn-outline-secondary:hover {
  background-color: #5c636a !important;
  border-color: #565e64 !important;
}

#add-note-form .btn-group .btn-check:checked + .btn-outline-secondary {
  background-color: #495057 !important;
  border-color: #495057 !important;
  color: white !important;
}

/* Note card backgrounds based on save option */
.note-card.note-type-normal {
  background-color: rgba(108, 117, 125, 0.08) !important;
}

.note-card.note-type-next-session {
  background-color: rgba(13, 202, 240, 0.08) !important;
}

.note-card.note-type-todo {
  background-color: rgba(13, 110, 253, 0.08) !important;
}

/* Dashboard cards with colored backgrounds need white text */
.dashboard-main-card h3,
.dashboard-main-card .card-title,
.dashboard-main-card .card-header {
  color: white !important;
}

.dashboard-main-card .badge {
  color: white !important;
}

/* Ensure card header titles are dark for readability */
.card-header h5,
.card-header .mb-0,
.card-header h4,
.card-header h3 {
  color: #212529 !important;
}

/* Ensure buttons in card headers are visible */
.card-header .btn-outline-light {
  border-color: #6c757d;
  color: #212529;
}

.card-header .btn-outline-light:hover {
  background-color: #6c757d;
  border-color: #6c757d;
  color: white;
}

.app-card .card-body {
  padding: 2rem;
}

.app-card .card-footer {
  background: #ffffff;
  border-top: 1px solid #e5e5e5;
  border-radius: 0 0 var(--app-radius) var(--app-radius) !important;
  padding: 1.5rem 2rem;
}

/* App Buttons */
.app-btn-primary {
  background: var(--app-primary);
  border-color: var(--app-primary);
  color: white;
  font-weight: 500;
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  transition: all 0.3s ease;
}

.app-btn-primary:hover {
  background: var(--app-primary-dark);
  border-color: var(--app-primary-dark);
  color: white;
  transform: translateY(-1px);
  box-shadow: var(--app-shadow-sm);
}

.app-btn-secondary {
  background: linear-gradient(45deg, #e91e63, #f06292);
  border-color: #e91e63;
  color: white;
  font-weight: 500;
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  transition: all 0.3s ease;
}

.app-btn-secondary:hover {
  background: linear-gradient(45deg, #c2185b, #e91e63);
  border-color: #c2185b;
  color: white;
  transform: translateY(-1px);
  box-shadow: var(--app-shadow-sm);
}

/* Glass Button Styles - Enhanced Contrast */
.btn-glass-blue {
  background: rgba(13, 110, 253, 0.1) !important;
  border: 1.5px solid #0d6efd !important;
  color: #0d6efd !important;
  font-weight: 600 !important;
  transition: all 0.3s ease;
}

.btn-glass-blue:hover {
  background: rgba(13, 110, 253, 0.2) !important;
  border-color: #0a58ca !important;
  color: #0a58ca !important;
  transform: translateY(-1px);
}

.btn-glass-green {
  background: rgba(25, 135, 84, 0.1) !important;
  border: 1.5px solid #198754 !important;
  color: #198754 !important;
  font-weight: 600 !important;
  transition: all 0.3s ease;
}

.btn-glass-green:hover {
  background: rgba(25, 135, 84, 0.2) !important;
  border-color: #146c43 !important;
  color: #146c43 !important;
  transform: translateY(-1px);
}

.btn-glass-orange {
  background: rgba(253, 126, 20, 0.1) !important;
  border: 1.5px solid #fd7e14 !important;
  color: #fd7e14 !important;
  font-weight: 600 !important;
  transition: all 0.3s ease;
}

.btn-glass-orange:hover {
  background: rgba(253, 126, 20, 0.2) !important;
  border-color: #e8680f !important;
  color: #e8680f !important;
  transform: translateY(-1px);
}

.btn-glass-red {
  background: rgba(220, 53, 69, 0.1) !important;
  border: 1.5px solid #dc3545 !important;
  color: #dc3545 !important;
  font-weight: 600 !important;
  transition: all 0.3s ease;
}

.btn-glass-red:hover {
  background: rgba(220, 53, 69, 0.2) !important;
  border-color: #bb2d3b !important;
  color: #bb2d3b !important;
  transform: translateY(-1px);
}

/* App Tables */
.app-table {
  border-radius: var(--app-radius);
  overflow: hidden;
  box-shadow: var(--app-shadow-sm);
}

.app-table thead th {
  background: #f8f9fa;
  border-bottom: 2px solid #e9ecef;
  font-weight: 600;
  color: #495057;
  padding: 1rem;
}

.app-table tbody tr:nth-child(odd) {
  background-color: white;
}

.app-table tbody tr:nth-child(even) {
  background-color: #f0f8ff;
}

.app-table tbody tr:hover {
  background-color: #e6f3ff !important;
}

/* App Modals - Enhanced Contrast */
.app-scope .modal-content {
  border-radius: var(--app-radius);
  border: none;
  box-shadow: var(--app-shadow-lg);
  background-color: white;
  z-index: 1100;
}

.app-scope .modal-header {
  background: var(--app-card-gradient);
  border-bottom: 1px solid rgba(102, 126, 234, 0.15);
  border-radius: var(--app-radius) var(--app-radius) 0 0;
  color: #495057;
}

.app-scope .modal-title {
  color: #343a40;
  font-weight: 600;
}

.app-scope .modal-body {
  background-color: white;
  color: #212529;
  padding: 1.5rem;
}

.app-scope .modal-footer {
  background-color: #f8f9fa;
  border-top: 1px solid #e9ecef;
  color: #6c757d;
  border-radius: 0 0 var(--app-radius) var(--app-radius);
}

/* Modal backdrop with better visibility */
.app-scope .modal-backdrop {
  background-color: rgba(0, 0, 0, 0.6);
}

/* Close button visibility */
.app-scope .btn-close {
  background-color: transparent;
  opacity: 0.8;
}

.app-scope .btn-close:hover {
  opacity: 1;
}

/* App Alerts */
.app-alert {
  border-radius: var(--app-radius);
  border: none;
  font-weight: 500;
}

/* ========================================
   BOOTSTRAP SEMANTIC CLASS FIXES (SCOPED)
   ======================================== */

/* Badge Visibility Fixes - Enhanced Contrast */
.app-scope .badge {
  font-weight: 700 !important;
  font-size: 0.75rem;
  padding: 0.5rem 0.75rem;
  text-shadow: none;
}

.app-scope .bg-secondary, 
.app-scope .badge.bg-secondary {
  background-color: #495057 !important;
  color: white !important;
  border: 1px solid #343a40;
}

.app-scope .bg-primary, 
.app-scope .badge.bg-primary {
  background-color: var(--app-primary) !important;
  color: white !important;
}

.app-scope .bg-success, 
.app-scope .badge.bg-success {
  background-color: #198754 !important;
  color: white !important;
}

.app-scope .bg-warning, 
.app-scope .badge.bg-warning {
  background-color: #ffc107 !important;
  color: #000 !important;
}

.app-scope .bg-danger, 
.app-scope .badge.bg-danger {
  background-color: #dc3545 !important;
  color: white !important;
}

.app-scope .bg-info, 
.app-scope .badge.bg-info {
  background-color: #0dcaf0 !important;
  color: #000 !important;
}

/* Text Color Fixes - Enhanced Contrast */
.app-scope .text-muted {
  color: #495057 !important;
}

.app-scope .text-secondary {
  color: #495057 !important;
}

.app-scope small, 
.app-scope .small {
  color: #495057 !important;
}

.app-scope .card-text.text-muted,
.app-scope .card .text-muted,
.app-scope .card-footer .text-muted {
  color: #343a40 !important;
}

/*Navbar school name visibility */
.app-scope .navbar .text-muted,
.app-scope .navbar-nav .text-muted {
  color: rgba(255, 255, 255, 0.9) !important;
}

.app-scope .card .small.text-muted,
.app-scope .card small.text-muted {
  color: #495057 !important;
  font-weight: 500;
}

.app-scope .text-primary {
  color: var(--app-primary) !important;
}

.app-scope .text-success {
  color: #198754 !important;
}

.app-scope .text-warning {
  color: #ffc107 !important;
}

.app-scope .text-danger {
  color: #dc3545 !important;
}

.app-scope .text-info {
  color: #0dcaf0 !important;
}

/* Button Visibility Fixes */
.app-scope .btn-secondary {
  background-color: #6c757d !important;
  border-color: #6c757d !important;
  color: white !important;
}

.app-scope .btn-secondary:hover {
  background-color: #5c636a !important;
  border-color: #565e64 !important;
  color: white !important;
}

.app-scope .btn-outline-secondary {
  color: #6c757d !important;
  border-color: #6c757d !important;
}

.app-scope .btn-outline-secondary:hover {
  background-color: #6c757d !important;
  border-color: #6c757d !important;
  color: white !important;
}

/* Table Styling Fixes - Enhanced for Maximum Readability */
.app-scope .table {
  color: #212529;
  background-color: white;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--app-radius);
  overflow: hidden;
  box-shadow: var(--app-shadow-sm);
}

.app-scope .table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-scope .table thead th {
  background: #E5E4E2;
  color: #343a40;
  font-weight: 700;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 3px solid var(--app-primary);
  border-top: none;
  padding: 1rem 0.75rem;
  text-align: left;
}

.app-scope .table tbody tr {
  border-bottom: 1px solid #e9ecef;
  transition: all 0.2s ease;
}

.app-scope .table tbody tr:nth-child(odd) {
  background-color: white;
}

.app-scope .table tbody tr:nth-child(even) {
  background-color: #f8f9ff;
}

.app-scope .table tbody tr:hover {
  background-color: #e6f3ff !important;
  box-shadow: inset 0 0 0 1px var(--app-primary);
}

.app-scope .table tbody td {
  color: #212529;
  vertical-align: middle;
  padding: 0.875rem 0.75rem;
  font-weight: 500;
  border-top: none;
}

.app-scope .table-responsive {
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-sm);
}

.app-scope .table-striped tbody tr:nth-of-type(odd) {
  background-color: white;
}

.app-scope .table-striped tbody tr:nth-of-type(even) {
  background-color: #f0f8ff;
}

.app-scope .table-hover tbody tr:hover {
  background-color: #e6f3ff !important;
}

/* Special styling for Todo table */
.app-scope .app-table.todo-table {
  margin-bottom: 0;
}

.app-scope .app-table.todo-table tbody tr {
  cursor: pointer;
}

.app-scope .app-table.todo-table tbody tr.completed {
  opacity: 0.7;
  background-color: #f8f9fa !important;
}

.app-scope .app-table.todo-table tbody tr.completed td {
  text-decoration: line-through;
  color: #6c757d;
}

.app-scope .table .btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  margin: 0 0.125rem;
}

.app-scope .table th,
.app-scope .table td {
  border-color: #e9ecef !important;
}

.app-scope .table-dark th,
.app-scope .table-dark td {
  border-color: #495057 !important;
}

/* Homework Tracker Enhancements */
.app-scope .homework-tracker-table,
#homework-grid table.homework-tracker-table {
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

.app-scope .homework-grid-scroll,
.homework-grid-scroll {
  max-width: 100%;
  overflow-x: auto;
}

.app-scope .homework-grid-scroll::-webkit-scrollbar,
.homework-grid-scroll::-webkit-scrollbar {
  height: 10px;
}

.app-scope .homework-grid-scroll::-webkit-scrollbar-track,
.homework-grid-scroll::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.app-scope .homework-grid-scroll::-webkit-scrollbar-thumb,
.homework-grid-scroll::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 10px;
}

.app-scope .homework-grid-scroll::-webkit-scrollbar-thumb:hover,
.homework-grid-scroll::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Assignment Header Card Styling */
.app-scope .assignment-header-card {
  padding: 0.5rem;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-radius: 8px;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.app-scope .assignment-title-multi-line {
  font-weight: 600;
  font-size: 0.875rem;
  color: #212529;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
  line-height: 1.3;
  cursor: help;
  word-break: break-word;
}

.app-scope .assignment-date-row {
  font-size: 0.75rem;
  color: #6c757d;
  padding-top: 0.25rem;
  border-top: 1px solid #e9ecef;
}

.app-scope .assignment-header-column {
  vertical-align: top !important;
  padding: 0.75rem !important;
  background: white;
}

/* Sticky student column - FIXED TO STAY IN VIEW WHEN SCROLLING */
/* Force table-responsive to allow sticky positioning */
#homework-grid .table-responsive {
  overflow-x: auto !important;
  overflow-y: auto !important;
  max-height: 70vh;
  position: relative;
}

#homework-grid table thead th.student-column {
  position: -webkit-sticky !important;
  position: sticky !important;
  left: 0 !important;
  top: 0 !important;
  z-index: 30 !important;
  background-color: #E5E4E2 !important;
  box-shadow: 2px 0 5px rgba(0,0,0,0.1);
  border-right: 2px solid #dee2e6 !important;
  min-width: 200px !important;
  max-width: 200px !important;
  width: 200px !important;
}

#homework-grid table tbody td.student-name-cell {
  position: -webkit-sticky !important;
  position: sticky !important;
  left: 0 !important;
  z-index: 15 !important;
  box-shadow: 2px 0 5px rgba(0,0,0,0.1);
  border-right: 2px solid #dee2e6 !important;
  font-weight: 600;
  color: #212529;
  min-width: 200px !important;
  max-width: 200px !important;
  width: 200px !important;
}

/* Ensure row backgrounds extend properly to sticky cells - match template colors */
#homework-grid table tbody tr:nth-child(odd) td.student-name-cell {
  background-color: #ffffff !important;
}

#homework-grid table tbody tr:nth-child(even) td.student-name-cell {
  background-color: #f8f9fa !important;
}

/* Student header box styling */
#homework-grid .student-header-box {
  padding: 0.75rem;
  background-color: #E5E4E2;
}

#homework-grid .student-header-title {
  font-weight: 700;
  font-size: 1rem;
  color: #495057;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#homework-grid .student-sort-row {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-scope .sort-label {
  color: #495057;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  text-transform: uppercase;
  flex-grow: 0;
  flex-shrink: 0;
}

.app-scope .sort-btn {
  position: relative;
  width: 42px;
  height: 42px;
  padding: 0.15rem 0.35rem;
  border: 2px solid #adb5bd;
  background-color: white;
  border-radius: 8px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  transition: all 0.2s ease;
}

.app-scope .sort-btn i {
  font-size: 1rem;
  color: #495057;
  flex-shrink: 0;
}

.app-scope .sort-btn .sort-az {
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.1;
  color: #495057;
  text-align: center;
  letter-spacing: 0.5px;
  display: flex;
  flex-direction: column;
}

.app-scope .sort-btn:hover {
  background-color: #f8f9fa;
  border-color: #6c757d;
}

/* 1. Sorting A-Z button blue indicator - Higher specificity */
#homework-grid .sort-btn.active,
.app-scope #homework-grid .sort-btn.active {
  background-color: #0d6efd !important; /* Blue */
  border-color: #0d6efd !important;
}

#homework-grid .sort-btn.active i,
#homework-grid .sort-btn.active .sort-az,
.app-scope #homework-grid .sort-btn.active i,
.app-scope #homework-grid .sort-btn.active .sort-az {
  color: white !important;
}

/* 2. Header boxes (Add assignment, download reports, homework tracking) - NOT assignment headers in grid */
#homework-container .card,
.app-scope #homework-container > .row > .col-md-6 > .card {
  background-color: #D3D3D3 !important; /* Light Gray */
  border: 1px solid #D3D3D3 !important;
  box-shadow: var(--app-shadow-sm);
  border-radius: 8px;
}

#homework-container .card .card-header,
.app-scope #homework-container > .row > .col-md-6 > .card .card-header {
  background-color: #D3D3D3 !important; /* Light Gray */
  border-bottom: 1px solid #b8b8b8 !important;
  color: #212529 !important;
}

#homework-container .card .card-body,
.app-scope #homework-container > .row > .col-md-6 > .card .card-body {
  background-color: #D3D3D3 !important; /* Light Gray */
}

/* Keep assignment header cards in the grid with their own styling */
.app-scope .assignment-header-card {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%) !important;
  border-radius: 8px;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.75rem;
}

/* 3. Background of every alternative student row */
#homework-grid table tbody tr:nth-child(odd),
.app-scope #homework-grid table tbody tr:nth-child(odd) {
  background-color: #ffffff !important;
}

#homework-grid table tbody tr:nth-child(even),
.app-scope #homework-grid table tbody tr:nth-child(even) {
  background-color: #D3D3D3 !important; /* Light Gray */
}

/* Ensure sticky student name cell has opaque background */
#homework-grid table tbody tr:nth-child(odd) td.student-name-cell,
.app-scope #homework-grid table tbody tr:nth-child(odd) td.student-name-cell {
  background-color: #ffffff !important;
}

#homework-grid table tbody tr:nth-child(even) td.student-name-cell,
.app-scope #homework-grid table tbody tr:nth-child(even) td.student-name-cell {
  background-color: #D3D3D3 !important; /* Light Gray */
}

/* 4. Homework cell status badges - match the key exactly */
/* Completed */
#homework-grid .hw-cell.bg-success,
.app-scope #homework-grid .hw-cell.bg-success {
  background-color: #198754 !important;
  color: white !important;
  border: 1px solid #146c43 !important;
}

/* Partial */
#homework-grid .hw-cell.bg-warning,
.app-scope #homework-grid .hw-cell.bg-warning {
  background-color: #ffc107 !important;
  color: #000 !important;
  border: 1px solid #ffb300 !important;
}

/* 5. Late - dark orange */
#homework-grid .hw-cell.bg-late,
.app-scope #homework-grid .hw-cell.bg-late {
  background-color: #ff6600 !important; /* Dark Orange */
  color: white !important;
  border: 1px solid #e65c00 !important;
}

/* Absent when set */
#homework-grid .hw-cell.bg-secondary,
.app-scope #homework-grid .hw-cell.bg-secondary {
  background-color: #495057 !important;
  color: white !important;
  border: 1px solid #343a40 !important;
}

/* 4. Absent when due - white with red border */
#homework-grid .hw-cell.bg-info,
.app-scope #homework-grid .hw-cell.bg-info {
  background-color: white !important;
  color: #dc3545 !important;
  border: 2px solid #dc3545 !important;
}

/* Not submitted / dash */
#homework-grid .hw-cell:not([class*="bg-"]),
.app-scope #homework-grid .hw-cell:not([class*="bg-"]) {
  background-color: white !important;
  color: #6c757d !important;
  border: 1px solid #dee2e6 !important;
}

/* Overdue (red background) */
#homework-grid .hw-cell.bg-danger,
.app-scope #homework-grid .hw-cell.bg-danger {
  background-color: #dc3545 !important;
  color: white !important;
  border: 1px solid #bb2d3b !important;
}

/* Dropdown menu styling for assignment actions */
.app-scope .assignment-header-card .dropdown-menu {
  min-width: 150px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.app-scope .assignment-header-card .dropdown-item {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.app-scope .assignment-header-card .dropdown-item:hover {
  background-color: #f8f9fa;
}

.app-scope .assignment-header-card .dropdown-item i {
  width: 20px;
  text-align: center;
}

/* Alert Visibility Fixes */
.app-scope .alert {
  border: 1px solid transparent;
  border-radius: 0.375rem;
  padding: 0.75rem 1.25rem;
  margin-bottom: 1rem;
}

.app-scope .alert-success {
  color: #0f5132;
  background-color: #d1e7dd;
  border-color: #badbcc;
}

.app-scope .alert-info {
  color: #055160;
  background-color: #d1ecf1;
  border-color: #b8daff;
}

.app-scope .alert-warning {
  color: #664d03;
  background-color: #fff3cd;
  border-color: #ffecb5;
}

.app-scope .alert-danger {
  color: #842029;
  background-color: #f8d7da;
  border-color: #f5c2c7;
}

/* Focus States */
.app-scope .btn:focus,
.app-scope .form-control:focus,
.app-scope .form-select:focus {
  outline: 2px solid var(--app-primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

/* Card Text Visibility - Enhanced */
.app-scope .card {
  color: #212529;
}

.app-scope .card-header {
  color: #343a40;
  font-weight: 600;
}

.app-scope .card-body {
  color: #212529;
}

.app-scope .card-body h1, 
.app-scope .card-body h2, 
.app-scope .card-body h3, 
.app-scope .card-body h4, 
.app-scope .card-body h5, 
.app-scope .card-body h6 {
  color: #212529 !important;
}

.app-scope .card-footer {
  color: #495057;
}

.app-scope .card-title {
  color: #212529 !important;
  font-weight: 600;
}

.app-scope .card-subtitle {
  color: #495057 !important;
  font-weight: 500;
}

.app-scope .card .text-center strong {
  color: #212529 !important;
}

.app-scope .card .text-center span {
  color: #495057 !important;
  font-weight: 500;
}

/* Department Text Styling */
.department-text {
  font-weight: 600 !important;
  color: white !important;
  padding: 0.25rem 0.5rem !important;
  border-radius: 4px !important;
  font-size: 0.85rem !important;
}

/* Department color styles */
.department-mathematics { background: rgba(0, 123, 255, 0.9) !important; }
.department-science, .department-sciences { background: rgba(23, 162, 184, 0.9) !important; }
.department-english { background: rgba(40, 167, 69, 0.9) !important; }
.department-history { background: rgba(255, 193, 7, 0.9) !important; color: #212529 !important; }
.department-geography { background: rgba(220, 53, 69, 0.9) !important; }
.department-modernlanguages { background: rgba(111, 66, 193, 0.9) !important; }
.department-physicaleducation { background: rgba(253, 126, 20, 0.9) !important; }
.department-artanddesign { background: rgba(214, 51, 132, 0.9) !important; }
.department-music { background: rgba(233, 30, 99, 0.9) !important; }
.department-computing { background: rgba(33, 37, 41, 0.9) !important; }
.department-religiouseducation { background: rgba(102, 16, 242, 0.9) !important; }
.department-designandtechnology { background: rgba(32, 201, 151, 0.9) !important; }
.department-languages { background: rgba(111, 66, 193, 0.9) !important; }
.department-humanities { background: rgba(156, 39, 176, 0.9) !important; }
.department-artsandcreativesubjects { background: rgba(214, 51, 132, 0.9) !important; }
.department-businessandeconomics { background: rgba(76, 175, 80, 0.9) !important; }
.department-vocationalandappliedsubjects { background: rgba(255, 152, 0, 0.9) !important; }
.department-learningsupport { background: rgba(63, 81, 181, 0.9) !important; }
.department-administration { background: rgba(96, 125, 139, 0.9) !important; }
.department-other { background: rgba(108, 117, 125, 0.9) !important; }

/* ========================================
   DASHBOARD PAGE STYLING
   ======================================== */

.hero-dashboard {
  background: #eeecea;
  padding: 3rem 2rem;
  border-radius: var(--app-radius);
  margin-bottom: 2rem;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: #212529;
  margin-bottom: 1rem;
}

.hero-description {
  font-size: 1.2rem;
  color: #6c757d;
  margin-bottom: 2rem;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-bottom: 3rem;
}

.dashboard-main-card {
  background: white;
  padding: 2rem;
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-sm);
  transition: all 0.3s ease;
  border: 1px solid #e9ecef;
}

.dashboard-main-card:hover {
  box-shadow: var(--app-shadow-md);
  transform: translateY(-5px);
}

.dashboard-main-card .card-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
}

.dashboard-main-card h3 {
  color: #212529;
  font-weight: 600;
  margin-bottom: 1rem;
}

.dashboard-main-card p {
  color: #6c757d;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.features-section {
  background: white;
  padding: 3rem 2rem;
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-sm);
}

.features-title {
  text-align: center;
  color: #212529;
  font-weight: 700;
  margin-bottom: 2rem;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
}

.feature-group h4 {
  color: #212529;
  font-weight: 600;
  margin-bottom: 1rem;
}

.feature-list {
  list-style: none;
  padding: 0;
}

.feature-list li {
  color: #6c757d;
  margin-bottom: 0.5rem;
  padding-left: 1.5rem;
  position: relative;
}

.feature-list li:before {
  content: "✓";
  color: var(--app-primary);
  font-weight: bold;
  position: absolute;
  left: 0;
}

/* Todo List Action Buttons */
.action-btn {
  border: 2px solid #333 !important;
  border-radius: 4px !important;
  padding: 0.375rem 0.5rem !important;
  font-size: 1rem !important;
  line-height: 1 !important;
  transition: all 0.2s ease !important;
  min-width: 36px !important;
  min-height: 36px !important;
}

.btn-complete {
  background-color: #c8e6c9 !important;
  color: #2e7d32 !important;
  border-color: #333 !important;
}

.btn-complete:hover {
  background-color: #a5d6a7 !important;
  color: #1b5e20 !important;
  border-color: #333 !important;
}

.btn-edit {
  background-color: #fff9c4 !important;
  color: #f57f17 !important;
  border-color: #333 !important;
}

.btn-edit:hover {
  background-color: #fff59d !important;
  color: #ef6c00 !important;
  border-color: #333 !important;
}

.btn-delete {
  background-color: #ffcdd2 !important;
  color: #c62828 !important;
  border-color: #333 !important;
}

.btn-delete:hover {
  background-color: #ef9a9a !important;
  color: #b71c1c !important;
  border-color: #333 !important;
}

/* Todo List Content Styling */
.todo-task-description {
  font-size: calc(1rem - 4pt) !important;
  color: #666 !important;
  margin-top: 0.25rem !important;
  line-height: 1.4 !important;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
  .app-card .card-body {
    padding: 1.5rem;
  }

  .app-card .card-header,
  .app-card .card-footer {
    padding: 1rem 1.5rem;
  }
}

/* Mobile nav accordion — navbar-expand-lg collapses below 992px */
@media (max-width: 991.98px) {
  .app-navbar {
    height: 70px;
    min-height: 70px;
    overflow: visible;
  }

  /* Floating panel drops below navbar */
  .app-navbar .navbar-collapse {
    position: absolute;
    top: 70px;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #3ab8b0 0%, #38a8c5 50%, #7bbfa4 100%);
    padding: 0.5rem 0.75rem 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    z-index: 1049;
    max-height: calc(100vh - 70px);
    overflow-y: auto;
  }

  /* Stack items tightly — no stretching */
  .app-navbar .navbar-collapse .navbar-nav {
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    width: 100%;
    gap: 2px;
  }

  .app-navbar .navbar-collapse .nav-item {
    width: 100%;
  }

  /* Section header rows */
  .app-navbar .navbar-collapse .nav-link {
    padding: 0.7rem 0.85rem !important;
    font-size: 0.95rem;
    border-radius: 8px;
    display: flex !important;
    align-items: center;
    width: 100%;
  }

  /* Rotate Bootstrap's caret when section is open */
  .app-navbar .navbar-collapse .nav-item.mobile-open > .nav-link::after {
    transform: rotate(180deg);
  }
  .app-navbar .navbar-collapse .nav-link::after {
    transition: transform 0.2s ease;
  }

  /* Accordion sub-menu: hidden by default, shown via .mobile-open */
  .app-navbar .navbar-collapse .dropdown-menu {
    display: none !important;
    position: static !important;
    float: none !important;
    background: rgba(0,0,0,0.14) !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 8px !important;
    margin: 0 0 4px 0.75rem !important;
    padding: 4px 0 !important;
    width: auto !important;
    min-width: 0 !important;
  }

  .app-navbar .navbar-collapse .nav-item.mobile-open > .dropdown-menu {
    display: block !important;
  }

  /* Sub-items */
  .app-navbar .navbar-collapse .dropdown-item {
    color: rgba(255,255,255,0.93) !important;
    padding: 0.6rem 1rem !important;
    border-radius: 6px !important;
    font-size: 0.9rem !important;
    background: transparent !important;
  }

  .app-navbar .navbar-collapse .dropdown-item:hover,
  .app-navbar .navbar-collapse .dropdown-item:focus {
    background: rgba(255,255,255,0.18) !important;
    color: white !important;
  }

  .app-navbar .navbar-collapse .dropdown-item.active {
    background: rgba(255,255,255,0.25) !important;
    color: white !important;
    font-weight: 600 !important;
  }

  .app-navbar .navbar-collapse .dropdown-divider {
    border-color: rgba(255,255,255,0.2) !important;
    margin: 4px 8px !important;
  }

  /* Right-side nav (user/bell) stacks cleanly below main nav */
  .app-navbar .navbar-collapse > ul + ul {
    border-top: 1px solid rgba(255,255,255,0.2);
    margin-top: 6px;
    padding-top: 6px;
  }
}

/* ========================================
   DARK MODE
   Activated by body.dark-mode class
   ======================================== */

body.dark-mode {
  --app-bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b2e 50%, #0f1f18 100%);
  --app-navbar-gradient: linear-gradient(135deg, #1a3a38 0%, #1a2e3a 40%, #1e2d28 100%);
  background: var(--app-bg-gradient);
  color: #e2e8f0;
}

body.dark-mode .main-content,
body.dark-mode .container {
  color: #e2e8f0;
}

/* Cards & sections */
body.dark-mode .card,
body.dark-mode .account-section,
body.dark-mode .settings-section,
body.dark-mode .profile-section,
body.dark-mode .profile-page-nav,
body.dark-mode .profile-nav,
body.dark-mode .save-bar,
body.dark-mode .faq-item,
body.dark-mode .plan-card,
body.dark-mode .service-row {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

body.dark-mode .card-header {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .card-body {
  color: #cbd5e1;
}

/* Navigation */
body.dark-mode .profile-page-nav a,
body.dark-mode .profile-nav a {
  color: #94a3b8;
}

body.dark-mode .profile-page-nav a:hover,
body.dark-mode .profile-nav a:hover {
  background: #334155;
  color: #e2e8f0;
}

body.dark-mode .profile-nav a.active {
  background: #e2e8f0;
  color: #0f172a;
}

/* Notes page dark mode */
body.dark-mode .tags-sidebar {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .tag-item:hover {
  background: #334155;
}

body.dark-mode .tag-item.active {
  background: rgba(102, 126, 234, 0.15);
}

body.dark-mode .tag-count {
  background: #334155;
  color: #94a3b8;
}

body.dark-mode .note-card {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .note-card:hover {
  border-color: #475569;
}

body.dark-mode .note-title {
  color: #f1f5f9;
}

body.dark-mode .note-preview {
  color: #94a3b8;
}

body.dark-mode .note-icon-display,
body.dark-mode .note-thumbnail-placeholder {
  background: #0f172a;
}

body.dark-mode .note-card:hover .note-icon-display,
body.dark-mode .note-card:hover .note-thumbnail-placeholder {
  background: #162032;
}

body.dark-mode .note-tag {
  background: #334155;
  color: #cbd5e1;
}

body.dark-mode .note-action-btn {
  background: rgba(30, 41, 59, 0.92);
  color: #94a3b8;
}

body.dark-mode .note-action-btn:hover {
  background: #334155;
  color: #f1f5f9;
}

body.dark-mode .toggle-tags-btn {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

body.dark-mode .toggle-tags-btn:hover {
  background: #334155;
  color: #e2e8f0;
}

body.dark-mode .notes-search-wrap .input-group {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .notes-search-wrap .form-control {
  background: transparent;
  color: #e2e8f0;
}

body.dark-mode .new-note-btn {
  background: #e2e8f0;
  color: #0f172a;
}

body.dark-mode .new-note-btn:hover {
  background: #f1f5f9;
}

body.dark-mode .view-toggle {
  background: #0f172a;
  border-color: #334155;
}

body.dark-mode .view-toggle-btn {
  color: #64748b;
}

body.dark-mode .view-toggle-btn.active {
  background: #334155;
  color: #e2e8f0;
}

body.dark-mode .notes-tabs {
  border-color: #334155;
}

body.dark-mode .notes-tab {
  color: #64748b;
}

body.dark-mode .notes-tab.active {
  color: #e2e8f0;
}

body.dark-mode .notes-tab.active::after {
  background: #e2e8f0;
}

body.dark-mode .filter-chip {
  background: rgba(102, 126, 234, 0.15);
  border-color: rgba(102, 126, 234, 0.3);
}

/* Text */
body.dark-mode h1, body.dark-mode h2, body.dark-mode h3,
body.dark-mode h4, body.dark-mode h5, body.dark-mode h6 {
  color: #f1f5f9;
}

body.dark-mode .text-muted {
  color: #94a3b8 !important;
}

body.dark-mode .text-dark {
  color: #e2e8f0 !important;
}

body.dark-mode .info-label,
body.dark-mode .setting-desc {
  color: #94a3b8;
}

body.dark-mode .info-value,
body.dark-mode .setting-label {
  color: #e2e8f0;
}

/* Form controls */
body.dark-mode .form-control,
body.dark-mode .form-select {
  background-color: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}

body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus {
  background-color: #0f172a;
  border-color: var(--app-primary);
  color: #e2e8f0;
}

body.dark-mode .form-text {
  color: #64748b;
}

body.dark-mode .form-check-label {
  color: #cbd5e1;
}

/* Inputs group */
body.dark-mode .input-group-text {
  background: #334155;
  border-color: #334155;
  color: #94a3b8;
}

/* Badges */
body.dark-mode .badge.bg-secondary {
  background: #334155 !important;
  color: #cbd5e1;
}

/* Borders */
body.dark-mode .info-row,
body.dark-mode .service-row,
body.dark-mode .setting-row {
  border-color: #334155;
}

/* Buttons */
body.dark-mode .btn-outline-primary {
  color: #93c5fd;
  border-color: #3b82f6;
}

body.dark-mode .btn-outline-primary:hover {
  background: #1e3a5f;
  color: #bfdbfe;
}

/* Theme toggle */
body.dark-mode .theme-toggle {
  background: #0f172a;
  border-color: #334155;
}

body.dark-mode .theme-toggle button {
  color: #94a3b8;
}

body.dark-mode .theme-toggle button.active {
  background: #e2e8f0;
  color: #0f172a;
}

/* Duration input */
body.dark-mode .duration-input {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}

/* Home option cards */
body.dark-mode .home-option {
  border-color: #334155;
  background: #1e293b;
  color: #94a3b8;
}

body.dark-mode .home-option:hover {
  border-color: #475569;
  background: #263044;
}

body.dark-mode .home-option.active {
  border-color: #e2e8f0;
  background: #e2e8f0;
  color: #0f172a;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}

/* Class chips */
body.dark-mode .class-chip {
  background: #0f172a;
  border-color: #334155;
  color: #cbd5e1;
}

body.dark-mode .class-chip:hover {
  background: #1e2d4a;
  border-color: #3b82f6;
  color: #93c5fd;
}

/* Dept chips */
body.dark-mode .dept-chip {
  background: #1e2d4a;
  border-color: #334155;
  color: #93c5fd;
}

/* Section accent bar - lighten for dark mode */
body.dark-mode .profile-section::before,
body.dark-mode .account-section::before,
body.dark-mode .settings-section::before {
  opacity: 0;
}

body.dark-mode .profile-section:hover::before,
body.dark-mode .account-section:hover::before,
body.dark-mode .settings-section:hover::before {
  opacity: 0.7;
}

/* Dark buttons - invert for dark mode */
body.dark-mode .btn-save-profile,
body.dark-mode .btn-primary,
body.dark-mode .btn-save {
  background: #e2e8f0;
  color: #0f172a;
}

body.dark-mode .btn-save-profile:hover,
body.dark-mode .btn-primary:hover,
body.dark-mode .btn-save:hover {
  background: #f1f5f9;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Edit button */
body.dark-mode .edit-btn {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

body.dark-mode .edit-btn:hover {
  background: #334155;
  color: #e2e8f0;
}

/* Service icons */
body.dark-mode .service-icon.disconnected {
  background: #334155;
  color: #64748b;
}

body.dark-mode .service-icon.connected {
  background: rgba(16, 185, 129, 0.15);
}

/* Modals */
body.dark-mode .modal-content {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

body.dark-mode .modal-header {
  border-color: #334155;
}

body.dark-mode .modal-footer {
  border-color: #334155;
}

body.dark-mode .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* Footer */
body.dark-mode footer.bg-dark {
  background: #0a0f1a !important;
}

/* Alerts */
body.dark-mode .alert {
  border: none;
}

/* Dropdown menus */
body.dark-mode .dropdown-menu {
  background: #1e293b !important;
  border-color: #334155 !important;
}

body.dark-mode .dropdown-item,
body.dark-mode .app-scope .dropdown-item {
  color: #cbd5e1 !important;
}

body.dark-mode .dropdown-item:hover,
body.dark-mode .dropdown-item:focus,
body.dark-mode .app-scope .dropdown-item:hover,
body.dark-mode .app-scope .dropdown-item:focus {
  background: #334155 !important;
  color: #f1f5f9 !important;
}

body.dark-mode .dropdown-divider {
  border-color: #334155;
}

body.dark-mode .dropdown-header {
  color: #94a3b8;
}

/* Beta banner */
body.dark-mode .beta-banner {
  background: rgba(30, 41, 59, 0.9) !important;
  border-color: #334155 !important;
}

/* Tables */
body.dark-mode .table {
  color: #e2e8f0;
  border-color: #334155;
}

body.dark-mode .table > thead {
  color: #94a3b8;
}

body.dark-mode .table-striped > tbody > tr:nth-of-type(odd) > * {
  background: rgba(15, 23, 42, 0.5);
  color: #e2e8f0;
}

/* Plan card (upgrade page) */
body.dark-mode .plan-card.recommended {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 1px var(--app-primary), 0 4px 16px rgba(0,0,0,0.4);
}

body.dark-mode .plan-name {
  color: #f1f5f9;
}

body.dark-mode .plan-desc {
  color: #94a3b8;
}

body.dark-mode .plan-features li {
  color: #cbd5e1;
}

body.dark-mode .plan-features li.disabled {
  color: #475569;
}

/* ── Note editor dark mode ── */
body.dark-mode .note-editor-container {
  background: #0f172a;
}

body.dark-mode .note-sidebar {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .note-sidebar::-webkit-scrollbar-thumb {
  background: #475569;
}

body.dark-mode .sidebar-header {
  border-color: #334155;
}

body.dark-mode .sidebar-title {
  color: #64748b;
}

body.dark-mode .sidebar-note-item:hover {
  background: #263044;
}

body.dark-mode .sidebar-note-item.active {
  background: rgba(102, 126, 234, 0.15);
  border-left-color: #d4550a;
}

body.dark-mode .sidebar-note-title {
  color: #f1f5f9;
}

body.dark-mode .sidebar-note-preview {
  color: #64748b;
}

body.dark-mode .tags-section {
  border-color: #334155;
}

body.dark-mode .tags-section-title {
  color: #64748b;
}

body.dark-mode .tag-pill {
  background: rgba(102, 126, 234, 0.2);
  border-color: rgba(102, 126, 234, 0.3);
  color: #93c5fd;
}

body.dark-mode .tag-pill:hover {
  background: rgba(102, 126, 234, 0.3);
}

body.dark-mode .tag-input {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}

body.dark-mode .tag-input:focus {
  border-color: #d4550a;
}

body.dark-mode .tag-add-btn {
  background: #0f172a;
  border-color: #334155;
  color: #94a3b8;
}

body.dark-mode .tag-add-btn:hover {
  background: #1e293b;
  border-color: #475569;
  color: #e2e8f0;
}

body.dark-mode .tags-hint {
  color: #475569;
}

body.dark-mode .note-toolbar-container {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .toggle-sidebar-btn {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

body.dark-mode .toggle-sidebar-btn:hover {
  background: #334155;
  color: #e2e8f0;
}

body.dark-mode .breadcrumb-nav {
  color: #64748b;
}

body.dark-mode .breadcrumb-nav a {
  color: #64748b;
}

body.dark-mode .breadcrumb-nav a:hover {
  color: #e2e8f0;
}

body.dark-mode .note-title-input {
  color: #f1f5f9;
  border-bottom-color: #334155;
}

body.dark-mode .note-title-input:focus {
  border-bottom-color: #d4550a;
}

body.dark-mode .note-title-input::placeholder {
  color: #475569;
}

body.dark-mode .note-icon-btn {
  background: #0f172a;
  border-color: #334155;
}

body.dark-mode .note-icon-btn:hover {
  border-color: #d4550a;
  background: rgba(102, 126, 234, 0.1);
}

body.dark-mode .note-icon-btn.has-icon {
  border-color: #d4550a;
  background: rgba(102, 126, 234, 0.15);
}

body.dark-mode .editor-wrapper {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.15);
}

body.dark-mode .toolbar-btn {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

body.dark-mode .toolbar-btn:hover {
  background: #334155;
  border-color: #475569;
  color: #e2e8f0;
}

body.dark-mode .toolbar-btn.danger:hover {
  background: rgba(220, 53, 69, 0.15);
  border-color: #dc3545;
  color: #f87171;
}

body.dark-mode .toolbar-btn[id="saveBtn"] {
  background: #e2e8f0;
  color: #0f172a;
  border-color: transparent;
}

body.dark-mode .toolbar-btn[id="saveBtn"]:hover {
  background: #f1f5f9;
}

body.dark-mode .save-status {
  background: #0f172a;
  color: #64748b;
}

body.dark-mode .save-status.saving {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

body.dark-mode .save-status.saved {
  background: rgba(40, 167, 69, 0.15);
  color: #4ade80;
}

body.dark-mode .icon-option {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .icon-option:hover {
  border-color: #d4550a;
  background: rgba(102, 126, 234, 0.1);
}

body.dark-mode .icon-option.selected {
  border-color: #d4550a;
  background: rgba(102, 126, 234, 0.2);
}

body.dark-mode .icon-option i {
  color: #94a3b8;
}

body.dark-mode .icon-option:hover i,
body.dark-mode .icon-option.selected i {
  color: #93c5fd;
}

body.dark-mode .icon-category-title {
  color: #64748b;
}

body.dark-mode .tox-tinymce {
  border-color: #334155 !important;
}

body.dark-mode .tox .tox-toolbar-overlord {
  background: #1e293b !important;
}

body.dark-mode .tox .tox-toolbar__primary {
  background: #1e293b !important;
}

body.dark-mode .tox .tox-tbtn {
  color: #94a3b8 !important;
}

body.dark-mode .tox .tox-tbtn:hover {
  background: #334155 !important;
  color: #e2e8f0 !important;
}

body.dark-mode .tox .tox-tbtn--enabled,
body.dark-mode .tox .tox-tbtn--enabled:hover {
  background: #334155 !important;
  color: #e2e8f0 !important;
}

body.dark-mode .tox .tox-tbtn svg {
  fill: #94a3b8 !important;
}

body.dark-mode .tox .tox-tbtn:hover svg,
body.dark-mode .tox .tox-tbtn--enabled svg {
  fill: #e2e8f0 !important;
}

body.dark-mode .tox .tox-toolbar__group:not(:last-of-type) {
  border-color: #334155 !important;
}

body.dark-mode .tox .tox-statusbar {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #64748b !important;
}

body.dark-mode .tox .tox-statusbar a,
body.dark-mode .tox .tox-statusbar__path-item {
  color: #64748b !important;
}

body.dark-mode .tox .tox-menubar {
  background: #1e293b !important;
}

body.dark-mode .tox .tox-mbtn {
  color: #94a3b8 !important;
}

body.dark-mode .tox .tox-mbtn:hover,
body.dark-mode .tox .tox-mbtn--active {
  background: #334155 !important;
  color: #e2e8f0 !important;
}

/* ========================================
   COLOUR THEMES (END)
   Placed AFTER body.dark-mode so source-order wins specificity ties
   on (0,1,1). Each theme overrides --app-teal-gradient so Bootstrap
   primary / bg-primary / btn-primary pick up the theme's palette.
   ======================================== */

/* Ocean Blue — same values as :root defaults; class exists so JS active state works */
body.theme-ocean-blue {
  --app-primary: #45b7d1; --app-primary-dark: #35a0ba;
  --app-navbar-gradient: linear-gradient(135deg,#1a3559 0%,#2d6b9a 40%,#45b7d1 70%,#78dcc0 100%);
  --app-teal-gradient: linear-gradient(135deg,#35a0ba 0%,#45b7d1 100%);
  --app-bg-gradient: #f7f6f3; --bs-primary: #45b7d1; --bs-primary-rgb: 69,183,209;
  --od-sidebar-bg: 210 60% 12%; --od-sidebar-primary: 174 50% 55%;
  --od-sidebar-accent: 210 50% 18%; --od-sidebar-border: 210 45% 20%;
  --od-primary: 195 55% 45%; --od-accent: 174 50% 55%;
  --od-ocean-dark: 210 60% 12%; --od-ocean-mid: 200 55% 27%;
  --od-ocean-teal: 195 55% 45%; --od-ocean-mint: 174 50% 55%;
}

/* Tan Leather Brown */
body.theme-tan-leather {
  --app-primary: #c8956c; --app-primary-dark: #b07040;
  --app-navbar-gradient: linear-gradient(135deg,#4a2810 0%,#8b5e3c 40%,#c8956c 70%,#d4a848 100%);
  --app-teal-gradient: linear-gradient(135deg,#b07040 0%,#c8956c 100%);
  --app-bg-gradient: #fdf8f0; --bs-primary: #c8956c; --bs-primary-rgb: 200,149,108;
  --od-sidebar-bg: 25 60% 18%; --od-sidebar-primary: 38 60% 55%;
  --od-sidebar-accent: 25 55% 25%; --od-sidebar-border: 25 50% 28%;
  --od-primary: 25 55% 58%; --od-accent: 38 60% 55%;
  --od-ocean-dark: 25 60% 18%; --od-ocean-mid: 25 55% 30%;
  --od-ocean-teal: 25 55% 50%; --od-ocean-mint: 38 60% 55%;
  /* Primary is warm here — shift the feature zone cool so the two stay distinct */
  --od-feature: 200 60% 45%; --od-feature-hover: 202 62% 38%;
  --od-feature-soft: 200 50% 92%; --od-feature-ink: 205 55% 30%;
}

/* Redwood Forest */
body.theme-redwood-forest {
  --app-primary: #3a8a3a; --app-primary-dark: #2a7a2a;
  --app-navbar-gradient: linear-gradient(135deg,#0d2b0d 0%,#1e5c1e 40%,#3a8a3a 70%,#7ec87e 100%);
  --app-teal-gradient: linear-gradient(135deg,#2a7a2a 0%,#3a8a3a 100%);
  --app-bg-gradient: #f0f7f0; --bs-primary: #3a8a3a; --bs-primary-rgb: 58,138,58;
  --od-sidebar-bg: 120 55% 12%; --od-sidebar-primary: 120 40% 60%;
  --od-sidebar-accent: 120 50% 18%; --od-sidebar-border: 120 45% 22%;
  --od-primary: 120 42% 40%; --od-accent: 120 40% 60%;
  --od-ocean-dark: 120 55% 12%; --od-ocean-mid: 120 50% 22%;
  --od-ocean-teal: 120 42% 40%; --od-ocean-mint: 120 40% 60%;
}

/* Sunny Skies */
body.theme-sunny-skies {
  --app-primary: #5b9bd5; --app-primary-dark: #4a7ab5;
  --app-navbar-gradient: linear-gradient(135deg,#1a2040 0%,#2d5080 40%,#5b9bd5 70%,#a0c8e8 100%);
  --app-teal-gradient: linear-gradient(135deg,#4a7ab5 0%,#5b9bd5 100%);
  --app-bg-gradient: #f5f9ff; --bs-primary: #5b9bd5; --bs-primary-rgb: 91,155,213;
  --od-sidebar-bg: 228 42% 18%; --od-sidebar-primary: 38 90% 55%;
  --od-sidebar-accent: 228 38% 25%; --od-sidebar-border: 228 35% 28%;
  --od-primary: 210 65% 58%; --od-accent: 38 90% 55%;
  --od-ocean-dark: 228 42% 18%; --od-ocean-mid: 218 50% 30%;
  --od-ocean-teal: 210 65% 50%; --od-ocean-mint: 38 90% 55%;
}

/* Amethyst Night — also gets body.dark-mode applied by JS/Jinja */
body.theme-amethyst-night {
  --app-primary: #8b2fc9; --app-primary-dark: #7a1ab8;
  --app-navbar-gradient: linear-gradient(135deg,#1a0a2e 0%,#4a1a7c 40%,#8b2fc9 70%,#c840d0 100%);
  --app-teal-gradient: linear-gradient(135deg,#7a1ab8 0%,#8b2fc9 100%);
  --app-bg-gradient: linear-gradient(135deg,#1a0a2e 0%,#2d0f4a 50%,#1a0a2e 100%);
  --bs-primary: #8b2fc9; --bs-primary-rgb: 139,47,201;
  --od-sidebar-bg: 270 55% 12%; --od-sidebar-primary: 295 65% 55%;
  --od-sidebar-accent: 270 50% 18%; --od-sidebar-border: 270 45% 22%;
  --od-primary: 280 55% 50%; --od-accent: 295 65% 55%;
  --od-ocean-dark: 270 55% 12%; --od-ocean-mid: 275 52% 28%;
  --od-ocean-teal: 280 55% 42%; --od-ocean-mint: 295 65% 55%;
}

/* Rose Blush */
body.theme-rose-blush {
  --app-primary: #c94a6a; --app-primary-dark: #b83060;
  --app-navbar-gradient: linear-gradient(135deg,#3d0a1a 0%,#7a1a3a 40%,#c94a6a 70%,#e8958c 100%);
  --app-teal-gradient: linear-gradient(135deg,#b83060 0%,#c94a6a 100%);
  --app-bg-gradient: #fff5f7; --bs-primary: #c94a6a; --bs-primary-rgb: 201,74,106;
  --od-sidebar-bg: 345 65% 15%; --od-sidebar-primary: 12 65% 72%;
  --od-sidebar-accent: 345 60% 22%; --od-sidebar-border: 345 55% 25%;
  --od-primary: 345 55% 55%; --od-accent: 12 65% 72%;
  --od-ocean-dark: 345 65% 15%; --od-ocean-mid: 345 60% 28%;
  --od-ocean-teal: 345 55% 45%; --od-ocean-mint: 12 65% 72%;
}

/* Metal Gear — also gets body.dark-mode applied by JS/Jinja */
body.theme-metal-gear {
  --app-primary: #00bcd4; --app-primary-dark: #0097a7;
  --app-navbar-gradient: linear-gradient(135deg,#0a0e14 0%,#1a2030 40%,#2a3545 70%,#00bcd4 100%);
  --app-teal-gradient: linear-gradient(135deg,#0097a7 0%,#00bcd4 100%);
  --app-bg-gradient: linear-gradient(135deg,#0a0e14 0%,#151b24 50%,#0a0e14 100%);
  --bs-primary: #00bcd4; --bs-primary-rgb: 0,188,212;
  --od-sidebar-bg: 215 25% 8%; --od-sidebar-primary: 188 100% 42%;
  --od-sidebar-accent: 215 25% 15%; --od-sidebar-border: 215 20% 20%;
  --od-primary: 188 100% 42%; --od-accent: 188 80% 60%;
  --od-ocean-dark: 215 25% 8%; --od-ocean-mid: 215 22% 15%;
  --od-ocean-teal: 215 18% 25%; --od-ocean-mint: 188 100% 42%;
}

/* Cloud 9 */
body.theme-cloud-9 {
  --app-primary: #c8b068; --app-primary-dark: #b09050;
  --app-navbar-gradient: linear-gradient(135deg,#1a1a2e 0%,#2a2a5e 40%,#4a5080 70%,#c8b068 100%);
  --app-teal-gradient: linear-gradient(135deg,#b09050 0%,#c8b068 100%);
  --app-bg-gradient: #fffdf5; --bs-primary: #c8b068; --bs-primary-rgb: 200,176,104;
  --od-sidebar-bg: 240 28% 15%; --od-sidebar-primary: 40 48% 58%;
  --od-sidebar-accent: 240 25% 22%; --od-sidebar-border: 240 22% 26%;
  --od-primary: 40 48% 58%; --od-accent: 240 20% 65%;
  --od-ocean-dark: 240 28% 15%; --od-ocean-mid: 240 25% 30%;
  --od-ocean-teal: 240 20% 50%; --od-ocean-mint: 40 48% 58%;
}

/* Rainbow Unicorn */
body.theme-rainbow-unicorn {
  --app-primary: #d63384; --app-primary-dark: #c01070;
  --app-navbar-gradient: linear-gradient(135deg,#4a1a7c 0%,#d63384 40%,#20c7c0 70%,#ffd700 100%);
  --app-teal-gradient: linear-gradient(135deg,#c01070 0%,#d63384 50%,#20c7c0 100%);
  --app-bg-gradient: #fff5ff; --bs-primary: #d63384; --bs-primary-rgb: 214,51,132;
  --od-sidebar-bg: 270 65% 28%; --od-sidebar-primary: 52 100% 50%;
  --od-sidebar-accent: 270 60% 35%; --od-sidebar-border: 270 55% 38%;
  --od-primary: 328 68% 52%; --od-accent: 177 70% 45%;
  --od-ocean-dark: 270 65% 28%; --od-ocean-mid: 300 65% 40%;
  --od-ocean-teal: 177 70% 45%; --od-ocean-mint: 52 100% 50%;
}

/* Christmas */
body.theme-christmas {
  --app-primary: #cc0000; --app-primary-dark: #aa0000;
  --app-navbar-gradient: linear-gradient(135deg,#0d2b0d 0%,#1e5c1e 40%,#2e8b2e 70%,#4cb84c 100%);
  --app-teal-gradient: linear-gradient(135deg,#aa0000 0%,#cc0000 100%);
  --app-bg-gradient: #f8fff8; --bs-primary: #cc0000; --bs-primary-rgb: 204,0,0;
  --od-sidebar-bg: 120 55% 12%; --od-sidebar-primary: 0 70% 45%;
  --od-sidebar-accent: 120 50% 18%; --od-sidebar-border: 120 45% 22%;
  --od-primary: 0 70% 40%; --od-accent: 120 42% 45%;
  --od-ocean-dark: 120 55% 12%; --od-ocean-mid: 120 50% 22%;
  --od-ocean-teal: 120 42% 35%; --od-ocean-mint: 0 70% 45%;
}

/* Hallow's Eve — also gets body.dark-mode applied by JS/Jinja */
body.theme-hallows-eve {
  --app-primary: #e05a00; --app-primary-dark: #c84800;
  --app-navbar-gradient: linear-gradient(135deg,#0a0a0a 0%,#2a1a0a 40%,#5a3010 70%,#c85200 100%);
  --app-teal-gradient: linear-gradient(135deg,#c84800 0%,#e05a00 100%);
  --app-bg-gradient: linear-gradient(135deg,#0a0a0a 0%,#1e1208 50%,#0a0a0a 100%);
  --bs-primary: #e05a00; --bs-primary-rgb: 224,90,0;
  --od-sidebar-bg: 25 30% 6%; --od-sidebar-primary: 42 90% 42%;
  --od-sidebar-accent: 25 28% 14%; --od-sidebar-border: 25 25% 18%;
  --od-primary: 22 100% 44%; --od-accent: 42 90% 42%;
  --od-ocean-dark: 25 30% 6%; --od-ocean-mid: 25 28% 14%;
  --od-ocean-teal: 22 70% 28%; --od-ocean-mint: 42 90% 42%;
  /* Primary is warm orange — push feature cool so the zones don't merge */
  --od-feature: 265 55% 58%; --od-feature-hover: 265 50% 50%;
  --od-feature-soft: 265 35% 16%; --od-feature-ink: 265 70% 82%;
}

/* ========================================
   LAYOUT TOGGLE BUTTON
   ======================================== */

.layout-toggle-btn {
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
  border: 1px solid rgba(255,255,255,0.25);
  transition: background 0.15s, color 0.15s;
}
.layout-toggle-btn:hover { background: rgba(255,255,255,0.15); color: inherit; }
.layout-toggle-icon { transition: transform 0.25s; display: inline-block; }
.layout-toggle-icon.is-side { transform: rotate(90deg); }

/* Dark (sidebar topbar) context */
.dash-topbar .layout-toggle-btn {
  border-color: hsl(var(--od-border));
  color: hsl(var(--od-muted-fg));
}
.dash-topbar .layout-toggle-btn:hover {
  background: hsl(var(--od-muted));
  color: hsl(var(--od-foreground));
}

/* Department selector: ensure checked buttons have white text */
.btn-check:checked + .btn-outline-secondary {
  color: #ffffff !important;
}