/* Barra ricerca globale + widget chat — sopra al resto del layout */

.site-global-search {
  position: relative;
  z-index: 140;
  background: linear-gradient(
    180deg,
    rgba(26, 22, 18, 0.98),
    rgba(18, 16, 14, 0.96)
  );
  border-bottom: 1px solid rgba(212, 175, 55, 0.18);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

@media (max-width: 1200px) and (min-width: 768px) {
  .site-global-search {
    padding-top: 25px;
  }
}

.site-global-search__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.65rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  position: relative;
}

.site-global-search__field {
  flex: 1;
  min-width: 0;
  position: relative;
}

.site-global-search__input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.85rem;
  padding-right: 2.25rem;
  border-radius: 999px;
  border: 1px solid rgba(212, 175, 55, 0.28);
  background: rgba(0, 0, 0, 0.35);
  color: var(--color-text, #f5f5f5);
  font-family: var(--font-ui, system-ui, sans-serif);
  font-size: 0.95rem;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.site-global-search__input::placeholder {
  color: rgba(245, 245, 245, 0.45);
}

.site-global-search__input:focus {
  outline: none;
  border-color: var(--color-accent, #d4af37);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
}

/* Rimuove il pulsante "clear" nativo (WebKit / Edge) */
.site-global-search__input[type="search"]::-webkit-search-decoration,
.site-global-search__input[type="search"]::-webkit-search-cancel-button,
.site-global-search__input[type="search"]::-webkit-search-results-button,
.site-global-search__input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.site-global-search__input[type="search"] {
  -webkit-appearance: textfield;
  appearance: textfield;
}

.site-global-search__icon {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.1rem;
  height: 1.1rem;
  opacity: 0.55;
  pointer-events: none;
}

.site-global-search__panel {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.35rem);
  max-height: min(70vh, 420px);
  overflow-y: auto;
  background: rgba(22, 20, 18, 0.98);
  border: 1px solid rgba(212, 175, 55, 0.22);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  padding: 0.5rem 0;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition:
    opacity 0.22s ease,
    transform 0.22s ease;
}

.site-global-search__panel.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.site-global-search__hint {
  padding: 0.35rem 1rem 0.5rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-accent, #d4af37);
  font-family: var(--font-ui, sans-serif);
}

.site-global-search__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-global-search__list a {
  display: block;
  padding: 0.55rem 1rem;
  color: var(--color-text, #eee);
  text-decoration: none;
  font-size: 0.9rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.15s ease;
}

.site-global-search__list a:hover,
.site-global-search__list a:focus-visible {
  background: rgba(212, 175, 55, 0.12);
  outline: none;
}

.site-global-search__meta {
  display: block;
  font-size: 0.72rem;
  color: var(--color-text-muted, #aaa);
  margin-top: 0.15rem;
}

.site-global-search__empty {
  padding: 0.75rem 1rem 0.25rem;
  font-size: 0.88rem;
  color: var(--color-text-muted, #bbb);
}

/* Chat widget */
.site-chat-launcher {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1950;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid rgba(212, 175, 55, 0.45);
  background: linear-gradient(
    145deg,
    rgba(212, 175, 55, 0.95),
    rgba(160, 120, 40, 0.98)
  );
  color: #1a1a1a;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.site-chat-launcher:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.site-chat-launcher svg {
  width: 26px;
  height: 26px;
}

.site-chat-panel {
  position: fixed;
  right: 1rem;
  bottom: calc(1rem + 56px + 0.75rem);
  z-index: 10051;
  width: min(100vw - 2rem, 380px);
  max-height: min(560px, calc(100vh - 6rem));
  background: rgba(18, 16, 14, 0.98);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition:
    opacity 0.28s ease,
    transform 0.28s ease;
}

.site-chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.site-chat-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: rgba(212, 175, 55, 0.12);
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
  font-family: var(--font-ui, sans-serif);
  font-weight: 600;
  font-size: 0.95rem;
}

.site-chat-panel__close {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  opacity: 0.85;
}

.site-chat-panel__close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.2);
}

.site-chat-panel__messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 220px;
}

.site-chat-msg {
  max-width: 92%;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
}

.site-chat-msg--bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.site-chat-msg--user {
  align-self: flex-end;
  background: rgba(212, 175, 55, 0.22);
  border: 1px solid rgba(212, 175, 55, 0.35);
}

.site-chat-msg a {
  color: var(--color-accent, #e8c85a);
  font-weight: 600;
}

.site-chat-typing {
  display: flex;
  gap: 4px;
  padding: 0.35rem 0.5rem;
  align-self: flex-start;
}

.site-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(212, 175, 55, 0.7);
  animation: site-chat-dot 1.2s ease-in-out infinite;
}

.site-chat-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.site-chat-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes site-chat-dot {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: scale(0.85);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

.site-chat-panel__foot {
  padding: 0.65rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  gap: 0.5rem;
}

.site-chat-panel__input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  border: 1px solid rgba(212, 175, 55, 0.25);
  background: rgba(0, 0, 0, 0.35);
  color: inherit;
  font-size: 0.9rem;
}

.site-chat-panel__input:focus {
  outline: none;
  border-color: var(--color-accent, #d4af37);
}

.site-chat-panel__send {
  flex-shrink: 0;
  padding: 0.5rem 0.85rem;
  border-radius: 10px;
  border: none;
  background: var(--color-accent, #d4af37);
  color: #1a1a1a;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}

.site-chat-panel__send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 767px) {
  .site-chat-panel {
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    width: 100%;
    max-height: none;
    border-radius: 0;
    transform: translateY(100%);
  }

  .site-chat-panel.is-open {
    transform: translateY(0);
  }

  .site-chat-launcher {
    bottom: max(1rem, env(safe-area-inset-bottom));
    right: max(1rem, env(safe-area-inset-right));
  }
}
