/* Variables */
:root {
  --bg-color: rgb(18, 18, 18);
  --text-color: rgb(205, 210, 214);
  --element-bg-color: rgb(63, 63, 63);
  --element-bg-color-hover: rgb(52, 73, 94);
  --element-text-color: rgb(205, 210, 214);
  --primary-button-bg-color: rgb(52, 73, 94);
  --primary-button-text-color: rgb(205, 210, 214);
  --secondary-button-bg-color: rgb(205, 210, 214);
  --secondary-button-text-color: rgb(18, 18, 18);
  --transparent-button-bg-color: rgba(18, 18, 18, 0.4);
}

body {
  font-family: Arial, sans-serif;
  background-color: var(--bg-color);
  /*   margin: 1.25rem; */
  height: 100vh;
  height: 100dvh; /* Utilise la hauteur dynamique du viewport pour iOS */
  margin: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.sort-buttons-container {
  display: flex;
  gap: 10px;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.sort-btn {
  color: var(--primary-button-text-color);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  opacity: 0.6;
  transition: all 0.2s ease;
}

.sort-btn.active {
  /* text-decoration: underline; */
  opacity: 1;
}

.sort-btn:hover {
  opacity: 1;
  transform: translateY(-1px);
}

.sort-btn:active {
  transform: translateY(0);
}

.gif-container {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
  width: 100%;
}

.edit-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.edit-btn:hover {
  opacity: 1;
}

.edit-btn .material-symbols-outlined {
  font-size: 1.2rem;
}

#drive {
  height: calc(100dvh - 150px); /* Utilise la hauteur dynamique du viewport */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling sur iOS */
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

#login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-color);
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1em;
}

input,
button {
  padding: 10px;
  font-size: 1rem;
}

#error-msg {
  color: red;
}

.modal-buttons {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 10px;
  z-index: 10000;
  align-items: flex-start;
}

.switch-container {
  margin-bottom: 1rem;
}

ul {
  list-style-type: none;
  padding-left: 1.25rem;
}

li {
  margin: 0.25rem 0;
}

button.folder {
  margin: 0.25rem;
  padding: 0.4rem 0.8rem;
  font-weight: 500;
  font-size: 1rem;
  cursor: pointer;
  background-color: var(--element-bg-color);
  border-radius: 16px;
  border: none;
  color: var(--element-text-color);
  transition: all 0.2s ease;
}

button.folder:hover {
  background-color: var(--element-bg-color-hover);
  transform: translateY(-1px);
}

button.folder:active {
  transform: translateY(0);
}

button.gif {
  margin: 0.25rem;
  padding: 0.4rem 0.8rem;
  font-weight: 500;
  font-size: 1rem;
  cursor: pointer;
  background-color: var(--primary-button-bg-color);
  border-radius: 16px;
  border: none;
  color: var(--primary-button-text-color);
  opacity: 0.8;
  transition: all 0.2s ease;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  padding-right: 10px;
  box-sizing: border-box;
  max-width: 99%; /* ou la largeur maximale souhaitée */
}

button.gif:hover {
  transform: translateY(-1px);
  opacity: 1;
}

#modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  justify-content: center;
  align-items: center;
  flex-direction: column;
  z-index: 9999;
}

#modal img,
#modal video {
  /* max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto; */
  height: 100%;
  width: auto;
  object-fit: contain;
  object-position: center;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: black;
}

#modal img.fullscreen,
#modal video.fullscreen {
  width: 100%;
  height: auto;
  /*   height: 100%;
  object-fit: contain; */
  object-position: center;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: black;
}

#modal .nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10001;
}

#prev-btn {
  left: 0.75rem;
}
#next-btn {
  right: 0.75rem;
}

/* Style pour les boutons de navigation */
#prev-btn,
#next-btn {
  width: 3.5rem;
  height: 3.5rem;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Style pour les icônes des boutons de navigation */
#prev-btn .material-symbols-outlined,
#next-btn .material-symbols-outlined {
  font-size: 2.5rem; /* Taille plus grande pour les flèches */
  font-variation-settings: "wght" 700; /* Plus épais */
  line-height: 1; /* Évite tout espace supplémentaire */
}

