/* =========================================================
   Força Aliada Chat — social-chat.css  v3.0
   Inspired by WhatsApp · Telegram · Discord · MSN
   Dark-first, polished, fast, accessible
   ========================================================= */

/* ── TOKEN SYSTEM ── */
#fa-chat-root {
  /* Surfaces */
  --fc-bg:         #0e0e0c;
  --fc-panel:      #141412;
  --fc-header:     #181816;
  --fc-surface:    #1c1c19;
  --fc-surface-2:  #232320;
  --fc-border:     rgba(201,168,76,.13);
  --fc-border-h:   rgba(201,168,76,.28);

  /* Text */
  --fc-ink:        #f0ede6;
  --fc-ink-2:      #c0bbaf;
  --fc-ink-3:      #7a756a;

  /* Accent */
  --fc-gold:       #c9a84c;
  --fc-gold-dark:  #a8872e;
  --fc-gold-glow:  rgba(201,168,76,.18);
  --fc-green:      #3dba5f;
  --fc-red:        #ff5f52;

  /* Bubbles */
  --fc-bub-me:       #c9a84c;
  --fc-bub-me-text:  #0e0d09;
  --fc-bub-them:     #1f1f1c;
  --fc-bub-them-text:#f0ede6;

  /* Effects */
  --fc-shadow:    0 32px 96px rgba(0,0,0,.82), 0 4px 20px rgba(0,0,0,.4);
  --fc-ease:      cubic-bezier(0.22, 1, 0.36, 1);
  --fc-spring:    cubic-bezier(0.34, 1.56, 0.64, 1);
  --fc-r:         22px;
  --fc-r-sm:      14px;

  /* FAB offset vars */
  --fa-chat-fab-right: 24px;
  --fa-chat-fab-width: 112px;
  --fa-chat-fab-bottom: 24px;
  --fa-chat-fab-gap:    10px;

  font-family: inherit;
  position: relative;
  z-index: 800;
  color: var(--fc-ink);
}

/* Light theme overrides */
[data-theme="light"] #fa-chat-root {
  --fc-bg:         #f5f0e8;
  --fc-panel:      #fdfcf9;
  --fc-header:     #f8f5ef;
  --fc-surface:    #ede8dd;
  --fc-surface-2:  #e4ddd0;
  --fc-border:     rgba(93,73,31,.15);
  --fc-border-h:   rgba(93,73,31,.30);
  --fc-ink:        #1a1710;
  --fc-ink-2:      #5a5448;
  --fc-ink-3:      #9e9588;
  --fc-gold:       #9b7a2d;
  --fc-gold-dark:  #7a5f1e;
  --fc-gold-glow:  rgba(155,122,45,.14);
  --fc-green:      #1e8c45;
  --fc-red:        #d93025;
  --fc-bub-me:       #9b7a2d;
  --fc-bub-me-text:  #fff;
  --fc-bub-them:     #ede8dd;
  --fc-bub-them-text:#1a1710;
  --fc-shadow:    0 20px 60px rgba(31,24,12,.18), 0 4px 14px rgba(31,24,12,.09);
}

/* ═══════════════════════════════════════════════
   LAUNCHER FAB
═══════════════════════════════════════════════ */
.fa-chat-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 1.5px solid rgba(201,168,76,.35);
  border-radius: 17px;
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,.26), transparent 20px),
    linear-gradient(145deg, var(--fc-gold), var(--fc-gold-dark));
  color: #0e0d09;
  cursor: pointer;
  box-shadow:
    0 6px 20px var(--fc-gold-glow),
    0 2px 6px rgba(0,0,0,.22),
    inset 0 1px 0 rgba(255,255,255,.20);
  transition:
    transform .2s var(--fc-spring),
    box-shadow .2s ease;
}

.fa-chat-launcher:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow:
    0 12px 32px var(--fc-gold-glow),
    0 3px 10px rgba(0,0,0,.25),
    inset 0 1px 0 rgba(255,255,255,.22);
}

.fa-chat-launcher:active { transform: scale(.94); }
.fa-chat-launcher svg { width: 22px; height: 22px; }

