/* FILE: public/css/app.css */

/* 
 * Modern EMS Application Styles
 * Professional, accessible, and performant design system
 */

:root {
  /* Enhanced color palette */
  --color-primary: #3b82f6;
  --color-primary-dark: #2563eb;
  --color-primary-light: #60a5fa;
  --color-success: #10b981;
  --color-success-dark: #059669;
  --color-info: #06b6d4;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-purple: #a855f7;
  
  /* Gradient definitions */
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --gradient-info: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  --gradient-purple: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
  
  /* Shadows - enhanced for depth */
  --shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.16);
  --shadow-xl: 0 12px 32px rgba(0, 0, 0, 0.2);
  --shadow-hover: 0 16px 48px rgba(0, 0, 0, 0.25);
  
  /* Animation timings */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Spacing scale */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;
}

body {
  font-family: "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  color: #1e293b;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Main content spacing next to sidebar */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 1.5rem 2rem;
  min-height: calc(100vh - 60px);
  transition: margin-left var(--transition-normal);
  background: transparent;
}

/* Navbar offset for sidebar */
.app-navbar {
  margin-left: var(--sidebar-width);
  transition: margin-left var(--transition-normal);
}

/* Footer */
footer {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #fff;
  text-align: center;
  padding: 1rem 0;
  margin-top: auto;
  margin-left: var(--sidebar-width);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
  transition: margin-left var(--transition-normal);
}

/* Tablet adjustments */
/* Corresponds to: min-width: var(--breakpoint-tablet-min) and max-width: var(--breakpoint-tablet-max) */
@media (min-width: 768px) and (max-width: 1024px) {
  .main-content {
    margin-left: var(--sidebar-width-tablet);
    padding: 1.25rem 1.5rem;
  }
  .app-navbar {
    margin-left: var(--sidebar-width-tablet);
  }
  footer {
    margin-left: var(--sidebar-width-tablet);
  }
}

/* Mobile: sidebar overlays content */
/* Corresponds to: max-width: var(--breakpoint-mobile) */
@media (max-width: 767.98px) {
  .main-content {
    margin-left: 0;
    padding: 1rem;
    padding-top: 5rem; /* space for the mobile toggle button */
  }
  .app-navbar {
    margin-left: 0;
  }
  footer {
    margin-left: 0;
  }
}

/* Enhanced card styles for dashboard */
.card {
  border: 1px solid rgba(0, 0, 0, 0.06);
  transition: all var(--transition-normal);
  background: white;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  contain: layout style;
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
  border-color: rgba(59, 130, 246, 0.1);
}

.card-header {
  font-weight: 600;
  border-bottom: 2px solid rgba(0, 0, 0, 0.1);
  padding: 1rem 1.5rem;
}

/* Dashboard metric cards */
.dashboard-metric-card {
  background: white;
  border-radius: 1rem;
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
  border: 1px solid rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
}

/* Add modern gradient overlay to metric cards */
.dashboard-metric-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.03) 0%, transparent 70%);
  pointer-events: none;
  animation: pulse-subtle 8s ease-in-out infinite;
}

@keyframes pulse-subtle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.05); }
}

.dashboard-metric-card:hover {
  box-shadow: var(--shadow-xl);
  transform: translateY(-6px) scale(1.02);
  border-color: rgba(59, 130, 246, 0.2);
}

.dashboard-metric-card h3 {
  font-weight: 800;
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.dashboard-metric-card h6 {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
  opacity: 0.8;
}

/* Dashboard specific styles */
.gradient-green {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.2);
}

.gradient-cyan {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  box-shadow: 0 4px 16px rgba(6, 182, 212, 0.2);
}

.gradient-blue {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.2);
}

.gradient-slate {
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
  box-shadow: 0 4px 16px rgba(100, 116, 139, 0.2);
}

.gradient-purple {
  background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
  box-shadow: 0 4px 16px rgba(168, 85, 247, 0.2);
}

.gradient-orange {
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.2);
}

