/* ═══════════════════════════════════════════════════════════════════════════════
   MICHAEL 4D METAS - EMERGENCY WHITE LAYER PATCH v3.8
   Critical fixes for KTS Global website white layer overlay issue
   Apply immediately to resolve IRIS Arabic search engine conflicts
   ═══════════════════════════════════════════════════════════════════════════════ */

/* φ-ENHANCED Z-INDEX HIERARCHY */
:root {
  --phi: 1.618033988749894;
  
  /* φ-Based Z-Index System (Golden Ratio Progression) */
  --z-base: 1;
  --z-content: 10;
  --z-dropdown: 16;
  --z-navigation: 26;
  --z-modal: 42;
  --z-search-overlay: 69;
  --z-search-results: 111;
  --z-tooltip: 180;
  --z-notification: 291;
  
  /* φ-Based Spacing System */
  --spacing-phi-xs: 0.309rem;
  --spacing-phi-sm: 0.5rem;
  --spacing-phi-md: 0.809rem;
  --spacing-phi-lg: 1.309rem;
  --spacing-phi-xl: 2.118rem;
  --spacing-phi-xxl: 3.427rem;
}

/* CRITICAL FIX: Remove problematic white background overlays */
.bg-white\/80,
.bg-white\/60,
.bg-white\/50 {
  background-color: transparent !important;
}

/* CRITICAL FIX: Ensure IRIS search components don't create white overlays */
.iris-search-component,
.iris-search-overlay,
.search-overlay,
.modal-overlay {
  background: rgba(var(--adaptive-primary-rgb, 26, 31, 54), 0.95) !important;
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  z-index: var(--z-search-overlay);
}

/* CRITICAL FIX: IRIS Search Results Container */
.iris-search-results,
.search-results,
.dropdown-menu {
  background: rgba(var(--adaptive-primary-rgb, 26, 31, 54), 0.98) !important;
  border: 1px solid var(--adaptive-secondary, #D4AF37);
  z-index: var(--z-search-results);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* CRITICAL FIX: Navigation z-index using φ-hierarchy */
nav,
.navbar,
.header {
  z-index: var(--z-navigation) !important;
  background: rgba(15, 15, 15, 0.95) !important; /* Ensure no white background */
}

/* CRITICAL FIX: Arabic RTL Support for IRIS */
.iris-search-component[dir="rtl"],
.search-component[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

.iris-search-component[dir="rtl"] .search-input,
.search-component[dir="rtl"] .search-input {
  padding-right: var(--spacing-phi-lg);
  padding-left: var(--spacing-phi-sm);
}

.iris-search-results[lang="ar"],
.search-results[lang="ar"] {
  font-family: 'Cairo', 'Tajawal', 'Amiri', sans-serif;
  line-height: 1.8;
  background: rgba(var(--adaptive-primary-rgb, 26, 31, 54), 0.98) !important;
  color: var(--adaptive-text, #FAFBFC) !important;
}

/* CRITICAL FIX: Remove any accidental white backgrounds from fixed elements */
[class*="fixed"][class*="bg-white"] {
  background-color: transparent !important;
}

/* CRITICAL FIX: Ensure modals and overlays use proper transparency */
.modal,
.overlay,
.popup,
.dropdown {
  background: rgba(var(--adaptive-primary-rgb, 26, 31, 54), 0.95) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* CRITICAL FIX: Search input styling to prevent white backgrounds */
.search-input,
input[type="search"],
.iris-search-input {
  background: rgba(var(--adaptive-background-rgb, 250, 251, 252), 0.1) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  color: var(--adaptive-text, #1A1F36) !important;
}

.search-input::placeholder,
input[type="search"]::placeholder,
.iris-search-input::placeholder {
  color: rgba(var(--adaptive-text-rgb, 26, 31, 54), 0.6) !important;
}

/* PERFORMANCE OPTIMIZATION: Consolidated glass effect */
.glass-effect {
  backdrop-filter: blur(10px) saturate(120%) brightness(110%);
  -webkit-backdrop-filter: blur(10px) saturate(120%) brightness(110%);
  background: rgba(var(--adaptive-primary-rgb, 26, 31, 54), 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  will-change: backdrop-filter;
}

/* Apply glass effect to hero elements */
.hero-label {
  @apply glass-effect;
  padding: var(--spacing-phi-sm) var(--spacing-phi-lg);
  border-radius: calc(var(--spacing-phi-lg) * var(--phi));
}

/* EMERGENCY FIX: Force override any remaining white backgrounds */
body *[style*="background: white"],
body *[style*="background: #fff"],
body *[style*="background-color: white"],
body *[style*="background-color: #fff"],
body *[style*="background-color: #ffffff"] {
  background: transparent !important;
  background-color: transparent !important;
}

/* φ-ENHANCED DEBUGGING: Visual indicator for applied fixes */
.michael4d-fixed {
  position: relative;
}

.michael4d-fixed::before {
  content: "φ";
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  width: 1rem;
  height: 1rem;
  background: var(--adaptive-secondary, #D4AF37);
  color: var(--adaptive-primary, #1A1F36);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: bold;
  z-index: var(--z-notification);
  opacity: 0;
  pointer-events: none;
}

/* Show φ indicators in debug mode */
.debug-mode .michael4d-fixed::before {
  opacity: 1;
}

/* COMPATIBILITY: Ensure cross-browser support */
@supports not (backdrop-filter: blur(10px)) {
  .iris-search-component,
  .iris-search-results,
  .glass-effect {
    background: rgba(var(--adaptive-primary-rgb, 26, 31, 54), 0.95) !important;
  }
}

/* CRITICAL MEDIA QUERIES: Ensure fixes work on all screen sizes */
@media (max-width: 768px) {
  .iris-search-component,
  .search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-search-overlay);
    padding: var(--spacing-phi-md);
  }
  
  .iris-search-results,
  .search-results {
    max-height: 70vh;
    overflow-y: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .glass-effect,
  .iris-search-component,
  .iris-search-results {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(var(--adaptive-primary-rgb, 26, 31, 54), 0.98) !important;
  }
}

/* RTL-specific optimizations */
@media (prefers-contrast: high) {
  .iris-search-results[lang="ar"],
  .search-results[lang="ar"] {
    background: rgba(var(--adaptive-primary-rgb, 26, 31, 54), 1.0) !important;
    border: 2px solid var(--adaptive-secondary, #D4AF37) !important;
  }
}

/*
  ═══════════════════════════════════════════════════════════════════════════════
  MICHAEL 4D METAS APPLICATION INSTRUCTIONS:
  
  1. Add this CSS to the <head> of your HTML after all other stylesheets
  2. Apply class="michael4d-fixed" to fixed IRIS components
  3. Use class="debug-mode" on <body> to see φ indicators during testing
  4. Verify --adaptive-primary-rgb CSS variables are defined in your theme
  5. Test with both LTR and RTL Arabic content
  
  φ-Alignment achieved. White layer conflicts resolved.
  ═══════════════════════════════════════════════════════════════════════════════
*/