/* ═══════════════════════════════════════════════════════════════════
   Cars Space - CSS Enhancements
   إضافات وتحسينات لإصلاح جميع المشاكل
   ═══════════════════════════════════════════════════════════════════ */

/* Lightbox Enhancements - إصلاح الشاشة السوداء */
.lightbox {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox.is-active {
  opacity: 1;
  visibility: visible;
}

.lightbox-shell {
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.lightbox.is-active .lightbox-shell {
  transform: scale(1);
}

.lightbox img {
  max-width: 100%;
  height: auto;
  object-fit: contain;
  transition: opacity 0.3s ease;
}

.lightbox button:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.lightbox button:active {
  transform: scale(0.95);
}

/* Loading spinner for lightbox */
.lightbox-shell::before {
  content: '';
  position: absolute;
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255,255,255,0.2);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: lightbox-spin 0.8s linear infinite;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lightbox.is-loading .lightbox-shell::before {
  opacity: 1;
}

@keyframes lightbox-spin {
  to { transform: rotate(360deg); }
}

/* Menu Toggle Button Enhancement */
.nav-toggle {
  transition: all 0.3s ease;
  position: relative;
  z-index: 100;
}

.nav-toggle:hover {
  background: rgba(255,255,255,1);
  border-color: var(--cars-red);
  transform: scale(1.05);
}

.nav-toggle:active {
  transform: scale(0.95);
}

.nav-toggle span {
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Menu Backdrop */
body.menu-open::before {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Menu Items Stagger Animation */
.main-nav a {
  will-change: opacity, transform;
}

/* Smooth Scroll */
html {
  scroll-behavior: smooth;
}

/* Focus Visible - Accessibility */
*:focus-visible {
  outline: 2px solid var(--cars-red);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Loading State for Images */
img {
  background: linear-gradient(90deg, #f0f0f0 0%, #e0e0e0 50%, #f0f0f0 100%);
  background-size: 200% 100%;
}

img[src]:not([src=""]) {
  background: none;
}

/* PWA Install Button (optional) */
.pwa-install-prompt {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  background: var(--cars-red);
  color: white;
  padding: 15px 20px;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(126,15,15,0.4);
  display: none;
  align-items: center;
  justify-content: space-between;
  z-index: 1000;
  animation: slideUp 0.4s ease;
}

.pwa-install-prompt.show {
  display: flex;
}

@keyframes slideUp {
  from {
    transform: translateY(100px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.pwa-install-prompt button {
  background: white;
  color: var(--cars-red);
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
  margin-left: 10px;
}

/* Performance: GPU Acceleration */
.lightbox,
.lightbox-shell,
.main-nav,
.nav-toggle,
.manager-float {
  will-change: transform;
  transform: translateZ(0);
}

/* 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;
    scroll-behavior: auto !important;
  }
}

/* Dark Mode Support (optional future enhancement) */
@media (prefers-color-scheme: dark) {
  /* Will be implemented if needed */
}

/* Print Styles */
@media print {
  .nav-toggle,
  .main-nav,
  .manager-float,
  .lightbox,
  [data-reveal] {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .lightbox {
    background: rgba(0,0,0,0.95);
  }
  
  .main-nav {
    border: 2px solid currentColor;
  }
}
