/* Dark Theme for DPS Calendar */
/* Implements WCAG 2.1 AA compliant color contrasts */

:root {
  /* Light theme (default) */
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --text-primary: #111827;
  --text-secondary: #374151;
  --text-tertiary: #6b7280;
  --border-color: #e5e7eb;
  --border-focus: #2563eb;
  --shadow: rgba(0, 0, 0, 0.1);
  --overlay: rgba(0, 0, 0, 0.4);
  
  /* Brand colors */
  --brand-primary: #2563eb;
  --brand-primary-hover: #1d4ed8;
  --brand-secondary: #374151;
  
  /* Semantic colors */
  --success: #10b981;
  --warning: #f59e0b;
  --error: #dc2626;
  --info: #3b82f6;
  
  /* Transitions */
  --transition-theme: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
  --calendar-grid-color: #e5e7eb;
}

[data-theme="dark"] {
  /* Dark theme overrides */
  --bg-primary: #1f2937;
  --bg-secondary: #111827;
  --bg-tertiary: #374151;
  --text-primary: #f9fafb;
  --text-secondary: #e5e7eb;
  --text-tertiary: #9ca3af;
  --border-color: #4b5563;
  --border-focus: #60a5fa;
  --shadow: rgba(0, 0, 0, 0.5);
  --overlay: rgba(0, 0, 0, 0.7);
  
  --brand-primary: #2563eb;
  --brand-primary-hover: #1d4ed8;
  --brand-secondary: #9ca3af;
  
  --success: #34d399;
  --warning: #fbbf24;
  --error: #dc2626;
  --info: #60a5fa;
  --calendar-grid-color: #6b7280;
  /* Calendar dark-specific */
  --cal-workday-bg: #121212;
  --cal-weekend-bg: #1E1E1E;
  --cal-col-sep: #4A4A4A;
  --cal-today-border: #4A90E2;
}

/* Apply theme variables to elements */
body {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  transition: var(--transition-theme);
}

header {
  background-color: var(--bg-primary);
  border-bottom-color: var(--border-color);
  transition: var(--transition-theme);
}

.card,
.bg-white {
  background-color: var(--bg-primary) !important;
  color: var(--text-primary);
  transition: var(--transition-theme);
}

.bg-gray-50 {
  background-color: var(--bg-secondary) !important;
  color: var(--text-secondary);
}

.bg-gray-100 {
  background-color: var(--bg-tertiary) !important;
}

.bg-gray-200 {
  background-color: var(--bg-tertiary) !important;
  color: var(--text-primary);
}

.text-gray-600,
.text-gray-700,
.text-gray-800 {
  color: var(--text-secondary) !important;
}

.text-gray-500 {
  color: var(--text-tertiary) !important;
}

.text-gray-900 {
  color: var(--text-primary) !important;
}

.border,
.border-b {
  border-color: var(--border-color) !important;
}

/* Inputs and forms */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--border-color);
  transition: var(--transition-theme);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
  opacity: 1;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--border-focus);
  outline-color: var(--border-focus);
}

