:root {
  --primary-color: #2381f7;
  --primary-hover: #1b5ebc;
  --secondary-color: #5eaaff;
  --background: #f7faff;
  --background-light: #fff;
  --background-gradient: linear-gradient(135deg, #e5effe 0%, #f7faff 100%);
  --shadow-light: 0 2px 12px rgba(35, 129, 247, 0.08);
  --shadow-strong: 0 10px 32px rgba(35, 129, 247, 0.1);
  --border-radius: 26px;
  --border-radius-sm: 16px;
  --font-family: 'Inter', 'Segoe UI', 'Arial', sans-serif;
  --text-main: #162032;
  --text-light: #7e9bc9;
  --border-color: #e3e9f3;
}

body {
  background: var(--background-gradient);
  min-height: 100vh;
  font-family: var(--font-family);
  color: var(--text-main);
  font-size: 18px;
}

/* HEADER */
.header-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 1100px;
  margin: 0 auto 0.2rem;
  padding: 0.1rem 0 0 0;
  background: transparent;
  border-radius: 0 0 var(--border-radius) var(--border-radius);
}

.logo-hero {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0;
  width: 100%;
}

.logo-img-main {
  width: 420px;
  height: 420px;
  object-fit: contain;
  display: block;
  background: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  margin: 0 auto 0 auto;
}

/* TITRES */
.main-title {
  text-align: center;
  font-size: 2.1rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  margin: 0 auto 0.2rem auto;
  line-height: 1.14;
  color: var(--text-main);
  font-family: var(--font-family);
}

.main-title b,
.blue-accent {
  color: var(--primary-color);
}
.slogan {
  display: block;
  margin-top: 0;
  font-size: 1.13rem;
  font-weight: 600;
  color: var(--text-light);
  letter-spacing: 0.01em;
  margin-bottom: 2.3rem; /* <-- Ajout d'un espace sous le bloc headline */
}