/* Bootstrap-compatible gradient classes */
.bg-gradient-purple {
  background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
  box-shadow: 0 4px 16px rgba(168, 85, 247, 0.15);
}

.bg-gradient-blue {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.15);
}

.bg-gradient-green {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.15);
}

.bg-gradient-cyan {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  box-shadow: 0 4px 16px rgba(6, 182, 212, 0.15);
}

.scrollable-list {
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(59, 130, 246, 0.3) rgba(0, 0, 0, 0.05);
}

/* Custom scrollbar for webkit browsers */
.scrollable-list::-webkit-scrollbar {
  width: 6px;
}

.scrollable-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
}

.scrollable-list::-webkit-scrollbar-thumb {
  background: rgba(59, 130, 246, 0.3);
  border-radius: 3px;
}

.scrollable-list::-webkit-scrollbar-thumb:hover {
  background: rgba(59, 130, 246, 0.5);
}

/* Chart containers with enhanced styling */
.chart-container {
  position: relative;
  background: white;
  border-radius: 1rem;
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.chart-container:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.1);
}

/* Loading state for charts */
.chart-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-primary);
}

/* Pulse animation for loading */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Badge enhancements */
.badge {
  font-weight: 600;
  padding: 0.375rem 0.875rem;
  border-radius: 0.5rem;
  letter-spacing: 0.025em;
  transition: all var(--transition-fast);
  font-size: 0.8125rem;
}

.badge:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-sm);
}

/* Button enhancements */
.btn {
  transition: all var(--transition-fast);
  font-weight: 600;
  border-radius: 0.625rem;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-xs);
}

/* Subtle ripple effect on click - only for primary actions */
.btn-primary::before,
.btn-success::before,
.btn-info::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  transform: translate(-50%, -50%);
  transition: width 0.3s, height 0.3s;
  pointer-events: none;
}

.btn-primary:active::before,
.btn-success:active::before,
.btn-info:active::before {
  width: 120px;
  height: 120px;
}

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

.btn:active {
  transform: translateY(0) scale(0.98);
  box-shadow: var(--shadow-xs);
}

/* Responsive utilities */
/* Corresponds to: max-width: var(--breakpoint-mobile) */
@media (max-width: 767.98px) {
  .dashboard-metric-card {
    padding: 1.25rem;
  }
  
  .card-body {
    padding: 1rem;
  }
  
  .btn {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
  }

  /* Reduce heavy animations on mobile for speed */
  .card:hover,
  .dashboard-metric-card:hover,
  .chart-container:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
  }

  .dashboard-metric-card::before {
    animation: none;
  }

  .modern-table tbody tr:hover {
    transform: none;
  }

  .btn:hover {
    transform: none;
  }

  /* Ensure tables don't cause horizontal scroll */
  .table {
    font-size: 0.85rem;
  }
  
  .table th,
  .table td {
    padding: 0.5rem;
    white-space: nowrap;
  }

  /* Compact card headers on mobile */
  .card-header {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }
}

/* Smooth scroll behavior */
html {
  scroll-behavior: smooth;
}

/* Accessibility: Focus visible styles */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 0.25rem;
}

/* Accessibility: Skip to main content link */
.skip-to-main {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-primary);
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  z-index: 1050;
  border-radius: 0 0 0.5rem 0;
}

.skip-to-main:focus {
  top: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .card {
    border: 2px solid currentColor;
  }
  
  .btn {
    border-width: 2px;
  }
}

/* Reduced motion support for accessibility */
@media (prefers-reduced-motion: reduce) {
  /* Disable animations for users with motion sensitivities */
  .dashboard-metric-card,
  .card,
  .btn,
  .collapsible,
  .nav-link-item {
    animation: none !important;
    transition-duration: 0s !important;
    transform: none !important;
  }
  
  html {
    scroll-behavior: auto !important;
  }
}

/* Print styles */
@media print {
  .sidebar,
  .sidebar-mobile-toggle,
  .sidebar-overlay,
  .btn,
  footer {
    display: none !important;
  }
  
  .main-content {
    margin-left: 0 !important;
  }
  
  .card {
    break-inside: avoid;
  }
}

