/* Oscilloscope Web - Styles CSS Optimisés */

/* === VARIABLES CSS POUR UNE MAINTENANCE FACILITÉE === */
:root {
  /* Couleurs principales */
  --primary-bg: linear-gradient(135deg, #1a1a1a, #000);
  --secondary-bg: rgba(50, 50, 50, 0.8);
  --canvas-border: #333;
  --text-color: #ffffff;
  --accent-color: #00ffff;
  
  /* Espacements */
  --spacing-xs: 5px;
  --spacing-sm: 10px;
  --spacing-md: 15px;
  --spacing-lg: 20px;
  --spacing-xl: 30px;
  
  /* Rayons de bordure */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 15px;
  
  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
  
  /* Ombres */
  --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-medium: 0 4px 15px rgba(0, 255, 255, 0.3);
  --shadow-heavy: 0 0 30px rgba(0, 255, 255, 0.3);
  
  /* Tailles de police responsive */
  --font-size-xs: clamp(11px, 2vw, 12px);
  --font-size-sm: clamp(12px, 2.2vw, 13px);
  --font-size-md: clamp(13px, 2.5vw, 14px);
  --font-size-lg: clamp(14px, 2.8vw, 16px);
}

/* === TITRE PRINCIPAL OSCILLOSCOPE === */
.main-header {
  text-align: center;
  margin-bottom: var(--spacing-lg);
}

.oscilloscope-title {
  font-family: 'Courier New', monospace;
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: bold;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin: 0;
  padding: var(--spacing-md);
  color: var(--accent-color);
  text-shadow: 
    0 0 5px currentColor,
    0 0 10px currentColor,
    0 0 15px rgba(0, 255, 255, 0.3);
  animation: subtle-pulse 3s ease-in-out infinite alternate;
  position: relative;
  background: linear-gradient(135deg, transparent 30%, rgba(0, 255, 255, 0.05) 50%, transparent 70%);
  border: 1px solid rgba(0, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(2px);
}

.oscilloscope-title::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 1px;
  background: linear-gradient(90deg, transparent, currentColor, transparent);
  animation: underline-flicker 2s ease-in-out infinite alternate;
}

@keyframes subtle-pulse {
  from {
    text-shadow: 
      0 0 5px currentColor,
      0 0 10px currentColor,
      0 0 15px rgba(0, 255, 255, 0.3);
  }
  to {
    text-shadow: 
      0 0 8px currentColor,
      0 0 16px currentColor,
      0 0 24px rgba(0, 255, 255, 0.4);
  }
}

@keyframes underline-flicker {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* === SIGNATURE === */
.signature {
  position: fixed;
  bottom: var(--spacing-sm);
  right: var(--spacing-sm);
  font-size: var(--font-size-xs);
  opacity: 0.7;
  transition: opacity var(--transition-normal);
  z-index: 1000;
}

.signature:hover {
  opacity: 1;
}

.signature a {
  color: var(--accent-color);
  text-decoration: none;
  font-family: 'Courier New', monospace;
  text-shadow: 0 0 5px currentColor;
  transition: all var(--transition-normal);
}

.signature a:hover {
  text-shadow: 
    0 0 8px currentColor,
    0 0 15px currentColor;
  transform: scale(1.05);
}

/* === RESET ET BASE === */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: var(--spacing-sm);
  background: var(--primary-bg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  color: var(--text-color);
  overflow-x: hidden;
  min-height: 100vh;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === CONTENEUR PRINCIPAL === */
#container {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  max-width: 100%;
  margin: 0 auto;
  padding: var(--spacing-sm);
  gap: var(--spacing-lg);
}

/* === CANVAS OSCILLOSCOPE === */
#oscilloscope {
  border: 2px solid var(--canvas-border);
  border-radius: var(--radius-lg);
  background: linear-gradient(to bottom, #1e1e1e, #000);
  box-shadow: var(--shadow-heavy);
  cursor: crosshair;
  display: block;
  flex-shrink: 0;
  transition: all var(--transition-normal);
  will-change: transform, box-shadow;
}

#oscilloscope:hover {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { 
    box-shadow: var(--shadow-heavy);
    transform: scale(1);
  }
  50% { 
    box-shadow: 0 0 40px rgba(0, 255, 255, 0.6);
    transform: scale(1.002);
  }
}

