/* gsm-chat2 custom layer (DESIGN-UI §0): the ~20% Bootstrap can't do —
   app-shell grid, chat bubbles, unread styling, pane transitions. */

html, body { height: 100%; overflow: hidden; }

/* ---------- shell: 2 panes desktop/tablet / 1 pane + tabs mobile ---------- */
.gsm-shell {
  display: grid;
  height: 100%; /* same box as html/body (overflow hidden), so the bottom rows can never be clipped; 100dvh was unreliable in some browsers */
  /* Android app (TWA) draws edge-to-edge: keep the bottom nav / composer above the system navigation bar (0 elsewhere) */
  padding-bottom: env(safe-area-inset-bottom);
  grid-template-columns: 300px minmax(0, 1fr);
  grid-template-rows: 1fr auto;
}
#paneA, #paneB, #paneC { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#paneA { grid-column: 1; border-right: 1px solid var(--bs-border-color); }
#paneB { grid-column: 2; border-right: 1px solid var(--bs-border-color); }
#paneC { grid-column: 2; display: none; }
#bottomNav { display: none; grid-row: 2; grid-column: 1 / -1; background: var(--bs-body-bg); }

/* two panes: conversation replaces the list */
@media (min-width: 768px) {
  .gsm-shell.conv-open #paneB { display: none; }
  .gsm-shell.conv-open #paneC { display: flex; animation: slide-in .2s ease-out; }
}

/* single pane + thumb-reach tabs */
@media (max-width: 767.98px) {
  .gsm-shell { grid-template-columns: 1fr; }
  #paneA, #paneB, #paneC { grid-column: 1; display: none; border-right: 0; }
  #bottomNav { display: flex; }
  .gsm-shell.show-a #paneA { display: flex; }
  .gsm-shell.show-b #paneB { display: flex; }
  .gsm-shell.conv-open #paneA, .gsm-shell.conv-open #paneB { display: none; }
  .gsm-shell.conv-open #paneC { display: flex; animation: slide-in .2s ease-out; }
}