/* FORMULAIRE ET RESTE */
.main-container {
  max-width: 1240px;
  margin: 0 auto;
  background: var(--background-light);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-strong);
  padding: 2.5rem 2.5rem 3rem 2.5rem;
}
.search-form {
  margin: 0 auto 2.2rem auto;
  padding: 2rem 1.5rem 1.5rem 1.5rem;
  background: var(--background-light);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-light);
  border: 1.5px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
  max-width: 690px;
}
.form-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-end;
  justify-content: center;
}
.form-btn-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 1.2rem;
}
.input-container {
  display: flex;
  flex-direction: column;
  min-width: 200px;
  flex: 1 1 210px;
  position: relative;
}
label {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.55rem;
  letter-spacing: 0.01em;
}
input[type='text'],
input[type='date'] {
  font-size: 1.01rem;
  padding: 1.1rem 1.1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  background: var(--background-light);
  color: var(--text-main);
  font-family: inherit;
  transition: border-color 0.18s, box-shadow 0.18s;
}
input[type='text']:focus,
input[type='date']:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px #2381f72a;
}
input[type='text']::placeholder {
  color: var(--text-light);
  opacity: 1;
  font-size: 1rem;
}
/* Autocomplete */
#gare-list {
  position: absolute;
  left: 0;
  top: 105%;
  width: 100%;
  background: #fff;
  border: 2px solid var(--primary-color);
  border-top: none;
  z-index: 50;
  max-height: 250px;
  overflow-y: auto;
  border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm);
  box-shadow: var(--shadow-strong);
  animation: slideDown 0.19s ease;
}
@keyframes slideDown {
  0% {
    opacity: 0;
    transform: translateY(-12px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}
#gare-list div {
  padding: 1rem 1.2rem;
  cursor: pointer;
  color: var(--primary-color);
  font-size: 1.03rem;
  border-bottom: 1px solid #f0f2f9;
  background: #fff;
  transition: background 0.17s, color 0.17s, padding 0.14s;
}
#gare-list div:hover {
  background: linear-gradient(90deg, #e5effe 10%, #f1f7ff 80%);
  color: var(--primary-hover);
  padding-left: 1.6rem;
}
/* BUTTON */
#searchBtn {
  display: flex;
  align-items: center;
  gap: 0.5em;
  background: linear-gradient(
    90deg,
    var(--primary-color),
    var(--secondary-color) 80%
  );
  color: #fff;
  border: none;
  padding: 1.08rem 2.7rem;
  font-size: 1.08rem;
  font-weight: 900;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  box-shadow: var(--shadow-light);
  transition: background 0.19s, box-shadow 0.18s, transform 0.13s;
  text-transform: uppercase;
  letter-spacing: 1px;
}
#searchBtn:hover {
  background: linear-gradient(
    90deg,
    var(--secondary-color),
    var(--primary-color)
  );
  transform: translateY(-1px) scale(1.03);
  box-shadow: var(--shadow-strong);
}
#searchBtn:active {
  transform: scale(0.98);
}
/* Résumé recherche */
#search-summary {
  text-align: center;
  margin-top: 18px;
  margin-bottom: 10px;
  font-weight: 700;
  color: var(--primary-color);
  font-size: 1.14rem;
  letter-spacing: 0.01em;
}
/* RESULTATS + MAP */
.container-flex {
  display: flex;
  gap: 2.2rem;
  align-items: flex-start;
  margin-top: 2.7rem;
  flex-wrap: wrap;
}
.results {
  flex: 1 1 390px;
  min-width: 350px;
  max-width: 600px;
  background: var(--background-light);
  border-radius: var(--border-radius);
  padding: 2.2rem;
  box-shadow: var(--shadow-strong);
  border: 1px solid var(--border-color);
  animation: fadeInUp 0.4s;
  min-height: 450px;
  max-height: 600px;
  overflow-y: auto;
}
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.results h3 {
  font-size: 1.23rem;
  font-weight: 900;
  margin-bottom: 1.2rem;
  padding-bottom: 0.7rem;
  border-bottom: 2px solid #eaf3ff;
  color: var(--primary-color);
  letter-spacing: 0.01em;
}
.results ul {
  list-style: none;
}
.results > ul > li {
  margin-bottom: 1.05rem;
  background: #f3f8ff;
  padding: 1.14rem 1rem;
  border-radius: var(--border-radius-sm);
  border-left: 5px solid var(--primary-color);
  box-shadow: var(--shadow-light);
  transition: all 0.19s;
}
.results > ul > li:hover {
  box-shadow: 0 4px 18px #2381f72a;
  background: #e7f1ff;
  transform: translateX(3px) scale(1.013);
}
.results > ul > li > b {
  font-size: 1.08rem;
  color: var(--primary-color);
  margin-bottom: 0.6rem;
  display: block;
}
.results ul ul {
  margin-top: 0.45rem;
}
.results ul ul li {
  background: #fff;
  margin-bottom: 0.55rem;
  padding: 0.92rem 0.95rem 0.86rem 0.95rem;
  border-radius: var(--border-radius-sm);
  border: 1.4px solid #ddeafc;
  font-size: 0.99rem;
  transition: all 0.18s;
}
.results ul ul li:hover {
  border-color: var(--primary-color);
  background: #f3f8ff;
}
.results ul ul li b {
  color: var(--primary-color);
}
.results hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, #eaf3ff, transparent);
  margin: 1rem 0 1.1rem 0;
}
.results:empty:before {
  content: 'Sélectionnez une gare et une date pour commencer votre recherche';
  color: var(--text-light);
  font-style: italic;
  display: block;
  text-align: center;
  padding: 3rem 1rem;
}
#map {
  flex: 1 1 400px;
  min-width: 340px;
  height: 600px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-strong);
  border: 1.5px solid var(--border-color);
  overflow: hidden;
  animation: fadeInUp 0.6s 0.12s both;
}
/* FOOTER */
footer {
  max-width: 1240px;
  margin: 2.7rem auto 0 auto;
  padding: 2.1rem 1rem;
  border-radius: var(--border-radius);
  background: #fff;
  box-shadow: var(--shadow-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.07rem;
  color: var(--text-light);
  gap: 1rem;
}
.footer-link {
  color: var(--primary-color);
  margin-left: 2rem;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.13s;
}
.footer-link:hover {
  color: var(--secondary-color);
  text-decoration: underline;
}
/* RESPONSIVE */
@media (max-width: 1050px) {
  .main-container,
  footer,
  .header-main {
    max-width: 98vw;
  }
  .container-flex {
    flex-direction: column;
    gap: 2rem;
  }
  #map,
  .results {
    min-width: 0;
    width: 100%;
    max-width: none;
  }
  #map,
  .results {
    max-height: 420px;
  }
  #map {
    height: 420px;
  }
}
@media (max-width: 600px) {
  .header-main {
    max-width: 100vw;
    padding: 0.02rem 0.3rem 0rem 0.3rem;
  }
  .main-container,
  footer,
  .header-main {
    padding: 1rem;
  }
  .main-container {
    padding-bottom: 1.3rem;
  }
  .results,
  .search-form {
    padding: 1rem;
  }
  h1.main-title {
    font-size: 1.18rem;
  }
  #map,
  .results {
    max-height: 320px;
  }
  #map {
    height: 320px;
  }
  .logo-img-main {
    width: 180px;
    height: 180px;
  }
}
/* Scrollbar for autocomplete */
#gare-list::-webkit-scrollbar {
  width: 7px;
}
#gare-list::-webkit-scrollbar-track {
  background: #e3f0ff;
}
#gare-list::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
}