/* Offset when FAB is present */
.fa-chat-has-fab .fa-chat-launcher {
  right: calc(var(--fa-chat-fab-right) + var(--fa-chat-fab-width) + var(--fa-chat-fab-gap));
  bottom: var(--fa-chat-fab-bottom);
}

/* ── Unread Badge ── */
.fa-chat-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  padding: 0 5px;
  border-radius: 999px;
  border: 2.5px solid var(--fc-panel);
  background: var(--fc-red);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: -.01em;
  animation: fcBadgePop .32s var(--fc-spring) both;
}

@keyframes fcBadgePop {
  from { transform: scale(0) rotate(-12deg); }
  to   { transform: scale(1) rotate(0deg); }
}

/* ═══════════════════════════════════════════════
   PANEL
═══════════════════════════════════════════════ */
.fa-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 86px;
  width: min(400px, calc(100vw - 28px));
  height: min(640px, calc(100vh - 112px));
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
  overflow: hidden;
  border: 1px solid var(--fc-border);
  border-radius: var(--fc-r);
  background: var(--fc-panel);
  box-shadow: var(--fc-shadow);

  /* Closed state */
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(.96);
  transform-origin: bottom right;
  transition:
    opacity .2s var(--fc-ease),
    transform .26s var(--fc-spring),
    visibility 0s linear .2s;
}

.fa-chat-panel.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition:
    opacity .2s var(--fc-ease),
    transform .26s var(--fc-spring),
    visibility 0s linear 0s;
}

/* Thin scrollbars */
.fa-chat-list::-webkit-scrollbar,
.fa-chat-messages::-webkit-scrollbar,
.fa-chat-member-list::-webkit-scrollbar {
  width: 3px;
}
.fa-chat-list::-webkit-scrollbar-track,
.fa-chat-messages::-webkit-scrollbar-track,
.fa-chat-member-list::-webkit-scrollbar-track { background: transparent; }
.fa-chat-list::-webkit-scrollbar-thumb,
.fa-chat-messages::-webkit-scrollbar-thumb,
.fa-chat-member-list::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 999px;
}
.fa-chat-list:hover::-webkit-scrollbar-thumb,
.fa-chat-messages:hover::-webkit-scrollbar-thumb,
.fa-chat-member-list:hover::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--fc-ink) 18%, transparent);
}

/* ═══════════════════════════════════════════════
   PANEL HEADER  (top bar + peer bar)
═══════════════════════════════════════════════ */
.fa-chat-top {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--fc-border);
  background: var(--fc-header);
}

/* Subtle gold shimmer line at top */
.fa-chat-top::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--fc-gold), transparent);
  opacity: .55;
  border-radius: var(--fc-r) var(--fc-r) 0 0;
  pointer-events: none;
}

.fa-chat-panel { position: fixed; }
.fa-chat-panel { overflow: hidden; }

.fa-chat-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.fa-chat-title strong {
  display: block;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--fc-ink);
}

.fa-chat-title span {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--fc-ink-3);
  line-height: 1.2;
  margin-top: 1px;
}

/* The chat icon in header */
.fa-chat-title .fa-chat-peer-av {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--fc-gold-glow);
  color: var(--fc-gold);
  border: 1px solid var(--fc-border);
  flex: 0 0 auto;
}

.fa-chat-title .fa-chat-peer-av svg { width: 18px; height: 18px; }

/* ═══════════════════════════════════════════════
   ICON BUTTONS
═══════════════════════════════════════════════ */
.fa-chat-icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--fc-border);
  border-radius: 10px;
  background: var(--fc-surface);
  color: var(--fc-ink-3);
  cursor: pointer;
  flex: 0 0 auto;
  transition: color .13s, background .13s, border-color .13s;
}

.fa-chat-icon-btn:hover {
  color: var(--fc-gold);
  background: var(--fc-surface-2);
  border-color: var(--fc-border-h);
}

.fa-chat-icon-btn:active { transform: scale(.92); }
.fa-chat-icon-btn svg { width: 15px; height: 15px; }

/* ═══════════════════════════════════════════════
   TABS
═══════════════════════════════════════════════ */
.fa-chat-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 5px;
  padding: 10px 10px 0;
}

