/**
 * Images and Visual Elements CSS
 * Theme-aware styling for images, icons, and visual elements
 * Supports both light and dark themes with proper contrast
 */

/* ===== Base Image Styles ===== */
img {
  max-width: 100%;
  height: auto;
  transition: all var(--theme-transition-normal);
}

/* ===== Logo Adaptations ===== */
.logo-image,
.layout-logo-image {
  filter: none;
  transition: filter var(--theme-transition-normal);
}

/* Dark theme logo adjustments */
[data-theme="dark"] .logo-image,
[data-theme="dark"] .layout-logo-image {
  filter: brightness(1.1) contrast(0.9);
}

/* Company logos that need inversion in dark mode */
.company-logo,
.brand-logo {
  transition: filter var(--theme-transition-normal);
}

[data-theme="dark"] .company-logo,
[data-theme="dark"] .brand-logo {
  filter: brightness(0) invert(1);
  opacity: 0.9;
}

/* ===== SVG Icon Adaptations ===== */
.icon,
.svg-icon {
  color: var(--theme-text-secondary);
  fill: currentColor;
  transition: color var(--theme-transition-normal);
}

.icon-primary {
  color: var(--theme-brand-primary);
}

.icon-secondary {
  color: var(--theme-text-secondary);
}

.icon-muted {
  color: var(--theme-text-muted);
}

.icon-success {
  color: var(--theme-brand-success);
}

.icon-warning {
  color: var(--theme-brand-warning);
}

.icon-error {
  color: var(--theme-brand-error);
}

/* Navigation icons */
.nav-icon {
  color: var(--theme-nav-link);
  transition: color var(--theme-transition-fast);
}

.nav-icon:hover {
  color: var(--theme-nav-link-hover);
}

/* ===== Feature Icons ===== */
.feature-icon,
.tool-icon,
.benefit-icon {
  width: 64px;
  height: 64px;
  transition: all var(--theme-transition-normal);
  filter: none;
}

/* Dark theme icon adjustments */
[data-theme="dark"] .feature-icon,
[data-theme="dark"] .tool-icon,
[data-theme="dark"] .benefit-icon {
  filter: brightness(1.1) saturate(1.1);
}

/* Specific icon color adjustments for dark theme */
[data-theme="dark"] .feature-icon[src*="blue"],
[data-theme="dark"] .tool-icon[src*="blue"] {
  filter: hue-rotate(15deg) brightness(1.2);
}

[data-theme="dark"] .feature-icon[src*="green"],
[data-theme="dark"] .tool-icon[src*="green"] {
  filter: hue-rotate(-10deg) brightness(1.1);
}

/* ===== Background Images ===== */
.hero-background,
.section-background {
  background-attachment: fixed;
  background-size: cover;
  background-position: center;
  transition: opacity var(--theme-transition-normal);
}

/* Dark theme background adjustments */
[data-theme="dark"] .hero-background,
[data-theme="dark"] .section-background {
  opacity: 0.7;
  filter: brightness(0.8) contrast(1.1);
}

/* ===== LED Display Visualizations ===== */
.led-display,
.screen-visualization {
  background-color: var(--theme-bg-primary);
  border: 1px solid var(--theme-border-primary);
  border-radius: 8px;
  padding: 1rem;
  transition: all var(--theme-transition-normal);
}

.led-pixel {
  background-color: var(--theme-brand-primary);
  border-radius: 2px;
  transition: background-color var(--theme-transition-fast);
}

.led-pixel.active {
  background-color: var(--theme-brand-accent);
  box-shadow: 0 0 4px var(--theme-brand-accent);
}

.led-pixel.inactive {
  background-color: var(--theme-bg-tertiary);
  opacity: 0.3;
}

/* LED display grid */
.led-grid {
  display: grid;
  gap: 1px;
  background-color: var(--theme-bg-secondary);
  padding: 2px;
  border-radius: 4px;
}

/* ===== Chart and Graph Elements ===== */
.chart-container {
  background-color: var(--theme-card-bg);
  border: 1px solid var(--theme-card-border);
  border-radius: 12px;
  padding: 1.5rem;
  transition: all var(--theme-transition-normal);
}

.chart-axis {
  stroke: var(--theme-border-secondary);
  stroke-width: 1;
}

.chart-grid {
  stroke: var(--theme-border-muted);
  stroke-width: 0.5;
  stroke-dasharray: 2,2;
}

.chart-line {
  stroke: var(--theme-brand-primary);
  stroke-width: 2;
  fill: none;
}

.chart-area {
  fill: var(--theme-brand-primary);
  opacity: 0.1;
}

.chart-point {
  fill: var(--theme-brand-primary);
  stroke: var(--theme-bg-primary);
  stroke-width: 2;
}

/* ===== Image Overlays and Filters ===== */
.image-overlay {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
}

.image-overlay::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    var(--theme-brand-primary) 0%,
    var(--theme-brand-secondary) 100%
  );
  opacity: 0;
  transition: opacity var(--theme-transition-normal);
  pointer-events: none;
}

.image-overlay:hover::after {
  opacity: 0.1;
}

/* ===== Product Images ===== */
.product-image {
  background-color: var(--theme-bg-secondary);
  border: 1px solid var(--theme-border-primary);
  border-radius: 8px;
  padding: 1rem;
  transition: all var(--theme-transition-normal);
}

.product-image img {
  filter: none;
  transition: filter var(--theme-transition-normal);
}

