/**
 * LagePilot Risk Icon Styling - Professional Edition
 * ===================================================
 * 
 * Modern, elegant icon system with gradients, shadows, and depth.
 * Icons are dynamically colored based on calculated risk levels.
 */

/* ============================================================================
   BASE ICON STYLING
   ============================================================================ */

.risk-icon {
  /* Icon is 100% size, container is 115% (15% larger) */
  width: 100%;
  height: 100%;
  display: inline-block;
  vertical-align: middle;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* White color for SVG icons - handled by filter below */

/* ============================================================================
   ICON CONTAINER - Professional Background Circle
   Background is 15% larger than icon (115%)
   ============================================================================ */

.risk-icon-container {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;  /* 40px icon * 1.15 = 46px */
  height: 46px;
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  
  /* Multi-layer shadow for depth */
  box-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.1),
    0 4px 8px rgba(0, 0, 0, 0.08),
    0 8px 16px rgba(0, 0, 0, 0.06);
}

/* Icon sizing: 40px base, container 15% larger = 46px */
.risk-icon-container .risk-icon {
  width: 40px;
  height: 40px;
}

/* Hover effect - lift and glow */
.risk-icon-container:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 
    0 4px 8px rgba(0, 0, 0, 0.12),
    0 8px 16px rgba(0, 0, 0, 0.1),
    0 16px 32px rgba(0, 0, 0, 0.08);
}

.risk-icon-container:active {
  transform: translateY(0) scale(1.02);
  transition: all 0.1s ease;
}

/* ============================================================================
   HIGHLIGHT EFFECT - Subtle shine on top
   ============================================================================ */

.risk-icon-container::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(
    circle at center,
    rgba(255, 255, 255, 0.35) 0%,
    rgba(255, 255, 255, 0.15) 40%,
    transparent 70%
  );
  pointer-events: none;
  opacity: 0.8;
  transition: opacity 0.3s ease;
}

.risk-icon-container:hover::before {
  opacity: 1;
}

/* ============================================================================
   OUTER GLOW EFFECT - Subtle colored aura
   ============================================================================ */

.risk-icon-container::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: -1;
}

.risk-icon-container:hover::after {
  opacity: 0.4;
}

/* ============================================================================
   RISK LEVEL COLORS - Matching map.html colors exactly
   ============================================================================ */

