/**
 * Global Styles
 *
 * Base styles and CSS variable definitions.
 * Theme-specific values are injected dynamically by ThemeProvider.
 */

/* Enable color-scheme switching for browser UI elements */
:root {
  color-scheme: light dark;
}

/* Theme-aware color scheme for form inputs, scrollbars, etc. */
[data-theme='light'],
[data-theme='high-contrast'] {
  color-scheme: light;
}

[data-theme='dark'] {
  color-scheme: dark;
}

/* Base styles */
body {
  margin: 0;
  padding: 0;
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Roboto,
    'Helvetica Neue',
    Arial,
    sans-serif;
  background-color: var(--color-bg-base);
  color: var(--color-text);
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}

#root {
  min-height: 100vh;
}

/* Smooth theme transitions for all elements */
*,
*::before,
*::after {
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

/* Disable transitions during theme switch to prevent flash */
[data-theme-switching] *,
[data-theme-switching] *::before,
[data-theme-switching] *::after {
  transition: none !important;
}

/* ============================================================================
 * Alert Animations
 * ============================================================================ */

/* Pulsating alert shadow for project cards */
@keyframes alert-pulse {
  0%,
  100% {
    box-shadow: 0 0 8px var(--color-error-bg, rgba(255, 77, 79, 0.4));
  }
  50% {
    box-shadow: 0 0 16px var(--color-error, rgba(255, 77, 79, 0.7));
  }
}

.project-card-alert {
  animation: alert-pulse 2s ease-in-out infinite;
}

/* Pulsating alert shadow for alert tags */
@keyframes alert-tag-pulse {
  0%,
  100% {
    box-shadow: 0 0 4px var(--color-error-bg, rgba(255, 77, 79, 0.4));
  }
  50% {
    box-shadow: 0 0 8px var(--color-error, rgba(255, 77, 79, 0.7));
  }
}

.alert-tag-pulse {
  animation: alert-tag-pulse 2s ease-in-out infinite;
}

/* Alert pulse for severity indicators */
@keyframes alertPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* Live indicator pulse */
@keyframes livePulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

/* Now line pulse on charts */
@keyframes nowLinePulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Value flash animation when data updates */
@keyframes valueFlash {
  0% {
    background-color: var(--color-primary-bg, rgba(24, 144, 255, 0.2));
  }
  100% {
    background-color: transparent;
  }
}

/* ============================================================================
 * Print Styles
 * ============================================================================ */

@media print {
  /* Force light theme colors for printing */
  :root {
    --color-bg-base: #ffffff !important;
    --color-bg-container: #ffffff !important;
    --color-bg-elevated: #ffffff !important;
    --color-bg-layout: #ffffff !important;
    --color-text: #000000 !important;
    --color-text-secondary: #333333 !important;
    --color-border: #d9d9d9 !important;
  }

  /* Remove transitions for print */
  * {
    transition: none !important;
    animation: none !important;
  }

  /* Hide theme switcher in print */
  .theme-switcher {
    display: none !important;
  }
}

/* ============================================================================
 * Accessibility
 * ============================================================================ */

/* Ensure focus indicators are visible */
:focus-visible {
  outline: 2px solid var(--color-primary, #1890ff);
  outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================================
 * Scrollbar Styling (for supported browsers)
 * ============================================================================ */

/* Webkit scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-spotlight, #fafafa);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border, #d9d9d9);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-tertiary, rgba(0, 0, 0, 0.45));
}

/* Dark theme scrollbars */
[data-theme='dark'] ::-webkit-scrollbar-track {
  background: var(--color-bg-spotlight, #262626);
}

[data-theme='dark'] ::-webkit-scrollbar-thumb {
  background: var(--color-border, #434343);
}

[data-theme='dark'] ::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-tertiary, rgba(255, 255, 255, 0.45));
}

/* ============================================================================
 * Sidebar Menu Styling
 * ============================================================================ */

/* Selected menu item left accent indicator */
.ant-menu-item-selected::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--color-primary, #1890ff);
  border-radius: 0 2px 2px 0;
}

/* Smoother menu item transitions */
.ant-menu-item {
  position: relative;
  transition: background-color 0.15s ease, color 0.15s ease !important;
}

/* Menu icon color transitions */
.ant-menu-item .anticon {
  transition: color 0.15s ease !important;
}

/* Sider collapse trigger styling */
.ant-layout-sider-trigger {
  background: var(--color-bg-spotlight) !important;
  border-top: 1px solid var(--color-border-secondary) !important;
  color: var(--color-text-secondary) !important;
}

.ant-layout-sider-trigger:hover {
  background: var(--color-bg-container) !important;
  color: var(--color-text) !important;
}