.fa-chat-tab {
  height: 32px;
  border: 1px solid var(--fc-border);
  border-radius: 9px;
  background: var(--fc-surface);
  color: var(--fc-ink-3);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .01em;
  cursor: pointer;
  transition: color .13s, background .13s, border-color .13s;
}

.fa-chat-tab.is-active {
  background: color-mix(in srgb, var(--fc-gold) 14%, var(--fc-surface));
  border-color: color-mix(in srgb, var(--fc-gold) 50%, var(--fc-border));
  color: var(--fc-gold);
  box-shadow: 0 2px 8px var(--fc-gold-glow);
}

.fa-chat-tab:hover:not(.is-active) {
  background: var(--fc-surface-2);
  color: var(--fc-ink-2);
  border-color: var(--fc-border-h);
}

/* Thin accent line under active tab */
.fa-chat-tab.is-active::after {
  content: '';
  display: block;
  height: 2px;
  background: var(--fc-gold);
  border-radius: 999px;
  margin-top: -1px;
}

/* ═══════════════════════════════════════════════
   BODY / LIST AREA
═══════════════════════════════════════════════ */
.fa-chat-body {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(0,1fr);
}

/* Search input */
.fa-chat-search { padding: 8px 10px; }

.fa-chat-search input {
  width: 100%;
  height: 34px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--fc-border);
  border-radius: 999px;
  outline: none;
  background: var(--fc-surface);
  color: var(--fc-ink);
  font: inherit;
  font-size: 12.5px;
  transition: border-color .13s, box-shadow .13s;
  /* search icon via background */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a756a' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
  background-size: 14px;
}

.fa-chat-search input:focus {
  border-color: color-mix(in srgb, var(--fc-gold) 55%, var(--fc-border));
  box-shadow: 0 0 0 3px var(--fc-gold-glow);
  background-color: var(--fc-surface-2);
}

.fa-chat-list,
.fa-chat-messages {
  min-height: 0;
  overflow-y: auto;
  padding: 6px 7px 10px;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.fa-chat-list:hover,
.fa-chat-messages:hover {
  scrollbar-color: color-mix(in srgb, var(--fc-ink) 14%, transparent) transparent;
}

/* ── Conversation / Friend rows ── */
.fa-chat-row,
.fa-chat-friend {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  position: relative;
}

.fa-chat-row:hover,
.fa-chat-friend:hover {
  border-color: var(--fc-border);
  background: var(--fc-surface);
}

/* Active/pressed effect */
.fa-chat-row:active,
.fa-chat-friend:active {
  transform: scale(.985);
  background: var(--fc-surface-2);
}

.fa-chat-row.is-unread::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  border-radius: 999px;
  background: var(--fc-gold);
}

.fa-chat-row.is-unread strong { color: var(--fc-gold); }

.fa-chat-row-meta,
.fa-chat-friend-meta { min-width: 0; }

.fa-chat-row strong,
.fa-chat-friend strong {
  display: block;
  overflow: hidden;
  color: var(--fc-ink);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fa-chat-row small,
.fa-chat-friend small {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: var(--fc-ink-3);
  font-size: 11.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fa-chat-row > small {
  color: var(--fc-ink-3);
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════
   AVATAR SYSTEM
═══════════════════════════════════════════════ */
.fa-chat-av-wrap {
  position: relative;
  flex: 0 0 auto;
  display: inline-block;
  line-height: 0;
}

/* Online dot */
.fa-chat-online-dot {
  position: absolute;
  bottom: -1px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--fc-green);
  border: 2px solid var(--fc-panel);
  animation: fcPulse 2.8s ease-in-out infinite;
}

.fa-chat-online-dot--peer {
  width: 11px; height: 11px;
  bottom: -2px; right: -2px;
}

@keyframes fcPulse {
  0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--fc-green) 30%, transparent); }
  50%      { box-shadow: 0 0 0 4px color-mix(in srgb, var(--fc-green) 10%, transparent); }
}

.fa-chat-peer-av,
.fa-chat-row img,
.fa-chat-friend img,
.fa-chat-av-wrap img {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 10px;
  object-fit: cover;
  background: var(--fc-surface);
  border: 1px solid var(--fc-border);
}

