/*
 * ImageFX - Consolidated Main CSS
 * 
 * This file contains all styles for the ImageFX application,
 * consolidated from multiple source files to reduce bloat and improve maintainability.
 */

/* ======== RESET & GLOBAL STYLES ======== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Color palette */
  --color-primary: #3498db;
  --color-primary-dark: #2980b9;
  --color-secondary: #2ecc71;
  --color-secondary-dark: #27ae60;
  --color-accent: #e74c3c;
  --color-accent-dark: #c0392b;
  
  /* Neutral colors */
  --color-background: #121212;
  --color-surface: #1e1e1e;
  --color-text: #e0e0e0;
  --color-text-secondary: #a0a0a0;
  --color-border: #333333;
  
  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  
  /* Typography */
  --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --font-size-xs: 12px;
  --font-size-sm: 14px;
  --font-size-md: 16px;
  --font-size-lg: 18px;
  --font-size-xl: 24px;
  
  /* Borders */
  --border-radius-sm: 4px;
  --border-radius-md: 8px;
  --border-radius-lg: 12px;
  --border-width: 1px;
  


  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);
}

body {
  font-family: var(--font-family);
  background-color: #000;
  color: var(--color-text);
  touch-action: manipulation; /* Allow pinch-zoom, prevent double-tap zoom */
}

.container {
  position: relative;
  width: 100vw;
  height: 100vh;
}

/* ======== LAYOUT COMPONENTS ======== */

/* Canvas styling */
#visualizer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
}

#visualizer:active {
  cursor: none;
}

/* Control panel sidebar */
.control-panel {
  position: fixed;
  top: 50px;
  left: 0;
  width: 280px;
  max-width: 90vw;
  height: calc(100vh - 50px);
  background-color: rgba(30, 30, 30, 0.25);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 990;
  transition: transform 0.3s ease-in-out;
}

/* Control panel open state */
.control-panel.open {
  left: 0;
}

/* Controls container */
#controls {
  position: fixed;
  top: 70px; /* Increased top position to avoid overlap with X button */
  left: 0;
  width: 280px;
  max-width: 280px;
  height: calc(100vh - 70px); /* Adjust height to compensate for top offset */
  z-index: 100;
  overflow-y: auto;
  padding: var(--spacing-md);
  /* Make scrollbar less visible but still functional */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
  background-color: transparent;
  border: none;
  box-shadow: none;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

#controls.hidden {
  transform: translateX(-330px);
  opacity: 0;
  pointer-events: none;
}

/* Burger menu button */
.menu-toggle {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 40px;
  height: 40px;
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 101;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: background-color 0.2s ease;
}

.menu-toggle:hover {
  background-color: rgba(0, 0, 0, 0.7);
}

.menu-toggle .burger,
.menu-toggle .close {
  color: white;
  font-size: 24px;
  transition: opacity 0.2s ease;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Default hide the close icon */
.menu-toggle .close {
  display: none;
}

/* Default show the burger icon */
.menu-toggle .burger {
  display: block;
}

/* Control sections */
.control-section {
  margin-bottom: 25px;
}

h2 {
  font-size: 1.5rem;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #333;
}

h3 {
  font-size: 1.2rem;
  margin-bottom: 15px;
}

/* Section Divider Line */
hr.section-divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  margin: 20px 0;
}

/* Responsive adjustments */
@media screen and (max-width: 768px) {
  .control-panel {
    width: 250px;
    left: -250px;
  }
}

/* ======== UI COMPONENTS ======== */

/* Base component styles */
.ui-component {
  font-family: var(--font-family);
  margin-bottom: var(--spacing-md);
  color: var(--color-text);
}

