/* Customer AI chat (customs + book) — mobile-app layout. Works with .customs-ai-* from figma-theme. */

.hf-ai-chat.customs-ai-chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
}

.hf-ai-chat-layout {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
  gap: 0.5rem;
}

.hf-ai-chat-mid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.hf-ai-chat-composer-wrap {
  margin-top: auto;
  flex-shrink: 0;
  padding-top: 0.35rem;
  background: var(--wb-bg, #0a0a0a);
}

.hf-ai-chat .customs-ai-checkout-card,
.hf-ai-chat .customs-ai-summary {
  border: 1px solid var(--wb-border, rgba(255, 255, 255, 0.22));
  border-radius: var(--wb-radius, 0.625rem);
  background: var(--wb-surface, #000);
}

.hf-ai-chat .customs-ai-send,
.hf-ai-chat .customs-ai-confirm,
.hf-ai-chat .customs-ai-checkout-pay {
  min-height: 44px;
}

@media (max-width: 767px) {
  /* Safari: stop rubber-band on document so fixed tab bar does not drift */
  html:has(main.container .hf-ai-chat),
  body:has(main.container .hf-ai-chat),
  body.hf-page-ai {
    overflow: hidden;
    overscroll-behavior: none;
    height: 100%;
  }

  /* Lock page scroll — only the message thread scrolls */
  main.container:has(.hf-ai-chat),
  body.hf-page-ai main.container {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: calc(100dvh - var(--hf-topbar-height, 56px));
    max-height: calc(100dvh - var(--hf-topbar-height, 56px));
    padding-bottom: var(--hf-content-pad-bottom, 56px) !important;
    box-sizing: border-box;
  }

  main.container:has(.hf-ai-chat) > .site-wide-renewal-banner,
  main.container:has(.hf-ai-chat) > .account-renewal-banner {
    flex-shrink: 0;
  }

  .customs-page:has(.hf-ai-chat) {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    padding-top: 0.75rem;
    padding-bottom: 0;
    margin: 0;
  }

  .customs-page-inner:has(.hf-ai-chat) {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    max-width: none;
    padding-left: 8px;
    padding-right: 8px;
  }

  .customs-page:has(.hf-ai-chat) .customs-page-header {
    flex-shrink: 0;
    margin-bottom: 0.75rem;
  }

  .hf-ai-chat.customs-form-panel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    padding: 0.75rem;
    border: 1px solid var(--wb-border, rgba(255, 255, 255, 0.22)) !important;
    border-radius: var(--wb-radius, 0.625rem) !important;
    overflow: hidden;
  }

  .hf-ai-chat-layout {
    flex: 1 1 auto;
    min-height: 0;
    gap: 0.35rem;
  }

  .hf-ai-chat .customs-ai-chat-header {
    flex-shrink: 0;
  }

  .hf-ai-chat .customs-ai-thread {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 0;
  }

  .hf-ai-chat-mid {
    flex-shrink: 0;
    max-height: min(28dvh, 240px);
    overflow-y: auto;
  }

  .hf-ai-chat-composer-wrap {
    position: static;
    margin-top: 0;
    background: var(--wb-bg, #000);
  }

  .hf-ai-chat .customs-ai-composer {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    margin-bottom: 0;
  }

  .hf-ai-chat .customs-ai-send {
    width: 100%;
  }
}

@media (min-width: 768px) {
  .customs-page-inner:has(.hf-ai-chat) {
    max-width: 840px;
    margin-left: auto;
    margin-right: auto;
  }

  .hf-ai-chat .customs-ai-thread {
    max-height: min(56vh, 520px);
  }
}
