/* ============================================
   VixViu Reactivity - Modern Modal Interface
   ============================================ */

/* Modal Styles */
.vixviu-reactivity-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: none;
    font-family: Roboto, Arial, Helvetica, sans-serif;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999999;
}

.modal-content {
    background-color: #1e1e1e;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 18px;
    max-width: 1200px;
    width: 90%;
    max-height: 95vh;
    min-height: 80vh;
    overflow-y: auto;
    position: relative;
    z-index: 1000000;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Close button */
.modal-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    background: none;
    border: none;
    color: #ccc;
    cursor: pointer;
    padding: 8px;
    border-radius: 3px;
    transition: all 0.2s ease;
    z-index: 1000001;
}

.modal-close-btn:hover {
    background-color: #333;
    color: #fff;
}

/* Modal Sections */
.modal-section {
    margin-bottom: 18px;
}

.modal-section:last-child {
    margin-bottom: 0;
}

/* Selection Controls */
.selection-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 18px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-label {
    font-size: 12px;
    font-weight: 500;
    color: #ccc;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-select {
    background-color: #2a2a2a;
    border: 1px solid #333;
    border-radius: 3px;
    color: #ffffff;
    padding: 10px 14px;
    font-size: 12px;
    font-family: inherit;
    transition: border-color 0.2s ease;
    height: 36px;
    line-height: 1.2;
}

.control-select:focus {
    outline: none;
    border-color: #e91e63;
}

.control-select option {
    background-color: #2a2a2a;
    color: #ffffff;
    padding: 8px 12px;
    font-size: 12px;
}

.control-select option:checked {
    background-color: #e91e63;
    color: #ffffff;
    font-weight: 500;
}

.control-select option:hover {
    background-color: #333;
    color: #ffffff;
}

/* Timeline & Preview */
.timeline-preview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}

.timeline-section, .preview-section {
    background-color: #2a2a2a;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 14px;
}