/* === CONTRÔLES === */
#controls-all {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--spacing-md);
  padding: var(--spacing-lg);
  background: var(--secondary-bg);
  border-radius: var(--radius-md);
  backdrop-filter: blur(10px) saturate(150%);
  width: 100%;
  max-width: 1000px;
  box-shadow: var(--shadow-light);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.control-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 180px;
  padding: var(--spacing-sm) var(--spacing-md);
  transition: all var(--transition-normal);
  background: linear-gradient(145deg, rgba(40, 40, 40, 0.9), rgba(20, 20, 20, 0.9));
  border-radius: var(--radius-md);
  box-shadow: 
    inset 2px 2px 5px rgba(0, 0, 0, 0.3),
    inset -2px -2px 5px rgba(80, 80, 80, 0.1),
    0 4px 15px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(0, 255, 255, 0.1);
  backdrop-filter: blur(3px);
}

.control-group:hover {
  transform: translateY(-3px);
  box-shadow: 
    inset 2px 2px 5px rgba(0, 0, 0, 0.4),
    inset -2px -2px 5px rgba(100, 100, 100, 0.15),
    0 8px 25px rgba(0, 255, 255, 0.15);
  border-color: rgba(0, 255, 255, 0.2);
}

.control-group.button-group {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--spacing-xs);
  min-width: 100%;
  grid-column: 1 / -1;
  padding: var(--spacing-md);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: var(--spacing-sm);
}