.fa-chat-group-av {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--fc-border);
  border-radius: 12px;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--fc-gold) 14%, var(--fc-surface)),
    color-mix(in srgb, var(--fc-green) 10%, var(--fc-surface)));
  color: var(--fc-gold);
}

.fa-chat-group-av svg { width: 18px; height: 18px; }

/* ═══════════════════════════════════════════════
   GROUP CREATOR
═══════════════════════════════════════════════ */
.fa-chat-new-group {
  width: calc(100% - 8px);
  min-height: 56px;
  display: grid;
  grid-template-columns: 40px minmax(0,1fr);
  gap: 10px;
  align-items: center;
  margin: 0 4px 4px;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--fc-gold) 22%, var(--fc-border));
  border-radius: 14px;
  background: color-mix(in srgb, var(--fc-gold) 7%, var(--fc-surface));
  color: var(--fc-ink);
  cursor: pointer;
  text-align: left;
  transition: background .13s, border-color .13s;
}

.fa-chat-new-group:hover {
  background: color-mix(in srgb, var(--fc-gold) 12%, var(--fc-surface));
  border-color: color-mix(in srgb, var(--fc-gold) 38%, var(--fc-border));
}

.fa-chat-new-group > span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  grid-row: 1 / span 2;
  border-radius: 12px;
  background: var(--fc-gold);
  color: #0e0d09;
}

.fa-chat-new-group svg { width: 17px; height: 17px; }
.fa-chat-new-group strong, .fa-chat-new-group small { grid-column: 2; }

.fa-chat-new-group strong {
  align-self: end;
  font-size: 13px;
  font-weight: 900;
  color: var(--fc-ink);
}

.fa-chat-new-group small {
  align-self: start;
  color: var(--fc-ink-3);
  font-size: 11.5px;
  font-weight: 650;
}

.fa-chat-group-maker {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto auto auto minmax(0,1fr) auto;
  gap: 8px;
  padding: 4px 6px 6px;
}

.fa-chat-maker-head {
  display: grid;
  grid-template-columns: 34px minmax(0,1fr);
  gap: 9px;
  align-items: center;
  padding: 4px 2px;
}

.fa-chat-maker-head strong {
  display: block;
  font-size: 13px;
  font-weight: 900;
}

.fa-chat-maker-head small {
  color: var(--fc-ink-3);
  font-size: 11.5px;
  font-weight: 650;
}

.fa-chat-group-name {
  width: 100%;
  height: 38px;
  padding: 0 13px;
  border: 1px solid var(--fc-border);
  border-radius: 999px;
  outline: none;
  background: var(--fc-surface);
  color: var(--fc-ink);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  transition: border-color .13s, box-shadow .13s;
}

.fa-chat-group-name:focus {
  border-color: color-mix(in srgb, var(--fc-gold) 55%, var(--fc-border));
  box-shadow: 0 0 0 3px var(--fc-gold-glow);
}

.fa-chat-selected {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  padding: 0 2px;
}

.fa-chat-selected span {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--fc-gold) 14%, var(--fc-surface));
  color: var(--fc-gold);
  font-size: 11px;
  font-weight: 850;
  border: 1px solid var(--fc-border-h);
}

.fa-chat-selected small { color: var(--fc-ink-3); font-size: 11.5px; }

.fa-chat-member-list {
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.fa-chat-member-list:hover {
  scrollbar-color: color-mix(in srgb, var(--fc-ink) 14%, transparent) transparent;
}

.fa-chat-member {
  width: 100%;
  display: grid;
  grid-template-columns: 40px minmax(0,1fr) 26px;
  gap: 9px;
  align-items: center;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: background .12s, border-color .12s;
}

.fa-chat-member:hover,
.fa-chat-member.is-selected {
  border-color: color-mix(in srgb, var(--fc-gold) 24%, var(--fc-border));
  background: color-mix(in srgb, var(--fc-gold) 7%, var(--fc-surface));
}

.fa-chat-member img {
  width: 38px; height: 38px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--fc-border);
}

.fa-chat-member strong, .fa-chat-member small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fa-chat-member strong { font-size: 13px; font-weight: 800; }

.fa-chat-member small {
  margin-top: 2px;
  color: var(--fc-ink-3);
  font-size: 11.5px;
}