/* HIGH RISK - Red (matching map.html #e63946 / #c1121f) */
.risk-icon-container.risk-high {
  background: linear-gradient(145deg, #e63946 0%, #c1121f 100%);
  color: #FFFFFF;
}

.risk-icon-container.risk-high::after {
  background: radial-gradient(circle, #e63946 0%, transparent 70%);
  box-shadow: 0 0 20px rgba(230, 57, 70, 0.6);
}

.risk-icon-container.risk-high:hover {
  box-shadow: 
    0 4px 8px rgba(230, 57, 70, 0.25),
    0 8px 16px rgba(230, 57, 70, 0.2),
    0 16px 32px rgba(230, 57, 70, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* MEDIUM RISK - Orange (matching map.html #fb8500 / #e07000) */
.risk-icon-container.risk-medium {
  background: linear-gradient(145deg, #fb8500 0%, #e07000 100%);
  color: #FFFFFF;
}

.risk-icon-container.risk-medium::after {
  background: radial-gradient(circle, #fb8500 0%, transparent 70%);
  box-shadow: 0 0 20px rgba(251, 133, 0, 0.6);
}

.risk-icon-container.risk-medium:hover {
  box-shadow: 
    0 4px 8px rgba(251, 133, 0, 0.25),
    0 8px 16px rgba(251, 133, 0, 0.2),
    0 16px 32px rgba(251, 133, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* LOW RISK - Blue (matching map.html #8ecae6 / #219ebc) */
.risk-icon-container.risk-low {
  background: linear-gradient(145deg, #8ecae6 0%, #219ebc 100%);
  color: #FFFFFF;
}

.risk-icon-container.risk-low::after {
  background: radial-gradient(circle, #8ecae6 0%, transparent 70%);
  box-shadow: 0 0 20px rgba(142, 202, 230, 0.6);
}

.risk-icon-container.risk-low:hover {
  box-shadow: 
    0 4px 8px rgba(142, 202, 230, 0.25),
    0 8px 16px rgba(142, 202, 230, 0.2),
    0 16px 32px rgba(142, 202, 230, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* NEUTRAL - Gray */
.risk-icon-container.risk-neutral {
  background: linear-gradient(145deg, #6B7280 0%, #4B5563 100%);
  color: #FFFFFF;
}

.risk-icon-container.risk-neutral::after {
  background: radial-gradient(circle, #6B7280 0%, transparent 70%);
  box-shadow: 0 0 20px rgba(107, 114, 128, 0.6);
}

.risk-icon-container.risk-neutral:hover {
  box-shadow: 
    0 4px 8px rgba(107, 114, 128, 0.25),
    0 8px 16px rgba(107, 114, 128, 0.2),
    0 16px 32px rgba(107, 114, 128, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* ============================================================================
   ICON SHADOW - Drop shadow for depth + White color
   ============================================================================ */

.risk-icon-container .risk-icon {
  /* Combine filters: make white + add shadow */
  filter: brightness(0) invert(1) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
}

.risk-icon-container:hover .risk-icon {
  filter: brightness(0) invert(1) drop-shadow(0 3px 5px rgba(0, 0, 0, 0.3));
}

/* ============================================================================
   CONTEXT-SPECIFIC SIZES (all 15% larger than icon)
   ============================================================================ */

/* Map markers - 32px icon, 37px container (32 * 1.15 = 36.8 ≈ 37px) */
.leaflet-marker-icon .risk-icon-container {
  width: 37px;
  height: 37px;
  box-shadow: 
    0 3px 6px rgba(0, 0, 0, 0.15),
    0 6px 12px rgba(0, 0, 0, 0.12);
}

.leaflet-marker-icon .risk-icon {
  width: 32px;
  height: 32px;
}

/* Popup icons - 48px icon, 55px container (48 * 1.15 = 55.2 ≈ 55px) */
.leaflet-popup-content .risk-icon-container {
  width: 55px;
  height: 55px;
  margin: 0 auto 16px;
  box-shadow: 
    0 4px 8px rgba(0, 0, 0, 0.12),
    0 8px 16px rgba(0, 0, 0, 0.1),
    0 16px 32px rgba(0, 0, 0, 0.08);
}

.leaflet-popup-content .risk-icon {
  width: 48px;
  height: 48px;
}

/* List view icons - 28px icon, 32px container (28 * 1.15 = 32.2 ≈ 32px) */
.risk-list-item .risk-icon-container {
  width: 32px;
  height: 32px;
  box-shadow: 
    0 1px 3px rgba(0, 0, 0, 0.12),
    0 2px 6px rgba(0, 0, 0, 0.08);
}

.risk-list-item .risk-icon {
  width: 28px;
  height: 28px;
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

/* Pulse animation for new/updated risks */
@keyframes riskPulse {
  0% {
    transform: scale(1);
    box-shadow: 
      0 2px 4px rgba(0, 0, 0, 0.1),
      0 4px 8px rgba(0, 0, 0, 0.08);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 
      0 4px 8px rgba(0, 0, 0, 0.15),
      0 8px 16px rgba(0, 0, 0, 0.12),
      0 0 0 4px rgba(255, 255, 255, 0.5);
  }
  100% {
    transform: scale(1);
    box-shadow: 
      0 2px 4px rgba(0, 0, 0, 0.1),
      0 4px 8px rgba(0, 0, 0, 0.08);
  }
}

.risk-icon-container.animating {
  animation: riskPulse 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Fade in animation for newly loaded icons */
@keyframes iconFadeIn {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.risk-icon-container.fade-in {
  animation: iconFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================================
   BADGE/COUNTER OVERLAY
   ============================================================================ */

.risk-icon-container[data-count]::after {
  content: attr(data-count);
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #DC2626 0%, #991B1B 100%);
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 9px;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

/* ============================================================================
   FOCUS STATES - Accessibility
   ============================================================================ */

.risk-icon-container:focus {
  outline: none;
  box-shadow: 
    0 0 0 3px rgba(59, 130, 246, 0.5),
    0 4px 8px rgba(0, 0, 0, 0.12),
    0 8px 16px rgba(0, 0, 0, 0.1);
}

.risk-icon-container:focus-visible {
  outline: 2px solid #3B82F6;
  outline-offset: 2px;
}

/* ============================================================================
   DISABLED STATE
   ============================================================================ */

.risk-icon-container.disabled,
.risk-icon-container:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(50%);
}

/* ============================================================================
   LOADING STATE
   ============================================================================ */

.risk-icon-container.loading {
  animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
  .risk-icon-container {
    box-shadow: none !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  
  .risk-icon-container::before,
  .risk-icon-container::after {
    display: none;
  }
  
  .risk-icon-container:hover {
    transform: none;
  }
}

/* ============================================================================
   DARK MODE SUPPORT
   ============================================================================ */

@media (prefers-color-scheme: dark) {
  .risk-icon-container {
    box-shadow: 
      0 2px 4px rgba(0, 0, 0, 0.3),
      0 4px 8px rgba(0, 0, 0, 0.25),
      0 8px 16px rgba(0, 0, 0, 0.2);
  }
  
  .risk-icon-container:hover {
    box-shadow: 
      0 4px 8px rgba(0, 0, 0, 0.35),
      0 8px 16px rgba(0, 0, 0, 0.3),
      0 16px 32px rgba(0, 0, 0, 0.25);
  }
  
  /* Slightly brighter variants for dark mode - based on map.html colors */
  .risk-icon-container.risk-high {
    background: linear-gradient(145deg, #f25767 0%, #e63946 100%);
  }
  
  .risk-icon-container.risk-medium {
    background: linear-gradient(145deg, #fc9520 0%, #fb8500 100%);
  }
  
  .risk-icon-container.risk-low {
    background: linear-gradient(145deg, #a8d8ec 0%, #8ecae6 100%);
  }
  
  .risk-icon-container.risk-neutral {
    background: linear-gradient(145deg, #9CA3AF 0%, #6B7280 100%);
  }
}

/* ============================================================================
   MOBILE OPTIMIZATION
   ============================================================================ */

@media (max-width: 768px) {
  /* Larger touch targets on mobile: 38px icon, 44px container (38 * 1.15 = 43.7 ≈ 44px) */
  .risk-icon-container {
    width: 44px;
    height: 44px;
  }
  
  .risk-icon-container .risk-icon {
    width: 38px;
    height: 38px;
  }
  
  /* Reduce shadow complexity on mobile for performance */
  .risk-icon-container {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }
  
  .risk-icon-container:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  }
  
  /* Remove hover effects on touch devices */
  @media (hover: none) {
    .risk-icon-container:hover {
      transform: none;
    }
  }
}

/* ============================================================================
   HIGH CONTRAST MODE
   ============================================================================ */

@media (prefers-contrast: high) {
  .risk-icon-container {
    border: 2px solid currentColor;
  }
  
  .risk-icon-container::before {
    opacity: 0;
  }
}

/* ============================================================================
   REDUCED MOTION
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  .risk-icon-container,
  .risk-icon,
  .risk-icon-container::before,
  .risk-icon-container::after {
    transition: none !important;
    animation: none !important;
  }
}
