/* Variables CSS pour une meilleure maintenabilité */
:root {
  --primary-color: #0088cc;
  --primary-hover: #138496;
  --secondary-color: #6c757d;
  --danger-color: #dc3545;
  --success-color: #28a745;
  --background-color: #f8f9fa;
  --text-color: #333;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 2px 4px rgba(0,0,0,0.2);
  --floating-button-size: 50px;
}

/* Reset & Base Styles */

html, body {
  height: 100%;
  margin: 0;
  overflow-x: hidden;
  overscroll-behavior: none;
}

.lang-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
}

.lang-switch {
  font-size: 1.5rem;
  text-decoration: none;
  cursor: pointer;
}

.install-container {
  display: flex;
  justify-content: center;
  margin: 1rem 0;
  width: 100%;
}

.install-pwa {
  max-width: 300px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  }

  .app-header {
    display: flex;
    flex-direction: column;      
    align-items: center;        
    padding: 0.5rem 1rem;
    background: #fff;
    z-index: 1000;
  }
  
  .logo-container {
    text-align: center;
    padding: 1rem 0;
  }
  
  .logo {
    width: 100%;
    max-width: 550px;
    height: auto;
    max-height: 250px;
    display: block;
    margin: 0 auto;
  }
  
  .controls-container {
    display: flex;               
    flex-direction: row;         
    gap: 0.75rem;              
    justify-content: center;     
    margin-bottom: 1rem;
    text-decoration: none;
  }
  
  .help-toggle,
  .pro-mode-toggle,
  .project-manager-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.8rem;
    padding: 0.25rem;
  }
  

body {
  font-family: system-ui, -apple-system, "Helvetica Neue", sans-serif;
  font-size: 0.8rem;
  background-color: #fff;
  color: #333;
  min-height: 100vh;

}


h1 {
  display: none;
}

h3 {
  margin-top: 1.5rem;
  font-size: 1.5rem;
}


.wrapper {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1rem;
}


/*.logo-container {
  text-align: center;
  padding: 1rem 0;
}

.logo {
  width: 60%;
  max-width: 550px;
  height: 100%;
  max-height: 250px;
  display: block;
  margin: 0 auto;
}*/


button {
  font-size: 1rem;
  background: #0088cc;
  text-align: center;
  color: white;
  border: none;
  border-radius: 4px;
  transition: all 0.2s ease;
  padding: 0.5rem;
  cursor: pointer;
}



button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: #ccc;
}


.clip {
  background: white;
  padding: 15px;
  border-radius: 4px;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.clip p {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--text-color);
  text-align: center;
  margin: 0;
}


audio {
  width: 100%;
  margin: 0.5rem 0;
}

/* Structure du clip */
.clip-content {
  display: flex;
  flex-direction: column; /* Par défaut en colonne (mobile) */
  gap: 1rem;
}

.clip-content audio {
  width: 100%;
  margin: 0;
}

.clip-content > .buttons-container {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0;
}

/* Container général des boutons - NE S'APPLIQUE PAS aux boutons dans clip-content */
.buttons-container:not(.clip-content .buttons-container) {
  display: flex;
  width: 100%;
  margin-top: 10px;
  gap: 0.5rem;
}

.navigation-container {
  display: flex;
  width: 100%;
  margin-top: 10px;
  gap: 0.5rem;
}

.action-container {
  display: flex;
  width: 100%;
  margin-top: 10px;
  gap: 0.5rem;
}

.navigation-buttons, 
.action-buttons {
  display: contents; 
}




.recording {
  background-color: var(--danger-color) !important;
  animation: pulse 2s infinite;
}

/* Styles communs pour tous les boutons */
button.move-up, 
button.move-down,
button.download, 
button.delete {
  flex: 1; 
  padding: 0.5rem;
  font-size: 0.9rem;
  height: 50px;
  min-width: 0; 
}

button.split {
  flex: 1;
  padding: 0.5rem;
  font-size: 0.9rem;
  height: 50px;
  min-width: 0;
  background: #2196F3;
  display: none; 
}

.pro-mode-active button.split {
  display: flex !important; 
  align-items: center;
  justify-content: center;
}