/* Modern Utility Classes */
.text-gradient-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-gradient-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-gradient-info {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Loading Skeleton */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 0.5rem;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
}

.skeleton-title {
  height: 1.5rem;
  margin-bottom: 0.75rem;
  width: 60%;
}

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.skeleton-card {
  height: 200px;
  width: 100%;
}

/* Glass morphism effect */
.glass {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.glass-dark {
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Floating animation */
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

.float {
  animation: float 3s ease-in-out infinite;
}

/* Shimmer effect */
.shimmer {
  position: relative;
  overflow: hidden;
}

.shimmer::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Modern scrollbar for webkit browsers */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #3b82f6 0%, #8b5cf6 100%);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #2563eb 0%, #7c3aed 100%);
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.875rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.025em;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-success {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

.status-warning {
  background: rgba(245, 158, 11, 0.1);
  color: #d97706;
}

.status-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

.status-info {
  background: rgba(6, 182, 212, 0.1);
  color: #0891b2;
}

/* Enhanced focus states for better accessibility */
*:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.5);
  outline-offset: 2px;
  border-radius: 0.375rem;
}

[data-theme="dark"] *:focus-visible {
  outline-color: rgba(96, 165, 250, 0.7);
}

/* Modern table styles */
.modern-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  contain: layout style;
}

.modern-table thead {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.modern-table th {
  padding: 1rem 1.5rem;
  text-align: left;
  font-weight: 700;
  font-size: 0.875rem;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modern-table td {
  padding: 1rem 1.5rem;
  border-top: 1px solid #e2e8f0;
}

.modern-table tbody tr {
  transition: all var(--transition-fast);
}

.modern-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.03);
  transform: scale(1.01);
}

/* =========================================
   Dark Mode Styles
   ========================================= */
[data-theme="dark"] body,
[data-theme="dark"] {
  background: #0f172a !important;
  color: #e2e8f0 !important;
}

[data-theme="dark"] .main-content {
  background: transparent;
}

[data-theme="dark"] .card {
  background: #1e293b !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
  color: #e2e8f0 !important;
}

[data-theme="dark"] .card-header {
  background: #1e293b !important;
  border-bottom-color: rgba(255, 255, 255, 0.1) !important;
  color: #e2e8f0 !important;
}

[data-theme="dark"] .app-navbar {
  background: #1e293b !important;
  border-bottom-color: rgba(255, 255, 255, 0.1) !important;
}

[data-theme="dark"] .app-navbar .navbar-brand {
  -webkit-text-fill-color: #60a5fa !important;
}

[data-theme="dark"] #themeToggle {
  border-color: rgba(255, 255, 255, 0.15) !important;
  color: #e2e8f0 !important;
}

