/* Widget de chat flotante + autocompletado mejorado — z-index por encima del header (1000) y modales */
.fm-chat-root {
  position: fixed;
  z-index: 10050;
  bottom: 24px;
  right: 24px;
  font-family: var(--font-body, "Open Sans", system-ui, sans-serif);
}

.fm-chat-launcher {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(145deg, var(--color-primary, #643695), var(--color-primary-dark, #4a2870));
  color: #fff;
  box-shadow: 0 8px 28px rgba(100, 54, 149, 0.45), 0 2px 8px rgba(26, 26, 26, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.fm-chat-launcher:hover {
  transform: scale(1.06);
  box-shadow: 0 10px 32px rgba(100, 54, 149, 0.5), 0 4px 12px rgba(26, 26, 26, 0.2);
}

.fm-chat-launcher:active {
  transform: scale(0.98);
}

.fm-chat-launcher svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

.fm-chat-panel {
  position: absolute;
  bottom: 74px;
  right: 0;
  width: min(400px, calc(100vw - 48px));
  max-height: min(560px, calc(100vh - 120px));
  background: var(--color-bg, #fff);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(26, 26, 26, 0.18), 0 4px 16px rgba(26, 26, 26, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.fm-chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.fm-chat-panel[hidden] {
  display: none !important;
}

@media (max-width: 600px) {
  .fm-chat-root {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }

  .fm-chat-panel {
    position: fixed;
    inset: 0;
    bottom: 0;
    right: 0;
    left: 0;
    top: auto;
    width: 100%;
    max-width: none;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    bottom: 0;
  }

  .fm-chat-launcher {
    position: fixed;
    bottom: 16px;
    right: 16px;
  }
}

.fm-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: var(--color-secondary, #1a1a1a);
  color: #fff;
}

.fm-chat-header h2 {
  margin: 0;
  font-size: 1rem;
  font-family: var(--font-heading, Montserrat, sans-serif);
  font-weight: 700;
  color: #fff;
}

.fm-chat-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s;
}

.fm-chat-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

[data-theme="dark"] .fm-chat-header {
  background: #ede9f2;
  color: #1a1a1a;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .fm-chat-header h2,
[data-theme="dark"] #fm-chat-title {
  color: #1a1a1a;
}

[data-theme="dark"] .fm-chat-close {
  background: rgba(0, 0, 0, 0.08);
  color: #1a1a1a;
}

[data-theme="dark"] .fm-chat-close:hover {
  background: rgba(0, 0, 0, 0.14);
}

.fm-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
  max-height: 340px;
  background: var(--color-bg-muted, #f5f7f6);
}

@media (max-width: 600px) {
  .fm-chat-messages {
    max-height: calc(92vh - 200px);
    min-height: 180px;
  }
}

.fm-chat-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  animation: fm-chat-fade 0.35s ease;
}

@keyframes fm-chat-fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fm-chat-msg--user {
  align-self: flex-end;
  background: var(--color-primary, #643695);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.fm-chat-msg--bot {
  align-self: flex-start;
  background: var(--color-bg, #fff);
  color: var(--color-text, #333);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.06));
}

[data-theme="dark"] .fm-chat-msg--bot {
  background: #2a2a2a;
  border-color: #444;
}

.fm-chat-msg a {
  color: var(--color-primary-dark, #4a2870);
  font-weight: 600;
}

.fm-chat-msg--user a {
  color: #fff;
  text-decoration: underline;
}

.fm-chat-msg ul {
  margin: 8px 0 0;
  padding-left: 1.1rem;
}

.fm-chat-typing {
  padding: 0 16px 8px;
  min-height: 28px;
}

.fm-chat-typing[hidden] {
  display: none !important;
}

.fm-chat-typing-dots {
  display: inline-flex;
  gap: 5px;
  padding: 8px 14px;
  background: var(--color-bg, #fff);
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.fm-chat-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-primary, #643695);
  opacity: 0.35;
  animation: fm-chat-bounce 1.2s ease infinite;
}

.fm-chat-typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.fm-chat-typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes fm-chat-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

.fm-chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  background: var(--color-bg, #fff);
}

.fm-chat-form input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--color-bg, #fff);
  color: var(--color-text, #333);
}

[data-theme="dark"] .fm-chat-form input {
  border-color: #444;
  background: var(--color-bg-muted, #1e1e1e);
}

.fm-chat-send {
  padding: 12px 18px;
  border: none;
  border-radius: 10px;
  background: var(--color-accent, #ffa724);
  color: #1a1a1a;
  font-weight: 700;
  font-family: var(--font-heading, Montserrat, sans-serif);
  cursor: pointer;
  transition: filter 0.2s;
}

.fm-chat-send:hover {
  filter: brightness(1.05);
}

/* Autocompletado cabecera: sin aspa nativa, animación */
input.global-search-input[type="text"]::-webkit-search-decoration,
input.global-search-input[type="text"]::-webkit-search-cancel-button,
input.global-search-input[type="text"]::-webkit-search-results-button,
input.global-search-input[type="text"]::-webkit-search-results-decoration {
  display: none;
}

input.global-search-input[type="text"] {
  -webkit-appearance: none;
  appearance: none;
}

.search-autocomplete {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.search-autocomplete.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.search-autocomplete__label {
  padding: 8px 14px 4px;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted, #5c5c5c);
}

.search-autocomplete__hint {
  padding: 8px 14px 10px;
  font-size: 0.8rem;
  color: var(--color-text-muted, #5c5c5c);
  border-bottom: 1px solid #eee;
}

[data-theme="dark"] .search-autocomplete__hint {
  border-color: #333;
}

.search-autocomplete a,
.search-autocomplete button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--color-text, #333);
  text-decoration: none;
  border-bottom: 1px solid #f0f0f0;
}

[data-theme="dark"] .search-autocomplete a,
[data-theme="dark"] .search-autocomplete button {
  border-color: #2a2a2a;
}

.search-autocomplete a:hover,
.search-autocomplete button:hover,
.search-autocomplete a:focus-visible,
.search-autocomplete button:focus-visible {
  background: var(--color-bg-muted, #f5f7f6);
}

.search-autocomplete .search-autocomplete__meta {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted, #5c5c5c);
  margin-top: 2px;
}