@keyframes slide-in { from { transform: translateX(30%); opacity: .3; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- icons (flat svg buttons, see public/assets/icons.svg) ---------- */
.icon { width: 1em; height: 1em; vertical-align: -0.125em; flex-shrink: 0; }

/* ---------- rows ---------- */
.row-unread { font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%;
       background: var(--bs-primary); flex-shrink: 0; }
.av { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; object-fit: cover; }
.snippet { color: var(--bs-secondary-color); font-size: .85rem; }
.chip { font-size: .7rem; }
.kb-active { outline: 2px solid var(--bs-primary); outline-offset: -2px; }

/* ---------- conversation ---------- */
.msg { display: flex; margin-bottom: .35rem; }
.msg.mine { justify-content: flex-end; }
.av-sm { width: 24px; height: 24px; align-self: flex-end; margin-right: .35rem; }
.av-lg { width: 96px; height: 96px; }
.msg-bubble {
  max-width: 75%; padding: .4rem .65rem; border-radius: 1rem;
  background: var(--bs-secondary-bg); white-space: pre-wrap; word-break: break-word;
}
.msg.mine .msg-bubble { background: var(--bs-primary); color: #fff; border-bottom-right-radius: .25rem; }
.msg:not(.mine) .msg-bubble { border-bottom-left-radius: .25rem; }
.msg-meta { font-size: .68rem; text-align: right; white-space: nowrap; margin-top: .15rem; opacity: .8; }
.msg:not(.mine) .msg-meta { color: var(--bs-secondary-color); }
.msg.mine .msg-meta { color: rgba(255, 255, 255, .85); }
.msg-deleted { font-style: italic; opacity: .6; }
.msg-img { max-width: 200px; max-height: 200px; border-radius: .5rem; cursor: pointer; display: block; }
.msg-actions { visibility: hidden; align-self: center; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions, .msg.tapped .msg-actions { visibility: visible; }
.reaction-slot { align-self: center; }
.ticks { font-size: .7rem; }
.ticks.read { color: #4fc3f7; }

/* ---------- pending image attachments (composer preview strip) ---------- */
.image-preview-item { position: relative; width: 56px; height: 56px; }
.image-preview-item img { width: 100%; height: 100%; object-fit: cover; border-radius: .375rem; display: block; }
.image-preview-remove {
  position: absolute; top: -.4rem; right: -.4rem; width: 1.1rem; height: 1.1rem;
  background-color: #fff; background-size: .6rem; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, .15);
}

/* ---------- image gallery lightbox ---------- */
.gallery-img { max-width: 100%; max-height: 90vh; object-fit: contain; }
.gallery-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  color: #fff; font-size: 1.5rem; padding: .5rem .75rem; z-index: 1;
}
.gallery-nav .icon { width: 1.5em; height: 1.5em; }
.gallery-nav-prev { left: .5rem; }
.gallery-nav-next { right: .5rem; }
.gallery-nav:disabled { opacity: .25; }
.icon-flip { transform: scaleX(-1); }

.unread-divider {
  display: flex; align-items: center; gap: .5rem; margin: .75rem 0;
  color: var(--bs-danger); font-size: .75rem; text-transform: uppercase;
}
.unread-divider::before, .unread-divider::after {
  content: ""; flex: 1; border-top: 1px solid var(--bs-danger);
}

.msg.hl .msg-bubble { animation: hl-fade 1.5s ease-out; }
.gallery-tile.hl { animation: hl-fade 1.5s ease-out; }
@keyframes hl-fade { from { box-shadow: 0 0 0 3px var(--bs-warning); } to { box-shadow: none; } }

/* ---------- grouped image "little gallery" bubble (consecutive bare images) ---------- */
.gallery-bubble { padding: .25rem; }
.gallery-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .2rem; width: 220px; }
/* clipping lives on the <img>/overlay, not .gallery-tile itself — the tile
   stays unclipped so the reaction dropdown-menu can pop out past its bounds */
.gallery-tile { position: relative; aspect-ratio: 1; cursor: pointer; }
.gallery-tile img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: .4rem; }
.gallery-more-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .55); color: #fff; font-weight: 600; font-size: 1.1rem; pointer-events: none;
  border-radius: .4rem;
}
.gallery-tile-remove {
  position: absolute; top: .2rem; right: .2rem; width: 1.3rem; height: 1.3rem; padding: 0;
  border: none; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; line-height: 1;
}
.gallery-tile-remove .icon { width: .7em; height: .7em; }
.gallery-tile-reply {
  position: absolute; top: .2rem; left: .2rem; width: 1.3rem; height: 1.3rem; padding: 0;
  border: none; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; line-height: 1;
}
.gallery-tile-reply .icon { width: .7em; height: .7em; }
.gallery-tile-react { position: absolute; bottom: .2rem; left: .2rem; }
.gallery-tile-react .reaction-toggle {
  background: rgba(0, 0, 0, .55); border-radius: 1rem; padding: .15rem .35rem;
}
.gallery-tile-react .reaction-toggle.empty { border-color: transparent; color: #fff; }

.msg-quote {
  border-left: 3px solid currentColor; opacity: .8; cursor: pointer;
  padding: .1rem .4rem; margin-bottom: .25rem; font-size: .8rem;
  border-radius: .2rem; overflow-wrap: break-word;
}
.msg:not(.mine) .msg-quote { background: rgba(0, 0, 0, .05); }

.reaction-toggle {
  display: inline-flex; align-items: center; gap: .25rem; border: none; background: transparent;
  padding: 0; transition: transform .1s ease-out;
}
.reaction-toggle:hover { transform: scale(1.06); }
.reaction-toggle.empty {
  border: 1px solid var(--bs-border-color); border-radius: 50%; color: var(--bs-secondary-color);
  padding: .3rem; opacity: .7;
}
.reaction-toggle.empty:hover { opacity: 1; }
.reaction-toggle.empty .icon { width: .85em; height: .85em; }
.reaction-pill {
  display: inline-flex; align-items: center; gap: .2rem; font-size: .8rem;
  border: 1.5px solid transparent; border-radius: 1rem; padding: .05rem .5rem;
  color: #1a1a1a; line-height: 1.4rem; font-weight: 600;
}
.reaction-pill.mine { border-width: 2px; }
.reaction-menu { min-width: auto; }
.reaction-menu.show { display: flex; gap: .25rem; }
.reaction-choice {
  border: none; background: transparent; font-size: 1.4rem; line-height: 1;
  padding: .3rem; border-radius: 50%; transition: transform .12s ease-out, background-color .12s;
}
.reaction-choice:hover, .reaction-choice:focus-visible {
  background: color-mix(in srgb, var(--accent) 25%, transparent);
  transform: scale(1.25);
}

#msgText { resize: none; max-height: 8rem; padding-right: 1.9rem; }
.recip-results { z-index: 1060; max-height: 40vh; overflow-y: auto; }
#composer .dropdown-menu { max-width: 90vw; }
.quick-item { white-space: normal; }

/* ponytail: WebKit-only pseudo-elements, no standard attribute hides just the
   volume slider on native <audio controls>; Firefox keeps its slider. */
#msgList audio::-webkit-media-controls-volume-slider,
#msgList audio::-webkit-media-controls-mute-button { display: none !important; }

#composerSettings { position: absolute; top: 2px; right: 2px; }
#composerSettingsBtn { width: 22px; height: 22px; line-height: 1; border: 0; background: transparent; color: var(--bs-body-color); opacity: 0; pointer-events: none; transition: opacity .15s; }
#composerSettings.show #composerSettingsBtn,
#msgTextWrap:focus-within #composerSettingsBtn { opacity: 1; pointer-events: auto; }
#composerSettingsBtn:hover, #composerSettingsBtn:focus { opacity: 1; }
#composerSettingsBtn .icon { width: 14px; height: 14px; }

/* Chat-area link/embed markup, server-rendered by Gsm\LinkFormat. */
.msg-text { overflow-wrap: anywhere; }
.msg-text a { color: inherit; text-decoration: underline; }

/* A bubble holding an embed grows past the 75% text cap so video is actually
   watchable, and shrinks to the viewport on mobile. Browsers without :has()
   fall back to the 75% cap — still usable, just narrower. */
.msg-bubble:has(.msg-embed) { width: 100%; max-width: min(600px, 92vw); }
.msg-embed { margin-top: .4rem; border: 0; border-radius: 8px; display: block; overflow: hidden; }
iframe.msg-embed { width: 100%; }
.msg-embed.msg-embed-portrait { max-width: 340px; }   /* TikTok is vertical */
