/* WATranslate v4.3 — compact WhatsApp-style conversation UI
   Mobile only. Desktop keeps the existing full original + translation layout.
*/

.mobile-message-content {
  display: none;
}

@media (max-width: 760px) {
  .desktop-message-content {
    display: none;
  }

  .mobile-message-content {
    display: block;
  }

  /* Conversation header */
  .chat-header {
    min-height: calc(58px + env(safe-area-inset-top));
    padding-bottom: 4px;
  }

  .mobile-back-button {
    width: 32px;
    flex-basis: 32px;
    height: 42px;
    font-size: 34px;
  }

  .chat-header-avatar {
    width: 38px;
    height: 38px;
  }

  .chat-header-contact strong {
    font-size: 17px;
    line-height: 1.15;
  }

  .chat-header-contact span {
    margin-top: 1px;
    font-size: 11px;
  }

  /* Messages */
  .messages {
    padding:
      9px
      max(8px, env(safe-area-inset-right))
      10px
      max(8px, env(safe-area-inset-left));
    background-color: #0b141a;
    background-image:
      radial-gradient(circle at 18px 18px, rgba(255,255,255,.018) 1px, transparent 1.2px);
    background-size: 34px 34px;
  }

  .message {
    box-sizing: border-box;
    width: fit-content;
    max-width: 86%;
    margin: 3px 0 5px;
    padding: 6px 8px 5px;
    border-radius: 9px;
    font-size: 15px;
    line-height: 1.3;
  }

  .message.in {
    background: #202c33;
    border-top-left-radius: 3px;
  }

  .message.out {
    background: #005c4b;
    border-top-right-radius: 3px;
  }

  .mobile-message-route {
    margin-bottom: 3px;
    color: #53bdeb;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.15;
  }

  .message.out .mobile-message-route {
    color: #80d7c3;
  }

  .mobile-primary-text,
  .mobile-secondary-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  .mobile-primary-text {
    color: #e9edef;
    font-size: 15.5px;
    line-height: 1.34;
  }

  .mobile-message-toggle {
    display: inline-block;
    margin: 5px 0 1px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #8db8ca;
    font-size: 10.5px;
    text-decoration: none;
    cursor: pointer;
  }

  .message.out .mobile-message-toggle {
    color: #a7ddcf;
  }

  .mobile-message-secondary {
    margin-top: 5px;
    padding: 6px 7px;
    border-left: 2px solid rgba(124,215,194,.52);
    border-radius: 4px;
    background: rgba(0,0,0,.11);
  }

  .mobile-secondary-label {
    margin-bottom: 2px;
    color: #9fb0b8;
    font-size: 9.5px;
    font-weight: 700;
  }

  .mobile-secondary-text {
    color: #cbd5d9;
    font-size: 12.5px;
    line-height: 1.3;
  }

  .mobile-message-footer {
    display: flex;
    min-height: 15px;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 3px;
  }

  .mobile-message-meta {
    margin-left: auto;
    color: #92a3ab;
    font-size: 9px;
    line-height: 1.1;
    white-space: nowrap;
  }

  .message.out .mobile-message-meta {
    color: #9fc5ba;
  }

  .mobile-reply-language {
    max-width: 145px;
    padding: 2px 0;
    border: 0;
    background: transparent;
    color: #8db8ca;
    font-size: 10px;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-reply-language:active {
    opacity: .65;
  }

  .translation-error {
    margin-top: 4px;
    font-size: 10px;
  }

  /* WhatsApp-like compact composer */
  .composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    column-gap: 7px;
    row-gap: 0;
    max-height: 54dvh;
    padding:
      8px
      max(9px, env(safe-area-inset-right))
      calc(8px + env(safe-area-inset-bottom))
      max(9px, env(safe-area-inset-left));
    background: #202c33;
  }

  .composer > label:first-child {
    display: none;
  }

  #replyText {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    height: 48px;
    min-height: 48px;
    max-height: 104px;
    padding: 12px 14px;
    border: 0;
    border-radius: 24px;
    background: #2a3942;
    font-size: 16px;
    line-height: 1.25;
  }

  .composer > .composer-actions:first-of-type {
    grid-column: 2;
    grid-row: 1;
    align-self: stretch;
    display: flex;
    margin: 0;
  }

  #translateButton {
    width: auto;
    min-width: 104px;
    height: 48px;
    min-height: 48px;
    padding: 0 15px;
    border-radius: 24px;
    background: #00a884;
    font-size: 14px;
    white-space: nowrap;
  }

  .preview {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-top: 8px;
    padding: 9px;
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 12px;
    background: #111b21;
  }

  .preview label {
    margin: 0 0 5px;
    color: #9fb0b8;
    font-size: 10px;
  }

  #translatedPreview {
    min-height: 54px;
    max-height: 100px;
    padding: 9px 10px;
    border: 0;
    border-radius: 9px;
    background: #202c33;
    font-size: 15px;
  }

  .preview .composer-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 7px;
    margin-top: 7px;
  }

  .preview .composer-actions button {
    min-height: 40px;
    border-radius: 20px;
    padding: 8px 14px;
  }

  .preview small {
    display: none;
  }

  .status {
    grid-column: 1 / -1;
    min-height: 0;
    margin-top: 4px;
    font-size: 10px;
    line-height: 1.2;
  }

  .status:empty {
    display: none;
  }
}

@media (max-width: 390px) {
  .message {
    max-width: 90%;
  }

  .mobile-primary-text {
    font-size: 14.5px;
  }

  #translateButton {
    min-width: 92px;
    padding-left: 12px;
    padding-right: 12px;
    font-size: 13px;
  }
}
