/* Style global de la page */
body {
  font-family: Arial, sans-serif;
  margin: 40px;
  color: #333;
    background: linear-gradient(180deg, 
    #1C0E30 0%,      /* Violet en haut */
    #110F14 40%,     /* Rose au milieu */
    #161616 100%);  /* Noir en bas */
  min-height: 100vh;
  color: white;
}

/* Titre principal */
h1 {
  text-align: center;
  color: #f0f0f0;
}
h2 {
  text-align: center;
  color: #f0f0f0;
  margin-bottom: 20px;
}

/* Carrousel d'images de films */
.carousel-container {
  text-align: center;
  margin: 20px auto;
  max-width: 300px;
  height: 450px;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.carousel-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.5s ease-in-out;
  border-radius: 12px;
}
p {
  text-align: center;
  color: #555;
  margin-bottom: 30px;
  font-weight: bold;
}
/* Formulaire centré avec marge */
form {
  text-align: center;
  margin-bottom: 30px;
}

/* Alignement des champs sur desktop : ligne unique quand l'espace le permet */
.form-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap; /* si l'écran est trop petit, les éléments se replient */
}

/* Faire en sorte que les inputs/selects .wide-input aient la même largeur que le titre */
.wide-input {
  width: 320px;
  padding: 10px;
  font-size: 1rem;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
  color: #fff;
  box-sizing: border-box; /* garantit la taille même avec padding/border */
}

/* Rendre les options du select lisibles sur fond sombre */
select.wide-input {
  color: #fff; /* selected value color */
  background: rgba(255,255,255,0.03);
}
select.wide-input option {
  color: #ffffff; 
  background: #1c1c1c; 
}
/* Bouton de recherche  */
button {
  padding: 10px 22px;
  font-size: 1rem;
  margin-left: 10px;
  background: linear-gradient(135deg, #ff6b6b 0%, #f06595 50%, #845ef7 100%);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(134,94,247,0.18), inset 0 -2px 0 rgba(0,0,0,0.08);
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 120ms ease;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(134,94,247,0.22), inset 0 -2px 0 rgba(0,0,0,0.06);
  opacity: 0.98;
}

button:active {
  transform: translateY(0);
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

/* Section des résultats*/
#resultSection {
  max-width: 700px;
  margin: 0 auto;
  background-color: #161616;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  box-sizing: border-box;
  min-height: 220px;
}

/* Résultat : carte avec affiche + détails */
#resultSection .result-card {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

/* Poster prend la moitié du conteneur */
#resultSection .poster {
  flex: 0 0 40%;
  max-width: 50%;
}

#resultSection .poster img {
  width: 100%; /* remplit sa colonne */
  height: auto;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  display: block;
}

/* Petit espacement entre l'image et les détails */
.result-card .details { padding-left: 12px; }

.meta-grid .col p strong {
  color: #5E6164; /* couleur demandée pour labels */
  font-weight: 700;
  margin-right: 6px;
}
.meta-value {
  color: #ffffff; /* garder la valeur en blanc */
  margin-left: 6px;
}
/* Titres dans les résultats */
#resultSection h2 {
  margin-top: 0;
  margin-bottom: 10px;
}

#resultSection .plot {
  color: #e6e6e6;
  font-style: italic;
  margin-bottom: 12px;
}

/* Style du titre/année  */
.movie-title { 
  color: #5E6164; 
}
.movie-year {
   color: #5E6164; 
   margin-left: 8px; font-weight: 700; 
   display: inline-flex;
    align-items: center;
     gap:6px; 
    }
.movie-year .year-text {
   color: #5E6164; 
  }
#resultSection .rating 
{
  display: inline-block;
  background: #ffd54f;
  color: #111;
  padding: 6px 10px;
  border-radius: 12px;
  font-weight: 700;
  margin-top: 8px;
}

/* Badge de note IMDb affiché en overlay sur l'affiche */
#resultSection .poster {
  position: relative;
}

#resultSection .rating-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 213, 79, 0.95); /* jaune doré */
  color: #111;
  padding: 4px 8px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.85rem; /* plus petit */
  box-shadow: 0 3px 8px rgba(0,0,0,0.4);
}

@media (max-width: 600px) {
  #resultSection .rating-badge {
    font-size: 0.8rem;
    top: 8px;
    right: 8px;
    padding: 3px 6px;
  }
}