.control-group label {
  margin-bottom: var(--spacing-xs);
  font-weight: 600;
  font-size: var(--font-size-md);
  text-align: center;
  color: var(--text-color);
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* === SLIDERS OPTIMISÉS AVEC EFFET 3D === */
.slider {
  width: 100%;
  min-width: 150px;
  height: 22px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(180deg, #1a1a1a, #2a2a2a, #1a1a1a);
  border-radius: var(--radius-lg);
  outline: none;
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
  will-change: transform, box-shadow;
  box-shadow: 
    inset 0 2px 5px rgba(0, 0, 0, 0.4),
    inset 0 -1px 2px rgba(80, 80, 80, 0.2),
    0 1px 2px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(0, 0, 0, 0.6);
  padding: 1px;
}

.slider:hover {
  background: linear-gradient(180deg, #2a2a2a, #3a3a3a, #2a2a2a);
  box-shadow: 
    inset 0 2px 6px rgba(0, 0, 0, 0.5),
    inset 0 -1px 3px rgba(100, 100, 100, 0.25),
    0 2px 4px rgba(0, 255, 255, 0.1);
  transform: scale(1.01);
}

.slider:active {
  cursor: grabbing;
  box-shadow: 
    inset 0 3px 8px rgba(0, 0, 0, 0.6),
    inset 0 -1px 2px rgba(120, 120, 120, 0.3);
}

.slider.dragging {
  transform: scale(1.02);
  z-index: 10;
  position: relative;
}

/* Curseurs Webkit (Chrome, Safari, Edge) - Effet 3D Profondeur et Reflets */
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 34px;
  background: linear-gradient(145deg, 
    rgba(255, 255, 255, 0.9) 0%,
    rgba(180, 240, 255, 0.8) 8%,
    var(--accent-color) 18%,
    rgba(0, 160, 200, 1) 35%,
    rgba(0, 100, 140, 1) 65%,
    rgba(0, 50, 90, 0.9) 85%,
    rgba(0, 20, 50, 0.8) 100%);
  border-radius: 8px;
  cursor: grab;
  transition: all var(--transition-fast);
  box-shadow: 
    0 6px 12px rgba(0, 0, 0, 0.4),
    0 2px 4px rgba(0, 0, 0, 0.6),
    inset 0 2px 4px rgba(255, 255, 255, 0.5),
    inset 0 -2px 4px rgba(0, 0, 0, 0.3),
    inset 1px 0 3px rgba(255, 255, 255, 0.3),
    inset -1px 0 3px rgba(0, 0, 0, 0.2),
    0 0 8px rgba(0, 255, 255, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.4);
  position: relative;
  will-change: box-shadow;
}

.slider::-webkit-slider-thumb:hover {
  background: linear-gradient(145deg, 
    rgba(255, 255, 255, 1) 0%,
    rgba(200, 250, 255, 0.9) 8%,
    rgba(80, 220, 255, 1) 18%,
    rgba(0, 180, 220, 1) 35%,
    rgba(0, 120, 160, 1) 65%,
    rgba(0, 70, 110, 1) 85%,
    rgba(0, 30, 70, 0.9) 100%);
  box-shadow: 
    0 8px 16px rgba(0, 0, 0, 0.5),
    0 3px 6px rgba(0, 0, 0, 0.7),
    inset 0 3px 6px rgba(255, 255, 255, 0.6),
    inset 0 -3px 6px rgba(0, 0, 0, 0.4),
    inset 2px 0 4px rgba(255, 255, 255, 0.4),
    inset -2px 0 4px rgba(0, 0, 0, 0.3),
    0 0 12px rgba(0, 255, 255, 0.6),
    0 0 20px rgba(0, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.6);
}

.slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  box-shadow: 
    0 3px 6px rgba(0, 0, 0, 0.6),
    0 1px 2px rgba(0, 0, 0, 0.8),
    inset 0 1px 3px rgba(255, 255, 255, 0.4),
    inset 0 -1px 3px rgba(0, 0, 0, 0.5),
    inset 1px 0 2px rgba(255, 255, 255, 0.3),
    inset -1px 0 2px rgba(0, 0, 0, 0.4),
    0 0 8px rgba(0, 255, 255, 0.5);
  background: linear-gradient(145deg, 
    rgba(240, 240, 240, 0.95) 0%,
    rgba(160, 230, 245, 0.85) 8%,
    rgba(60, 200, 240, 1) 18%,
    rgba(0, 160, 200, 1) 35%,
    rgba(0, 100, 140, 1) 65%,
    rgba(0, 50, 90, 0.95) 85%,
    rgba(0, 20, 50, 0.85) 100%);
}

/* Curseurs Firefox - Effet 3D Profondeur et Reflets */
.slider::-moz-range-thumb {
  width: 26px;
  height: 34px;
  background: linear-gradient(145deg, 
    rgba(255, 255, 255, 0.9) 0%,
    rgba(180, 240, 255, 0.8) 8%,
    var(--accent-color) 18%,
    rgba(0, 160, 200, 1) 35%,
    rgba(0, 100, 140, 1) 65%,
    rgba(0, 50, 90, 0.9) 85%,
    rgba(0, 20, 50, 0.8) 100%);
  border-radius: 8px;
  cursor: grab;
  border: 1px solid rgba(255, 255, 255, 0.4);
  transition: all var(--transition-fast);
  box-shadow: 
    0 6px 12px rgba(0, 0, 0, 0.4),
    0 2px 4px rgba(0, 0, 0, 0.6),
    0 0 8px rgba(0, 255, 255, 0.4);
}

.slider::-moz-range-thumb:hover {
  background: linear-gradient(145deg, 
    rgba(255, 255, 255, 1) 0%,
    rgba(200, 250, 255, 0.9) 8%,
    rgba(80, 220, 255, 1) 18%,
    rgba(0, 180, 220, 1) 35%,
    rgba(0, 120, 160, 1) 65%,
    rgba(0, 70, 110, 1) 85%,
    rgba(0, 30, 70, 0.9) 100%);
  box-shadow: 
    0 8px 16px rgba(0, 0, 0, 0.5),
    0 3px 6px rgba(0, 0, 0, 0.7),
    0 0 12px rgba(0, 255, 255, 0.6),
    0 0 20px rgba(0, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.6);
}

.slider::-moz-range-thumb:active {
  cursor: grabbing;
  box-shadow: 
    0 3px 6px rgba(0, 0, 0, 0.6),
    0 1px 2px rgba(0, 0, 0, 0.8),
    0 0 8px rgba(0, 255, 255, 0.5);
  background: linear-gradient(145deg, 
    rgba(240, 240, 240, 0.95) 0%,
    rgba(160, 230, 245, 0.85) 8%,
    rgba(60, 200, 240, 1) 18%,
    rgba(0, 160, 200, 1) 35%,
    rgba(0, 100, 140, 1) 65%,
    rgba(0, 50, 90, 0.95) 85%,
    rgba(0, 20, 50, 0.85) 100%);
}

/* === BOUTONS AVEC EFFET 3D === */
button {
  padding: var(--spacing-sm) var(--spacing-md);
  background: linear-gradient(145deg, 
    rgba(60, 60, 60, 0.9), 
    rgba(40, 40, 40, 0.9), 
    rgba(20, 20, 20, 0.9));
  color: var(--text-color);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-weight: 600;
  transition: all var(--transition-normal);
  white-space: nowrap;
  min-width: 120px;
  position: relative;
  overflow: hidden;
  will-change: transform, box-shadow;
  box-shadow: 
    0 4px 8px rgba(0, 0, 0, 0.3),
    0 1px 2px rgba(0, 0, 0, 0.5),
    inset 0 1px 2px rgba(255, 255, 255, 0.1),
    inset 0 -1px 2px rgba(0, 0, 0, 0.2);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
    transparent, 
    rgba(255, 255, 255, 0.15), 
    transparent);
  transition: left var(--transition-slow);
}