.timeline-header, .preview-header {
    font-size: 14px;
    font-weight: 500;
    color: #ffffff;
    margin: 0 0 14px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Timeline States */
.timeline-content {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.timeline-state {
    text-align: center;
}

.state-upload {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.upload-zone {
    border: 2px dashed #333;
    border-radius: 4px;
    padding: 10px;
    text-align: center;
    transition: all 0.2s ease;
    background-color: #1e1e1e;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.upload-zone:hover {
    border-color: #e91e63;
    background-color: #2a1a1a;
}

.upload-icon {
    color: #999;
    width: 16px;
    height: 16px;
}

.upload-text {
    font-size: 11px;
    color: #999;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.upload-btn {
    background-color: #e91e63;
    color: #ffffff;
    border: none;
    border-radius: 3px;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.upload-btn:hover {
    background-color: #c2185b;
}

.upload-status {
    font-size: 10px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 8px;
    margin-top: 4px;
    border-radius: 3px;
    background-color: rgba(233, 30, 99, 0.1);
    border: 1px solid rgba(233, 30, 99, 0.2);
}

.image-preview {
    display: none;
    margin-top: 6px;
}

.image-preview img {
    max-width: 100%;
    max-height: 40px;
    object-fit: contain;
    border-radius: 2px;
}

/* Timeline Scrubber */
.timeline-scrubber {
    margin-top: 14px;
}

.scrubber-track {
    position: relative;
    height: 4px;
    background-color: #333;
    border-radius: 2px;
    margin-bottom: 10px;
}

.scrubber-marker {
    position: absolute;
    top: -4px;
    width: 12px;
    height: 12px;
    background-color: #999;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    transform: translateX(-50%);
}

.scrubber-marker:hover {
    background-color: #e91e63;
    transform: translateX(-50%) scale(1.2);
}

.scrubber-marker.active {
    background-color: #e91e63;
}

.timeline-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Preview Section */
.preview-window {
    background-color: #1e1e1e;
    border: 1px solid #333;
    border-radius: 4px;
    height: 210px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.preview-placeholder {
    text-align: center;
    color: #999;
}

.preview-icon {
    margin-bottom: 10px;
    color: #666;
}

.preview-placeholder p {
    font-size: 12px;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.preview-controls {
    display: flex;
    gap: 10px;
}

.preview-play-btn, .preview-stop-btn, .preview-reset-btn {
    background-color: #e91e63;
    color: #ffffff;
    border: none;
    border-radius: 3px;
    padding: 8px 14px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.preview-play-btn:hover, .preview-stop-btn:hover, .preview-reset-btn:hover {
    background-color: #c2185b;
}

.preview-play-btn:disabled, .preview-stop-btn:disabled, .preview-reset-btn:disabled {
    background-color: #333;
    color: #666;
    cursor: not-allowed;
}

/* Settings Panel */
.settings-panel {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    background-color: #2a2a2a;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 14px;
    margin-bottom: 18px;
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setting-label {
    font-size: 11px;
    font-weight: 500;
    color: #ccc;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.setting-control {
    background-color: #1e1e1e;
    border: 1px solid #333;
    border-radius: 3px;
    color: #ffffff;
    padding: 8px 10px;
    font-size: 12px;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.setting-control:focus {
    outline: none;
    border-color: #e91e63;
}

.setting-value {
    font-size: 10px;
    color: #999;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Radio and Checkbox Groups */
.radio-group {
    display: flex;
    gap: 10px;
}

.radio-label, .checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #ccc;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.radio-label input, .checkbox-label input {
    margin: 0;
}

.audio-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Apply Section */
.apply-section {
    display: flex;
    gap: 14px;
    justify-content: flex-end;
}

.apply-button, .save-preset-button {
    background-color: #e91e63;
    color: #ffffff;
    border: none;
    border-radius: 3px;
    padding: 10px 18px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.apply-button:hover, .save-preset-button:hover {
    background-color: #c2185b;
}

/* Ensure WordPress media library appears above our modal */
.media-modal {
    z-index: 1000002 !important;
}

.media-modal-backdrop {
    z-index: 1000001 !important;
}

/* Legacy Reactivity Container (for backward compatibility) */
.vixviu-reactivity-container {
  position: relative;
  width: 100%;
  min-height: 300px;
  background: #1e1e1e;
  border-radius: 8px;
  overflow: hidden;
  display: block;
  box-sizing: border-box;
}

/* Demo Content Styling */
.vixviu-reactivity-demo-content {
  position: relative;
  z-index: 1;
  padding: 40px 20px;
  text-align: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.vixviu-reactivity-demo-content.incomplete {
  background: linear-gradient(135deg, #ffa726 0%, #ff7043 100%);
}

.vixviu-reactivity-demo-content h3 {
  margin: 0 0 15px 0;
  font-size: 1.5em;
  font-weight: 600;
}

.vixviu-reactivity-demo-content p {
  margin: 0 0 10px 0;
  opacity: 0.9;
  font-size: 1em;
  line-height: 1.4;
}

.vixviu-reactivity-demo-content small {
  opacity: 0.8;
  font-size: 0.85em;
  font-style: italic;
}

/* Reactive Overlay */
.vixviu-reactivity-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  background: transparent;
  z-index: 999;
  cursor: pointer;
}

/* Effect Elements */
.vixviu-reactivity-effect {
  position: absolute;
  pointer-events: none;
  will-change: transform, opacity;
  transform-origin: center center;
  user-select: none;
  z-index: 1000;
}

.vixviu-reactivity-effect img,
.vixviu-reactivity-effect svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Custom Animation Styles */
.custom-animation {
  transition: opacity 0.2s ease;
}

.custom-animation img {
  transition: opacity 0.1s ease;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* Image Loading States */
.custom-animation.loading img {
  opacity: 0.5;
  filter: blur(1px);
}

.custom-animation.error img {
  opacity: 0.3;
  filter: grayscale(100%);
}

/* WebP Support Detection */
.webp .custom-animation img[src$=".jpg"],
.webp .custom-animation img[src$=".png"] {
  /* Enhanced compression for WebP-supported browsers */
  image-rendering: auto;
}

/* Image Memory Optimization */
.custom-animation img {
  max-width: 200px;
  max-height: 200px;
  object-fit: contain;
  will-change: opacity;
}

/* State-specific effects (optional enhancement) */
.custom-animation[data-state="1"] {
  /* Initial state styling */
}

.custom-animation[data-state="2"] {
  /* Press state styling */
  filter: brightness(0.9);
}

.custom-animation[data-state="3"] {
  /* Peak state styling */
  filter: brightness(1.1) saturate(1.2);
}

.custom-animation[data-state="4"] {
  /* Exit state styling */
  filter: brightness(0.8);
}

/* Mobile Optimizations */
@media (max-width: 768px) {
  .vixviu-reactivity-container {
    min-height: 200px;
  }
  
  .vixviu-reactivity-demo-content {
    padding: 30px 15px;
  }
  
  .vixviu-reactivity-demo-content h3 {
    font-size: 1.3em;
  }
  
  .vixviu-reactivity-demo-content p {
    font-size: 0.9em;
  }
  
  .vixviu-reactivity-effect {
    /* Slightly smaller effects on mobile */
    transform: scale(0.8);
  }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .vixviu-reactivity-effect,
  .vixviu-reactivity-effect * {
    animation: none !important;
    transition: none !important;
  }
  
  .vixviu-reactivity-overlay {
    cursor: default;
  }
  
  .vixviu-reactivity-container::after {
    content: "Animation disabled due to motion preference";
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-size: 0.75em;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 8px;
    border-radius: 4px;
    z-index: 1001;
  }
}

/* Focus Styles for Accessibility */
.vixviu-reactivity-overlay:focus-visible {
  outline: 2px solid #e91e63;
  outline-offset: -2px;
}

.vixviu-reactivity-container:focus-within {
  box-shadow: 0 0 0 2px rgba(233, 30, 99, 0.3);
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .vixviu-reactivity-demo-content {
    background: #000;
    border: 2px solid #fff;
  }
  
  .effect-punch {
    filter: contrast(200%) brightness(1.5);
  }
  
  .effect-sparkle {
    filter: contrast(200%) brightness(1.5);
  }
  
  .effect-money {
    filter: contrast(200%) brightness(1.5);
  }
}

/* Elementor Editor Compatibility */
.elementor-widget-vixviu-reactivity .vixviu-reactivity-container {
  /* High specificity for editor overrides */
  position: relative !important;
}

.elementor-editor-active .vixviu-reactivity-overlay {
  /* Reduce overlay interference in editor */
  pointer-events: none;
}

.elementor-editor-active .vixviu-reactivity-container::before {
  content: "VixViu Reactivity Layer (Preview Mode)";
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 0.8em;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(0, 0, 0, 0.6);
  padding: 4px 8px;
  border-radius: 4px;
  z-index: 1001;
}

/* Loading State */
.vixviu-reactivity-container.loading {
  opacity: 0.7;
}

.vixviu-reactivity-container.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 1002;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Performance Mode Styles */
.vixviu-reactivity-container[data-performance-mode="low"] .vixviu-reactivity-effect {
  /* Simplified animations for low performance mode */
  filter: none;
  box-shadow: none;
}

.vixviu-reactivity-container[data-performance-mode="high"] .vixviu-reactivity-effect {
  /* Enhanced effects for high performance mode */
  filter: brightness(1.1) saturate(1.2);
}

/* Disabled State */
.vixviu-reactivity-container[data-enabled="false"] .vixviu-reactivity-overlay {
  pointer-events: none;
  cursor: default;
}

.vixviu-reactivity-container[data-enabled="false"]::before {
  content: "Reactivity Disabled";
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.75em;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 0, 0, 0.6);
  padding: 4px 8px;
  border-radius: 4px;
  z-index: 1001;
}

/* Debug Toggle Styles */
.debug-toggle-section {
  position: absolute;
  bottom: 14px;
  left: 14px;
  z-index: 1000001;
}

.debug-toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.debug-toggle-checkbox {
  display: none;
}

.debug-toggle-slider {
  position: relative;
  width: 40px;
  height: 20px;
  background-color: #333;
  border-radius: 10px;
  transition: background-color 0.3s ease;
  border: 1px solid #555;
}

.debug-toggle-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background-color: #ccc;
  border-radius: 50%;
  transition: transform 0.3s ease, background-color 0.3s ease;
}

.debug-toggle-checkbox:checked + .debug-toggle-slider {
  background-color: #00ff00;
  border-color: #00ff00;
}

.debug-toggle-checkbox:checked + .debug-toggle-slider::before {
  transform: translateX(20px);
  background-color: #fff;
}

.debug-toggle-text {
  font-size: 11px;
  color: #ccc;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.debug-toggle-label:hover .debug-toggle-text {
  color: #fff;
}

.debug-toggle-label:hover .debug-toggle-slider {
  border-color: #666;
}