.ui-component-label {
  display: block;
  margin-bottom: var(--spacing-xs);
  font-size: var(--font-size-sm);
  color: rgba(255, 255, 255, 0.95);
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.ui-component-description {
  font-size: var(--font-size-xs);
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: var(--spacing-xs);
}

.ui-component.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Play section styling */
.play-section {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.play-button {
  width: 40px;
  height: 40px;
  background-color: rgba(0, 0, 0, 0.7);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-right: 10px;
}

.play-button:hover {
  background-color: rgba(0, 0, 0, 0.9);
  transform: scale(1.1);
}

.play-icon {
  color: white;
  font-size: 20px;
  line-height: 1;
}

.play-label {
  color: white;
  font-size: 14px;
}

/* Make play section sticky inside the control panel */
.control-panel .play-section {
  position: sticky;
  top: 0; /* Stick to the top of the scrollable panel */
  background-color: rgba(60, 60, 60, 0.95); /* Slightly different background */
  z-index: 10; /* Ensure it stays on top */
  padding: 10px 0; /* Adjust padding as needed */
  margin: 0 -20px 20px -20px; /* Extend background to panel edges, add bottom margin */
  padding-left: 20px; /* Re-apply left padding */
  padding-right: 20px; /* Re-apply right padding */
  border-bottom: 1px solid rgba(255, 255, 255, 0.2); /* Separator line */
}

/* Effects Styling */
.effects-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.effect-card {
  background-color: rgba(30, 30, 30, 0.7);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.effect-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  cursor: pointer;
  width: 100%;
}

/* Collapsible cards */
.effect-card h3 {
  cursor: pointer;
  position: relative;
  padding-right: 20px;
}

/* Standard h3 triangle for most cards */
.effect-card h3::after {
  content: '▼';
  font-size: 10px;
  color: rgba(255, 255, 255, 0.7);
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  transition: transform 0.3s ease;
}

/* Hide the h3 triangle for Rotation effect that has a custom header */
.effect-header h3::after {
  display: none;
}

/* For the Rotation card, add a collapse indicator after the toggle */
.effect-header {
  position: relative;
  padding-right: 20px; /* Space for the triangle */
}

/* Add the triangle after the effect-header */
.effect-header::after {
  content: '▼';
  font-size: 10px;
  color: rgba(255, 255, 255, 0.7);
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  transition: transform 0.3s ease;
}

/* Rotate triangle for collapsed state */
.effect-card.collapsed h3::after,
.effect-card.collapsed .effect-header::after {
  transform: translateY(-50%) rotate(-90deg);
}

/* Ensure all controls are hidden when card is collapsed, EXCEPT the toggle in the header */
.effect-card.collapsed .effect-controls,
.effect-card.collapsed .control-group,
.effect-card.collapsed .effect-description,
.effect-card.collapsed .control-row,
.effect-card.collapsed .ui-component,
.effect-card.collapsed .ui-slider-container,
.effect-card.collapsed .effect-controls .ui-toggle-container,
.effect-card.collapsed label:not(.effect-header label),
.effect-card.collapsed button:not(h3 button),
.effect-card.collapsed select {
  display: none !important;
}

/* Explicitly ensure the header toggle stays visible when collapsed */
.effect-card.collapsed .effect-header,
.effect-card.collapsed .effect-header .effect-toggle,
.effect-card.collapsed .effect-header .ui-toggle-container {
  display: flex !important;
}



.effect-name {
  font-weight: bold;
  color: #fff;
  font-size: 14px;
}

.effect-toggle {
  margin-left: 10px;
  display: flex;
  align-items: center;
}

.effect-header .ui-toggle-container {
  margin: 0;
  padding: 0;
}

.effect-header h3 {
  padding-right: 0;
  margin-right: 10px;
}

.effect-header .ui-toggle-text {
  font-size: 11px;
  min-width: 22px;
}

.effect-description {
  font-size: 11px;
  color: #aaa;
  margin-bottom: 5px;
}

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

.effect-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 5px;
}

.effect-status span {
  margin-left: 8px;
  font-size: 12px;
  color: #aaa;
}

/* Component group */
.ui-component-group, .ui-component.effect-card {
  border: var(--border-width) solid rgba(255, 255, 255, 0.15);
  border-radius: var(--border-radius-md);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
  background-color: rgba(30, 30, 30, 0.7);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  width: 100%; /* Ensure cards take full width of container */
}

.ui-component-group-title {
  font-size: var(--font-size-md);
  font-weight: 600;
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-xs);
  border-bottom: var(--border-width) solid rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

/* Slider component */
.ui-slider-container {
  position: relative;
  display: flex;
  align-items: center;
  padding-right: 55px; /* Increased space for value display */
  margin: 6px 0;
}

/* Base slider track styling */
.ui-slider-input {
  flex: 1;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  height: 8px; /* Slightly thicker for better visibility */
  background: rgba(60, 60, 60, 0.6); /* Darker semi-transparent track */
  border-radius: 4px;
  outline: none;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
  margin: 10px 0;
  position: relative;
}

/* Chrome/Safari/Edge thumb styling */
.ui-slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(145deg, #3498db, #2980b9); /* Gradient background */
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease-in-out;
  position: relative; 
  top: 0; /* Reset any vertical positioning */
  transform: translateY(0); /* Remove transform-based positioning */
  margin-top: -2px; /* Use margin for better reliability */
}

/* Firefox thumb styling */
.ui-slider-input::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  background: linear-gradient(145deg, #3498db, #2980b9); /* Gradient background */
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease-in-out;
}

/* Hover effects */
.ui-slider-input:hover::-webkit-slider-thumb,
.ui-slider-input:focus::-webkit-slider-thumb {
  background: linear-gradient(145deg, #2980b9, #3498db); /* Reversed gradient */
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.6); /* Glow effect */
  transform: scale(1.05); /* Slight enlargement only */
  margin-top: -2px; /* Match the normal state margin */
}

.ui-slider-input:hover::-moz-range-thumb,
.ui-slider-input:focus::-moz-range-thumb {
  background: linear-gradient(145deg, #2980b9, #3498db); /* Reversed gradient */
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.6); /* Glow effect */
  transform: scale(1.05); /* Slight enlargement */
}

/* Value display styling */
.slider-value, .ui-slider-value {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(30, 30, 30, 0.7);
  color: white;
  border-radius: 4px;
  padding: 2px 6px;
  min-width: 30px;
  text-align: center;
  font-size: 12px;
  z-index: 2; /* Ensure it appears above the slider */
}

/* Toggle component */
.ui-toggle-container {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.ui-toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  -ms-appearance: none;
  appearance: none;
}

.ui-toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
  background-color: var(--color-border);
  border-radius: 10px;
  transition: background-color var(--transition-fast);
  cursor: pointer;
}

