:root {
  --primary-color: #bb86fc;
  --secondary-color: #9f75d6;
  --accent-color: #bb86fc;
  --text-color: #f0f0f0;
  --light-bg: #1c1c1c;
  --dark-bg: #121212;
  --border-color: #2a2a2a;
  --border-accent: #333;
  --text-muted: #b3b3b3;
  --border-radius: 8px;
  --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  --transition-speed: 0.3s;
}

/* Réinitialisation */
html, body {
  margin: 0;
  margin-top: 20px; /* Espace tampon pour éviter le chevauchement */
  padding: 0;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  font-family: Arial, sans-serif;
  box-sizing: border-box;
}

/* Arrière-plan */
body {
  background: linear-gradient(135deg, #232526, #aab0b6); 
  /* On peut aussi tester: background: #1f1f1f; */
  background-attachment: fixed;
  background-size: cover;
  color: #f0f0f0; /* le texte par défaut sera blanc */
}

/* Menu principal (alignement horizontal avec espace égal) */
.menu-container {
  display: flex;
  flex-direction: row;       /* Alignement côte à côte */
  justify-content: center;   /* Centrage horizontal */
  align-items: center;
  gap: 20px;                 /* Espacement uniforme entre les éléments */
  margin: 20px auto;
}

/* 2 colonnes */
.content {
  display: flex;
  width: 100%;
  height: calc(85%);
  box-sizing: border-box;
  margin-bottom: 50px; /* Espace tampon pour éviter le chevauchement */
}

.preview-column {
  width: calc(100% - 18rem);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

#rectangle-container {
  position: relative;
  max-width: 100%;
  max-height: 100%;
}

.params-column {
  width: 18rem;
  height: 100%;
  background-color: rgba(20, 20, 20, 0.6);
  color: #fff;
  box-sizing: border-box;
  padding: 20px;
  overflow-y: auto;
  border-radius: 15px;
  box-shadow: 0 10px 15px rgba(0,0,0,0.3);
}

/* == BOUTON DE TÉLÉCHARGEMENT (NOUVELLE VERSION) == */
.button-container {
  position: relative;
  display: inline-block; /* Pour que l'input apparaisse juste en dessous */
}

/* Styles du bouton Download */
#downloadButton {
  padding: 10px 20px;
  font-size: 16px;
  cursor: pointer;
  border: none;
  border-radius: 5px;
  background-color: #6a11cb;
  color: #fff;
  transition: background-color 0.3s ease;
}
#downloadButton:hover {
  background-color: #2575fc;
}

/* Conteneur de l'input qui s'affiche sous le bouton */
.input-container {
  position: absolute;
  top: calc(100% + 5px); 
  left: 50%;
  transform: translateX(-50%);
  background-color: #fff;
  border-radius: 5px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease, padding 0.3s ease;
  width: auto;
  min-width: 180px;
  padding: 0;
  display: flex;
  justify-content: center;
}

/* Au survol, on déploie l'input */
.button-container:hover .input-container {
  max-height: 50px;
  padding: 5px;
}

/* Zone cliquable pour saisir */
.editable-container {
  display: inline-flex;
  border: 1px solid #ccc;
  border-radius: 5px;
  background: #fff;
  font-size: 16px;
  align-items: center;
  padding: 3px 8px;
  width: auto;
  min-width: 150px;
  cursor: text;
  box-sizing: border-box;
}

/* Champ de texte réel (invisible tant qu'on n'a pas cliqué/survolé) */
.input-field {
  border: none;
  outline: none;
  text-align: right;
  font-size: 16px;
  background: transparent;
  padding: 0;
  width: auto;
  min-width: 30px;
  max-width: 100px;
  display: none;
}

/* Les différents libellés autour de l'input */
.suffix, .ratio-result, #ratio-value {
  color: black;
  font-size: 16px;
  padding: 0 5px;
  display: none;
}

.placeholder-text {
  font-size: 16px;
  color: grey;
}

/* == DROPDOWN PERSONNALISÉ (pour le format principal et le crop) == */
.ratio-dropdown {
  position: relative;
  width: 220px;
}

.ratio-selected {
  background-color: #fff;
  color: #000;
  padding: 8px 12px;
  border-radius: 5px;
  border: 1px solid #ccc;
  transition: all 0.3s ease;
  cursor: pointer;
}

.ratio-selected:hover {
  border-color: #6a11cb;
  box-shadow: 0 0 5px rgba(106,17,203,0.5);
}

