/**
 * LUMAVINE.AI - VISUAL BUG FIXES
 * Fixes for specific visual bugs and inconsistencies across the platform
 */

/* =====================================================
   LAYOUT STABILITY FIXES (PREVENT CLS)
   ===================================================== */

/* Ensure all images have proper aspect ratios */
img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Reserve space for loading elements */
.loading-placeholder {
  min-height: 200px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0.05) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

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

/* Font loading - prevent flash of unstyled text */
@font-face {
  font-display: optional;
}

/* =====================================================
   Z-INDEX HIERARCHY
   ===================================================== */

/* Establish proper z-index hierarchy */
.modal-overlay {
  z-index: 9998;
}

.modal-content {
  z-index: 9999;
}

.language-switcher-widget {
  z-index: 9997;
}

.language-switcher-dropdown {
  z-index: 9998;
}

.navigation {
  z-index: 1000;
}

.dropdown-menu {
  z-index: 1001;
}

.toast-notification {
  z-index: 10000;
}

.skip-link:focus {
  z-index: 10001;
}

/* =====================================================
   BUTTON CONSISTENCY
   ===================================================== */

/* Standardize button styles */
button,
.btn,
[role="button"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  text-decoration: none;
  white-space: nowrap;
}

/* Fix button hover state consistency */
button:hover:not(:disabled),
.btn:hover:not(:disabled),
[role="button"]:hover:not([aria-disabled="true"]) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

button:active:not(:disabled),
.btn:active:not(:disabled) {
  transform: translateY(0);
}

/* Disabled button state */
button:disabled,
.btn:disabled,
[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* =====================================================
   TEXT SELECTION
   ===================================================== */

/* Consistent text selection color */
::selection {
  background: rgba(124, 58, 237, 0.5);
  color: #ffffff;
}

::-moz-selection {
  background: rgba(124, 58, 237, 0.5);
  color: #ffffff;
}

/* =====================================================
   SCROLLBAR STYLING
   ===================================================== */

/* Custom scrollbar for webkit browsers */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* =====================================================
   MODAL FIXES
   ===================================================== */

/* Fix modal backdrop */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* Fix modal content centering */
.modal-content {
  position: relative;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  background: rgba(26, 26, 36, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* =====================================================
   CARD COMPONENT FIXES
   ===================================================== */

/* Consistent card styling */
.card {
  background: rgba(22, 29, 40, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 20px;
  transition: all 0.25s ease;
}

.card:hover {
  background: rgba(28, 36, 48, 0.9);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* =====================================================
   INPUT FIELD FIXES
   ===================================================== */

/* Consistent input styling */
input,
select,
textarea {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

/* Fix iOS input zoom */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="number"],
select,
textarea {
  font-size: 16px; /* Prevents iOS zoom */
}

/* Placeholder consistency */
::placeholder {
  color: rgba(255, 255, 255, 0.4);
  opacity: 1;
}

:-ms-input-placeholder {
  color: rgba(255, 255, 255, 0.4);
}

::-ms-input-placeholder {
  color: rgba(255, 255, 255, 0.4);
}

/* =====================================================
   ANIMATION TIMING FIXES
   ===================================================== */

/* Smooth all transitions */
* {
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Fix animation performance */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* =====================================================
   ICON ALIGNMENT FIXES
   ===================================================== */

/* Fix icon alignment in buttons */
button svg,
.btn svg,
[role="button"] svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

/* Fix icon color inheritance */
svg {
  fill: currentColor;
  stroke: currentColor;
}

/* =====================================================
   GRADIENT CONSISTENCY
   ===================================================== */

/* Standardize gradient backgrounds */
.gradient-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.gradient-secondary {
  background: linear-gradient(135deg, #00d4ff 0%, #b44aff 100%);
}

.gradient-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

/* =====================================================
   BORDER RADIUS CONSISTENCY
   ===================================================== */

/* Standardize border radius values */
.rounded-sm {
  border-radius: 4px;
}

.rounded-md {
  border-radius: 8px;
}

.rounded-lg {
  border-radius: 12px;
}

.rounded-xl {
  border-radius: 16px;
}

.rounded-full {
  border-radius: 9999px;
}

/* =====================================================
   SHADOW CONSISTENCY
   ===================================================== */

/* Standardize box shadows */
.shadow-sm {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.shadow-md {
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.shadow-lg {
  box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
}

.shadow-xl {
  box-shadow: 0 20px 25px rgba(0, 0, 0, 0.15);
}

.shadow-glow {
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.4);
}

/* =====================================================
   OVERFLOW FIXES
   ===================================================== */

/* Fix horizontal scroll issues */
html,
body {
  overflow-x: hidden;
  max-width: 100%;
}

/* Fix long text overflow */
.text-overflow {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-wrap {
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}

/* =====================================================
   GRID LAYOUT FIXES
   ===================================================== */

/* Fix grid gap inconsistencies */
.grid {
  display: grid;
  gap: 20px;
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 768px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* =====================================================
   FLEX LAYOUT FIXES
   ===================================================== */

/* Fix flex alignment issues */
.flex {
  display: flex;
  align-items: center;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.flex-column {
  display: flex;
  flex-direction: column;
}

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

/* Loading spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: #2dd4bf;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* =====================================================
   PRINT FIXES
   ===================================================== */

@media print {
  /* Hide non-printable elements */
  .no-print,
  button,
  .modal-overlay,
  .language-switcher-widget {
    display: none !important;
  }

  /* Ensure proper contrast */
  * {
    background: white !important;
    color: black !important;
  }

  /* Prevent page breaks in inappropriate places */
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    page-break-after: avoid;
  }

  table,
  figure,
  img {
    page-break-inside: avoid;
  }
}

/* =====================================================
   PERFORMANCE OPTIMIZATIONS
   ===================================================== */

/* GPU acceleration for transforms and animations */
.animate,
.transition {
  will-change: transform, opacity;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

/* Remove will-change after animation completes */
.animate:not(:hover):not(:focus),
.transition:not(:hover):not(:focus) {
  will-change: auto;
}