.fa-chat-member i {
  width: 24px; height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--fc-surface-2);
  color: var(--fc-ink-3);
  font-style: normal;
  font-size: 13px;
  font-weight: 900;
  border: 1px solid var(--fc-border);
}

.fa-chat-member.is-selected i {
  background: var(--fc-gold);
  color: #0e0d09;
  border-color: var(--fc-gold);
}

.fa-chat-create {
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--fc-gold), var(--fc-gold-dark));
  color: #0e0d09;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  transition: opacity .13s, transform .13s;
  box-shadow: 0 4px 14px var(--fc-gold-glow);
}

.fa-chat-create:hover:not(:disabled) { opacity: .88; transform: scale(1.02); }
.fa-chat-create:active:not(:disabled) { transform: scale(.97); }
.fa-chat-create:disabled { cursor: not-allowed; opacity: .38; }

/* ═══════════════════════════════════════════════
   PILLS & STATUS
═══════════════════════════════════════════════ */
.fa-chat-pill {
  min-width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--fc-gold);
  color: #0e0d09;
  font-size: 10px;
  font-weight: 900;
  flex: 0 0 auto;
}

/* ═══════════════════════════════════════════════
   EMPTY / ERROR STATES
═══════════════════════════════════════════════ */
.fa-chat-empty {
  padding: 32px 18px;
  color: var(--fc-ink-3);
  text-align: center;
  line-height: 1.5;
}

.fa-chat-error {
  padding: 24px 16px;
  color: var(--fc-red);
  text-align: center;
}

.fa-chat-inline-error {
  margin: 4px 4px 10px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--fc-red) 24%, var(--fc-border));
  border-radius: 12px;
  background: color-mix(in srgb, var(--fc-red) 8%, var(--fc-surface));
  color: var(--fc-red);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fa-chat-inline-error strong {
  font-size: 12px;
  font-weight: 900;
}

.fa-chat-empty strong,
.fa-chat-error strong {
  display: block;
  color: var(--fc-ink-2);
  font-size: 13.5px;
  font-weight: 800;
  margin-bottom: 5px;
}

/* ═══════════════════════════════════════════════
   SKELETON LOADERS
═══════════════════════════════════════════════ */
.fa-chat-skel {
  display: grid;
  grid-template-columns: 40px minmax(0,1fr) 34px;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
}

.fa-chat-skel span,
.fa-chat-skel i,
.fa-chat-skel b {
  display: block;
  min-width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg,
    var(--fc-surface),
    color-mix(in srgb, var(--fc-surface) 44%, var(--fc-surface-2)),
    var(--fc-surface));
  background-size: 220% 100%;
  animation: fcSkel 1.4s ease-in-out infinite;
}

.fa-chat-skel span { width: 38px; height: 38px; border-radius: 10px; }
.fa-chat-skel i   { width: 80%; height: 11px; }
.fa-chat-skel b   { width: 30px; height: 16px; }

@keyframes fcSkel {
  from { background-position: 100% 0; }
  to   { background-position: -100% 0; }
}

@keyframes fcSpin {
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════
   THREAD LAYOUT
═══════════════════════════════════════════════ */
.fa-chat-thread {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0,1fr) auto;
}

/* ── Peer Bar ── */
.fa-chat-peerbar {
  min-height: 56px;
  display: grid;
  grid-template-columns: auto auto minmax(0,1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--fc-border);
  background: var(--fc-header);
}

.fa-chat-peerbar strong {
  display: block;
  overflow: hidden;
  font-size: 13.5px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fc-ink);
}

.fa-chat-peerbar small {
  display: block;
  color: var(--fc-ink-3);
  font-size: 11px;
  font-weight: 650;
  margin-top: 1px;
}

.fa-chat-peerbar img.fa-chat-peer-av,
.fa-chat-peerbar .fa-chat-av-wrap img {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

/* ═══════════════════════════════════════════════
   DATE SEPARATOR
═══════════════════════════════════════════════ */
.fa-chat-date-sep {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 14px 0 8px;
  pointer-events: none;
}

.fa-chat-date-sep span {
  padding: 3px 13px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--fc-surface-2) 80%, transparent);
  border: 1px solid var(--fc-border);
  color: var(--fc-ink-3);
  font-size: 10.5px;
  font-weight: 750;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ═══════════════════════════════════════════════
   MESSAGES AREA