.ratio-list {
  position: absolute;
  left: 0;
  top: 42px;
  width: 100%;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
  display: none;
  z-index: 999;
}

.ratio-list li {
  padding: 8px 12px;
  color: #000;
  border-bottom: 1px solid #ccc;
  cursor: pointer;
}

.ratio-list li:last-child {
  border-bottom: none;
}

.ratio-list li:hover {
  background-color: #ededed;
}

.custom-li {
  display: flex;
  align-items: center;
  gap: 5px;
}

.custom-li input {
  width: 40px;
  text-align: center;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 0.9rem;
  box-sizing: border-box;
}

.x-sep {
  user-select: none;
  pointer-events: none;
  color: #000;
}

.ratio-dropdown.open .ratio-list {
  display: block;
}

/* Bouton d'orientation */
.toggle-button {
  color: #090909;
  padding: 0.1em 0.2em;
  font-size: 22px;
  border-radius: 0.5em;
  background: #ffffff;
  cursor: pointer;
  border: 1px solid #e8e8e8;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

.toggle-button:hover {
  transform: scale(1.05);
}

.toggle-button:active {
  box-shadow: inset 4px 4px 12px #c5c5c5, inset -4px -4px 12px #ffffff;
}

.toggle-button-text {
  display: inline-block;
  transform: scale(0.9);
  transform-origin: center;
}

/* Bordure du rectangle principal */
.border-option {
  margin-top: 20px;
  font-size: 1rem;
}

.border-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

input[type="checkbox"] {
  cursor: pointer;
}

input[type="color"] {
  width: 30px;
  height: 30px;
  border: none;
  cursor: pointer;
  padding: 0;
  background: none;
  box-shadow: 0 0 5px rgba(0,0,0,0.3);
  border-radius: 5px;
}

#borderWidth {
  width: 60px;
  padding: 5px;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 5px;
  background-color: #fff;
}

/* Rectangle principal */
.rectangle {
  background-color: transparent;
  box-shadow: 0 10px 15px rgba(0, 0, 0, 0.4);
  box-sizing: content-box;
  position: relative;
  z-index: 1;
  transition: all 0.3s ease;
}

/* Section Crop */
.crop-container {
  margin-top: 20px;
}

.add-crop-button {
  background-color: #fff;
  color: #000;
  border: none;
  border-radius: 5px;
  padding: 8px 12px;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  transition: background-color 0.3s ease, transform 0.2s ease;
}

.add-crop-button:hover {
  background-color: #6a11cb;
  color: #fff;
  transform: scale(1.05);
}

#cropSectionList {
  margin-top: 10px;
}

.single-crop-settings {
  background-color: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 5px;
  padding: 10px;
  margin-bottom: 10px;
}

.single-crop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

.remove-crop-button {
  background-color: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.9rem;
}

.remove-crop-button:hover {
  background-color: #c0392b;
}

.sub-rectangle {
  position: absolute;
  border: 2px solid #000;
  box-sizing: border-box;
  background: none;
  z-index: 2;
  transition: all 0.3s ease;
}

.border-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

/* SortableJS */
.sortable-chosen {
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.sortable-ghost {
  opacity: 0.4;
}

/* =============================
   Responsive (écran < 800px)
   ============================= */
@media screen and (max-width: 800px) {
  .content {
    min-height: 100vh; /* Permet à la section de s'étendre si nécessaire */
    flex-direction: column;
    align-items: center;
    margin-bottom: 100px; /* Espace tampon pour éviter le chevauchement */
  }
  .preview-column {
    width: 100%;
    max-width: 600px;
    margin-bottom: 20px;
  }
  .params-column {
    width: 100%;
    height: auto;
    margin: 0 auto;
    box-sizing: border-box;
    padding: 0 10px;
    overflow-y: visible;
  }
  #cropSectionList {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 0;
    margin: 10px 0;
    border-top: 1px solid #ccc;
  }
  .single-crop-settings {
    flex-shrink: 0;
    min-width: 240px;
    background-color: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 2px;
    margin-bottom: 10px;
    max-height: none;
    overflow-y: visible;
  }
  .crop-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
}
.advanced-button {
  background: none;
  border: none;
  cursor: pointer;
  margin-left: 10px;
}

.advanced-button i {
  font-size: 16px;
  color: #ffffff;
}

.advanced-button:hover i {
  color: #000;
}

.size-slider-container {
  margin-top: 10px;
}

.size-slider-container label {
  margin-right: 10px;
}

.size-slider-container input[type="range"] {
  width: 200px;
  margin-left: 10px;
}