.ui-toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--color-surface);
  transition: transform var(--transition-fast);
}

.ui-toggle-input:checked + .ui-toggle-switch {
  background-color: var(--color-primary);
}

.ui-toggle-input:checked + .ui-toggle-switch::after {
  transform: translateX(20px);
}

.ui-toggle-input:focus + .ui-toggle-switch {
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.3);
}

.ui-toggle-text {
  font-size: var(--font-size-sm);
  color: white;
}

.ui-toggle-on .ui-toggle-text {
  color: var(--color-primary);
}

/* Button component */
.ui-button-element {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--border-radius-sm);
  background-color: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  outline: none;
}

.ui-button-element:hover {
  background-color: var(--color-background);
}

.ui-button-element:active {
  transform: translateY(1px);
}

.ui-button-element:focus {
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.3);
}

.ui-button-primary {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.ui-button-primary:hover {
  background-color: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}

.ui-button-secondary {
  background-color: var(--color-secondary);
  border-color: var(--color-secondary);
  color: white;
}

.ui-button-secondary:hover {
  background-color: var(--color-secondary-dark);
  border-color: var(--color-secondary-dark);
}

.ui-button-danger {
  background-color: var(--color-accent);
  border-color: var(--color-accent);
  color: white;
}

.ui-button-danger:hover {
  background-color: var(--color-accent-dark);
  border-color: var(--color-accent-dark);
}

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

.ui-button-text {
  line-height: 1;
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 30px;
  height: 17px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #555;
  transition: .3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 13px;
  width: 13px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .3s;
}

input:checked + .slider {
  background-color: #2196F3;
}

input:checked + .slider:before {
  transform: translateX(13px);
}

.slider.round {
  border-radius: 17px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Audio Control Styles */

/* Play/Stop Button Styling - ALWAYS BLUE OVERRIDE */
#audio-play-btn, #audio-stop-btn,
#audio-play-btn.active, #audio-stop-btn.active,
.ui-button-element#audio-play-btn, .ui-button-element#audio-stop-btn,
.ui-button-element#audio-play-btn.active, .ui-button-element#audio-stop-btn.active {
  background-color: #3f51b5 !important; /* Always blue */
  border-color: #3f51b5 !important;
  color: white !important;
}

/* Music Button Styles */
.music-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background-color: var(--color-surface);
  color: var(--color-text);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin: 0 var(--spacing-xs);
}

