/* ==========================================================================
   Vision Status Component - Custom Styles
   ========================================================================== */

/* ==========================================================================
   CSS Custom Properties (Design Tokens)
   ========================================================================== */

#vision-status {
  /* Color Palette */
  --accent-primary: #FF8A00;
  --accent-secondary: #3b82f6;
  
  /* Neutrals */
  --color-text-primary: #E9EEF5;
  --color-text-secondary: #A1ADBD;
  --color-text-tertiary: #cfd7e6;
  --color-text-bright: #eaf2ff;
  
  /* Surfaces */
  --color-surface-card: rgba(255, 255, 255, 0.03);
  --color-surface-input: rgba(255, 255, 255, 0.05);
  
  /* Borders */
  --color-border-subtle: rgba(255, 255, 255, 0.08);
  --color-border-interactive: rgba(255, 255, 255, 0.12);
  
  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 18px 45px rgba(0, 0, 0, 0.45);
  --shadow-glow-blue: 0 0 18px rgba(59, 130, 246, 0.35);
  --shadow-cta: 0 10px 22px rgba(59, 130, 246, 0.35);
  
  /* Spacing */
  --spacing-xs: clamp(8px, 1vw, 12px);
  --spacing-sm: clamp(12px, 1.5vw, 16px);
  --spacing-md: clamp(18px, 2.6vw, 28px);
  --spacing-lg: clamp(28px, 5vw, 64px);
  
  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 22px;
  --radius-full: 999px;
  
  /* Transitions */
  --transition-fast: 0.12s ease-out;
  --transition-base: 0.2s ease-out;
  --transition-slow: 0.3s ease-out;
  
  /* Typography */
  --font-size-xs: 0.875rem;
  --font-size-sm: 0.92rem;
  --font-size-base: 1rem;
  --font-size-lg: clamp(1.4rem, 2.6vw, 2rem);
  
  /* Z-Index Scale */
  --z-base: 0;
  --z-overlay: 1;
  --z-modal: 10;
}


/* ==========================================================================
   Main Container
   ========================================================================== */

#vision-status {
  position: relative;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--spacing-md);
  margin-block: var(--spacing-lg);
  background: linear-gradient(
    180deg, 
    rgba(255, 255, 255, 0.15), 
    rgba(0, 0, 0, 0.16)
  );
  box-shadow: 
    var(--shadow-lg), 
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
  isolation: isolate;
}


/* ==========================================================================
   Visual Effects
   ========================================================================== */

/* Ambient Light Scan Effect */
.x-scan {
  position: absolute;
  inset: -40% -20% auto -20%;
  height: 70%;
  pointer-events: none;
  mix-blend-mode: screen;
  background:
    radial-gradient(
      40% 35% at 20% 0%, 
      rgba(0, 110, 255, 0.25), 
      transparent 60%
    ),
    radial-gradient(
      40% 35% at 80% 0%, 
      rgba(255, 193, 115, 0.15), 
      transparent 60%
    );
  filter: blur(30px);
  opacity: 0.35;
  animation: ambient-pulse 7s ease-in-out infinite;
}

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

/* Grid Overlay */
.x-grid {
  position: absolute;
  inset: -2px;
  pointer-events: none;
  opacity: 0.18;
  background-image:
    radial-gradient(
      circle at 50% -10%, 
      rgba(255, 138, 0, 0.14), 
      transparent 30%
    ),
    linear-gradient(transparent 0 0),
    linear-gradient(
      rgba(255, 255, 255, 0.04) 1px, 
      transparent 1px
    ),
    linear-gradient(
      90deg, 
      rgba(255, 255, 255, 0.04) 1px, 
      transparent 1px
    );
  background-size: 
    100% 100%, 
    100% 100%, 
    36px 36px, 
    36px 36px;
  background-position: 0 0;
}


/* ==========================================================================
   Header Section
   ========================================================================== */

.x-status-head {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 22px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: clamp(14px, 2vw, 18px);
}

/* Title & Subtitle */
.x-title {
  margin: 0;
  font-weight: 800;
  font-size: var(--font-size-lg);
  letter-spacing: 0.2px;
  color: var(--color-text-primary);
  line-height: 1.2;
}

.x-em {
  color: var(--accent-secondary);
  text-shadow: var(--shadow-glow-blue);
}

.x-sub {
  color: var(--color-text-secondary);
  margin: 0.25rem 0 0;
  font-size: var(--font-size-sm);
}

/* Right Side Controls */
.x-head-right {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}


/* ==========================================================================
   Legend & Tags
   ========================================================================== */

.x-legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.x-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-full);
  color: var(--color-text-tertiary);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  font-size: var(--font-size-xs);
  font-weight: 500;
  cursor: pointer;
  transition: 
    border-color var(--transition-base),
    transform var(--transition-fast),
    opacity var(--transition-base);
  user-select: none;
}

.x-tag:hover {
  border-color: var(--color-border-interactive);
}

.x-tag:not(.is-on) {
  opacity: 0.55;
}

.x-tag:active {
  transform: translateY(1px);
}

.x-tag .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 12px var(--c);
}


/* ==========================================================================
   Tools & Inputs
   ========================================================================== */

.x-tools {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Search Input */
.x-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-subtle);
  background: var(--color-surface-input);
  color: var(--color-text-tertiary);
  transition: border-color var(--transition-base);
}

