/* Autocomplete suggestions styles */
.search-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 9999;
  background: #ffffff;
  border: 1px solid #d0d7df;
  border-radius: 6px;
  box-shadow: 0 8px 20px rgba(16,24,40,0.08);
  max-height: 260px;
  overflow: auto;
  width: 100%;
  padding: 4px 0;
  box-sizing: border-box;
}

.search-suggestions div[role="option"] {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  color: #12263a;
  font-size: 0.98rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-suggestions div[role="option"]:hover,
.search-suggestions div[aria-selected="true"] {
  background: #eef6ff;
  font-weight: 700;
}

/* Small helper to hide when empty */
.search-suggestions.hidden {
  display: none !important;
}

/* Soft animations for the suggestions dropdown */
.search-suggestions {
  transition: opacity 0.12s ease, transform 0.12s ease;
  opacity: 0;
  transform: translateY(-6px);
  will-change: opacity, transform;
}

/* Visible/open state */
.search-suggestions.open {
  opacity: 1;
  transform: translateY(0);
}

/* Ensure visible when opened (overrides .hidden) */
.search-suggestions.open.hidden {
  display: block !important;
}

/* On smaller screens ensure suggestions remain usable */
@media (max-width: 520px) {
  .search-suggestions {
    max-height: 200px;
    top: calc(100% + 6px);
  }
  .search-suggestions div[role="option"] {
    padding: 0.45rem 0.6rem;
    font-size: 0.95rem;
  }
}

/* ==========================
   Mobile full-screen modal
   ==========================
   These styles support the mobile-only full-screen search modal
   used when touch devices or narrow viewports are detected.
*/

.search-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 10000;
  -webkit-tap-highlight-color: transparent;
}

.search-modal {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
  animation: modal-in 180ms ease;
  box-sizing: border-box;
}

@keyframes modal-in {
  from { transform: translateY(6px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.search-modal-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  gap: 8px;
  border-bottom: 1px solid #eee;
}

/* Top row: centered icon + title on one line */
.search-modal-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 6px 0;
}

.search-modal-icon {
  width: 30px;
  height: 30px;
  display: inline-block;
  object-fit: contain;
  opacity: 0.95;
}

.search-modal-title {
  font-size: 1.18rem;
  font-weight: 700;
  color: #c0392b; /* red */
  line-height: 1;
}

/* Controls row: input + close button */
.search-modal-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  width: 100%;
}

.search-modal-input {
  flex: 1;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1px solid #d0d7df;
  border-radius: 8px;
  outline: none;
  box-sizing: border-box;
}

.search-modal-input:focus {
  border-color: #7aa7ff;
  box-shadow: 0 2px 8px rgba(122,167,255,0.12);
}

.search-modal-close {
  background: transparent;
  border: none;
  font-size: 20px;
  line-height: 1;
  padding: 6px;
  cursor: pointer;
  color: #333;
}

.search-modal-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 0;
  box-sizing: border-box;
}

/* Touch-friendly list items */
.search-modal-list > div[role="option"],
.search-modal-list .fuzzy-suggestion,
.search-modal-list .fuzzy-show-all {
  padding: 14px 16px;
  cursor: pointer;
  color: #12263a;
  font-size: 1.03rem;
  line-height: 1.3;
  border-bottom: 1px solid #f1f3f5;
  background: transparent;
  white-space: normal;
}

/* Visual states */
.search-modal-list > div[role="option"]:active,
.search-modal-list > div[role="option"]:hover,
.search-modal-list > div[aria-selected="true"] {
  background: #eef6ff;
  font-weight: 700;
}

/* Fuzzy hint styling inside modal */
.search-modal-list .fuzzy-hint {
  padding: 10px 16px;
  color: #4a5568;
  font-size: 0.95rem;
  border-bottom: 1px solid #f1f3f5;
  background: #fafafa;
}

/* Make sure the desktop dropdown remains above page content but below modal */
.search-suggestions {
  z-index: 9999;
}

/* When modal is open, optionally style body (class added by JS) */
body.search-modal-open {
  touch-action: none;
}

/* Keep original small-screen tweaks intact */
@media (max-width: 420px) {
  .search-modal-input {
    font-size: 0.98rem;
    padding: 9px 10px;
  }
  .search-modal-list > div[role="option"] {
    padding: 12px 14px;
    font-size: 1rem;
  }
}

/* Analisi info banner (moved here from JS dynamic injection)
   Used in dropdown/modal (#search-suggestions or .search-modal-list) and in #messaggio.
*/
.analisi-info {
  background: #fff8e1;
  border-left: 4px solid #ffd54f;
  padding: 10px;
  margin: 8px 6px;
  border-radius: 6px;
  color: #6b4f00;
  font-size: 0.95rem;
  line-height: 1.3;
  box-sizing: border-box;
}
.analisi-info strong {
  display: block;
  margin-bottom: 4px;
  color: #8a6d3b;
  font-weight: 700;
}
.analisi-info a {
  color: #8a6d3b;
  text-decoration: underline;
}

/* Slightly larger and centered when shown inside the central #messaggio area */
#messaggio .analisi-info {
  max-width: 760px;
  margin: 10px auto;
  font-size: 1rem;
  padding: 12px;
}

/* Ensure it looks good in the modal list (no extra margin) */
.search-modal-list .analisi-info,
#search-suggestions .analisi-info {
  margin-left: 6px;
  margin-right: 6px;
}