/* --- Correction du footer mobile --- */
footer {
  max-width: 1240px;
  margin: 2.7rem auto 0 auto;
  padding: 2.1rem 1rem;
  border-radius: var(--border-radius);
  background: #fff;
  box-shadow: var(--shadow-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.07rem;
  color: var(--text-light);
  gap: 1rem;
  flex-wrap: wrap;
  box-sizing: border-box;
}

.footer-link {
  color: var(--primary-color);
  margin-left: 2rem;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.13s;
  word-break: break-word;
}

.footer-link:first-child {
  margin-left: 0;
}

/* RESPONSIVE FOOTER propre et liens bien alignés */
@media (max-width: 600px) {
  footer {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    padding: 1.2rem 1.2rem 1.4rem 1.2rem;
    gap: 0.5rem;
  }
  .footer-link {
    margin-left: 0;
    margin-right: 1.2rem;
    font-size: 1.08rem;
    display: inline-block;
    margin-top: 0.5rem;
  }
  footer > span:last-child {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    margin-top: 0.5rem;
  }
}

/* --- Correction du débordement de la liste de résultats --- */
.container-flex,
.results,
#map {
  box-sizing: border-box;
}

@media (max-width: 1050px) {
  .container-flex {
    flex-direction: column;
    gap: 2rem;
    width: 100%;
    box-sizing: border-box;
    margin: 0 auto;
    padding: 0;
  }
  .results,
  #map {
    min-width: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    border-radius: 18px !important;
    box-sizing: border-box;
  }
}

/* Pour s'assurer qu'aucune div ne dépasse */
.results {
  overflow-x: auto;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

@media (max-width: 600px) {
  .results,
  #map {
    max-height: 320px;
    border-radius: 15px !important;
    padding-left: 0.3rem;
    padding-right: 0.3rem;
  }
}

@media (max-width: 600px) {
  .results > ul > li {
    margin-left: -0.8rem !important; /* Colle vraiment à gauche */
    padding-left: 0 !important;
    width: calc(100% + 0.8rem) !important;
    box-sizing: border-box;
    /* Si tu veux encore plus collé, augmente la valeur négative */
  }
}
