/* --- RESET GLOBAL --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  font-family: system-ui, sans-serif;
  background: #f5f5f5;
  min-width: 350px;
}

header {
  width: 100%;
  height: 50px;
  display: grid;
  grid-template-columns: 1fr auto 1fr; 
  align-items: center; /* Centre verticalement */
  position: fixed;
  top: 0;
  border-bottom: 1px solid black;
  background-color: white;
  z-index: 10;
}

.gauche {
  display: flex;
  align-items: center;
  gap: 10px; /* Espace entre l'image et le titre */
}

.menu {
  grid-column: 2; /* Force le menu à rester exactement au centre */
}

header img{
  width: 48px;
  height: 48px;
}

.menu-app{
  display: flex;
  align-items: center;
}

.menu-app a{
  text-decoration: none;
  font-size: x-large;
  margin: 0 5px 0 5px;
}

footer{
  width: 100%;
  height: 33px;
  position: fixed;
  bottom: 0;
  z-index: 10;
  border-top: 1px solid black;
  background-color: white;
  display: flex;
  justify-content: space-between;
  p{
    margin: 5px;
  }
  a{
    text-decoration: none;
  }
}

.menu-app{
  display: flex;
  align-items: center;
}

.menu-app a{
  text-decoration: none;
  font-size: x-large;
}

/* --- CONTAINER PRINCIPAL --- */
.container {
  position: relative;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 50px - 32px);
  margin-top: 48px;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  transition: width 0.3s ease;
}

/* Responsive : 100% mobile, 80% desktop */
@media (max-width: 750px) {
  .container {
    flex-direction: column;
  }
}

@media (min-width: 769px) {
  body{
    display: flex;
    justify-content: space-evenly;
  }
  .container {
    flex-direction: row;
  }
}

@media (max-width: 769px) {
  header{
    display: flex;
    justify-content: space-between;
    font-size: x-small;
  }
  .droite{
    display: none;
  }
}

/* --- BOUTONS GÉNÉRIQUES --- */
button, .modal-menu a {
  text-decoration: none;
  background: #0078ff;
  color: white;
  font-size: 16px;
  padding: 6px 8px;
  margin: 5px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

button:hover,.modal-menu a:hover {
  background: #005fcc;
}

li button,
p button {
  margin-left: 5px;
  padding: 4px 6px;
}

/* --- ÉDITEUR / METADATA --- */
#story_part{
    height: 30px;
    margin: 15px;
    padding: 5px;
}

#metadata {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fafafa;
  border-right: 1px solid #ddd;
  overflow-y: auto;
  min-width: 325px;
}

#metadataOption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid #ddd;
}

#metadataOption button {
  flex: 0 0 auto;
}

/* Liste des éléments (bulles, choix, etc.) */
#list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

#list div {
  padding: 8px;
  margin-bottom: 6px;
  background: white;
  border: 1px solid #ccc;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

#list div:hover {
  background: #e6f0ff;
}

#list p a {
  display: inline-block;
  /* ou block, selon le contexte */
  width: 90%;
  /* largeur fixe nécessaire */
  white-space: nowrap;
  /* empêche le retour à la ligne */
  overflow: hidden;
  /* cache le texte qui dépasse */
  text-overflow: ellipsis;
  /* ajoute "..." à la fin */
}

/* --- ZONE D'ÉDITION --- */
#editor {
  flex: 2;
  display: flex;
  flex-direction: column;
  padding: 15px;
  background: #fff;
  overflow: auto;
}

/* Formulaire */
#editor label {
  font-weight: 500;
  color: #333;
  margin-top: 8px;
  display: block;
}

#editor input,
#editor select {
  width: 100%;
  padding: 8px;
  margin-top: 4px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 15px;
}

#form {
  flex: 1;
  margin-top: 10px;
  background: #fafafa;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 10px;
}

/* --- BOUTON "ENREGISTRER" --- */
#save,
#saveAux {
  position: absolute;
  bottom: 15px;
  right: 15px;
  font-weight: bold;
}

#save:hover {
  background: #00964a;
}

/* --- SCROLL DOUX & ADAPTÉ --- */
#list::-webkit-scrollbar,
#form::-webkit-scrollbar {
  width: 8px;
}

#list::-webkit-scrollbar-thumb,
#form::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

#content{
  width: 100%;
}

/* --- Liste des éléments (bulles, choix, etc.) --- */
#list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 15px;
}