button:hover {
  background: linear-gradient(145deg, 
    rgba(80, 80, 80, 0.95), 
    rgba(60, 60, 60, 0.95), 
    rgba(40, 40, 40, 0.95));
  transform: translateY(-3px);
  box-shadow: 
    0 8px 16px rgba(0, 0, 0, 0.4),
    0 2px 4px rgba(0, 0, 0, 0.6),
    inset 0 1px 3px rgba(255, 255, 255, 0.15),
    inset 0 -1px 3px rgba(0, 0, 0, 0.25),
    0 0 10px rgba(0, 255, 255, 0.2);
  border-color: rgba(0, 255, 255, 0.2);
}

button:hover::before {
  left: 100%;
}

button:active {
  transform: translateY(-1px);
  box-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.5),
    0 1px 2px rgba(0, 0, 0, 0.7),
    inset 0 1px 2px rgba(255, 255, 255, 0.1),
    inset 0 -1px 2px rgba(0, 0, 0, 0.3);
}

button:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
  box-shadow: 
    0 4px 8px rgba(0, 0, 0, 0.3),
    0 1px 2px rgba(0, 0, 0, 0.5),
    inset 0 1px 2px rgba(255, 255, 255, 0.1),
    inset 0 -1px 2px rgba(0, 0, 0, 0.2),
    0 0 10px rgba(0, 255, 255, 0.5);
}

/* === CLASSES UTILITAIRES === */
.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === MODE PLEIN ÉCRAN === */
.fullscreen-mode {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: #000 !important;
  z-index: 9999 !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
  padding: 0 !important;
  margin: 0 !important;
}

.fullscreen-mode #oscilloscope {
  display: block !important;
  margin: auto !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
}

/* === MEDIA QUERIES OPTIMISÉES === */