button.delete { 
  background: #dc3545; 
}
button.delete:hover { 
  background: #c82333; 
}

button.download { 
  background: #28a745; 
}
button.download:hover { 
  background: #218838; 
}

button.move-up,
  button.move-down {
    background: #6c757d;
  }


.combined-clips {
  text-align: center;
  width: 100%;
  font-weight: bold;
  margin: 1rem 0;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}


.progress-container {
  width: 100%;
  background: #f0f0f0;
  border-radius: 4px;
  margin: 20px 0;
  overflow: hidden;
  height: 15px;
  display: none;
}

.progress-container.active {
  display: block;
}

.progress-bar {
  width: 0;
  height: 100%;
  background: linear-gradient(45deg, var(--primary-color), var(--primary-hover));
  transition: width 0.3s ease-in-out;
}

.combined-clips {
  text-align: center;
  width: 100%;
  font-weight: bold;
  margin: 1rem 0;
}

.visualizer {
  display: block;
  width: 100% !important;
  height: 80px;
  margin-bottom: 1rem;
  background: #f5f5f5;
  border-radius: 4px;
}

.timer-display {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 2rem;
  text-align: center;
  margin: 10px 0;
  font-weight: bold;
  color: #333;
  padding: 0.5rem;
  background: white;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.countdown {
  font-size: 2.5rem;
  color: #dc3545;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.95);
  padding: 20px;
  border-radius: 50%;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  z-index: 1000;
}





.pro-mode {
  display: none;
}

.pro-mode-active .pro-mode {
  display: block;
}


.file-input {
  display: none;
}


aside {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: white;
  overflow-y: auto;
  z-index: 2000;
  padding: 1.5rem;
}

#toggle {
  display: none;
}

#toggle:checked + aside {
  display: block;
}


.close-aside {
  position: fixed;
  top: 20px;
  right: 20px;
  font-size: 1.8rem;
  cursor: pointer;
  z-index: 2001;
}


.main-controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}


.import-button {
  display: none;
  width: 100%;
  max-width: none;
  margin-bottom: 1rem;
  background: #138496;
}

.import-button.visible {
  display: block;
}

.import-options {
  display: none;
  flex-direction: row;
  gap: 10px;
  /*margin-top: 10px;*/
}

.import-option-btn {
  padding: 8px 12px !important;
  cursor: pointer;
  flex: 1;
}

.library-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.library-content {
  background-color: white;
  padding: 20px;
  border-radius: 8px;
  width: 80%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
}

.library-source-info {
  margin: 10px 0;
  padding: 8px 12px;
  background-color: #f5f5f5;
  border-radius: 4px;
  font-weight: bold;
}

.library-filters {
  margin: 15px 0;
  padding: 10px;
  background-color: #f9f9f9;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

#category-filter {
  padding: 6px;
  border-radius: 4px;
  border: 1px solid #ddd;
}

.library-sounds-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 15px 0;
}

.library-sound-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.sound-info {
  display: flex;
  flex-direction: column;
}

.sound-name {
  font-weight: bold;
}

.sound-details {
  display: flex;
  gap: 10px;
  font-size: 0.8em;
  color: #666;
  margin-top: 3px;
}

.sound-category {
  background-color: #e0e0e0;
  padding: 2px 6px;
  border-radius: 3px;
}

.sound-source {
  font-style: italic;
}

.sound-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-sound-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: green;
  cursor: pointer;
  border: 1px solid green;
}

.preview-sound-btn:hover {
  background-color: #ddd;
}

.play-icon, .pause-icon {
  font-size: 14px;
  color: #f8f9fa
}

.select-sound-btn {
  padding: 5px 10px;
  cursor: pointer;
}

.close-library-btn {
  margin-top: 15px;
  padding: 8px 12px;
  cursor: pointer;
}


.download-all-container {
  text-align: center;
  margin-top: 20px;
}

