/* WhatsApp-like media compose: gallery preview lifts the textbox on mobile/WebView */

@media (max-width: 900px) {
  body.wa-media-composing {
    overscroll-behavior: none;
  }

  body.wa-media-composing .giantpulse-main .message-input,
  body.wa-media-composing .giantpulse-container .giantpulse-main .message-input {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    border-radius: 16px 16px 0 0 !important;
    padding: 0 !important;
    z-index: 1200 !important;
    background: #fff !important;
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.18) !important;
    display: flex !important;
    flex-direction: column !important;
    max-height: min(72vh, 560px) !important;
  }

  body.wa-media-composing .message-input .file-previews-container {
    order: 1;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 16px 16px 0 0 !important;
    background: #0b0b0b !important;
    padding: 10px 10px 8px !important;
    flex: 1 1 auto;
    min-height: 210px;
    max-height: 48vh;
    display: flex !important;
    flex-direction: column !important;
  }

  body.wa-media-composing .message-input .file-previews-container > .d-flex.justify-content-between {
    color: #fff !important;
    margin-bottom: 8px !important;
  }

  body.wa-media-composing .message-input .file-previews-container > .d-flex.justify-content-between .small,
  body.wa-media-composing .message-input .file-previews-container > .d-flex.justify-content-between span {
    color: #f2f2f2 !important;
  }

  body.wa-media-composing .message-input .file-previews-container .btn-link {
    color: #ffb4b4 !important;
  }

  body.wa-media-composing .message-input .file-previews-container-content {
    display: flex !important;
    flex-direction: row !important;
    gap: 10px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    max-height: none !important;
    padding-bottom: 4px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  body.wa-media-composing .message-input .file-preview-item {
    flex: 0 0 auto !important;
    width: min(78vw, 320px) !important;
    height: 210px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 14px !important;
    overflow: hidden !important;
    background: #1a1a1a !important;
    position: relative !important;
    scroll-snap-align: center;
    display: block !important;
  }

  body.wa-media-composing .message-input .file-preview-item img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    background: #111 !important;
    border-radius: 14px !important;
  }

  body.wa-media-composing .message-input .file-preview-item .flex-grow-1,
  body.wa-media-composing .message-input .file-preview-item .file-preview-item-content {
    display: none !important;
  }

  body.wa-media-composing .message-input .file-preview-item > button,
  body.wa-media-composing .message-input .file-preview-item .btn-link {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    z-index: 2 !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    background: rgba(0, 0, 0, 0.55) !important;
    color: #fff !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Textbox row sits under gallery (shifted up from nav / keyboard) */
  body.wa-media-composing .message-input form.emojis-main,
  body.wa-media-composing .message-input .emojis-main.wrap {
    order: 2 !important;
    width: 100% !important;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    background: #fff !important;
    border-top: 1px solid #ececec !important;
    gap: 8px !important;
  }

  body.wa-media-composing .message-input textarea.setemoj,
  body.wa-media-composing .message-input .setemoj {
    background: #f0f2f5 !important;
    border-radius: 22px !important;
    min-height: 44px !important;
    font-size: 16px !important;
  }

  body.wa-media-composing .contact-chat {
    padding-bottom: min(78vh, 620px) !important;
  }

  /* Dim chat behind media composer */
  body.wa-media-composing .contact-chat::after {
    content: "";
    position: fixed;
    inset: 0 0 0 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1100;
    pointer-events: none;
  }
}

body.dark.wa-media-composing .giantpulse-main .message-input,
body.dark.wa-media-composing .message-input form.emojis-main {
  background: #1a1d1f !important;
}

body.dark.wa-media-composing .message-input textarea.setemoj {
  background: #2a2e31 !important;
  color: #fff !important;
}