/* Fil d'ariane */
#breadcrumb {
  margin: 0.75rem 0 1.25rem 0;
  margin-left: 0.75rem;
  font-size: 1rem;
  user-select: none;
}

#breadcrumb span {
  cursor: pointer;
  color: var(--primary-button-bg-color);
}

#breadcrumb span + span::before {
  content: " / ";
  color: var(--primary-button-bg-color);
}

#breadcrumb span:hover {
  text-decoration: underline;
}

/* Boutons rond semi transparent pour croix et switch version */
.close-btn,
.switch-version-btn,
.share-btn,
.favorite-btn,
.nav-btn,
.toggle-size-btn,
.edit-btn-modal {
  background: var(--transparent-button-bg-color);
  position: static; /* Supprime le positionnement absolu */
  font-size: 1.5rem;
  border-radius: 50%;
  border: none;
  color: var(--text-color);
  width: 2.5rem;
  height: 2.5rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s, transform 0.2s;
  user-select: none;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  line-height: 1;
  flex-shrink: 0;
}

.close-btn:hover,
.switch-version-btn:hover,
.share-btn:hover,
.favorite-btn:hover,
.nav-btn:hover,
.toggle-size-btn:hover,
.edit-btn-modal:hover {
  opacity: 1;
  transform: scale(1.05);
}

.switch-version-btn {
  font-size: 1rem;
  font-weight: bold;
  font-family: sans-serif;
  height: 2.5rem;
  min-width: 3.75rem;
  border-radius: 1.25rem; /* coins arrondis mais pas un rond complet */
}

.favorite-outlined .material-symbols-outlined {
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
}

.favorite-filled .material-symbols-outlined {
  font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24 !important;
}

.share-btn {
  font-size: 1.25rem;
}

#toaster {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 10002;
}

.toast {
  background: rgba(var(--transparent-button-bg-color));
  color: var(--text-color);
  padding: 0.5rem 1rem;
  margin-top: 0.5rem;
  border-radius: 0.5rem;
  font-size: 1rem;
  opacity: 0;
  transform: translateY(1.25rem);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Styles pour la modale */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  color: var(--text-color);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 1rem;
  transition: all 0.3s ease;
}

/* Style par défaut de l'image dans la modale */
.modal img {
  max-width: 90%;
  max-height: 80vh;
  width: auto;
  height: auto;
  object-fit: contain;
  margin: 0 auto;
  display: block;
  transition: all 0.3s ease;
}

.modal.hidden {
  display: none;
}

#addGifForm,
#modifyGifForm {
  background: var(--element-bg-color);
  color: var(--element-text-color);
  padding: 20px;
  border-radius: 8px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: Arial, sans-serif;
}

#modifyGifModal {
  z-index: 10000 !important;
}

#addGifForm label,
#modifyGifForm label {
  font-weight: 600;
  font-size: 14px;
}

#addGifForm input,
#addGifForm select,
#modifyGifForm input,
#modifyGifForm select {
  padding: 8px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.gif-name-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.gif-name-input-wrapper input {
  flex: 1;
  padding-right: 70px;
}

.gif-name-history-btn,
.gif-name-clear-btn {
  position: absolute;
  padding: 0 !important;
  background: none;
  border: none;
  color: var(--element-text-color);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  transition: opacity 0.2s;
  font-size: 1.2rem;
}

.gif-name-history-btn:hover,
.gif-name-clear-btn:hover {
  opacity: 1;
}

.gif-name-history-btn {
  right: 32px;
}

.gif-name-clear-btn {
  right: 8px;
}

.form-buttons {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

#addGifForm button,
#modifyGifForm button {
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}

#addGifForm button[type="submit"],
#modifyGifForm button[type="submit"] {
  background-color: var(--primary-button-bg-color);
  color: var(--primary-button-text-color);
  opacity: 0.9;
}

#addGifForm button[type="submit"]:hover,
#modifyGifForm button[type="submit"]:hover {
  opacity: 1;
  transform: scale(1.05);
}