.download-all {
  background: #28a745;
  font-size: 0.9rem;
  width: 150px;
  height: 70px;
  padding: 0;
  margin: 20px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

/* ===========================
   GESTIONNAIRE DE PROJETS
   =========================== */
  
  .project-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
  }
  
  .project-content {
    background-color: white;
    color: #333;
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    position: relative;
  }
  
  .project-content h3 {
    margin: 0 0 20px 0;
    color: #333;
    text-align: center;
    font-size: 1.5em;
  }
  
  .project-actions {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
  
  .action-group {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    background-color: #f9f9f9;
  }
  
  .action-group h4 {
    margin: 0 0 12px 0;
    color: #333;
    font-size: 1.1em;
  }
  
  .save-project-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }
  
  #project-name-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
  }
  
  #save-project-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background-color: #4285f4;
    color: white;
    font-weight: bold;
    transition: background-color 0.2s;
  }
  
  .save-project-form input {
    width: 100%;
    box-sizing: border-box;
  }
  
  .save-project-form button {
    width: 100%;
    box-sizing: border-box;
  }

  #save-project-btn:hover:not(:disabled) {
    background-color: #3367d6;
  }
  
  #save-project-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
  
  .storage-stats {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 10px;
    padding: 8px;
    background-color: #fff;
    border-radius: 4px;
  }
  
  .projects-list-container {
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 6px;
    background-color: white;
  }
  
  .project-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s;
  }
  
  .project-item:hover {
    background-color: #f5f5f5;
  }
  
  .project-item:last-child {
    border-bottom: none;
  }
  
  .project-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
  }
  
  .project-name {
    font-weight: bold;
    color: #333;
    font-size: 1.05em;
  }
  
  .project-date,
  .project-clips-count {
    font-size: 0.85em;
    color: #777;
  }
  
  .project-item .project-actions {
    display: flex;
    gap: 6px;
    flex-direction: row;
  }
  
  .load-project-btn,
  .delete-project-btn,
  .export-single-project-btn,
  .close-project-modal-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
  }
  
  .load-project-btn {
    background-color: #4285f4;
    color: white;
  }
  
  .load-project-btn:hover:not(:disabled) {
    background-color: #3367d6;
  }
  
  .export-single-project-btn {
    background-color: #34a853;
    color: white;
  }
  
  .export-single-project-btn:hover:not(:disabled) {
    background-color: #2d8e47;
  }
  
  .delete-project-btn {
    background-color: #ea4335;
    color: white;
  }
  
  .delete-project-btn:hover:not(:disabled) {
    background-color: #c5221f;
  }
  
  .advanced-actions .advanced-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
  }
  
  .advanced-buttons button {
    flex: 1;
    min-width: 150px;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
  }
  
  .danger-btn {
    background-color: #ea4335;
    color: white;
  }
  
  .danger-btn:hover:not(:disabled) {
    background-color: #c5221f;
  }
  
  #export-all-projects-btn {
    background-color: #34a853;
    color: white;
  }
  
  #export-all-projects-btn:hover:not(:disabled) {
    background-color: #2d8e47;
  }
  
  /* Barre de progression pour l'export */
  #export-progress {
    margin-top: 15px;
    padding: 10px;
    background-color: #fff;
    border-radius: 6px;
    border: 1px solid #ddd;
  }
  
  .progress-bar {
    width: 100%;
    height: 20px;
    background-color: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 8px;
  }
  
  .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #34a853 0%, #2d8e47 100%);
    transition: width 0.3s ease;
    width: 0%;
  }
  
  #export-progress-text {
    margin: 0;
    text-align: center;
    font-size: 0.9em;
    color: #555;
  }
  
  .close-project-modal-btn {
    display: block;
    margin: 20px auto 0;
    background-color: #5f6368;
    color: white;
    padding: 10px 30px;
  }
  
  .close-project-modal-btn:hover {
    background-color: #3c4043;
  }
  
  .success-message {
    color: #0f5132;
    background-color: #d1e7dd;
    padding: 10px;
    border-radius: 6px;
    margin-top: 10px;
    border-left: 4px solid #0f5132;
  }
  
  .error-message {
    color: #842029;
    background-color: #f8d7da;
    padding: 10px;
    border-radius: 6px;
    margin-top: 10px;
    border-left: 4px solid #842029;
  }
  
  .info-message {
    color: #055160;
    background-color: #cff4fc;
    padding: 10px;
    border-radius: 6px;
    margin-top: 10px;
    border-left: 4px solid #055160;
  }
  
  .empty-state,
  .error-state {
    text-align: center;
    padding: 30px;
    color: #999;
  }
  
  /* Scrollbar personnalisée */
  .projects-list-container::-webkit-scrollbar {
    width: 8px;
  }
  
  .projects-list-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
  }
  
  .projects-list-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
  }
  
  .projects-list-container::-webkit-scrollbar-thumb:hover {
    background: #555;
  }

