/**
 * Search Modal UI Styles - Figma Design Implementation
 * Agence Minimal - 2025
 *
 * Full-screen overlay search with centered modal
 */

/* ==========================================
   Accessibility
   ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap');

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ==========================================
   Main container
   ========================================== */
.eventSearch {
  display: flex;
  /* position: relative; */
  align-items: center;
  justify-content: flex-start;
  margin-right: 24px;
}

/* ==========================================
   Search icon (trigger)
   ========================================== */
.searchIcon {
  cursor: pointer;
  color: #333;
  padding: 8px;
  border-radius: 4px;
  transition: background-color 0.3s ease;
  position: relative;
  z-index: 999;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.searchIcon:focus {
  outline: 2px solid #EEC21B;
  outline-offset: 2px;
}

.searchIcon:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

/* Color adaptation based on context (Agnico theme) */
.siteHeader .searchIcon {
  color: #101720;
}

.siteHeader .searchIcon:hover {
  /* color: #EEC21B; */
  background-color: transparent;
}

/*-------------------------*/
/*----- Search style -----*/
/*-----------------------*/
.headerNavWrap {
  width: auto;
  display: flex;
  position: relative;
}

.eventSearch {
  display: flex;
  /* position: relative; */
  align-items: center;
  justify-content: flex-start;
  margin-right: 24px;
}

.removePaddingLeft .eventSearch {
  margin: 0;
}

.eventSearch .searchIcon {
  padding: 17.5px 20px 11.5px 20px !important;
  position: relative !important;
  border-bottom: 6px solid transparent !important;
  height: 100%;
  border-radius: 0;
}

.eventSearch .searchIcon:hover,
.eventSearch .searchIcon.searchToggle[aria-expanded="true"] {
  border-color: #eec21b !important;
}

.eventSearch .searchIcon.searchToggle[aria-expanded="true"] {
  background: #f7f7f7;
}

/*-------------------------*/
/*----- Search style -----*/
/*-----------------------*/

/* ==========================================
   Full-screen Overlay
   ========================================== */
.searchOverlay {
  /* position: fixed; */
  position: absolute;
  top: 75px;
  left: 0;
  width: calc(100% - 155px);
  height: auto;
  background: #f7f7f7;
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 51px 54px;

}

.searchOverlay.active {
  opacity: 1;
  visibility: visible;
}

/* ==========================================
   Search Modal (centered white box)
   ========================================== */
/* .searchModal {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 650px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideDown 0.3s ease;
} */
.searchModal {
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  width: 100%;
  max-width: 100%;
  max-height: 70vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.searchOverlay.active .searchModal {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================
   Modal Header (search bar + close button)
   ========================================== */
.searchModalHeader {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0;
  border: none;
}

/* ==========================================
   Form
   ========================================== */
#eventSearchForm {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
}

/* ==========================================
   Search input
   ========================================== */
#eventSearchForm input#eventSearchInput::placeholder {
  /* font-family: "Suisse Intl", Arial, sans-serif; */
  font-family: "Open Sans", sans-serif;
  box-sizing: border-box;
  font-size: 14px;
  color: #101720;
}

#eventSearchForm input#eventSearchInput {
  width: 100%;
  padding: 18px 14px 18px 10px;
  outline: none !important;
  /* font-family: "Suisse Intl", Arial, sans-serif; */
  font-family: "Open Sans", sans-serif;
  box-sizing: border-box;
  font-size: 14px;
  color: #101720;
  border-radius: 8px;
  background-color: #fff;
  border: 0.5px solid #101720;
  height: auto;
  line-height: normal;
}

#eventSearchForm input#eventSearchInput:focus-visible {
  outline-offset: 0px !important;
}

#eventSearchForm input#eventSearchInput:focus {
  border-color: #EEC21B;
  outline: 2px solid #EEC21B;
  outline-offset: 2px;
  box-shadow: none;
}

/* Hide native X from search type */
#eventSearchForm input#eventSearchInput[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

#eventSearchForm input#eventSearchInput::placeholder {
  font-size: 16px;
  line-height: 120%;
  /* font-family: 'Suisse Intl', Arial, sans-serif; */
  font-family: "Open Sans", sans-serif;
  color: #101720;
}

/* ==========================================
   Search Clear Button (X icon inside input)
   ========================================== */
.searchClearBtn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: #101720;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.searchClearBtn:hover {
  color: #EEC21B;
}

.searchClearBtn:focus {
  outline: 2px solid #EEC21B;
  outline-offset: 2px;
}

/* ==========================================
   Close Button (FERMER)
   ========================================== */
.closeBtn {
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: #101720;
  padding: 0px;
  white-space: nowrap;
  /* font-family: "Suisse Intl", Arial, sans-serif; */
  font-family: "Open Sans", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: color 0.2s ease;
}

.closeBtn:hover {
  color: #EEC21B;
}

.closeBtn:focus {
  outline: 2px solid #EEC21B;
  outline-offset: 2px;
}

/* ==========================================
   Results container
   ========================================== */
.searchResults {
  overflow-y: auto;
  padding: 0;
  display: none;
}