/* Adaptation par résolution d'écran */
@media screen and (min-width: 3840px), screen and (min-height: 2160px) {
  :root {
    --font-size-base: 14px;
    --spacing-scale: 1;
  }
}

@media screen and (min-width: 2560px) and (max-width: 3839px), 
       screen and (min-height: 1440px) and (max-height: 2159px) {
  :root {
    --font-size-base: 13px;
    --spacing-scale: 0.95;
  }
  
  #controls-all {
    gap: calc(var(--spacing-md) * 0.95);
    padding: calc(var(--spacing-lg) * 0.95);
  }
}

@media screen and (min-width: 1920px) and (max-width: 2559px), 
       screen and (min-height: 1080px) and (max-height: 1439px) {
  :root {
    --font-size-base: 12px;
    --spacing-scale: 0.9;
  }
  
  #controls-all {
    gap: calc(var(--spacing-md) * 0.85);
    padding: calc(var(--spacing-lg) * 0.85);
  }
  
  button {
    min-width: 110px;
  }
}

@media screen and (max-width: 1919px), screen and (max-height: 1079px) {
  :root {
    --font-size-base: 11px;
    --spacing-scale: 0.8;
  }
  
  #controls-all {
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
  }
  
  button {
    min-width: 100px;
  }
}

/* Adaptation par taille de viewport */
@media (max-width: 1024px) {
  #controls-all {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-sm);
  }
  
  #oscilloscope {
    max-width: 95vw;
    max-height: 60vh;
  }
}

@media (max-width: 768px) {
  body {
    padding: var(--spacing-xs);
  }
  
  #container {
    padding: var(--spacing-xs);
    gap: var(--spacing-md);
  }
  
  #controls-all {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
  }
  
  #oscilloscope {
    max-width: 95vw;
    max-height: 50vh;
  }
  
  .control-group {
    min-width: 140px;
    padding: var(--spacing-xs);
  }
  
  .slider {
    min-width: 120px;
  }
  
  button {
    padding: var(--spacing-xs) var(--spacing-sm);
    min-width: 100px;
  }
}

@media (max-width: 480px) {
  #controls-all {
    grid-template-columns: 1fr;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm);
  }
  
  #oscilloscope {
    max-width: 95vw;
    max-height: 45vh;
  }
  
  .control-group.button-group {
    flex-direction: column;
    gap: var(--spacing-xs);
  }
  
  button {
    padding: var(--spacing-xs);
    min-width: 80px;
    font-size: var(--font-size-xs);
  }
}

/* === OPTIMISATIONS POUR LES PERFORMANCES === */

/* Réduction des repaints pour les animations */
.slider,
button,
#oscilloscope {
  contain: layout style;
}

/* Optimisation GPU pour les transformations */
.slider:hover,
.slider.dragging,
button:hover,
#oscilloscope:hover {
  will-change: transform;
}

/* Préchargement des transformations courantes */
@media (hover: hover) {
  .control-group:hover {
    will-change: transform;
  }
}

/* === AMÉLIORATIONS D'ACCESSIBILITÉ === */

/* Mode sombre forcé respecté */
@media (prefers-color-scheme: light) {
  :root {
    --primary-bg: linear-gradient(135deg, #f0f0f0, #e0e0e0);
    --secondary-bg: rgba(200, 200, 200, 0.8);
    --text-color: #333;
    --canvas-border: #666;
  }
}

/* Respect des préférences de mouvement réduit */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  #oscilloscope:hover {
    animation: none;
  }
}

/* Amélioration du focus pour la navigation clavier */
.slider:focus,
button:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* === STYLES POUR LE MODE DEBUG === */
.debug-info {
  position: fixed;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.8);
  color: #00ff00;
  padding: 10px;
  border-radius: 5px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  z-index: 10000;
  display: none;
}

.debug-mode .debug-info {
  display: block;
}
