/*
 * Floating support stack (_SupportPartial.cshtml), consulting popup (support-react.js) and AI chat widget (chat-react.js).
 * Colours use the brand tokens defined in styles.css (:root); fallbacks keep the widgets readable if loaded alone.
 */

/* ---------- Floating action stack ---------- */

.support-fab-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 65;
  display: grid;
  gap: 0.5rem;
  justify-items: end;
  padding-bottom: env(safe-area-inset-bottom);
  transition: bottom 150ms ease;
}

/* Google's reCAPTCHA v3 badge is fixed at the bottom-right whenever a site key is configured (_Layout adds .has-recaptcha). */
.has-recaptcha .support-fab-stack {
  bottom: 5.25rem;
}

.support-fab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  border: 1px solid var(--brand-700, #3141b4);
  border-radius: 9999px;
  background: var(--brand-700, #3141b4);
  color: #fff;
  padding: 0.55rem 1rem 0.55rem 0.6rem;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(30, 39, 99, 0.28);
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.support-fab:hover {
  border-color: var(--brand-800, #2b3891);
  background: var(--brand-800, #2b3891);
}

.support-fab-alt {
  border-color: #cbd5e1;
  background: #fff;
  color: #0f172a;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.14);
}

.support-fab-alt:hover {
  border-color: var(--brand-600, #3b52d6);
  background: var(--brand-50, #f0f5ff);
  color: var(--brand-800, #2b3891);
}

/* The icons are dark outline SVGs, so every bubble is light enough for them to stay visible. */
.support-fab-icon {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 9999px;
  background: #fff;
}

.support-fab-alt .support-fab-icon {
  background: var(--brand-50, #f0f5ff);
}

@media (max-width: 767px) {
  body.is-header-compact #favorites-link {
    display: none;
  }

  /* Collapsed by default on phones; the "Liên hệ" toggle adds .is-open (app.js). */
  .support-fab-stack .support-fab-action {
    display: none;
  }

  .support-fab-stack.is-open .support-fab-action {
    display: inline-flex;
  }
}

@media (min-width: 768px) {
  .support-fab-toggle {
    display: none;
  }
}

/* Pages with a fixed mobile booking bar mark it with [data-sticky-cta]; app.js then adds .has-sticky-cta. */
@media (max-width: 1023px) {
  .has-sticky-cta .support-fab-stack {
    bottom: 6rem;
  }

  .has-sticky-cta.has-recaptcha .support-fab-stack {
    bottom: 10.25rem;
  }
}

/* ---------- Shared dialog controls ---------- */

.support-popup-close,
.support-popup-expand {
  position: absolute;
  top: 0.75rem;
  z-index: 1;
  display: inline-flex;
  width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0.625rem;
  background: transparent;
  color: #475569;
  padding: 0;
  appearance: none;
  cursor: pointer;
}

.support-popup-close {
  right: 0.75rem;
}

.support-popup-expand {
  right: 3.25rem;
  font-size: 1.35rem;
  line-height: 1;
}

.support-popup-close:hover,
.support-popup-expand:hover {
  background: #f1f5f9;
  color: var(--brand-700, #3141b4);
}

.support-popup-close:focus-visible,
.support-popup-expand:focus-visible {
  outline: 3px solid var(--focus, #fbbf24);
  outline-offset: 2px;
}

/* ---------- Consulting popup ---------- */

.support-popup {
  position: fixed;
  inset: 0;
  z-index: 75;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.support-popup.hidden {
  display: none;
}

.support-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}

.support-popup-card {
  position: relative;
  width: min(440px, 100%);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 1.25rem;
  background: #fff;
  padding: 1.5rem;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.25);
}

.support-popup-title {
  margin: 0;
  padding-right: 2.5rem;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.3;
  color: #0f172a;
}

.support-popup-desc {
  margin-top: 0.375rem;
  font-size: 0.875rem;
  color: #475569;
}

.support-popup-note {
  display: block;
  margin-top: 0.75rem;
  text-align: center;
  font-size: 0.75rem;
  line-height: 1.4;
  color: #64748b;
}

.support-popup-note a {
  color: var(--brand-700, #3141b4);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.support-popup-note a:hover {
  color: var(--brand-800, #2b3891);
}

.support-popup-note a:focus-visible {
  outline: 2px solid var(--focus, #fbbf24);
  outline-offset: 2px;
}

.support-popup-form {
  margin-top: 1rem;
  display: grid;
  gap: 0.75rem;
}

.support-popup-form input,
.support-popup-form textarea {
  width: 100%;
  font-size: 0.875rem;
}

.support-popup-submit {
  border: 1px solid var(--brand-700, #3141b4);
  border-radius: 0.75rem;
  background: var(--brand-700, #3141b4);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 700;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.support-popup-submit:hover {
  background: var(--brand-800, #2b3891);
}

.support-popup-submit:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* ---------- AI chat widget ---------- */

.support-chat-widget {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 80;
}

.support-chat-widget.hidden {
  display: none;
}

.support-chat-card {
  position: relative;
  width: min(480px, calc(100vw - 2rem));
  border: 1px solid #e2e8f0;
  border-radius: 1.25rem;
  background: #fff;
  padding: 1rem;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.25);
}

.support-chat-card #support-chat-messages {
  max-height: 16rem;
  overflow-y: auto;
}

.support-chat-widget.is-expanded {
  inset: 1rem;
}

.support-chat-widget.is-expanded .support-chat-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.support-chat-widget.is-expanded .support-chat-card #support-chat-messages {
  max-height: calc(100dvh - 12rem);
  flex: 1;
}

.support-chat-source-image {
  max-width: min(500px, calc(100vw - 4rem));
}

.support-chat-ai-icon {
  display: inline-block;
  margin-right: 0.25rem;
  font-size: 1.15em;
  line-height: 1;
  vertical-align: -0.08em;
}

#support-chat-input:disabled {
  cursor: not-allowed;
  border-color: #cbd5e1;
  background-color: #f1f5f9;
  color: #64748b;
  opacity: 1;
}

@media (max-width: 767px) {
  .support-chat-widget,
  .support-chat-widget.is-expanded {
    inset: 0;
  }

  .support-chat-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    min-height: 100dvh;
    border-radius: 0;
  }

  .support-chat-card #support-chat-messages {
    flex: 1;
    min-height: 0;
    max-height: 70dvh;
  }
}

/* ---------- Footer social links (SocialMedia component) ---------- */

.footer-social-link {
  display: inline-flex;
  height: 2.25rem;
  width: 2.25rem;
  align-items: center;
  justify-content: center;
  border: 1px solid #334155;
  border-radius: 0.5rem;
  color: #cbd5e1;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.footer-social-link img {
  filter: invert(88%) sepia(13%) saturate(377%) hue-rotate(175deg) brightness(91%) contrast(87%);
}

.footer-social-link:hover {
  border-color: var(--accent-400, #fbbf24);
  background: rgba(255, 255, 255, 0.06);
}

.footer-social-link:hover img {
  filter: invert(1);
}
