/* =====================================================================
   Anymacs Chat – readable chat bubbles + clean photo / video messages
   Loaded after the app CSS (index.html). Uses the am-* class hooks added
   in main.66753c9d.am4.js. Remove the <link> in index.html to switch off.
   Contrast (WCAG AA 4.5:1) checked 2026-10-20:
     light: text #111B21 on #E7F6EE 15.6 / on #FFF 17.5, links #0B57D0 5.7 / 6.4,
            time #5B6B75 4.95 / 5.6
     dark:  text #E9EDEF on #005C4B 6.8 / on #202C33 12.1, links #8CD5F5 4.9 / #53BDEB 6.7,
            time #D1D7DB 5.5 / #8696A0 4.7
   Rebrand Phase C (2026-10-20): colours now come from brand/anymacs-tokens.css (Light / Gray / Dark).
   ===================================================================== */

/* ---------- bubble shape ---------- */
.am-bubble-wrap { max-width: 70% !important; }
@media (max-width: 600px) { .am-bubble-wrap { max-width: 85% !important; } }

.am-bubble {
  border-radius: 12px !important;
  padding: 8px 12px 6px !important;
  box-shadow: 0 1px 1px rgba(11, 20, 26, .08) !important;
}
.am-bubble:hover { box-shadow: 0 1px 2px rgba(11, 20, 26, .14) !important; }
.am-bubble .MuiTypography-root { overflow-wrap: anywhere; word-break: break-word; }

/* ---------- light mode ---------- */
.am-bubble.am-light.am-out { background: var(--am-out-bubble) !important; border: 0 !important; }
.am-bubble.am-light.am-in  { background: var(--am-surface) !important; border: 1px solid var(--am-border) !important; }
.am-bubble.am-light,
.am-bubble.am-light .MuiTypography-root { color: var(--am-text) !important; }
.am-bubble.am-light .MuiSvgIcon-root { color: var(--am-muted); }
.am-bubble.am-light > .MuiTypography-caption:first-child { color: var(--am-link) !important; } /* group: sender name */

/* ---------- dark mode ---------- */
.am-bubble.am-dark.am-out { background: var(--am-out-bubble) !important; border: 0 !important; }
.am-bubble.am-dark.am-in  { background: var(--am-surface) !important; border: 1px solid var(--am-border) !important; }
.am-bubble.am-dark,
.am-bubble.am-dark .MuiTypography-root { color: var(--am-text) !important; }
.am-bubble.am-dark .MuiSvgIcon-root { color: var(--am-muted); }
.am-bubble.am-dark > .MuiTypography-caption:first-child { color: var(--am-link) !important; }

/* ---------- links ---------- */
.am-bubble a { color: var(--am-link) !important; text-decoration: underline !important; overflow-wrap: anywhere; word-break: break-word; }
.am-bubble.am-dark.am-in a  { color: var(--am-link) !important; }
.am-bubble.am-dark.am-out a { color: var(--am-link) !important; }

/* ---------- time + ticks ---------- */
.am-meta { justify-content: flex-end !important; gap: 3px !important; }
.am-meta .MuiTypography-root { font-size: 11px !important; opacity: 1 !important; }
.am-bubble.am-light .am-meta .MuiTypography-root,
.am-bubble.am-light .am-meta .MuiSvgIcon-root { color: var(--am-muted) !important; }
.am-bubble.am-dark.am-out .am-meta .MuiTypography-root,
.am-bubble.am-dark.am-out .am-meta .MuiSvgIcon-root { color: var(--am-muted) !important; }
.am-bubble.am-dark.am-in .am-meta .MuiTypography-root,
.am-bubble.am-dark.am-in .am-meta .MuiSvgIcon-root { color: var(--am-muted) !important; }
.am-bubble.am-light .am-meta .am-tick-read { color: var(--am-link) !important; }
.am-bubble.am-dark .am-meta .am-tick-read { color: var(--am-link) !important; }

