/* CSCS UI Helpers - additive-only, scoped */
.cscs-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.cscs-confirm-overlay.open {
  opacity: 1;
}
.cscs-confirm-modal {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
  width: 92%;
  max-width: 420px;
  overflow: hidden;
  transform: translateY(10px);
  transition: transform 0.2s ease;
}
.cscs-confirm-overlay.open .cscs-confirm-modal {
  transform: translateY(0);
}
.cscs-confirm-header {
  padding: 14px 18px;
  font-weight: 700;
  font-size: 1rem;
  color: #0f172a;
  border-bottom: 1px solid #e2e8f0;
}
.cscs-confirm-body {
  padding: 16px 18px;
  color: #334155;
  font-size: 0.95rem;
}
.cscs-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}
.cscs-confirm-btn {
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 600;
  cursor: pointer;
  color: white;
  min-height: 38px;
}
.cscs-confirm-btn-cancel {
  background: #94a3b8;
}
.cscs-confirm-btn-primary {
  background: linear-gradient(135deg, #fbbf24, #f59e0b, #ea580c);
}

/* Toast notifications */
.cscs-toast-container {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 9998;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  pointer-events: none;
}
.cscs-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 280px;
  max-width: 420px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.22);
  padding: 12px 12px 12px 14px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.cscs-toast.show {
  opacity: 1;
  transform: translateY(0);
}
.cscs-toast-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.cscs-toast-success .cscs-toast-icon { color: #16a34a; }
.cscs-toast-danger .cscs-toast-icon { color: #dc2626; }
.cscs-toast-info .cscs-toast-icon { color: #2563eb; }
.cscs-toast-content {
  flex: 1 1 auto;
  min-width: 0;
}
.cscs-toast-title {
  font-weight: 700;
  color: #0f172a;
  font-size: 0.92rem;
}
.cscs-toast-message {
  color: #334155;
  font-size: 0.88rem;
  margin-top: 2px;
}
.cscs-toast-close {
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.cscs-toast-close:hover { color: #0f172a; }

/* Empty state */
.cscs-empty-state {
  text-align: center;
  padding: 32px 18px;
  color: #64748b;
}
.cscs-empty-state .cscs-empty-icon {
  font-size: 2.4rem;
  color: #94a3b8;
  margin-bottom: 10px;
}
.cscs-empty-state p {
  margin: 0;
  font-size: 0.95rem;
}

/* Skeleton loader */
.cscs-skeleton {
  position: relative;
  overflow: hidden;
  background: #e2e8f0;
  border-radius: 8px;
}
.cscs-skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.55) 50%, rgba(255,255,255,0) 100%);
  transform: translateX(-100%);
  animation: cscs-shimmer 1.4s infinite;
}
@keyframes cscs-shimmer {
  100% { transform: translateX(100%); }
}

/* Focus indicators for accessibility */
:focus-visible {
  outline: 2px solid #3b82f6 !important;
  outline-offset: 2px !important;
  border-radius: 4px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #3b82f6 !important;
  outline-offset: 2px !important;
}

/* Skip to content link */
.skip-nav-link {
  position: absolute !important;
  top: -40px !important;
  left: 0 !important;
  background: #3b82f6 !important;
  color: white !important;
  padding: 8px 16px !important;
  text-decoration: none !important;
  z-index: 99999 !important;
  transition: top 0.2s ease !important;
  border-radius: 0 0 8px 0 !important;
}

.skip-nav-link:focus {
  top: 0 !important;
}

/* Loading states for buttons */
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
  pointer-events: none;
}

.btn .spinner-border-sm {
  width: 1rem;
  height: 1rem;
  border-width: 0.2em;
}

/* Button active states */
.btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

/* Ensure minimum touch target size */
.btn,
.btn-sm {
  min-height: 44px;
  min-width: 44px;
}

@media (max-width: 768px) {
  .btn-sm {
    min-height: 40px;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
  }
}

/* Smooth transitions */
.btn,
.btn-group > .btn {
  transition: all 0.2s ease;
}

/* Hover states for buttons */
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Visual feedback for button groups */
.btn-group > .btn:not(:hover) {
  opacity: 0.9;
}

.btn-group > .btn:hover {
  opacity: 1;
  z-index: 1;
}

/* Sidebar link hover states */
.app-sidebar-link:hover:not(.active) {
  background-color: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
}

/* Dropdown hover improvements */
.dropdown-item:hover,
.dropdown-item:focus {
  background-color: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  outline: none;
}

/* Table row hover improvements */
.table-hover tbody tr:hover {
  background-color: rgba(59, 130, 246, 0.05);
  transition: background-color 0.15s ease;
}

/* Card hover improvements */
.card {
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Link transitions */
a {
  transition: color 0.2s ease, text-decoration 0.2s ease;
}

/* Ensure proper spacing for touch targets */
.nav-link,
.btn-group > .btn,
.input-group-text {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Badge improvements */
.badge {
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: all 0.2s ease;
}

/* Toast z-index */
.toast {
  z-index: 99999 !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .table {
    font-size: 0.875rem;
  }
  
  .btn {
    min-height: 44px;
  }
  
  h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
  }
  
  .card-body {
    padding: 1rem;
  }
  
  .card-header {
    padding: 0.75rem 1rem;
  }
  
  /* Improve breadcrumb on mobile */
  .breadcrumb-nav {
    font-size: 0.85rem;
  }
  
  .breadcrumb-item + .breadcrumb-item::before {
    padding: 0 0.3rem;
  }
}

/* Standardize all transitions to 0.2s ease */
.btn,
.btn-group > .btn,
.card,
.form-control,
.table-hover tbody tr,
.nav-link,
.dropdown-item,
.sidebar-link,
.alert,
.badge {
  transition: all 0.2s ease !important;
}

/* Form required field indicators */
.form-label.required::after,
label.required::after {
  content: " *";
  color: #dc3545;
  font-weight: 600;
}

/* Sticky table headers for long tables */
.table-responsive-sticky {
  max-height: 400px;
  overflow-y: auto;
}

.table-responsive-sticky thead th {
  position: sticky;
  top: 0;
  background: #f8f9fa;
  z-index: 10;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Improved empty state component */
.cscs-empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
}

.cscs-empty-state .cscs-empty-icon {
  font-size: 3rem;
  color: #94a3b8;
  margin-bottom: 1rem;
  display: block;
}

.cscs-empty-state h3 {
  color: #334155;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.cscs-empty-state p {
  color: #64748b;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.cscs-empty-state .btn {
  margin-top: 0.5rem;
}

/* Color-blind friendly chart patterns */
.chart-pattern-bar {
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 2px,
    rgba(255,255,255,0.3) 2px,
    rgba(255,255,255,0.3) 4px
  );
}

.chart-pattern-pie {
  background-image: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.1) 3px,
    rgba(0,0,0,0.1) 6px
  );
}

