/* ==========================================================================
   Coaching Messages — chat surface + notification bell.
   Self-contained colours (with graceful fallbacks) so the one stylesheet looks
   right on the parchment member portal AND the clean white admin.
   ========================================================================== */

:root {
  --chat-mine: var(--color-gold, #b89045);
  --chat-mine-ink: #22324a;
  --chat-theirs: #eef1f4;
  --chat-theirs-ink: #22324a;
  --chat-line: rgba(34, 50, 74, 0.12);
}

/* --- The chat surface ------------------------------------------------------ */
.chat {
  display: flex;
  flex-direction: column;
  height: min(72vh, 640px);
  border: 1px solid var(--chat-line);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
}

.chat__stream {
  flex: 1;
  overflow-y: auto;
  /* Never a horizontal bar: the absolutely-positioned reaction menus would
     otherwise push width past the edge and trip the site's gold scrollbar. */
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
}

.chat__day {
  align-self: center;
  font-size: 0.72rem;
  color: #7d8992;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 12px 0 6px;
}

.chat__empty {
  margin: auto;
  max-width: 34ch;
  text-align: center;
  color: #7d8992;
  font-size: 0.95rem;
}

.chat__line {
  display: flex;
  flex-direction: column;
  max-width: 78%;
}
.chat__line--mine { align-self: flex-end; align-items: flex-end; }
.chat__line--theirs { align-self: flex-start; align-items: flex-start; }

.chat__msg {
  position: relative;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 0.95rem;
  line-height: 1.4;
  word-wrap: break-word;
}
.chat__line--mine .chat__msg { background: var(--chat-mine); color: var(--chat-mine-ink); border-bottom-right-radius: 4px; }
.chat__line--theirs .chat__msg { background: var(--chat-theirs); color: var(--chat-theirs-ink); border-bottom-left-radius: 4px; }
.chat__msg--gone { font-style: italic; opacity: 0.7; background: transparent !important; padding-left: 0; }

.chat__who { display: block; font-size: 0.72rem; font-weight: 700; opacity: 0.75; margin-bottom: 2px; }
.chat__text { display: block; white-space: pre-wrap; }
.chat__meta { display: block; font-size: 0.68rem; opacity: 0.6; margin-top: 3px; }
.chat__receipt { font-size: 0.68rem; color: #7d8992; }

/* The footer under the bubble: reactions + receipt on one line. */
.chat__foot { display: flex; align-items: center; gap: 6px; margin-top: 3px; flex-wrap: wrap; }
.chat__line--mine .chat__foot { justify-content: flex-end; }

/* Reactions */
.chat__reacts { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chat__react {
  border: 1px solid var(--chat-line);
  background: #fff;
  border-radius: 999px;
  padding: 0 7px;
  height: 22px;
  font-size: 0.75rem;
  cursor: pointer;
  line-height: 1;
}
.chat__react.is-mine { border-color: var(--color-gold, #b89045); background: rgba(184, 144, 69, 0.14); }
.chat__react-add { position: relative; display: inline-block; }
.chat__react-btn {
  border: 1px solid transparent; background: transparent; cursor: pointer;
  /* Faint by default so it doesn't shout, but always tappable — there's no hover
     on touch, and the button now sits below the bubble where it must be reachable. */
  opacity: 0.5; transition: opacity 0.12s; font-size: 0.95rem; line-height: 1; padding: 0 4px; color: #7d8992;
}
.chat__line:hover .chat__react-btn,
.chat__react-btn:focus-visible { opacity: 1; }
.chat__react-menu {
  position: absolute; bottom: 24px; left: 0; z-index: 5;
  display: flex; gap: 2px; padding: 4px 6px;
  background: #fff; border: 1px solid var(--chat-line); border-radius: 999px;
  box-shadow: 0 6px 20px rgba(20, 30, 45, 0.14);
}
/* The picker starts closed. A bare `display:flex` above outranks the [hidden]
   UA rule, so restore it explicitly — otherwise every message's emoji menu
   sits permanently open. Same story for the typing dots below. */
.chat__react-menu[hidden] { display: none; }
/* My messages hug the right edge; open the menu leftward so it stays on-screen. */
.chat__line--mine .chat__react-menu { left: auto; right: 0; }
.chat__react-menu button { border: 0; background: transparent; cursor: pointer; font-size: 1.05rem; padding: 2px; border-radius: 6px; }
.chat__react-menu button:hover { background: #eef1f4; }

/* Own-message actions */
.chat__actions { position: absolute; top: -10px; right: 6px; display: none; gap: 4px; }
.chat__line--mine:hover .chat__actions { display: inline-flex; }
.chat__actions button {
  border: 1px solid var(--chat-line); background: #fff; color: #5c6a73;
  font-size: 0.68rem; border-radius: 6px; padding: 1px 6px; cursor: pointer;
}
.chat__edit { width: 100%; min-width: 220px; border: 1px solid var(--chat-line); border-radius: 8px; padding: 6px 8px; font: inherit; }

/* Composer */
.chat__composer {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 10px; border-top: 1px solid var(--chat-line); background: #fbfcfd;
}
.chat__input {
  flex: 1; resize: none; border: 1px solid var(--chat-line); border-radius: 12px;
  padding: 10px 12px; font: inherit; font-size: 0.95rem; max-height: 160px;
}
.chat__input:focus-visible { outline: none; border-color: var(--color-gold, #b89045); box-shadow: 0 0 0 3px rgba(184, 144, 69, 0.25); }
.chat__send {
  flex: none; width: 42px; height: 42px; border: 0; border-radius: 50%;
  background: var(--color-gold, #b89045); color: #22324a; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.chat__send:hover { filter: brightness(1.05); }

/* Typing dots (reserved; shown by future presence work) */
.chat__typing { display: flex; gap: 4px; padding: 4px 16px 8px; }
.chat__typing[hidden] { display: none; }
.chat__typing span { width: 6px; height: 6px; border-radius: 50%; background: #c3ccd4; animation: chatblink 1.2s infinite; }
.chat__typing span:nth-child(2) { animation-delay: 0.2s; }
.chat__typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatblink { 0%, 60%, 100% { opacity: 0.3; } 30% { opacity: 1; } }

/* --- Notification bell ----------------------------------------------------- */
.notif-bell { position: relative; display: inline-flex; }
.notif-bell__btn {
  position: relative; border: 0; background: transparent; cursor: pointer;
  color: currentColor; padding: 6px; line-height: 0; border-radius: 8px;
}
.notif-bell__btn:hover { background: rgba(120, 130, 140, 0.12); }
.notif-bell.has-unread .notif-bell__btn { color: var(--color-gold, #b89045); }
.notif-bell__badge {
  position: absolute; top: 0; right: 0; min-width: 17px; height: 17px;
  padding: 0 4px; border-radius: 999px; background: #a4544c; color: #fff;
  font-size: 0.66rem; font-weight: 700; line-height: 17px; text-align: center;
}
.notif-bell__panel {
  position: absolute; top: 44px; right: 0; z-index: 60; width: 320px; max-width: 88vw;
  background: #fff; color: #22324a; border: 1px solid rgba(34, 50, 74, 0.14);
  border-radius: 12px; box-shadow: 0 12px 34px rgba(20, 30, 45, 0.18); overflow: hidden;
}
.notif-bell__head { margin: 0; padding: 10px 14px; font-weight: 700; font-size: 0.85rem; border-bottom: 1px solid rgba(34, 50, 74, 0.1); }
.notif-bell__list { list-style: none; margin: 0; padding: 0; max-height: 340px; overflow-y: auto; }
.notif-bell__empty { padding: 18px 14px; color: #7d8992; font-size: 0.9rem; text-align: center; }
.notif-bell__item { display: block; padding: 10px 14px; text-decoration: none; color: inherit; border-bottom: 1px solid rgba(34, 50, 74, 0.06); }
.notif-bell__item:hover { background: #f4f7fa; }
.notif-bell__row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.notif-bell__count { background: #a4544c; color: #fff; border-radius: 999px; font-size: 0.68rem; padding: 0 6px; }
.notif-bell__preview { display: block; color: #5c6a73; font-size: 0.85rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-bell__when { display: block; color: #98a3ab; font-size: 0.72rem; margin-top: 2px; }
.notif-bell__all { display: block; text-align: center; padding: 10px; font-weight: 600; font-size: 0.85rem; text-decoration: none; color: #2a5b8c; }
.notif-bell__all:hover { background: #f4f7fa; }

/* --- Admin inbox (list + conversation chrome) ------------------------------ */
.admin-page__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.admin-inbox-search input { padding: 8px 12px; border: 1px solid #c3ccd4; border-radius: 8px; min-width: 240px; font: inherit; }
.admin-inbox { list-style: none; margin: 0; padding: 0; border: 1px solid #e1e6ea; border-radius: 12px; overflow: hidden; background: #fff; }
.admin-inbox__row + .admin-inbox__row { border-top: 1px solid #eef1f4; }
.admin-inbox__row a { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 16px; text-decoration: none; color: #22324a; }
.admin-inbox__row a:hover { background: #f6f8fa; }
.admin-inbox__name { font-weight: 700; }
.admin-inbox__preview { grid-column: 1; color: #5c6a73; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60ch; }
.admin-inbox__meta { grid-row: 1 / span 2; grid-column: 2; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; color: #98a3ab; font-size: 0.75rem; }
.admin-inbox__badge { background: #a4544c; color: #fff; border-radius: 999px; font-weight: 700; font-size: 0.7rem; padding: 1px 7px; }
.admin-inbox__row--unread .admin-inbox__name { color: #1c3d63; }
.admin-inbox__row--unread { background: #f3f8ff; }

.admin-convo__head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.admin-convo__head h1 { margin: 0; font-size: 1.25rem; }
.admin-convo__actions { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.admin-convo__actions a, .admin-linkbtn { color: #2a5b8c; text-decoration: none; font-size: 0.9rem; background: none; border: 0; cursor: pointer; font: inherit; padding: 0; }
.admin-back { color: #5c6a73; text-decoration: none; font-size: 0.9rem; }
.admin-empty { color: #7d8992; padding: 24px 0; }