/* Ligne séparatrice sous le résumé */
.divider {
  height: 1px;
  background: rgba(255,255,255,0.12);
  margin: 12px 0;
  border-radius: 1px;
}

/* Grille deux colonnes pour métadonnées */
.meta-grid {
  display: flex;
  gap: 20px;
  margin-top: 8px;
}
.meta-grid .col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Un meta-item: label au-dessus, valeur en dessous */
.meta-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.meta-label {
  color: #5E6164;
  font-weight: 700;
  font-size: 0.95rem;
}
.meta-value {
  color: #ffffff;
  font-size: 0.98rem;
}

@media (max-width: 600px) {
  .meta-grid {
    flex-direction: column;
  }
}

/* Paragraphes des informations complémentaires */
#resultSection p {
  margin: 8px 0;
}
/* Message d'erreur ou info centré */
.message {
  text-align: center;
  font-style: italic;
  color: #ffffff;
}

/* Texte général des résultats en blanc pour meilleure lisibilité sur fond sombre */
#resultSection,
#resultSection h2,
#resultSection p {
  color: #ffffff;
}

/* Responsive : empiler sur petits écrans */
@media (max-width: 600px) {
  #resultSection .result-card {
    flex-direction: column;
    align-items: center;
  }
  /* Sur mobile, l'image et le texte s'empilent ; image à 80% pour garder du padding */
  #resultSection .poster {
    flex: 0 0 auto;
    /* shrink the poster container to the image on mobile so overlay badges sit correctly */
    max-width: none;
    display: inline-block;
    text-align: center;
  }
  #resultSection .poster img {
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    display: block;
  }
  #resultSection .details {
    text-align: left;
    max-width: 100%;
    padding-top: 12px;
  }
}

/* Mobile: stack the form fields and make inputs/buttons full-ish width */
@media (max-width: 600px) {
  form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
  }

  /* Lorsque la largeur est petite, on empile les éléments de .form-row */
  .form-row {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .wide-input {
    width: 92% !important;
    max-width: 420px;
    box-sizing: border-box;
  }

  button {
    width: 92% !important;
    margin-left: 0 !important;
  }

  .result-card .poster img {
    width: 100%;
    max-width: 240px;
    margin: 0 auto;
    display: block;
  }

  #resultSection {
    max-width: none;
    width: calc(100% - 24px);
    margin: 8px 12px;
    padding: 16px;
    border-radius: 8px;
    box-sizing: border-box;
    min-height: 200px;
  }

  body {
    margin: 12px;
  }
}

/* Grille des résultats pour plusieurs éléments */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}

.result-card {
  display: flex;
  gap: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
  border-radius: 10px;
  padding: 12px;
  align-items: flex-start;
  transition: transform 200ms ease, box-shadow 200ms ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

.result-card:focus,
.result-card:hover {
  transform: translateY(-6px) scale(1.01);
  box-shadow: 0 14px 30px rgba(0,0,0,0.5);
}

.result-card .poster
 { flex: 0 0 120px;
   max-width: 120px; 
  }
.result-card .poster img
 { width: 100%; 
  height: auto; 
  border-radius: 6px;
 }
.result-card .details {
   padding: 0; 
  }
.result-card h3 {
   margin: 0 0 6px 0;
    font-size: 1.05rem;
   }
.result-card .meta-line { 
  color: #bdbdbd;
   font-size: 0.95rem;
    margin-bottom: 8px; 
  }
.result-card .plot { margin: 0;
   color: #e6e6e6;
    font-size: 0.95rem; 
  }

/* Spinner de chargement */
.spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  margin: 40px auto;
  border: 5px solid rgba(222, 8, 8, 0.08);
  border-top-color: rgba(255,255,255,0.6);
  animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Accessibilité : aide .visually-hidden pour les labels */
.visually-hidden {
  position: absolute !important;
  height: 1px; width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

.detail-view {
   max-width: 900px;
    margin: 0 auto; 
  }
/* Ajustements pour la vue détail */
.detail-view .back-button {
  display: inline-block;
  margin-bottom: 12px;
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.08);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.result-card.full { display: flex; gap: 20px; align-items: flex-start; }
.result-card.full .poster { flex: 0 0 40%; max-width: 40%; }
.result-card.full .details { flex: 1; }

@media (max-width: 600px) {
  .result-card.full { 
    flex-direction: column;
   }
  .result-card.full .poster {
     max-width: 100%;
      flex: 0 0 auto; 
    }
}