[data-theme="dark"] footer {
  background: #0f172a !important;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .dashboard-metric-card {
  background: #1e293b !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

[data-theme="dark"] .dashboard-metric-card h6,
[data-theme="dark"] .text-muted,
[data-theme="dark"] small.text-muted {
  color: #94a3b8 !important;
}

[data-theme="dark"] .dashboard-metric-card .dash-text-dark {
  color: #e2e8f0 !important;
}

[data-theme="dark"] .dashboard-metric-card .dash-item-bg {
  background: rgba(255, 255, 255, 0.05) !important;
}

[data-theme="dark"] .dashboard-metric-card .dash-item-bg-warm {
  background: rgba(239, 68, 68, 0.1) !important;
}

[data-theme="dark"] .dash-subtitle {
  color: #94a3b8 !important;
}

[data-theme="dark"] .dash-section-title {
  color: #f1f5f9 !important;
}

[data-theme="dark"] .dash-btn-light {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  color: #cbd5e1 !important;
}

[data-theme="dark"] .dash-alert-info {
  background: rgba(59, 130, 246, 0.1) !important;
  border-color: rgba(59, 130, 246, 0.25) !important;
}

[data-theme="dark"] .dash-alert-info .dash-alert-title {
  color: #93c5fd !important;
}

[data-theme="dark"] .dash-alert-info .dash-alert-body {
  color: #cbd5e1 !important;
}

[data-theme="dark"] .chart-container {
  background: #1e293b !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

[data-theme="dark"] .table {
  color: #e2e8f0 !important;
}

[data-theme="dark"] .table-light {
  background: #334155 !important;
  color: #e2e8f0 !important;
}

[data-theme="dark"] .table-light th {
  background: #334155 !important;
  color: #e2e8f0 !important;
}

[data-theme="dark"] .table td,
[data-theme="dark"] .table th {
  border-color: rgba(255, 255, 255, 0.08) !important;
}

[data-theme="dark"] .table-hover tbody tr:hover {
  background-color: rgba(59, 130, 246, 0.1) !important;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background-color: #334155 !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
  color: #e2e8f0 !important;
}

[data-theme="dark"] .form-control::placeholder {
  color: #64748b !important;
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  border-color: rgba(59, 130, 246, 0.5) !important;
  box-shadow: 0 0 0 0.25rem rgba(59, 130, 246, 0.15) !important;
}

[data-theme="dark"] .input-group-text {
  background-color: #334155 !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
  color: #e2e8f0 !important;
}

[data-theme="dark"] .dropdown-menu {
  background-color: #1e293b !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

[data-theme="dark"] .dropdown-item {
  color: #e2e8f0 !important;
}

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
  background-color: rgba(59, 130, 246, 0.1) !important;
  color: #f1f5f9 !important;
}

[data-theme="dark"] .alert-success {
  background: rgba(16, 185, 129, 0.15) !important;
  border-color: rgba(16, 185, 129, 0.3) !important;
  color: #34d399 !important;
}

[data-theme="dark"] .alert-warning {
  background: rgba(245, 158, 11, 0.15) !important;
  border-color: rgba(245, 158, 11, 0.3) !important;
  color: #fbbf24 !important;
}

[data-theme="dark"] .alert-danger {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
  color: #f87171 !important;
}

[data-theme="dark"] .alert-info {
  background: rgba(6, 182, 212, 0.15) !important;
  border-color: rgba(6, 182, 212, 0.3) !important;
  color: #22d3ee !important;
}

[data-theme="dark"] .bg-white {
  background-color: #1e293b !important;
}

[data-theme="dark"] .list-group-item {
  background-color: #1e293b !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
  color: #e2e8f0 !important;
}

[data-theme="dark"] .modal-content {
  background-color: #1e293b !important;
  color: #e2e8f0 !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
  border-color: rgba(255, 255, 255, 0.1) !important;
}

[data-theme="dark"] h1, [data-theme="dark"] h2,
[data-theme="dark"] h3, [data-theme="dark"] h4,
[data-theme="dark"] h5, [data-theme="dark"] h6 {
  color: #f1f5f9 !important;
}

[data-theme="dark"] .btn-outline-secondary {
  border-color: rgba(255, 255, 255, 0.2) !important;
  color: #94a3b8 !important;
}

[data-theme="dark"] a:not(.btn):not(.nav-link-item):not(.navbar-brand) {
  color: #60a5fa;
}

[data-theme="dark"] .modern-table thead {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%) !important;
}

[data-theme="dark"] .modern-table th {
  color: #94a3b8 !important;
}

[data-theme="dark"] .modern-table td {
  border-top-color: rgba(255, 255, 255, 0.06) !important;
}

[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, #1e293b 0%, #334155 50%, #1e293b 100%) !important;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
  background: #1e293b;
}

[data-theme="dark"] .pagination .page-link {
  background-color: #1e293b !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #e2e8f0 !important;
}

[data-theme="dark"] .pagination .page-item.active .page-link {
  background-color: #3b82f6 !important;
  border-color: #3b82f6 !important;
}

/* ===================================
   Mobile App-Like Experience
   =================================== */

/* Safe area insets for notched devices */
@supports (padding: env(safe-area-inset-top)) {
  .app-navbar {
    padding-top: env(safe-area-inset-top);
  }
  .sidebar {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Smooth momentum scrolling */
.main-content,
.card-body,
.table-responsive {
  -webkit-overflow-scrolling: touch;
}

/* Touch-friendly tap targets */
@media (max-width: 767.98px) {
  /* Ensure minimum touch target sizes (44px) */
  .btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .btn-sm {
    min-height: 36px;
  }

  .form-control,
  .form-select {
    min-height: 44px;
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  .nav-link,
  .list-group-item {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* App-like header with safe area */
  .app-navbar {
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
  }

  /* Smooth page transitions */
  .main-content {
    padding-bottom: 1.5rem;
  }

  /* Full-width cards on mobile */
  .container,
  .container-fluid {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .card {
    border-radius: 0.75rem;
    margin-bottom: 0.75rem;
  }

  /* Stacked action buttons */
  .d-inline form,
  td .d-inline,
  td form[style*="inline"] {
    margin-bottom: 0.25rem;
  }

  /* Compact page titles */
  h1, .h1 {
    font-size: 1.5rem;
  }

  h2, .h2 {
    font-size: 1.25rem;
  }

  h3, .h3 {
    font-size: 1.15rem;
  }

  h4, .h4 {
    font-size: 1.05rem;
  }

  /* Better pagination on mobile */
  .pagination {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
  }

  .pagination .page-link {
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem !important;
  }

  /* Pull-down refresh visual hint */
  .main-content::before {
    content: '';
    display: block;
    height: 0;
  }

  /* Badge improvements */
  .badge {
    font-size: 0.7rem;
    padding: 0.35em 0.6em;
  }

  /* Alert improvements */
  .alert {
    border-radius: 0.75rem;
    font-size: 0.9rem;
  }

  /* Modal improvements for mobile */
  .modal-dialog {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
  }

  .modal-content {
    border-radius: 1rem;
  }

  /* Floating action area spacing */
  .d-flex.gap-2 {
    flex-wrap: wrap;
  }
}

/* Standalone mode (when added to home screen) */
@media (display-mode: standalone) {
  .app-navbar {
    padding-top: env(safe-area-inset-top, 0);
  }

  /* Hide browser-specific elements in standalone */
  .main-content {
    min-height: calc(100vh - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0));
  }
}

/* Dark mode mobile app adjustments */
[data-theme="dark"] .main-content {
  background-color: #0f172a;
}

[data-theme="dark"] .card {
  background-color: #1e293b;
  border-color: rgba(255, 255, 255, 0.08);
}

/* ==========================================================================
   Chart Loading Skeletons
   ========================================================================== */

.chart-loading canvas {
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
}

.chart-loading.loaded canvas {
  opacity: 1;
}

.chart-skeleton {
  height: 200px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  border-radius: 0.75rem;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.chart-loading.loaded .chart-skeleton {
  display: none;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

[data-theme="dark"] .chart-skeleton {
  background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
  background-size: 200% 100%;
}

/* ==========================================================================
   Page Load & Staggered Animations
   ========================================================================== */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes countUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in-up {
  animation: fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.animate-fade-in-scale {
  animation: fadeInScale 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.animate-slide-in-left {
  animation: slideInLeft 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Staggered delay utilities */
.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.1s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.2s; }
.delay-5 { animation-delay: 0.25s; }
.delay-6 { animation-delay: 0.3s; }
.delay-7 { animation-delay: 0.35s; }
.delay-8 { animation-delay: 0.4s; }

/* ==========================================================================
   Enhanced Breadcrumb
   ========================================================================== */
.breadcrumb {
  background: rgba(255, 255, 255, 0.7) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0.75rem 1.25rem !important;
  border-radius: 0.75rem !important;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  animation: fadeInUp 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.breadcrumb-item + .breadcrumb-item::before {
  content: '\f054' !important;
  font-family: 'Font Awesome 6 Free' !important;
  font-weight: 900 !important;
  font-size: 0.6rem !important;
  color: #94a3b8 !important;
  vertical-align: middle;
}

.breadcrumb-item a {
  transition: color 0.2s ease, transform 0.2s ease;
  display: inline-flex;
  align-items: center;
}

.breadcrumb-item a:hover {
  color: #2563eb !important;
}

[data-theme="dark"] .breadcrumb {
  background: rgba(30, 41, 59, 0.7) !important;
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .breadcrumb-item.active {
  color: #94a3b8 !important;
}

/* ==========================================================================
   Enhanced Form Controls
   ========================================================================== */
.form-control,
.form-select {
  border-radius: 0.625rem;
  border: 1.5px solid #e2e8f0;
  padding: 0.625rem 0.875rem;
  transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  font-size: 0.9375rem;
}

.form-control:hover,
.form-select:hover {
  border-color: #cbd5e1;
}

.form-control:focus,
.form-select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12), 0 1px 2px rgba(0, 0, 0, 0.05);
}

.form-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: #334155;
  margin-bottom: 0.375rem;
  letter-spacing: 0.01em;
}

/* Validation states */
.form-control.is-invalid,
.form-select.is-invalid {
  border-color: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.08);
}

.form-control.is-valid,
.form-select.is-valid {
  border-color: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.08);
}

.invalid-feedback {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #ef4444;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.375rem;
}

/* ==========================================================================
   Toast Notification System
   ========================================================================== */
@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastSlideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

@keyframes progressShrink {
  from { width: 100%; }
  to { width: 0%; }
}

.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast-notification {
  pointer-events: auto;
  min-width: 320px;
  max-width: 420px;
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
  animation: toastSlideIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.toast-notification.toast-dismissing {
  animation: toastSlideOut 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.toast-notification .toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  border-radius: 0 0 1rem 1rem;
  animation: progressShrink 5s linear forwards;
}

.toast-success {
  background: linear-gradient(135deg, rgba(236, 253, 245, 0.95), rgba(209, 250, 229, 0.95));
  border: 1px solid rgba(110, 231, 183, 0.5);
}

.toast-success .toast-progress {
  background: linear-gradient(90deg, #10b981, #059669);
}

.toast-error {
  background: linear-gradient(135deg, rgba(254, 242, 242, 0.95), rgba(254, 226, 226, 0.95));
  border: 1px solid rgba(252, 165, 165, 0.5);
}

.toast-error .toast-progress {
  background: linear-gradient(90deg, #ef4444, #dc2626);
}

.toast-warning {
  background: linear-gradient(135deg, rgba(255, 251, 235, 0.95), rgba(254, 243, 199, 0.95));
  border: 1px solid rgba(252, 211, 77, 0.5);
}

.toast-warning .toast-progress {
  background: linear-gradient(90deg, #f59e0b, #d97706);
}

.toast-info {
  background: linear-gradient(135deg, rgba(239, 246, 255, 0.95), rgba(219, 234, 254, 0.95));
  border: 1px solid rgba(147, 197, 253, 0.5);
}

.toast-info .toast-progress {
  background: linear-gradient(90deg, #3b82f6, #2563eb);
}

/* ==========================================================================
   Enhanced Modal Styles
   ========================================================================== */
.modal-content {
  border: none;
  border-radius: 1.25rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.15), 0 8px 24px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.modal-header {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  padding: 1.25rem 1.5rem;
}

.modal-title {
  font-weight: 700;
  font-size: 1.125rem;
  color: #1e293b;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding: 1rem 1.5rem;
}

.modal-backdrop.show {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

[data-theme="dark"] .modal-header {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%) !important;
  border-bottom-color: rgba(255, 255, 255, 0.1) !important;
}

[data-theme="dark"] .modal-footer {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%) !important;
  border-top-color: rgba(255, 255, 255, 0.1) !important;
}

[data-theme="dark"] .modal-title {
  color: #f1f5f9 !important;
}

/* ==========================================================================
   Enhanced Pagination
   ========================================================================== */
.pagination {
  gap: 0.25rem;
}

.pagination .page-link {
  border-radius: 0.5rem !important;
  border: 1px solid #e2e8f0;
  color: #475569;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.5rem 0.875rem;
  transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  min-width: 40px;
  text-align: center;
}

.pagination .page-link:hover {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.3);
  color: #3b82f6;
  transform: translateY(-1px);
}

.pagination .page-item.active .page-link {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.pagination .page-item.disabled .page-link {
  opacity: 0.5;
}

/* ==========================================================================
   Empty State Styles
   ========================================================================== */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: #94a3b8;
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 1.5rem;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, rgba(139, 92, 246, 0.08) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: float 3s ease-in-out infinite;
}

.empty-state-icon i {
  font-size: 2rem;
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.empty-state h5 {
  font-weight: 700;
  color: #475569;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: #94a3b8;
  font-size: 0.9375rem;
  max-width: 320px;
  margin: 0 auto;
}

[data-theme="dark"] .empty-state h5 {
  color: #cbd5e1 !important;
}

[data-theme="dark"] .empty-state-icon {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
}

/* ==========================================================================
   Enhanced Button Variants
   ========================================================================== */
.btn-gradient-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border: none;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.btn-gradient-primary:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: white;
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.35);
}

.btn-gradient-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.btn-gradient-success:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: white;
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

.btn-gradient-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  border: none;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

.btn-gradient-danger:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  color: white;
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
}

.btn-gradient-warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  border: none;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.btn-gradient-warning:hover {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  color: white;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.35);
}

/* ==========================================================================
   Enhanced Card Variants
   ========================================================================== */
.card-hover-glow:hover {
  box-shadow: 0 8px 32px rgba(59, 130, 246, 0.12), 0 0 0 1px rgba(59, 130, 246, 0.08);
}

.card-hover-lift:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-xl);
}

/* Decorative gradient border on cards */
.card-gradient-border {
  position: relative;
}

.card-gradient-border::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
  border-radius: 1rem 1rem 0 0;
}

/* ==========================================================================
   User Avatar Styles
   ========================================================================== */
.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 0.9rem;
  flex-shrink: 0;
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
  transition: transform 0.2s ease;
}

.user-avatar:hover {
  transform: scale(1.1);
}

.user-avatar-sm {
  width: 32px;
  height: 32px;
  font-size: 0.75rem;
}

.user-avatar-lg {
  width: 56px;
  height: 56px;
  font-size: 1.25rem;
}

/* ==========================================================================
   Notification Dot / Pulse
   ========================================================================== */
@keyframes notificationPulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1); opacity: 0; }
}