.music-btn:hover {
  transform: scale(1.1);
  background-color: var(--color-background);
}

.music-btn.active {
  background-color: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.music-btn-container {
  display: flex;
  justify-content: center;
  margin-bottom: var(--spacing-md);
}

/* Beat Indicator Styling */
.audio-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 5px;
  margin-bottom: 5px;
  position: relative; /* For proper positioning of beat indicator */
}

#beat-indicator {
  display: inline-block;
  margin-left: 8px;
  opacity: 0.3;
  transition: all 0.1s ease;
  font-size: 1.2rem;
  vertical-align: middle;
}

#beat-indicator.active {
  opacity: 1;
  transform: scale(1.2);
}

/* Image Thumbnail Styling */
.image-btn-container {
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-md);
}

.image-btn {
  width: 35px;
  height: 35px;
  border-radius: var(--border-radius-sm);
  border: 2px solid var(--color-border);
  background-color: var(--color-surface);
  background-size: cover;
  background-position: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0;
}

.image-btn:hover {
  transform: scale(1.05);
  border-color: var(--color-primary-dark);
  box-shadow: var(--shadow-sm);
}

.image-btn.active {
  border: 2px solid var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary), var(--shadow-md);
}

/* Upload buttons styling */
.upload-container {
  display: flex;
  justify-content: center;
  margin-top: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.upload-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--border-radius-md);
  background: var(--color-primary);
  color: white;
  cursor: pointer;
  font-size: var(--font-size-sm);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  width: 80%;
  max-width: 200px;
}

.upload-button:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.upload-button:active {
  transform: translateY(1px);
  box-shadow: var(--shadow-sm);
}

/* Quick Select Media Buttons */
.quick-select-row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.quick-select-label {
  margin-right: 8px;
  display: flex;
  align-items: center;
}

.quick-select {
  display: flex;
  gap: 5px;
}

.quick-select-button {
  background-color: #555;
  border: 1px solid #777;
  color: white;
  border-radius: 4px;
  padding: 5px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

.quick-select-button .material-icons {
  font-size: 18px;
  margin-right: 3px;
}

.quick-select-button:hover {
  background-color: #777;
  transform: scale(1.05);
}

.quick-select-button.selected {
  background-color: #007bff;
  box-shadow: 0 0 5px rgba(0, 123, 255, 0.7);
  transform: scale(1.05);
}

/* Zoom Status Indicator */
.zoom-status-container {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  pointer-events: none;
}

.zoom-status {
  background-color: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--border-radius-md);
  opacity: 0.6;
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform: translateY(10px);
}

.zoom-status.active {
  opacity: 1;
  transform: translateY(0);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .ui-slider-container {
    flex-direction: column;
    align-items: stretch;
    gap: var(--spacing-xs);
  }
  
  .slider-value {
    text-align: left;
  }
  
  button.reset {
    padding: 6px 8px;
    font-size: 11px;
  }
}