/* iOS 16 compatible: Use JS to add .has-results class instead of :has() */
.searchResults.has-results {
  display: block;
  flex: 1;
}

/* ==========================================
   Results Header (Popular results (4))
   ========================================== */
.resultsHeader {
  padding: 40px 0px 19px;
  /* font-family: "Suisse Intl", Arial, sans-serif; */
  font-family: "Open Sans", sans-serif;
  font-size: 14px;
  color: #666;
  font-weight: 400;
}

.resultsHeader:empty {
  display: none;
  padding: 0;
}

/* ==========================================
   Results list
   ========================================== */
.resultsList {
  list-style: none;
  margin: 0;
  padding: 0 0 16px 0;
}

.resultsList .loading,
#mobileSearchResults .loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  color: #666;
  font-size: 14px;
}

.resultsList .loading .spinner,
#mobileSearchResults .loading .spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(16, 23, 32, 0.2);
  border-top-color: #EEC21B;
  border-radius: 50%;
  animation: searchSpinner 0.7s linear infinite;
}

@keyframes searchSpinner {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================
   Result items
   ========================================== */
.result-item {
  display: flex;
  align-items: flex-start;
  padding: 16px 0px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  gap: 16px;
  border-bottom: 1px solid #f0f0f0;
}

.result-item:last-child {
  border-bottom: none;
}

.result-item:hover {
  background-color: #f8f8f8;
}

.result-item.focused {
  background-color: #f0f0f0;
  border-left: 3px solid #EEC21B;
  padding-left: 21px;
}

.result-item:focus {
  outline: revert !important;
  outline-offset: 2px;
}

/* Search icon on left of each result */
.result-item .result-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  color: #101720;
}

.result-item .result-icon svg {
  width: 100%;
  height: 100%;
}

/* ==========================================
   Event information
   ========================================== */
.event-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.event-title {
  /* font-family: "Suisse Intl", Arial, sans-serif; */
  font-family: "Open Sans", sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: #101720;
  line-height: 1.4;
}

.event-excerpt {
  /* font-family: "Suisse Intl", Arial, sans-serif; */
  font-family: "Open Sans", sans-serif;
  font-size: 14px;
  color: #666;
  line-height: 1.5;
}

/* ==========================================
   States: Loading, No Results, Error
   ========================================== */
.loading,
.no-results,
.error {
  padding: 80px 24px;
  text-align: center;
  /* font-family: "Suisse Intl", Arial, sans-serif; */
  font-family: "Open Sans", sans-serif;
  font-size: 18px;
  color: #666;
  font-weight: 500;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.error {
  color: #d32f2f;
}

/* ==========================================
   RESPONSIVE
   ========================================== */

@media (max-width: 1199px) {
  .searchOverlay {
    top: 69px;
    width: calc(100% - 136px);
  }

  .searchModal {
    max-height: 65vh;
  }
}

@media (max-width: 997px) {
  .searchOverlay {
    top: 90px;
    width: calc(100% - 135px);
  }
}

/* Tablets */
@media (max-width: 992px) {
  .searchModal {
    width: 100%;
    max-width: 100%;
  }

  .searchOverlay {
    padding-top: 51px;
  }
}

@media (max-width: 991px) {
  .searchOverlay {
      top: 85px;
      width: calc(100% - 144px);
      max-height: 350px;
      overflow: hidden !important;
      display: flex;
      flex-direction: column;
  }

  .searchOverlay .searchModal {
      width: 100%;
      height: 100%;
      max-height: 100%;
      border-radius: 0;
  }

  .eventSearch .searchIcon {
    padding: 29px 20px 29px 20px !important;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .searchOverlay {
    padding-top: 80px;
    align-items: flex-start;
  }

  .searchModal {
    width: 95%;
    max-height: 85vh;
    border-radius: 8px;
  }

  .searchModalHeader {
    padding: 16px;
    gap: 12px;
    flex-wrap: wrap;
  }

  #eventSearchForm {
    width: 100%;
  }

  #eventSearchForm input#eventSearchInput {
    padding: 10px 40px 10px 12px;
    font-size: 14px;
  }

  .closeBtn {
    font-size: 12px;
    padding: 0px;
  }

  .result-item {
    padding: 12px 16px;
    gap: 12px;
  }

  .event-title {
    font-size: 14px;
  }

  .event-excerpt {
    font-size: 13px;
  }

  .resultsHeader {
    padding: 12px 16px 8px;
    font-size: 13px;
  }

  .searchOverlay .searchModal {
      width: 100%;
      height: 100%;
      max-height: 100%;
      border-radius: 0;
  }
}

/* Very small mobile */
@media (max-width: 600px) {
  .d-lg-none.gap-3 {
    gap: 0.5rem !important;
  }

  .searchIcon {
    padding: 4px;
  }

  .searchIcon svg {
    width: 18px;
    height: 18px;
  }

  .eventSearch {
    margin-right: 0;
  }
}

@media (max-width: 480px) {
  .searchModal {
    width: 100%;
    border-radius: 0;
    max-height: 100vh;
  }

  .searchOverlay {
    padding-top: 0;
  }
}