.notification-dot {
  position: relative;
}

.notification-dot::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid white;
}

.notification-dot-animated::after {
  animation: notificationPulse 2s ease-in-out infinite;
}

/* ==========================================================================
   Progress Bar Enhancement
   ========================================================================== */
.progress {
  border-radius: 999px;
  height: 8px;
  background: rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.progress-bar {
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer 2s infinite;
}

/* ==========================================================================
   Stat Counter Animation
   ========================================================================== */
.stat-value {
  font-weight: 800;
  font-size: 2.5rem;
  line-height: 1;
  animation: countUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.stat-label {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-top: 0.25rem;
}

/* ==========================================================================
   Responsive animation suppression
   ========================================================================== */
@media (max-width: 767.98px) {
  .toast-container {
    top: auto;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
  }
  
  .toast-notification {
    min-width: auto;
    max-width: 100%;
  }
  
  .empty-state-icon {
    animation: none;
  }
  
  .animate-fade-in-up,
  .animate-fade-in-scale,
  .animate-slide-in-left {
    animation: none;
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .animate-fade-in-up,
  .animate-fade-in-scale,
  .animate-slide-in-left {
    animation: none !important;
    opacity: 1;
  }
  
  .toast-notification,
  .toast-notification.toast-dismissing {
    animation: none !important;
  }
  
  .toast-notification .toast-progress {
    animation: none !important;
  }
  
  .empty-state-icon {
    animation: none !important;
  }
  
  .notification-dot-animated::after {
    animation: none !important;
  }
  
  .progress-bar::after {
    animation: none !important;
  }
}