/* MEDIA QUERIES*/

  @media (min-width: 600px) {
    button.move-up, 
    button.move-down,
    button.download, 
    button.delete,
    button.split {
      height: 55px;
      font-size: 1rem;
      padding: 0.6rem;
    }
  }
  
  /* MOBILE - Max 768px */
  @media (max-width: 768px) {
    /* Clip content reste en colonne sur mobile */
    .clip-content {
      flex-direction: column;
      align-items: center; /* Centre le contenu */
    }
    
    .clip-content audio {
      width: 100%;
    }
  
    .clip-content > .buttons-container {
      width: 100%;
      margin-top: 10px;
      justify-content: center; /* Centre les boutons */
    }
    
    .buttons-container {
      flex-wrap: nowrap;
    }
  
    button.move-up, 
    button.move-down,
    button.download, 
    button.delete,
    button.split {
      flex: 0 1 auto;
    }
  
    button.combine {
      width: 40%;
      min-width: auto;
      padding: 0.8rem 2rem;
      margin-bottom: 1rem;
    }
    
    button.normalize {
      width: 40%;
      min-width: auto;
      padding: 0.8rem 2rem;
    }
  
    .import-options {
      display: none;
      flex-direction: column;
      width: 100%;
      gap: 10px;
      margin-top: 10px;
    }
  
    .import-option-btn {
      width: 100%;
      padding: 12px;
    }
  }
  
  /* DESKTOP - Min 769px */
  @media (min-width: 769px) {
    body {
      font-size: 1rem;
    }
    
    .wrapper {
      padding: 0 2rem 4rem;
    }
    
    #buttons {
      flex-direction: row;
      flex-wrap: wrap;
      align-items: stretch;
    }
    
    #buttons button {
      flex: 1;
      min-width: 150px;
      height: 80px;
      padding: 0 24px;
    }
  
    /* *** CONFIGURATION DESKTOP POUR CLIP-CONTENT *** */
    .clip-content {
      flex-direction: row; /* Ligne sur desktop */
      align-items: center;
    }
    
    .clip-content audio {
      flex: 1;
      min-width: 0; /* Permet de rétrécir sans disparaître */
      width: auto;
    }
    
    .clip-content > .buttons-container {
      flex-shrink: 0; /* Les boutons ne rétrécissent pas */
      width: auto; /* Annule le width: 100% */
      margin-top: 0;
    }
    /* *** FIN CONFIGURATION CLIP-CONTENT *** */
    
    .clip {
      flex-direction: column;
    }
    
    /* Container général des boutons (hors clip-content) */
    .buttons-container:not(.clip-content > .buttons-container) {
      display: flex;
      width: 100%;
      margin-top: 10px;
      gap: 0.5rem;
    }
  
    .navigation-buttons,
    .action-buttons {
      display: contents;
    }
  
    button.move-up, 
    button.move-down,
    button.download, 
    button.delete,
    button.split {
      height: 60px;
      font-size: 1rem;
      padding: 0.75rem;
    }
  
    .move-up,
    .move-down {
      max-width: 120px;
      background: #6c757d;
    }
    
    button.combine {
      width: 50%;
      min-width: auto;
      padding: 0.8rem 2rem;
      margin-bottom: 1rem;
      background: #17a2b8;
    }
    
    button.normalize {
      width: 50%;
      min-width: auto;
      padding: 0.8rem 2rem;
      background: #138496;
    }
  }


/* Ajustements pour éviter le chevauchement avec les boutons flottants */
aside {
  padding-bottom: 150px;
}

.sound-clips {
  margin-bottom: 100px;
}