#addGifForm button[type="submit"]:active,
#modifyGifForm button[type="submit"]:active {
  transform: scale(1);
}

#addGifForm button#cancelAddGif,
#modifyGifForm button#cancelModifyGif {
  background-color: var(--secondary-button-bg-color);
  color: var(--secondary-button-text-color);
  opacity: 0.9;
}

#addGifForm button#cancelAddGif:hover,
#modifyGifForm button#cancelModifyGif:hover {
  opacity: 1;
  transform: scale(1.05);
}

#sticky-buttons {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 1000;
  gap: 10px;
}

.sticky-delete-btn {
  /* padding: 12px 22px; */
  border-radius: 50% !important;
  background-color: rgba(255, 0, 0, 0.4);
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 !important;
  color: white;
  font-weight: 700;
  border: none;
  cursor: pointer;
  z-index: 900;
  font-family: Arial, sans-serif;
  transition: opacity 0.3s ease, transform 0.3s ease;
  opacity: 0.8;
}

.sticky-delete-btn:hover {
  opacity: 1;
  transform: scale(1.05);
}

/* Sticky bouton Add Gif */
.sticky-add-btn,
.sticky-filter-btn,
.sticky-favorite-btn,
.sticky-fullscreen-btn,
.sticky-logout-btn,
.sticky-shuffle-btn {
  padding: 12px 22px;
  border-radius: 10px;
  background-color: var(--primary-button-bg-color);
  color: var(--primary-button-text-color);
  font-weight: 700;
  border: none;
  cursor: pointer;
  z-index: 900;
  font-family: Arial, sans-serif;
  transition: opacity 0.3s ease, transform 0.3s ease;
  opacity: 0.8;
}

.sticky-add-btn:hover,
.sticky-filter-btn:hover,
.sticky-fullscreen-btn:hover,
.sticky-logout-btn:hover,
.sticky-shuffle-btn:hover,
.sticky-favorite-btn:hover {
  opacity: 1;
  transform: scale(1.05);
}

/* Sticky bouton Shuffle */
.sticky-shuffle-btn,
.sticky-favorite-btn,
.sticky-fullscreen-btn,
.sticky-filter-btn {
  background-color: var(--secondary-button-bg-color);
  color: var(--secondary-button-text-color);
  transition: all 0.3s ease;
}

.sticky-shuffle-btn.active {
  background-color: var(--primary-button-bg-color);
  color: white;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

/* Sticky bouton Logout */
.sticky-logout-btn {
  background-color: rgb(255, 0, 0);
  opacity: 0.4;
}

.sticky-logout-btn:hover {
  opacity: 0.8;
  transform: scale(1);
}

/* Styles pour les écrans mobiles */
@media (max-width: 1000px) {
  body {
    margin: 0.5rem;
    font-size: 1.1rem;
  }

  button.folder,
  button.gif {
    font-size: 1.2rem;
    padding: 4px 12px;
    margin-bottom: 6px;
  }

  button.gif {
    margin-bottom: 16px;
  }

  #modal .nav-btn {
    font-size: 1.25rem;
    width: 40px;
    height: 40px;
    position: fixed;
    top: 10px;
    transform: translateY(0%);
    background-color: rgba(0, 0, 0, 0);
  }

  #prev-btn {
    left: 10px;
  }
  #next-btn {
    left: 66px;
  }

  #close-modal {
    font-size: 1.5rem;
    padding: 15px 25px;
  }

  .modal-buttons {
    top: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0);
  }

  .sticky-fullscreen-btn {
    display: none;
  }

  .sticky-add-btn,
  .sticky-filter-btn,
  .sticky-fullscreen-btn,
  .sticky-favorite-btn,
  .sticky-logout-btn,
  .sticky-shuffle-btn {
    padding: 6px 12px;
  }

  .close-btn,
  .switch-version-btn,
  .share-btn,
  .favorite-btn,
  .nav-btn,
  .toggle-size-btn,
  .edit-btn-modal {
    background: rgba(0, 0, 0, 0);
    /* color: white; */
  }
}