.x-input:focus-within {
  border-color: var(--color-border-interactive);
}

.x-input input {
  background: transparent;
  border: 0;
  color: inherit;
  outline: 0;
  width: 200px;
  font-size: var(--font-size-xs);
  font-family: inherit;
}

.x-input input::placeholder {
  color: var(--color-text-secondary);
  opacity: 0.6;
}

/* Refresh Button */
.x-refresh {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: #fff;
  font-weight: 600;
  font-size: var(--font-size-xs);
  background: linear-gradient(180deg, #60a5fa, #3b82f6);
  border: 1px solid rgba(59, 130, 246, 0.35);
  box-shadow: 
    var(--shadow-cta), 
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: 
    transform var(--transition-fast),
    box-shadow var(--transition-base);
  user-select: none;
}

.x-refresh:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 12px 28px rgba(59, 130, 246, 0.45), 
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.x-refresh:active {
  transform: translateY(0);
}


/* ==========================================================================
   Content Groups
   ========================================================================== */

.x-group {
  position: relative;
  margin-top: 18px;
}

.x-group-head h2 {
  margin: 0 0 10px;
  font-size: var(--font-size-xs);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}


/* ==========================================================================
   Card Grid
   ========================================================================== */

.x-cards {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
}

/* Responsive Grid Breakpoints */
@media (max-width: 1200px) {
  .x-cards {
    grid-template-columns: repeat(8, 1fr);
  }
}

@media (max-width: 880px) {
  .x-cards {
    grid-template-columns: repeat(6, 1fr);
  }
}

@media (max-width: 640px) {
  .x-cards {
    grid-template-columns: repeat(1, 1fr);
  }
}


/* ==========================================================================
   Product Cards
   ========================================================================== */

.x-card {
  --st: #9aa4b2; /* Status color - dynamically set */
  
  position: relative;
  z-index: var(--z-base);
  grid-column: span 12;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-decoration: none;
  cursor: pointer;
  padding: 14px;
  border-radius: var(--radius-lg);
  color: var(--color-text-primary);
  background: var(--color-surface-card);
  border: 1px solid var(--color-border-subtle);
  overflow: hidden;
  transition: 
    transform var(--transition-fast),
    border-color var(--transition-base);
}

/* Responsive Card Spans */
@media (min-width: 641px) {
  .x-card {
    grid-column: span 6;
  }
}

@media (min-width: 881px) {
  .x-card {
    grid-column: span 4;
  }
}

.x-card:hover {
  transform: translateY(-2px);
  border-color: var(--color-border-interactive);
}

/* Card Main Content */
.x-card-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Card Name Section */
.x-name {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.x-label {
  font-weight: 700;
  font-size: var(--font-size-base);
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.x-subtle {
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
}

/* Status Pill */
.x-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-full);
  border: 1px solid color-mix(in srgb, var(--st) 45%, transparent);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--st) 18%, transparent),
    rgba(0, 0, 0, 0.15)
  );
  color: var(--color-text-bright);
  white-space: nowrap;
}

.x-pill .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--st);
  box-shadow: 0 0 14px var(--st);
  flex-shrink: 0;
}

.x-pill .txt {
  font-weight: 600;
  font-size: var(--font-size-xs);
  opacity: 0.95;
}

/* Card Metadata */
.x-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  color: #c9d2e1;
  font-size: var(--font-size-sm);
}

.x-price {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--color-border-subtle);
  font-weight: 600;
}


/* ==========================================================================
   Card Visual Effects
   ========================================================================== */

/* Glow Effect */
.x-card .x-glow {
  position: absolute;
  inset: -30% -10%;
  background: radial-gradient(
    30% 30% at 70% 0%,
    color-mix(in srgb, var(--st) 25%, transparent),
    transparent 60%
  );
  filter: blur(28px);
  opacity: 0.25;
  pointer-events: none;
  transition: opacity var(--transition-slow);
  z-index: -1;
}

.x-card:hover .x-glow {
  opacity: 0.4;
}

/* Rotating Border Effect */
.x-card .x-border {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.35;
  background: conic-gradient(
    from 0deg at 50% 50%,
    rgba(255, 255, 255, 0),
    color-mix(in srgb, var(--st) 60%, transparent),
    rgba(255, 255, 255, 0) 45%
  ) border-box;
  -webkit-mask: 
    linear-gradient(#000 0 0) padding-box,
    linear-gradient(#000 0 0) border-box;
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  border: 1px solid transparent;
  animation: border-rotation 14s linear infinite;
}

@keyframes border-rotation {
  to {
    transform: rotate(360deg);
  }
}


/* ==========================================================================
   Utilities & States
   ========================================================================== */

/* Hidden Groups */
#vision-status [data-group][style*="display: none"] {
  margin: 0;
  padding: 0;
  height: 0;
  overflow: hidden;
}

/* Focus Visible for Accessibility */
.x-card:focus-visible,
.x-tag:focus-visible,
.x-refresh:focus-visible {
  outline: 2px solid var(--accent-secondary);
  outline-offset: 2px;
}


/* ==========================================================================
   Performance Optimizations
   ========================================================================== */

.x-scan,
.x-grid,
.x-glow,
.x-border {
  will-change: opacity, transform;
}

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