/* Widgets: búsqueda, chat, modal (z-index por encima del contenido y cookies) */
.site-header__inner {
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

/* ——— Búsqueda en cabecera ——— */
.site-search {
  position: relative;
  flex: 1 1 auto;
  max-width: 220px;
  margin: 0 0.5rem 0 0.75rem;
  z-index: 1420;
}

@media (max-width: 1160px) {
  .site-search {
    display: none;
  }
}

.site-search__input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 999px;
  font: inherit;
  font-size: 0.88rem;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 12px rgba(27, 31, 36, 0.06);
  transition:
    border-color 0.25s ease,
    box-shadow 0.25s ease;
}

.site-search__input::-webkit-search-cancel-button,
.site-search__input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.site-search__input::-ms-clear {
  display: none;
}

.site-search__input:focus {
  outline: none;
  border-color: var(--kf-green, #00a651);
  box-shadow: 0 0 0 3px rgba(0, 166, 81, 0.15);
}

.site-search__icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--kf-muted, #5a6570);
  font-size: 0.85rem;
  pointer-events: none;
}

.site-search__icon .icon-svg {
  display: block;
  width: 1em;
  height: 1em;
}

.site-search__panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: min(100vw - 2rem, 320px);
  max-height: min(70vh, 360px);
  overflow-y: auto;
  background: #fff;
  border-radius: var(--radius-lg, 1.25rem);
  box-shadow: 0 16px 48px rgba(27, 31, 36, 0.14);
  border: 1px solid rgba(0, 0, 0, 0.06);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.98);
  pointer-events: none;
  transition:
    opacity 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.28s;
}

