/**
 * NY Chatbot - Pre-chat Lead Capture Module
 *
 * Loaded only for guests when pre-chat lead capture is enabled
 * (ny_chatbot_prechat_enabled). Renders the overlay shown over the chat
 * body to collect name/phone/email before the conversation starts.
 *
 * Selectors are prefixed with #ny-chatbot-container so their specificity
 * beats the global button/input resets in frontend.css (core).
 */

/* Keep the chat header (and its close/reset buttons) ABOVE the overlay so the
   user can always close the chat — even while the pre-chat form is showing.
   Without this, the absolutely-positioned overlay (inset:0) covers the header
   and swallows clicks on the close button, most visibly on mobile. */
#ny-chatbot-container #ny-chatbot-header {
  position: relative;
  z-index: 60;
}

#ny-chatbot-container #ny-prechat-overlay {
  position: absolute;
  /* Start the overlay BELOW the header instead of inset:0, so it never sits on
     top of the close button. flex layout keeps the header as the first row. */
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.1rem;
  background: rgba(17, 24, 39, 0.32);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  direction: rtl;
  animation: ny-prechat-fade 0.22s ease;
}
@keyframes ny-prechat-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
#ny-chatbot-container #ny-prechat-overlay .ny-prechat-box {
  width: 100%;
  max-width: 330px;
  max-height: calc(100% - 0.5rem);
  overflow-y: auto;
  background: var(--ny-container-bg, #fff);
  border-radius: 1.1rem;
  box-shadow: 0 16px 48px -8px rgba(17, 24, 39, 0.35), 0 0 0 1px rgba(17, 24, 39, 0.04);
  padding: 1.5rem 1.35rem 1.35rem;
  text-align: center;
  animation: ny-prechat-pop 0.28s cubic-bezier(0.18, 0.89, 0.32, 1.15);
}
@keyframes ny-prechat-pop {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
#ny-chatbot-container #ny-prechat-overlay .ny-prechat-title {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.8;
  color: var(--ny-bot-msg-text, #111827);
  margin: 0 0 1.15rem;
}

#ny-chatbot-container #ny-prechat-overlay .ny-prechat-row {
  position: relative;
  display: block;
  margin-bottom: 0.95rem;
  text-align: start;
}
#ny-chatbot-container #ny-prechat-overlay input.ny-prechat-input {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  height: auto;
  min-height: 42px;
  padding: 0.7em 1em;
  font-size: 0.76rem;
  font-family: inherit;
  line-height: 1.4;
  color: var(--ny-input-text, #111827);
  background: var(--ny-input-bg, #fff);
  border: 1.5px solid color-mix(in srgb, var(--ny-accent-color, #145dee) 30%, transparent);
  border-radius: 1.2em;
  box-shadow: 0 2px 7px 0 rgb(0 0 0 / 0.1);
  box-sizing: border-box;
  direction: rtl;
  text-align: start;
  outline: 0;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#ny-chatbot-container #ny-prechat-overlay input.ny-prechat-input::placeholder {
  color: transparent;
}
#ny-chatbot-container #ny-prechat-overlay input.ny-prechat-input:focus {
  outline: 0;
  border-color: var(--ny-accent-color, #145dee);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ny-accent-color, #145dee) 20%, transparent);
}
#ny-chatbot-container #ny-prechat-overlay input.ny-prechat-input.ny-prechat-invalid {
  border-color: #ef4444;
  box-shadow: 0 0 0 2px color-mix(in srgb, #ef4444 16%, transparent);
}

#ny-chatbot-container #ny-prechat-overlay .ny-prechat-label {
  position: absolute;
  top: 50%;
  inset-inline-start: 1em;
  transform: translateY(-50%);
  transform-origin: right center;
  margin: 0;
  padding: 0.1em 0.3em;
  max-width: calc(100% - 2em);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: color-mix(in srgb, var(--ny-input-text, #111827) 50%, transparent);
  background: var(--ny-input-bg, #fff);
  border-radius: 0.35em;
  pointer-events: none;
  transition: top 0.16s ease, transform 0.16s ease, color 0.16s ease, font-size 0.16s ease;
}
#ny-chatbot-container #ny-prechat-overlay input.ny-prechat-input:focus + .ny-prechat-label,
#ny-chatbot-container #ny-prechat-overlay input.ny-prechat-input:not(:placeholder-shown) + .ny-prechat-label {
  /* Sit the floated label ON the input's top border line (notched-outline
     style). The label's own background masks the border behind it. */
  top: 0;
  transform: translateY(-50%) scale(0.82);
  font-weight: 600;
  color: var(--ny-accent-color, #145dee);
}
#ny-chatbot-container #ny-prechat-overlay input.ny-prechat-input.ny-prechat-invalid + .ny-prechat-label {
  color: #ef4444;
}
#ny-chatbot-container #ny-prechat-overlay .ny-prechat-req {
  color: #ef4444;
  margin-inline-start: 2px;
  font-weight: 700;
}

#ny-chatbot-container #ny-prechat-overlay .ny-prechat-error {
  color: #ef4444;
  font-size: 0.78rem;
  margin: 0.15rem 0 0.4rem;
  line-height: 1.6;
  text-align: start;
}

#ny-chatbot-container #ny-prechat-overlay .ny-prechat-actions {
  display: flex;
  gap: 0.55rem;
  margin-top: 1.15rem;
}

#ny-chatbot-container #ny-prechat-overlay button.ny-prechat-submit {
  flex: 1 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 46px;
  padding: 0.7em 1.2em;
  font-size: 0.92rem;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.2px;
  line-height: normal;
  color: var(--ny-send-btn-icon, #fff);
  background: var(--ny-send-btn-bg, var(--ny-primary-color, #145dee));
  border: 1.5px solid var(--ny-send-btn-bg, var(--ny-primary-color, #145dee));
  border-radius: 1.2em;
  cursor: pointer;
  box-shadow: 0 2px 7px 0 rgb(0 0 0 / 0.14);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
  text-transform: none;
  appearance: none;
  -webkit-appearance: none;
}
#ny-chatbot-container #ny-prechat-overlay button.ny-prechat-submit:hover {
  background: var(--ny-primary-color, #145dee);
  border-color: var(--ny-primary-color, #145dee);
  border: 1.5px solid var(--ny-primary-color, #145dee);
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.18);
  transform: translateY(-1px);
  outline: 0;
  text-decoration: none;
}
#ny-chatbot-container #ny-prechat-overlay button.ny-prechat-submit:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.15);
  border: 1.5px solid var(--ny-primary-color, #145dee);
  outline: 0;
}
#ny-chatbot-container #ny-prechat-overlay button.ny-prechat-submit:focus {
  outline: 0;
  border: 1.5px solid var(--ny-primary-color, #145dee);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ny-accent-color, #145dee) 30%, transparent);
}
#ny-chatbot-container #ny-prechat-overlay button.ny-prechat-submit:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
  box-shadow: none;
}

#ny-chatbot-container #ny-prechat-overlay button.ny-prechat-skip {
  flex: 0 0 auto;
  min-height: 46px;
  padding: 0.7em 1.1em;
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 500;
  line-height: normal;
  color: color-mix(in srgb, var(--ny-bot-msg-text, #111827) 65%, transparent);
  background: transparent;
  border: 1.5px solid color-mix(in srgb, var(--ny-bot-msg-text, #111827) 18%, transparent);
  border-radius: 1.2em;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  text-decoration: none;
  appearance: none;
  -webkit-appearance: none;
}
#ny-chatbot-container #ny-prechat-overlay button.ny-prechat-skip:hover {
  background: color-mix(in srgb, var(--ny-bot-msg-text, #111827) 6%, transparent);
  border: 1.5px solid color-mix(in srgb, var(--ny-bot-msg-text, #111827) 30%, transparent);
  color: color-mix(in srgb, var(--ny-bot-msg-text, #111827) 85%, transparent);
  outline: 0;
  text-decoration: none;
  box-shadow: none;
}
#ny-chatbot-container #ny-prechat-overlay button.ny-prechat-skip:focus {
  outline: 0;
  border: 1.5px solid color-mix(in srgb, var(--ny-bot-msg-text, #111827) 30%, transparent);
  box-shadow: none;
}