═══════════════════════════════════════════════ */
.fa-chat-messages {
  padding: 10px 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Bubble Row ── */
.fa-chat-bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  margin-top: 2px;
}

/* Breathing room on first of group */
.fa-chat-bubble-row.is-group-first { margin-top: 12px; }

.fa-chat-bubble-row.is-me { justify-content: flex-end; }

/* Avatar in bubble */
.fa-chat-bubble-av {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  object-fit: cover;
  background: var(--fc-surface);
  flex: 0 0 auto;
  align-self: flex-end;
  border: 1px solid var(--fc-border);
}

.fa-chat-bubble-av-spacer {
  width: 26px;
  flex: 0 0 auto;
}

/* Wrap: alert icon + bubble */
.fa-chat-bubble-wrap {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  max-width: 78%;
}

.fa-chat-bubble-row.is-me .fa-chat-bubble-wrap {
  flex-direction: row-reverse;
}

/* ── The Bubble ── */
.fa-chat-bubble {
  position: relative;
  padding: 8px 12px 7px;
  border-radius: 17px;
  background: var(--fc-bub-them);
  color: var(--fc-bub-them-text);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  border: 1px solid var(--fc-border);
}

/* Tail — first bubble of a block */
.fa-chat-bubble-row:not(.is-me) .fa-chat-bubble.has-tail {
  border-bottom-left-radius: 5px;
}

.fa-chat-bubble-row.is-me .fa-chat-bubble.has-tail {
  border-bottom-right-radius: 5px;
}

/* Me bubble */
.fa-chat-bubble-row.is-me .fa-chat-bubble {
  background: var(--fc-bub-me);
  color: var(--fc-bub-me-text);
  border-color: color-mix(in srgb, var(--fc-bub-me) 60%, transparent);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--fc-bub-me) 25%, transparent);
}

/* Pending */
.fa-chat-bubble-row.is-pending .fa-chat-bubble { opacity: .62; }

/* Failed */
.fa-chat-bubble-row.is-failed .fa-chat-bubble {
  background: color-mix(in srgb, var(--fc-red) 90%, #000);
  color: #fff;
  border-color: var(--fc-red);
  animation: fcShake .44s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes fcShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-5px); }
  35% { transform: translateX(5px); }
  55% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
  90% { transform: translateX(-1px); }
}

/* Fail-alert button */
.fa-chat-fail-alert {
  width: 22px; height: 22px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--fc-red);
  color: #fff;
  font-size: 11px;
  cursor: pointer;
  align-self: flex-end;
  margin-bottom: 4px;
  transition: transform .15s, opacity .15s;
}

.fa-chat-fail-alert:hover { transform: scale(1.18); opacity: .9; }

/* New message entrance */
.fa-chat-bubble-row.is-new .fa-chat-bubble {
  animation: fcMsgIn .22s var(--fc-ease) both;
}

.fa-chat-bubble-row.is-new.is-me .fa-chat-bubble {
  animation: fcMsgInMe .22s var(--fc-ease) both;
}