[data-theme="dark"] .product-image img {
  filter: brightness(1.05) contrast(0.95);
}

/* ===== Avatar and Profile Images ===== */
.avatar,
.profile-image {
  border-radius: 50%;
  border: 2px solid var(--theme-border-primary);
  transition: border-color var(--theme-transition-normal);
}

.avatar:hover,
.profile-image:hover {
  border-color: var(--theme-brand-primary);
}

/* ===== Icon Buttons ===== */
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 8px;
  border: 1px solid var(--theme-border-primary);
  background-color: var(--theme-bg-elevated);
  color: var(--theme-text-secondary);
  cursor: pointer;
  transition: all var(--theme-transition-fast);
}

.icon-button:hover {
  background-color: var(--theme-hover-bg);
  border-color: var(--theme-border-focus);
  color: var(--theme-brand-primary);
  transform: translateY(-1px);
}

.icon-button:active {
  transform: translateY(0);
}

.icon-button.primary {
  background-color: var(--theme-brand-primary);
  border-color: var(--theme-brand-primary);
  color: var(--theme-text-inverse);
}

.icon-button.primary:hover {
  background-color: var(--theme-brand-secondary);
  border-color: var(--theme-brand-secondary);
}

/* ===== Image Loading States ===== */
.image-loading {
  background: linear-gradient(
    90deg,
    var(--theme-bg-secondary) 25%,
    var(--theme-bg-tertiary) 50%,
    var(--theme-bg-secondary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
  border-radius: 8px;
}

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

/* ===== Image Error States ===== */
.image-error {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--theme-bg-secondary);
  border: 2px dashed var(--theme-border-secondary);
  border-radius: 8px;
  color: var(--theme-text-muted);
  font-size: 0.875rem;
  min-height: 200px;
}

.image-error::before {
  content: '🖼️';
  font-size: 2rem;
  margin-right: 0.5rem;
}

/* ===== Responsive Image Adaptations ===== */
@media (max-width: 768px) {
  .feature-icon,
  .tool-icon,
  .benefit-icon {
    width: 48px;
    height: 48px;
  }
  
  .led-display,
  .screen-visualization {
    padding: 0.75rem;
  }
  
  .chart-container {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .feature-icon,
  .tool-icon,
  .benefit-icon {
    width: 40px;
    height: 40px;
  }
  
  .icon-button {
    width: 2rem;
    height: 2rem;
  }
}

/* ===== Print Styles ===== */
@media print {
  .image-overlay::after {
    display: none;
  }
  
  .led-display,
  .screen-visualization {
    border: 1px solid #000;
    background-color: #fff;
  }
  
  .chart-container {
    border: 1px solid #000;
    background-color: #fff;
  }
}

/* ===== High Contrast Mode ===== */
@media (prefers-contrast: high) {
  .icon,
  .svg-icon {
    filter: contrast(1.5);
  }
  
  .led-pixel.active {
    box-shadow: 0 0 8px currentColor;
  }
  
  .chart-line {
    stroke-width: 3;
  }
  
  .chart-point {
    stroke-width: 3;
  }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  .image-loading {
    animation: none;
    background: var(--theme-bg-secondary);
  }
  
  .led-pixel,
  .icon,
  .svg-icon,
  .feature-icon,
  .tool-icon,
  .benefit-icon {
    transition: none;
  }
}

/* ===== Dark Theme Specific Image Adjustments ===== */
[data-theme="dark"] {
  /* Adjust image brightness for better visibility */
  .hero-image,
  .feature-image,
  .product-screenshot {
    filter: brightness(0.9) contrast(1.1);
  }
  
  /* Invert monochrome icons */
  .icon-monochrome {
    filter: invert(1);
  }
  
  /* Adjust logo brightness */
  .logo-dark-adjust {
    filter: brightness(1.2);
  }
  
  /* LED display dark theme adjustments */
  .led-display {
    background-color: #1a1a1a;
    border-color: #333;
  }
  
  .led-pixel.active {
    box-shadow: 0 0 6px var(--theme-brand-accent);
  }
}

/* ===== Theme Toggle Icon Specific Styles ===== */
.theme-icon {
  width: 16px;
  height: 16px;
  transition: all var(--theme-transition-fast);
}

.theme-icon-sun {
  color: #fbbf24;
}

.theme-icon-moon {
  color: #60a5fa;
}

/* ===== Favicon Dark Mode Support ===== */
@media (prefers-color-scheme: dark) {
  link[rel="icon"][href*="favicon.svg"] {
    filter: brightness(1.2);
  }
}

/* ===== Image Accessibility ===== */
/* Only highlight images that completely lack alt attributes (not decorative images with alt="") */
img:not([alt]) {
  outline: 2px solid var(--theme-brand-warning);
  outline-offset: 2px;
}

/* Decorative images with empty alt attributes are properly handled */
img[alt=""] {
  /* No outline needed - these are properly marked as decorative */
}

/* Screen reader only images */
.sr-only-image {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== Custom Image Filters ===== */
.image-filter-sepia {
  filter: sepia(0.5);
}

.image-filter-grayscale {
  filter: grayscale(1);
}

.image-filter-blur {
  filter: blur(2px);
}

[data-theme="dark"] .image-filter-sepia {
  filter: sepia(0.3) brightness(1.1);
}

[data-theme="dark"] .image-filter-grayscale {
  filter: grayscale(1) brightness(1.1);
}

[data-theme="dark"] .image-filter-blur {
  filter: blur(2px) brightness(0.9);
}