.site-search__panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.site-search__empty {
  padding: 0.85rem 1rem;
  font-size: 0.88rem;
  color: var(--kf-muted, #5a6570);
}

.site-search__hit {
  display: block;
  padding: 0.65rem 1rem;
  text-decoration: none;
  color: var(--kf-ink, #1b1f24);
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  transition: background 0.2s ease;
}

.site-search__hit:last-child {
  border-bottom: none;
}

.site-search__hit:hover,
.site-search__hit:focus-visible {
  background: var(--kf-green-soft, #e6f7ef);
  outline: none;
}

.site-search__hit-title {
  font-weight: 600;
  font-family: var(--font-heading, Montserrat, sans-serif);
}

.site-search__hit-path {
  font-size: 0.75rem;
  color: var(--kf-muted, #5a6570);
  margin-top: 0.15rem;
}

.site-search__hint {
  padding: 0.5rem 1rem 0.25rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--kf-muted, #5a6570);
}

/* ——— Chat flotante ——— */
.chat-widget {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  z-index: 2540;
  font-family: var(--font-body, "Open Sans", system-ui, sans-serif);
}

html:not(.js-cookie-done) .chat-widget {
  bottom: calc(5.5rem + env(safe-area-inset-bottom));
}

@media (min-width: 720px) {
  html:not(.js-cookie-done) .chat-widget {
    bottom: calc(4.25rem + env(safe-area-inset-bottom));
  }
}

html.js-cookie-done .chat-widget {
  bottom: max(1rem, env(safe-area-inset-bottom));
}

.chat-widget__launcher {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(
    135deg,
    var(--kf-green, #00a651),
    var(--kf-green-dark, #008544)
  );
  color: #fff;
  box-shadow: 0 10px 32px rgba(0, 166, 81, 0.4);
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  transition:
    transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.3s ease;
}

.chat-widget__launcher:hover {
  transform: scale(1.06);
  box-shadow: 0 14px 40px rgba(0, 166, 81, 0.5);
}

.chat-widget__launcher:focus-visible {
  outline: 3px solid var(--kf-warm, #ff8a3d);
  outline-offset: 3px;
}

.chat-widget__launcher .icon-svg {
  width: 1.35em;
  height: 1.35em;
  display: block;
}

.chat-widget__close .icon-svg,
.chat-widget__send .icon-svg {
  display: block;
  width: 1.1rem;
  height: 1.1rem;
}

.chat-widget__send .icon-svg {
  width: 1.15rem;
  height: 1.15rem;
}

.chat-widget__panel {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  width: min(100vw - 2rem, 400px);
  height: min(560px, calc(100dvh - 6rem));
  max-height: calc(100dvh - 6rem);
  background: #fff;
  border-radius: var(--radius-lg, 1.25rem);
  box-shadow: 0 24px 60px rgba(27, 31, 36, 0.18);
  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.32s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 2541;
}

html:not(.js-cookie-done) .chat-widget__panel {
  bottom: calc(5.5rem + 3.75rem + env(safe-area-inset-bottom));
}

@media (min-width: 720px) {
  html:not(.js-cookie-done) .chat-widget__panel {
    bottom: calc(4.25rem + 3.75rem + env(safe-area-inset-bottom));
  }
}

html.js-cookie-done .chat-widget__panel {
  bottom: calc(1rem + 3.75rem + env(safe-area-inset-bottom));
}

.chat-widget__panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

@media (max-width: 540px) {
  .chat-widget__panel {
    left: max(0.75rem, env(safe-area-inset-left));
    right: max(0.75rem, env(safe-area-inset-right));
    width: auto;
    height: calc(100dvh - 1.5rem);
    max-height: calc(100dvh - 1.5rem);
    bottom: 0.75rem !important;
    top: auto;
  }

  html:not(.js-cookie-done) .chat-widget__panel {
    height: calc(100dvh - 7rem);
    max-height: calc(100dvh - 7rem);
  }

  .chat-widget__launcher {
    bottom: auto;
  }
}

.chat-widget__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, #f4f8f6, #fff);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.chat-widget__title {
  margin: 0;
  font-family: var(--font-heading, Montserrat, sans-serif);
  font-size: 1rem;
  font-weight: 700;
}

.chat-widget__close {
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.05);
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--kf-ink, #1b1f24);
  transition: background 0.2s ease;
}

.chat-widget__close:hover {
  background: rgba(0, 0, 0, 0.1);
}

.chat-widget__messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: #fafbfb;
}

.chat-widget__msg {
  max-width: 88%;
  padding: 0.65rem 0.85rem;
  border-radius: 1rem;
  font-size: 0.9rem;
  line-height: 1.45;
  animation: chatMsgIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes chatMsgIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-widget__msg--user {
  align-self: flex-end;
  background: var(--kf-green, #00a651);
  color: #fff;
  border-bottom-right-radius: 0.25rem;
}

.chat-widget__msg--bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 4px 16px rgba(27, 31, 36, 0.06);
  border-bottom-left-radius: 0.25rem;
}

.chat-widget__msg--bot a {
  color: var(--kf-green-dark, #008544);
  font-weight: 600;
}

.chat-widget__typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 0.6rem 0.85rem;
  background: #fff;
  border-radius: 1rem;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.chat-widget__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--kf-green, #00a651);
  opacity: 0.35;
  animation: chatDot 1.1s ease-in-out infinite;
}

.chat-widget__typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.chat-widget__typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes chatDot {
  0%,
  100% {
    opacity: 0.25;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

.chat-widget__foot {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  background: #fff;
}

.chat-widget__input {
  flex: 1;
  border: 1px solid #d5dde0;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font: inherit;
  font-size: 0.9rem;
}

.chat-widget__input:focus {
  outline: none;
  border-color: var(--kf-green, #00a651);
}

.chat-widget__send {
  flex-shrink: 0;
  width: 2.65rem;
  height: 2.65rem;
  border-radius: 50%;
  border: none;
  background: var(--kf-green, #00a651);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition:
    transform 0.2s ease,
    background 0.2s ease;
}

.chat-widget__send:hover {
  background: var(--kf-green-dark, #008544);
  transform: scale(1.05);
}

/* ——— Modal éxito formulario ——— */
.form-success-dialog {
  border: none;
  border-radius: var(--radius-lg, 1.25rem);
  padding: 0;
  max-width: min(calc(100vw - 2rem), 420px);
  box-shadow: 0 28px 70px rgba(27, 31, 36, 0.22);
  z-index: 2700;
}

.form-success-dialog::backdrop {
  background: rgba(15, 25, 22, 0.45);
  backdrop-filter: blur(4px);
  animation: formBackdropIn 0.35s ease both;
}

@keyframes formBackdropIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.form-success-dialog__inner {
  padding: 1.75rem 1.5rem 1.5rem;
  text-align: center;
}

.form-success-dialog__icon {
  width: 3.25rem;
  height: 3.25rem;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: var(--kf-green-soft, #e6f7ef);
  color: var(--kf-green, #00a651);
  display: grid;
  place-items: center;
  font-size: 1.5rem;
}

.form-success-dialog__icon .icon-svg {
  width: 1.5rem;
  height: 1.5rem;
  display: block;
}

.form-success-dialog__title {
  margin: 0 0 0.5rem;
  font-family: var(--font-heading, Montserrat, sans-serif);
  font-size: 1.25rem;
}

.form-success-dialog__text {
  margin: 0 0 1.25rem;
  color: var(--kf-muted, #5a6570);
  font-size: 0.95rem;
  line-height: 1.55;
}

.form-success-dialog__btn {
  font-family: var(--font-heading, Montserrat, sans-serif);
  font-weight: 600;
  padding: 0.65rem 1.5rem;
  border-radius: 999px;
  border: none;
  background: var(--kf-green, #00a651);
  color: #fff;
  cursor: pointer;
  font-size: 0.95rem;
}

.form-success-dialog__btn:focus-visible {
  outline: 2px solid var(--kf-warm, #ff8a3d);
  outline-offset: 2px;
}