@keyframes fcMsgIn {
  from { opacity: 0; transform: translateY(5px) translateX(-3px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

@keyframes fcMsgInMe {
  from { opacity: 0; transform: translateY(5px) translateX(3px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

/* Group name badge inside bubble */
.fa-chat-bubble-name {
  display: block;
  margin-bottom: 3px;
  color: var(--fc-gold);
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: .01em;
}

/* Timestamp */
.fa-chat-bubble time {
  display: block;
  margin-top: 3px;
  color: currentColor;
  font-size: 9.5px;
  font-weight: 700;
  opacity: .55;
}

/* Read receipt placeholder (future) */
.fa-chat-bubble-row.is-me .fa-chat-bubble time::after {
  content: ' ✓';
  opacity: .7;
}

/* ═══════════════════════════════════════════════
   COMPOSE BAR  (WhatsApp-style pill)
═══════════════════════════════════════════════ */
.fa-chat-compose-wrap {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--fc-border);
  background: var(--fc-header);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.fa-chat-compose { padding: 8px 10px 10px; }

.fa-chat-compose-pill {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  background: var(--fc-surface);
  border: 1.5px solid var(--fc-border);
  border-radius: 999px;
  padding: 5px 5px 5px 15px;
  transition: border-color .13s, box-shadow .13s;
}

.fa-chat-compose-pill:focus-within {
  border-color: color-mix(in srgb, var(--fc-gold) 55%, var(--fc-border));
  box-shadow: 0 0 0 3px var(--fc-gold-glow);
  background: var(--fc-surface-2);
}

.fa-chat-compose-pill textarea {
  flex: 1 1 auto;
  min-height: 28px;
  max-height: 110px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--fc-ink);
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
  padding: 3px 0;
  scrollbar-width: none;
}

.fa-chat-compose-pill textarea::placeholder { color: var(--fc-ink-3); }
.fa-chat-compose-pill textarea::-webkit-scrollbar { display: none; }

/* Send button — circular, inside pill */
.fa-chat-send {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(145deg, var(--fc-gold), var(--fc-gold-dark));
  color: #0e0d09;
  cursor: pointer;
  box-shadow: 0 3px 10px var(--fc-gold-glow);
  transition: transform .18s var(--fc-spring), opacity .13s;
}

.fa-chat-send:hover:not(:disabled) {
  transform: scale(1.1);
  box-shadow: 0 5px 18px var(--fc-gold-glow);
}

.fa-chat-send:active:not(:disabled) { transform: scale(.92); }
.fa-chat-send:disabled { cursor: not-allowed; opacity: .36; transform: none; }
.fa-chat-send svg { width: 15px; height: 15px; }

/* Char counter */
[data-chat-char-counter] {
  text-align: right;
  font-size: 10px;
  padding: 0 14px 2px;
  opacity: 0;
  transition: opacity .15s;
  color: var(--fc-ink-3);
}

/* ═══════════════════════════════════════════════
   LOADING SPINNER (inside messages)
═══════════════════════════════════════════════ */
.fa-chat-message-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--fc-ink-3);
}

.fa-chat-message-loading svg {
  animation: fcSpin .8s linear infinite;
  opacity: .7;
}

.fa-chat-message-loading span {
  font-size: 12px;
  font-weight: 700;
}

/* ═══════════════════════════════════════════════
   RESPONSIVE  — Mobile
═══════════════════════════════════════════════ */
@media (max-width: 768px) {
  .fa-chat-launcher {
    right: 16px;
    bottom: 16px;
  }

  /* Hide floating launcher when mobile bottom nav is present */
  .fa-chat-has-mobile-nav .fa-chat-launcher {
    display: none;
  }

  .fa-chat-has-fab .fa-chat-launcher {
    right: calc(var(--fa-chat-fab-right) + var(--fa-chat-fab-width) + 8px);
    bottom: var(--fa-chat-fab-bottom);
  }

  .fa-chat-panel {
    left: 8px;
    right: 8px;
    bottom: 94px;
    width: auto;
    height: min(630px, calc(100dvh - 100px));
    border-radius: 18px;
    transform-origin: bottom center;
  }

  .fa-chat-has-mobile-nav .fa-chat-panel {
    left: 8px;
    right: 8px;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    height: min(630px, calc(100dvh - 98px - env(safe-area-inset-bottom, 0px)));
  }

  .fa-chat-thread {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
  }

  .fa-chat-thread .fa-chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .fa-chat-thread .fa-chat-compose-wrap {
    flex: 0 0 auto;
    position: sticky;
    bottom: 0;
    z-index: 1;
  }
}

/* ═══════════════════════════════════════════════
   FA SHELL OVERRIDES  (cosmetic polish)
═══════════════════════════════════════════════ */
#fa-chat-root .fa-chat-panel {
  border-color: var(--fc-border);
}

#fa-chat-root .fa-chat-top {
  background: var(--fc-header);
}

/* Keep avatar corners consistent with the rest of the shell */
#fa-chat-root .fa-chat-peer-av,
#fa-chat-root .fa-chat-row img,
#fa-chat-root .fa-chat-friend img,
#fa-chat-root .fa-chat-av-wrap img,
#fa-chat-root .fa-chat-bubble-av {
  border-radius: 8px;
}