#list p{
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  height: 40px;
  padding: 5px;
  border-top: 1px solid black;
  white-space: nowrap; /* Empêche le retour à la ligne */
  overflow: hidden; /* Masque le texte qui dépasse */
  text-overflow: ellipsis; /* Ajoute "..." si le texte est trop long */
}

#list p a{
  width: 100%;
}

#list p button{
  height: 100%;
}

/* Chaque item de la liste */
#list div {
  padding: 10px 12px;
  margin-bottom: 8px;
  background: white;
  border: 1px solid black;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  list-style-position: inside;
}

/* Effet survol */
#list div:hover {
  background: #e6f0ff;
  transform: translateX(2px);
}

/* Si tu utilises une liste numérotée (<ol>) à l’intérieur */
ol {
  padding-left: 20px;
  /* assure la visibilité des puces/numéros */
  margin: 0;
}

/* --- Ajustement du bandeau des métadonnées --- */
#metadataOption {
  display: flex;
  align-items: center;
  gap: 10px;
  /* petit espace entre les deux boutons */
  padding: 10px;
  border-bottom: 1px solid #ddd;
}

#metadataOption #setTitle {
  flex: 1;
  /* occupe tout l’espace disponible */
  text-align: left;
  /* aligner le texte à gauche (ou center selon ton goût) */
  font-weight: 500;
}

#metadataOption #newBubble {
  flex-shrink: 0;
  /* reste compact à droite */
  width: auto;
  padding: 6px 10px;
  font-size: 20px;
  font-weight: bold;
}

/* --- Mode mobile (<=768px) --- */
@media (max-width: 900px) {

  .container {
    flex-direction: column;
  }

  #metadata {
    flex: none;
    height: 40%;
    overflow-y: auto;
    border-right: none;
    border-bottom: 1px solid #ddd;
  }

  #editor {
    flex: none;
    height: 60%;
    overflow-y: auto;
  }

  /* Bouton Enregistrer toujours visible */
  #save {
    position: fixed;
    bottom: 15px;
    right: 15px;
    z-index: 20;
  }
}

/* Écran de flash invisible par défaut */
#flashOverlay {
  position: fixed;
  inset: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
}

/* Animation du flash */
@keyframes screenFlash {
  0% {
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  /* flash intense */
  100% {
    opacity: 0;
  }
}

#flashOverlay.active {
  animation: screenFlash 0.4s ease;
}

.content {
  display: flex;
  align-items: center;
}

.content img {
  max-height: 200px;
}

#openModalBtn {
  display: inline-block;
  width: 80%;
  height: 30px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Overlay --- */
.modal-overlay {
  position: fixed;
  z-index: 30;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  justify-content: center;
  align-items: center;
}

/* --- Fenêtre modale --- */
.modal {
  background: white;
  border-radius: 12px;
  width: 400px;
  max-width: 90%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid #ddd;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* --- Menu --- */
.modal-menu {
  display: flex;
  justify-content: space-around;
  padding: 12px;
  border-bottom: 1px solid #eee;
}

.modal-publish{
  text-align: center;
  padding: 12px;
  border-bottom: 1px solid #eee;
}

.modal-menu a{
  text-decoration: none;
  background: #0078ff;
  color: white;
  font-size: 16px;
  padding: 6px 8px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

/* --- Formulaire couverture --- */
.modal-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-content input[type="text"],
.modal-content textarea {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #ccc;
  font-size: 14px;
}

.modal-content textarea {
  resize: vertical;
  height: 80px;
}

.thumbnail-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #f0f0f0;
  border-radius: 8px;
  object-fit: cover;
}

input[type="file"] {
  display: none;
}

.clear-reset{
  display: flex;
}

.clear-reset button{
  background-color: red;
  width: 100%;
}

.clear-reset button:hover{
  background-color: darkred;
}

/* --- Re-order Modal --- */
.order-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.order-modal.active {
  display: flex;
}

/* Style du contenu */
.order-modal-content {
  background: white;
  padding: 20px;
  border-radius: 8px;
  width: 80%;
  max-width: 500px;
}

/* Style modal tutorial */
.back-modal{
  position: absolute;
  top: 0;
  left:0;
  height: 100vh;
  width: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal.tutorial{
  display: flex;
  flex-direction: column;
  padding: 10px;
}

.modal-options{
  display: flex;
  width: 100%;
  justify-content: space-around;
}