/* Page transition animations */
.page-enter {
  animation: pageEnter 0.3s ease-out;
}

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Apply page animation to main content */
.main-content,
.page-content {
  animation: pageEnter 0.3s ease-out;
}

/* Sticky table headers - already defined .table-responsive-sticky */
.table-responsive {
  max-height: 500px;
  overflow-y: auto;
}

.table-responsive thead th {
  position: sticky;
  top: 0;
  background: #f8f9fa;
  z-index: 10;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Defer Chart.js loading */
.chart-container {
  position: relative;
  min-height: 250px;
}

.chart-container canvas {
  max-height: 400px;
}

/* Dark mode CSS variables */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #e9ecef;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --border-color: #dee2e6;
  --shadow-color: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
  --bg-primary: #1e293b;
  --bg-secondary: #0f172a;
  --bg-tertiary: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --border-color: #475569;
  --shadow-color: rgba(0, 0, 0, 0.4);
}

/* Apply dark mode variables */
[data-theme="dark"] body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

[data-theme="dark"] .card {
  background-color: var(--bg-secondary);
  border-color: var(--border-color);
}

[data-theme="dark"] .card-header {
  background-color: var(--bg-tertiary);
  border-color: var(--border-color);
}

[data-theme="dark"] .form-control {
  background-color: var(--bg-secondary);
  border-color: var(--border-color);
  color: var(--text-primary);
}

[data-theme="dark"] .modal-content {
  background-color: var(--bg-primary);
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
  border-color: var(--border-color);
}

/* Keyboard shortcut indicator */
kbd {
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  color: #495057;
  display: inline-block;
  font-size: 0.875em;
  font-weight: 600;
  line-height: 1;
  padding: 4px 8px;
  white-space: nowrap;
}

/* Tooltip improvements */
.tooltip {
  font-size: 0.85rem;
  font-weight: 500;
}

.tooltip-inner {
  padding: 8px 12px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Icon button with tooltip */
.btn-icon-only {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}