/* Buttons */
.btn { background-color: var(--bg-tertiary); color: var(--text-primary); border-color: var(--border-color); transition: var(--transition-theme); }
.btn:hover { background-color: var(--bg-secondary); }
.btn-primary { background-color: var(--brand-primary); color: #ffffff; border-color: var(--brand-primary); }
.btn-primary:hover { background-color: var(--brand-primary-hover); color:#ffffff; }
.btn-secondary { background-color: var(--brand-secondary); color: #ffffff; border-color: var(--brand-secondary); }
.btn-secondary:hover { filter: brightness(1.1); color:#ffffff; }
.btn-success { background-color: var(--success); color: #111827; border-color: var(--success); }
.btn-warning { background-color: #c2410c; color: #ffffff; border-color: #c2410c; }
.btn-warning:hover { background-color: #9a3412; color: #ffffff; border-color: #9a3412; }
.btn-danger { background-color: #b91c1c; color: #ffffff; border-color: #b91c1c; }
.btn-danger:hover { background-color: #991b1b; color: #ffffff; border-color: #991b1b; }
.btn-outline { background-color: transparent; color: var(--text-primary); border-color: var(--border-color); }
.btn:focus-visible { outline: 3px solid var(--border-focus); outline-offset: 2px; }
.btn[disabled], .btn.disabled { opacity:1; cursor:not-allowed; pointer-events:none; background:#4b5563; color:#f9fafb; border-color:#6b7280; }

/* Gray buttons maintain contrast on hover - light mode */
button.bg-gray-700:hover {
  background-color: #1f2937 !important;
}

/* Gray buttons in dark mode */
[data-theme="dark"] button.bg-gray-700:hover {
  background-color: #111827 !important;
}

/* Modals */
.modal {
  background-color: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color) !important;
  box-shadow: 0 4px 6px var(--shadow);
}

.modal .dialog {
  background-color: var(--bg-primary) !important;
  color: var(--text-primary) !important;
  border-radius: 8px;
  padding: 1rem;
}

.modal .dialog .modal-header {
  background-color: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
  border-bottom: 1px solid var(--border-color) !important;
}

.modal .dialog .modal-footer {
  background-color: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
  border-top: 1px solid var(--border-color) !important;
}

.modal .dialog .modal-body {
  background-color: var(--bg-secondary) !important;
  color: var(--text-secondary) !important;
  overflow-y: auto;
}

.modal .dialog .btn {
  background-color: var(--brand-primary) !important;
  color: #ffffff !important;
  border: 1px solid var(--brand-primary) !important;
}

.modal .dialog .btn:hover {
  background-color: var(--brand-primary-hover) !important;
  color: #ffffff !important;
}

/* Calendar specific */
.fc {
  color: var(--text-primary);
}

/* Calendar surface backgrounds */
[data-theme="dark"] .fc,
[data-theme="dark"] .fc .fc-view-harness,
[data-theme="dark"] .fc .fc-scrollgrid,
[data-theme="dark"] .fc .fc-scrollgrid-section-body,
[data-theme="dark"] .fc .fc-timegrid-body,
[data-theme="dark"] .fc .fc-daygrid-body,
[data-theme="dark"] .fc .fc-scroller {
  background-color: var(--bg-secondary) !important;
}

[data-theme="dark"] .fc .fc-timegrid-slot,
[data-theme="dark"] .fc .fc-timegrid-slot-lane {
  background-color: transparent !important;
}
[data-theme="dark"] .fc .fc-daygrid-day {
  background-color: var(--bg-primary) !important;
}

/* Header band and grid line consistency */
[data-theme="dark"] .fc .fc-col-header,
[data-theme="dark"] .fc .fc-col-header-cell,
[data-theme="dark"] .fc .fc-scrollgrid-section-header,
[data-theme="dark"] .fc .fc-scrollgrid-section-header > th {
  background-color: var(--bg-primary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .fc .fc-timegrid-axis,
[data-theme="dark"] .fc .fc-timegrid-axis-frame,
[data-theme="dark"] .fc .fc-scrollgrid-section-header .fc-timegrid-axis {
  background-color: var(--bg-primary) !important;
}

[data-theme="dark"] .fc .fc-timegrid-slot,
[data-theme="dark"] .fc .fc-timegrid-slot-lane,
[data-theme="dark"] .fc .fc-timegrid-col,
[data-theme="dark"] .fc .fc-daygrid-day,
[data-theme="dark"] .fc .fc-scrollgrid-section-body td,
[data-theme="dark"] .fc .fc-scrollgrid-section-body th {
  border-color: var(--border-color) !important;
}

/* Vertical day separators across full height */
[data-theme="dark"] .fc .fc-timegrid-col,
[data-theme="dark"] .fc .fc-daygrid-day,
[data-theme="dark"] .fc .fc-timegrid-col-frame {
  border-right: 1px solid var(--cal-col-sep) !important;
}
[data-theme="dark"] .fc .fc-timegrid-cols .fc-timegrid-col:last-child {
  border-right: 0 !important;
}

[data-theme="dark"] .fc .fc-col-header-cell {
  border-right: 1px solid var(--cal-col-sep) !important;
}
[data-theme="dark"] .fc .fc-col-header .fc-col-header-cell:last-child {
  border-right: 0 !important;
}

[data-theme="dark"] .fc .fc-timegrid-col-frame { position: relative !important; }
[data-theme="dark"] .fc .fc-timegrid-col-frame::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 2px;
  background: var(--cal-col-sep);
  pointer-events: none;
}
[data-theme="dark"] .fc .fc-timegrid-cols .fc-timegrid-col:last-child .fc-timegrid-col-frame::after { display: none; }
[data-theme="dark"] .fc .fc-col-header { position: relative !important; }
[data-theme="dark"] .fc .fc-col-header .fc-col-header-cell { position: relative !important; }
[data-theme="dark"] .fc .fc-col-header .fc-col-header-cell::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  background: var(--cal-col-sep);
}
[data-theme="dark"] .fc .fc-col-header .fc-col-header-cell:last-child::after { display: none; }

[data-theme="dark"] .fc .fc-scrollgrid-sync-table td,
[data-theme="dark"] .fc .fc-scrollgrid-sync-table th {
  border-right: 1px solid var(--cal-col-sep) !important;
}

[data-theme="dark"] .fc .fc-timegrid-cols table td.fc-timegrid-col,
[data-theme="dark"] .fc .fc-timegrid-cols table td.fc-timegrid-axis {
  border-left: 1px solid var(--cal-col-sep) !important;
}

[data-theme="dark"] .fc .fc-timegrid-cols table td {
  border-left: 1px solid var(--cal-col-sep) !important;
}

[data-theme="dark"] .fc .fc-timegrid-cols table td,
[data-theme="dark"] .fc .fc-timegrid-cols table th {
  border-right: 1px solid var(--cal-col-sep) !important;
}

[data-theme="dark"] .fc .fc-col-header table th {
  border-left: 1px solid var(--cal-col-sep) !important;
}

/* Today highlight */
[data-theme="dark"] .fc .fc-day-today,
[data-theme="dark"] .fc .fc-timegrid-col.fc-day-today,
[data-theme="dark"] .fc .fc-daygrid-day.fc-day-today,
[data-theme="dark"] .fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-frame,
[data-theme="dark"] .fc .fc-timegrid-col.fc-day-today .fc-timegrid-col-frame,
[data-theme="dark"] .fc .fc-scrollgrid-sync-table .fc-day-today {
  background-color: rgba(96, 165, 250, 0.12) !important;
}

[data-theme="dark"] .fc .fc-timegrid-col.fc-day-today .fc-timegrid-col-bg,
[data-theme="dark"] .fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-bg {
  background-color: rgba(96, 165, 250, 0.12) !important;
}

[data-theme="dark"] .fc .fc-timegrid-col.fc-day-today .fc-highlight {
  background-color: rgba(96, 165, 250, 0.12) !important;
  opacity: 1 !important;
}

[data-theme="dark"] .fc .fc-timegrid-col.fc-day-today .fc-timegrid-bg-harness,
[data-theme="dark"] .fc .fc-timegrid-col.fc-day-today .fc-timegrid-col-bg {
  background-color: rgba(96, 165, 250, 0.12) !important;
}

[data-theme="dark"] .fc .fc-timegrid-col-bg {
  box-shadow: inset -1px 0 0 var(--cal-col-sep), inset 1px 0 0 var(--cal-col-sep) !important;
}
[data-theme="dark"] .fc .fc-timegrid-cols .fc-timegrid-col:first-child .fc-timegrid-col-bg {
  box-shadow: inset -1px 0 0 var(--cal-col-sep) !important;
}
[data-theme="dark"] .fc .fc-timegrid-cols .fc-timegrid-col:last-child .fc-timegrid-col-bg {
  box-shadow: inset 1px 0 0 var(--cal-col-sep) !important;
}

.fc .fc-button {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.fc .fc-button:hover {
  background-color: var(--bg-secondary);
}

.fc .fc-col-header-cell {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.fc-theme-standard td,
.fc-theme-standard th {
  border-color: var(--border-color) !important;
}

/* Force all grid borders in dark theme with explicit width */
[data-theme="dark"] .fc-theme-standard td,
[data-theme="dark"] .fc-theme-standard th {
  border-color: var(--border-color) !important;
  border-style: solid !important;
  border-width: 1px !important;
}

[data-theme="dark"] .fc .fc-scrollgrid table {
  border-collapse: collapse !important;
}

[data-theme="dark"] .fc .fc-timegrid-slot,
[data-theme="dark"] .fc .fc-timegrid-slot-lane {
  border-color: var(--calendar-grid-color) !important;
  border-style: solid !important;
  border-width: 1px 1px 0 0 !important;
}

[data-theme="dark"] .fc .fc-col-header-cell,
[data-theme="dark"] .fc .fc-timegrid-col {
  border-color: var(--calendar-grid-color) !important;
  border-style: solid !important;
  border-width: 0 1px 0 0 !important;
}

.fc-daygrid-day-number {
  color: var(--text-primary);
}

[data-theme="dark"] .fc-timegrid-axis {
  color: var(--text-secondary);
}

[data-theme="dark"] .fc-timegrid-slot-label {
  color: var(--text-secondary) !important;
}

/* Print button contrast in dark mode */
[data-theme="dark"] #print {
  background-color: var(--brand-primary) !important;
  color: #ffffff !important;
  border: 1px solid var(--brand-primary) !important;
}

[data-theme="dark"] #print:hover {
  background-color: var(--brand-primary-hover) !important;
}

[data-theme="dark"] #toggle-loc-legend {
  color: #93c5fd !important;
}

[data-theme="dark"] .text-red-600 {
  color: #fca5a5 !important;
}

[data-theme="dark"] #mobile-menu .text-red-700 {
  color: #fca5a5 !important;
}

[data-theme="dark"] .section-nav {
  background: var(--bg-primary) !important;
  border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] .section-nav a {
  background: var(--bg-secondary) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .section-nav a.active {
  background: var(--brand-primary) !important;
  color: #ffffff !important;
  border-color: var(--brand-primary) !important;
}

[data-theme="dark"] .wizard {
  background: var(--bg-primary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .wizard .step {
  border-color: var(--border-color) !important;
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .wizard .step.active {
  color: #ffffff !important;
}

[data-theme="dark"] .wizard .content {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .help details {
  background: var(--bg-tertiary) !important;
}

[data-theme="dark"] .help summary {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .admin-panel table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.025) !important;
}

[data-theme="dark"] .admin-panel table tbody tr:hover {
  background: rgba(96, 165, 250, 0.08) !important;
}

[data-theme="dark"] .admin-panel table thead th {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .admin-panel section.card {
  box-shadow: 0 1px 2px rgba(0, 0, 0, .22) !important;
}

[data-theme="dark"] .section-nav:focus-within {
  box-shadow: inset 0 0 0 2px rgba(96,165,250,.18) !important;
}

[data-theme="dark"] .help p,
[data-theme="dark"] .help ul {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .hover\:bg-gray-100:hover {
  background-color: var(--bg-tertiary) !important;
}

[data-theme="dark"] .hover\:bg-gray-200:hover {
  background-color: var(--bg-tertiary) !important;
}

[data-theme="dark"] #heatmap table,
[data-theme="dark"] #heatmap td,
[data-theme="dark"] #heatmap th {
  color: var(--text-primary) !important;
}

/* List view */
[data-theme="dark"] #list-view { color: var(--text-primary); }
[data-theme="dark"] .list-day {
  background: var(--bg-primary) !important;
  border-color: var(--calendar-grid-color) !important;
}
[data-theme="dark"] .list-day-header {
  font-weight: 600;
  color: var(--text-primary) !important;
  background: var(--bg-primary) !important;
  border-bottom: 2px solid var(--calendar-grid-color) !important;
}
[data-theme="dark"] .list-event {
  display: flex;
  gap: .75rem;
  background: var(--bg-tertiary) !important;
  border-color: var(--calendar-grid-color) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .list-event:hover {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  box-shadow: 0 2px 10px rgba(0,0,0,.35) !important;
}
[data-theme="dark"] .list-event:active { transform: translateY(0); border-color: var(--brand-primary) !important; }
[data-theme="dark"] .list-event:focus-visible { outline: 2px solid var(--border-focus) !important; outline-offset: 2px; }
[data-theme="dark"] .list-event.disabled,
[data-theme="dark"] .list-event[aria-disabled="true"] { opacity: .6; cursor: not-allowed; }
[data-theme="dark"] .list-event.selected { background: rgba(59,130,246,.12) !important; border-color: var(--brand-primary) !important; }
[data-theme="dark"] .list-event-time { color: var(--text-secondary) !important; }
[data-theme="dark"] .list-event-title { color: var(--text-primary) !important; }
[data-theme="dark"] .list-event-meta { color: var(--text-tertiary) !important; }
[data-theme="dark"] .list-event-bar { background-color: var(--brand-primary) !important; }
[data-theme="dark"] .list-event-location {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--calendar-grid-color);
  padding: .25rem .5rem;
  border-radius: .375rem;
}
[data-theme="dark"] .list-event-location svg { color: currentColor; }
[data-theme="dark"] .list-event-category {
  background: rgba(59,130,246,.12);
  color: var(--brand-primary);
  border: 1px solid var(--brand-primary);
}

/* Month view (daygrid) – dark styles */
[data-theme="dark"] .fc .fc-daygrid-event {
  border: 1px solid var(--brand-primary) !important;
  color: var(--text-primary);
}
[data-theme="dark"] .fc .fc-daygrid-event-frame {
  padding: 2px 4px;
}
[data-theme="dark"] .fc .fc-daygrid-event .fc-event-title {
  color: #111827;
  font-weight: 600;
}

[data-theme="dark"] .fc .fc-daygrid-event .fc-event-time {
  color: #111827 !important;
  font-weight: 600;
}

[data-theme="dark"] .fc .fc-timegrid-event .fc-event-title {
  color: #111827;
  font-weight: 600;
}

[data-theme="dark"] .fc .fc-timegrid-event .fc-event-time {
  color: #111827 !important;
}

[data-theme="dark"] .fc .fc-daygrid-event:hover {
  background: rgba(59,130,246,.35);
  border-color: var(--brand-primary-hover) !important;
}
[data-theme="dark"] .fc .fc-daygrid-day-number {
  color: var(--text-primary) !important;
}
[data-theme="dark"] .fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-frame {
  background-color: rgba(96, 165, 250, 0.14) !important;
}
[data-theme="dark"] .fc .fc-daygrid-day.fc-day-other {
  opacity: .6;
}
[data-theme="dark"] .fc .fc-daygrid-day,
[data-theme="dark"] .fc .fc-scrollgrid-section-body td,
[data-theme="dark"] .fc .fc-scrollgrid-section-body th {
  border-color: var(--calendar-grid-color) !important;
}

/* Weekend subtle background */
[data-theme="dark"] .fc .fc-day-sat .fc-timegrid-col,
[data-theme="dark"] .fc .fc-day-sun .fc-timegrid-col { background-color: transparent !important; }
[data-theme="dark"] .fc .fc-day-sat .fc-timegrid-col .fc-timegrid-col-bg,
[data-theme="dark"] .fc .fc-day-sun  .fc-timegrid-col .fc-timegrid-col-bg {
  background-color: var(--cal-weekend-bg) !important;
}
[data-theme="dark"] .fc .fc-day-sat .fc-col-header-cell,
[data-theme="dark"] .fc .fc-day-sun .fc-col-header-cell {
  background-color: var(--cal-weekend-bg) !important;
}
[data-theme="dark"] .fc .fc-day-mon .fc-timegrid-col,
[data-theme="dark"] .fc .fc-day-tue .fc-timegrid-col,
[data-theme="dark"] .fc .fc-day-wed .fc-timegrid-col,
[data-theme="dark"] .fc .fc-day-thu .fc-timegrid-col,
[data-theme="dark"] .fc .fc-day-fri .fc-timegrid-col { background-color: transparent !important; }
[data-theme="dark"] .fc .fc-day-mon .fc-timegrid-col .fc-timegrid-col-bg,
[data-theme="dark"] .fc .fc-day-tue .fc-timegrid-col .fc-timegrid-col-bg,
[data-theme="dark"] .fc .fc-day-wed .fc-timegrid-col .fc-timegrid-col-bg,
[data-theme="dark"] .fc .fc-day-thu .fc-timegrid-col .fc-timegrid-col-bg,
[data-theme="dark"] .fc .fc-day-fri .fc-timegrid-col .fc-timegrid-col-bg {
  background-color: var(--cal-workday-bg) !important;
}
[data-theme="dark"] .fc .fc-day-mon .fc-col-header-cell,
[data-theme="dark"] .fc .fc-day-tue .fc-col-header-cell,
[data-theme="dark"] .fc .fc-day-wed .fc-col-header-cell,
[data-theme="dark"] .fc .fc-day-thu .fc-col-header-cell,
[data-theme="dark"] .fc .fc-day-fri .fc-col-header-cell {
  background-color: var(--cal-workday-bg) !important;
}

/* Today border highlight */
[data-theme="dark"] .fc .fc-day-today .fc-timegrid-col { box-shadow: inset 0 0 0 2px var(--cal-today-border) !important; }
[data-theme="dark"] .fc .fc-day-today .fc-timegrid-col .fc-timegrid-col-bg { background-color: #141922 !important; }
[data-theme="dark"] .fc .fc-day-today .fc-col-header-cell {
  box-shadow: inset 0 -2px 0 0 var(--cal-today-border) !important;
}

/* Alerts */
.bg-yellow-50 {
  background-color: var(--warning) !important;
  color: var(--bg-primary);
}

.bg-red-50 {
  background-color: var(--error) !important;
  color: var(--bg-primary);
}

.bg-green-50 {
  background-color: var(--success) !important;
  color: var(--bg-primary);
}

/* Theme toggle button */
#theme-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: var(--brand-primary);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 6px var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background-color 0.2s ease;
  z-index: 1000;
}

#theme-toggle:hover {
  transform: scale(1.1);
  background-color: var(--brand-primary-hover);
}

#theme-toggle:focus {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

#theme-toggle svg {
  width: 24px;
  height: 24px;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Respect system preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary: #1f2937;
    --bg-secondary: #111827;
    --bg-tertiary: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #e5e7eb;
    --text-tertiary: #9ca3af;
    --border-color: #4b5563;
    --border-focus: #60a5fa;
    --shadow: rgba(0, 0, 0, 0.5);
    --overlay: rgba(0, 0, 0, 0.7);
    --brand-primary: #2563eb;
    --brand-primary-hover: #1d4ed8;
  }
}

/* Dropdown menu styling - light mode */
.action-menu-dropdown {
  background-color: #ffffff;
  border-color: #d1d5db;
}

.action-menu-dropdown a,
.action-menu-dropdown button {
  color: #374151;
}

.action-menu-dropdown a:hover,
.action-menu-dropdown button:hover {
  background-color: #f3f4f6;
  color: #111827;
}

.action-menu-dropdown form button {
  background-color: transparent;
  border: none;
  padding: 0.5rem 1rem;
  cursor: pointer;
}

/* Dark mode dropdown */
[data-theme="dark"] .action-menu-dropdown {
  background-color: #1f2937 !important;
  border-color: #4b5563 !important;
}

[data-theme="dark"] .action-menu-dropdown a,
[data-theme="dark"] .action-menu-dropdown button {
  color: #e5e7eb !important;
}

[data-theme="dark"] .action-menu-dropdown a:hover,
[data-theme="dark"] .action-menu-dropdown button:hover,
[data-theme="dark"] .action-menu-dropdown form button:hover {
  background-color: #374151 !important;
  color: #f9fafb !important;
}

/* Modal styling in dark mode */
[data-theme="dark"] .modal {
  background-color: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color) !important;
  box-shadow: 0 4px 6px var(--shadow);
}

[data-theme="dark"] .modal .dialog {
  background-color: var(--bg-primary) !important;
  color: var(--text-primary) !important;
  border-radius: 8px;
  padding: 1rem;
}

[data-theme="dark"] .modal .dialog .modal-header {
  background-color: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
  border-bottom: 1px solid var(--border-color) !important;
}

[data-theme="dark"] .modal .dialog .modal-footer {
  background-color: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
  border-top: 1px solid var(--border-color) !important;
}

[data-theme="dark"] .modal .dialog .modal-body {
  background-color: var(--bg-secondary) !important;
  color: var(--text-secondary) !important;
  overflow-y: auto;
}

[data-theme="dark"] .modal .dialog .btn {
  background-color: var(--brand-primary) !important;
  color: #ffffff !important;
  border: 1px solid var(--brand-primary) !important;
}

[data-theme="dark"] .modal .dialog .btn:hover {
  background-color: var(--brand-primary-hover) !important;
  color: #ffffff !important;
}

/* Print mode - always light */
@media print {
  :root {
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --text-primary: #111827;
    --text-secondary: #374151;
    --border-color: #e5e7eb;
  }
  
  #theme-toggle {
    display: none !important;
  }
}