/* ---------- quoted reply inside a bubble ---------- */
.am-bubble .am-reply { border-radius: 8px !important; padding: 4px 8px !important; }
.am-bubble.am-light .am-reply { background: var(--am-hover) !important; border-left: 3px solid var(--am-accent-fill) !important; }
.am-bubble.am-light .am-reply .MuiTypography-root { color: var(--am-text-2) !important; }
.am-bubble.am-light .am-reply .MuiTypography-root:first-child { color: var(--am-link) !important; }
.am-bubble.am-dark .am-reply { background: var(--am-hover) !important; border-left: 3px solid var(--am-accent-fill) !important; }
.am-bubble.am-dark .am-reply .MuiTypography-root { color: var(--am-muted) !important; }
.am-bubble.am-dark .am-reply .MuiTypography-root:first-child { color: var(--am-link) !important; }

/* ---------- photos + videos: thin bubble, rounded media, time as a pill ---------- */
.am-bubble.am-t-image,
.am-bubble.am-t-video { padding: 3px !important; position: relative; }
.am-media {
  display: block;
  width: auto !important;
  max-width: 320px !important;   /* fixed (not %) so the bubble shrinks to the photo */
  height: auto !important;
  max-height: 420px !important;
  border-radius: 10px !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}
/* phone: about 75% of the chat width, always inside the 85% bubble limit */
@media (max-width: 600px) { .am-media { max-width: calc(72vw - 45px) !important; } }
.am-bubble.am-t-image:not(.am-cap) > .am-meta,
.am-bubble.am-t-video:not(.am-cap) > .am-meta {
  position: absolute; right: 10px; bottom: 10px; margin: 0 !important;
  background: rgba(0, 0, 0, .6); border-radius: 10px; padding: 3px 7px !important; pointer-events: none;
}
/* video: the player controls are at the bottom, so the time pill sits at the top */
.am-bubble.am-t-video:not(.am-cap) > .am-meta { bottom: auto; top: 10px; }
.am-bubble.am-t-image:not(.am-cap) > .am-meta .MuiTypography-root,
.am-bubble.am-t-image:not(.am-cap) > .am-meta .MuiSvgIcon-root,
.am-bubble.am-t-video:not(.am-cap) > .am-meta .MuiTypography-root,
.am-bubble.am-t-video:not(.am-cap) > .am-meta .MuiSvgIcon-root { color: #FFFFFF !important; }
.am-bubble.am-t-image:not(.am-cap) > .am-meta .am-tick-read,
.am-bubble.am-t-video:not(.am-cap) > .am-meta .am-tick-read { color: #8CD5F5 !important; }
/* photo / video with a caption: caption + time under the media */
.am-bubble.am-cap .MuiTypography-caption { padding: 4px 8px 0 !important; font-size: 13.5px !important; line-height: 1.45 !important; }
.am-bubble.am-cap > .am-meta { padding: 0 8px 3px !important; }

/* ---------- stickers: no bubble at all ---------- */
.am-bubble.am-t-sticker { background: transparent !important; border: 0 !important; box-shadow: none !important; padding: 0 !important; }

/* ---------- search: matched part of a chat name / number ---------- */
mark.am-hl { background: rgba(255, 200, 0, .45); color: inherit; border-radius: 3px; padding: 0 1px; }

/* =====================================================================
   Add-ons 2026-10-20: label filter, header label/group menu, group media
   "Download" box, supplier status tag
   ===================================================================== */
.am-lf, .am-ht { position: relative; display: inline-flex; }
.am-lf-btn {
  height: 24px; padding: 0 10px; border-radius: 8px; font: 600 11px/22px inherit; cursor: pointer;
  border: 1px solid var(--am-border); background: transparent; color: var(--am-text-2); max-width: 190px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.am-lf-btn.on { background: var(--am-accent); border-color: var(--am-accent); color: var(--am-on-accent); }
.am-ht-btn {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--am-border); background: transparent;
  cursor: pointer; font-size: 16px; line-height: 32px;
}
.am-ht-btn.on, .am-ht-btn:hover { border-color: var(--am-accent); background: var(--am-green-soft); }
.am-pop {
  position: absolute; z-index: 1400; top: calc(100% + 6px); min-width: 250px; max-width: 320px;
  background: var(--am-surface); color: var(--am-text); border: 1px solid var(--am-border); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(11, 20, 26, .16); padding: 10px; font-size: 13px;
}
.am-lf .am-pop { left: 0; }
.am-ht .am-pop { right: 0; }
.am-pop-h { font-size: 11px; font-weight: 700; color: var(--am-muted); text-transform: uppercase; letter-spacing: .03em; margin: 2px 2px 8px; }
.am-pop-empty { color: var(--am-muted); padding: 4px 2px; }
.am-pop-msg { margin-top: 8px; padding: 6px 8px; border-radius: 8px; background: var(--am-green-soft); color: var(--am-text); font-size: 12px; }
.am-lf-list { max-height: 280px; overflow-y: auto; }
.am-lf-row { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-radius: 8px; cursor: pointer; margin: 0; }
.am-lf-row:hover { background: var(--am-hover); }
.am-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.am-lf-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am-lf-n { font-size: 11px; color: var(--am-muted); font-variant-numeric: tabular-nums; }
.am-link { display: inline-block; margin-top: 8px; border: 0; background: none; color: var(--am-link); font-size: 12px; font-weight: 600; cursor: pointer; text-decoration: underline; padding: 0; }
.am-ht-labels { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.am-chip { border: 1px solid var(--am-border); background: transparent; color: var(--am-text); border-radius: 8px; padding: 3px 9px; font-size: 12px; font-weight: 600; cursor: pointer; }
.am-chip.on { color: #FFFFFF; text-shadow: 0 0 2px rgba(0, 0, 0, .45); }
.am-ht-group { border-top: 1px solid var(--am-border); margin-top: 8px; padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.am-btn { border: 0; border-radius: 9px; padding: 7px 12px; background: var(--am-accent); color: var(--am-on-accent); font-size: 12.5px; font-weight: 600; cursor: pointer; text-align: left; }
.am-btn[disabled] { opacity: .6; cursor: default; }
.am-btn-soft { background: var(--am-green-soft); color: var(--am-link); }
.am-check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin: 2px 0; cursor: pointer; }
.am-dark-ui .am-pop { background: var(--am-surface); color: var(--am-text); border-color: var(--am-border); }
.am-dark-ui .am-pop-h, .am-dark-ui .am-pop-empty, .am-dark-ui .am-lf-n { color: var(--am-muted); }
.am-dark-ui .am-lf-btn { color: var(--am-muted); border-color: var(--am-border); }
.am-dark-ui .am-lf-btn.on { color: var(--am-on-accent); border-color: var(--am-accent); }
.am-dark-ui .am-ht-btn { border-color: var(--am-border); }
.am-dark-ui .am-chip { color: var(--am-text); }
.am-dark-ui .am-link { color: var(--am-link); }
.am-dark-ui .am-ht-group { border-color: var(--am-border); }
.am-dark-ui .am-pop-msg { background: var(--am-green-soft); color: var(--am-text); }

/* supplier status: tag inside the bubble + chip in the chat list */
.am-status-tag {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 8px; margin-bottom: 6px;
  background: var(--am-amber-soft); color: var(--am-amber-text);
}
.am-bubble.am-dark .am-status-tag { background: var(--am-amber-soft); color: var(--am-amber-text); }
.am-chip-status {
  display: inline-flex; align-items: center; padding: 1px 6px; border-radius: 4px; font-size: .58rem; font-weight: 700;
  background: var(--am-amber-soft); color: var(--am-amber-text); border: 1px solid var(--am-amber-text); line-height: 1.4;
}

/* group media not downloaded yet */
.am-dl { display: flex; gap: 10px; align-items: center; padding: 6px; min-width: 220px; flex-wrap: wrap; }
.am-dl-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; filter: blur(1px); flex-shrink: 0; }
.am-dl-icon { width: 64px; height: 64px; border-radius: 8px; background: var(--am-hover); display: flex; align-items: center; justify-content: center; font-size: 28px; flex-shrink: 0; }
.am-bubble.am-dark .am-dl-icon { background: var(--am-hover); }
.am-dl-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.am-dl-kind { font-size: 12.5px; font-weight: 600; overflow-wrap: anywhere; }
.am-dl-gone { font-size: 12.5px; font-style: italic; opacity: .85; }
.am-dl-cap { flex-basis: 100%; font-size: 13.5px; padding: 0 2px; }
.am-dl-doc { font-weight: 600; }
