/* ============================================================================
   Message Centre — shared sidebar/strip/thread layout used by both the athlete
   portal (athlete-profile.js) and the coach portal (athlete-profile-detail.js)
   via window.MessageCentre.mount(host, opts).

   Mirrors docs/projects/message_centre/wireframe-AP-06-message-centre.html.
   Bubble classes (.acf-msg-out / .acf-msg-in) are reused from
   athlete-condition-feed.css. The .ap-mc- prefix is shared (kept for backward
   compatibility — the rules originated in athlete-profile.css).
============================================================================ */

.ap-mc {
  position: relative;
  display: flex;
  background: #fff;
  border: 0.5px solid #e0e0dc;
  margin: 0 16px 16px;
  /* No fixed height — panel grows with message volume, page is the scroller.
     Minimum keeps the empty state from collapsing to nothing. */
  min-height: 420px;
}
.ap-mc-sidebar {
  width: 220px;
  flex-shrink: 0;
  border-right: 0.5px solid #e0e0dc;
  display: flex;
  flex-direction: column;
  background: #fff;
}
.ap-mc-sidebar-hdr {
  padding: 10px 12px;
  border-bottom: 0.5px solid #e0e0dc;
  background: #f5f5f3;
  flex-shrink: 0;
  min-height: 49px;
  display: flex;
  align-items: center;
}
.ap-mc-sidebar-title {
  font-size: 11px;
  font-weight: 500;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.ap-mc-brief-list {
  flex: 1;
  overflow-y: auto;
}
.ap-mc-brief-item {
  padding: 10px 12px;
  border-bottom: 0.5px solid #e0e0dc;
  cursor: pointer;
  border-left: 2px solid transparent;
}
.ap-mc-brief-item:hover { background: #f9f9f7; }
/* Athlete portal — blue active highlight. Coach portal overrides below. */
.ap-mc-brief-item.ap-mc-active {
  background: #E6F1FB;
  border-left-color: #185FA5;
}
.ap-mc-portal-coach .ap-mc-brief-item.ap-mc-active {
  background: #E1F5EE;
  border-left-color: #0F6E56;
}
.ap-mc-brief-date { font-size: 11px; font-weight: 500; color: #1a1a18; margin-bottom: 3px; }
.ap-mc-brief-summary { font-size: 11px; color: #666; line-height: 1.4; margin-bottom: 5px; }
.ap-mc-brief-pills { display: flex; gap: 3px; flex-wrap: wrap; }
.ap-mc-bpill { font-size: 9px; padding: 1px 5px; font-weight: 500; }
.ap-mc-bp-t { background: #E1F5EE; color: #085041; }
.ap-mc-bp-m { background: #E6F1FB; color: #0C447C; }
.ap-mc-bp-w { background: #FAEEDA; color: #633806; }

.ap-mc-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.ap-mc-main-hdr {
  padding: 10px 14px;
  border-bottom: 0.5px solid #e0e0dc;
  background: #f5f5f3;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 49px;
}
.ap-mc-main-hdr-left { flex: 1; min-width: 0; }
.ap-mc-main-date { font-size: 13px; font-weight: 500; color: #1a1a18; }
.ap-mc-main-meta { font-size: 11px; color: #666; margin-top: 1px; }
.ap-mc-briefs-btn {
  padding: 5px 12px;
  font-size: 12px;
  border: 0.5px solid #ccc;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  color: #666;
  display: none;
  flex-shrink: 0;
}

.ap-mc-strip {
  border-bottom: 0.5px solid #e0e0dc;
  background: #f9f9f7;
  flex-shrink: 0;
  overflow: hidden;
  transition: max-height 0.2s ease;
}
.ap-mc-strip.ap-mc-expanded { max-height: 200px; }
.ap-mc-strip.ap-mc-collapsed { max-height: 0; }
.ap-mc-strip-inner { padding: 10px 14px; }
.ap-mc-strip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
}
.ap-mc-strip-lbl {
  font-size: 10px;
  font-weight: 500;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ap-mc-strip-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}
.ap-mc-strip-row:last-child { margin-bottom: 0; }
.ap-mc-strip-tag {
  font-size: 9px;
  padding: 2px 5px;
  font-weight: 500;
  flex-shrink: 0;
  margin-top: 1px;
}
.ap-mc-strip-text { font-size: 12px; color: #444; line-height: 1.4; flex: 1; }
.ap-mc-strip-link { font-size: 11px; color: #185FA5; cursor: pointer; flex-shrink: 0; }
.ap-mc-portal-coach .ap-mc-strip-link { color: #0F6E56; }
.ap-mc-strip-toggle {
  padding: 5px 14px;
  font-size: 10px;
  color: #999;
  cursor: pointer;
  border-bottom: 0.5px solid #e0e0dc;
  text-align: center;
  user-select: none;
  background: #f9f9f7;
  flex-shrink: 0;
}
.ap-mc-strip-toggle:hover { background: #f0f0ee; }

.ap-mc-thread {
  /* No fixed height / overflow — thread grows with content and the page
     provides the scroll. */
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ap-mc-date-div {
  text-align: center;
  font-size: 10px;
  color: #999;
  padding: 4px 0 8px;
  flex-shrink: 0;
}
.ap-mc-msg-wrap-out { display: flex; flex-direction: column; align-items: flex-end; }
.ap-mc-msg-wrap-in { display: flex; flex-direction: column; align-items: flex-start; }
.ap-mc-empty-thread {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #999;
}

.ap-mc-compose {
  padding: 10px 14px;
  border-top: 0.5px solid #e0e0dc;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  background: #fff;
}

/* ---------------------------------------------------------------------------
   Contextual thread containers (wireframe AP-07)
   Appear inline in the main thread, anchored at their first message's
   created_at. Left border follows the portal (athlete blue / coach teal),
   but bubble colours are identical across both portals — teal out / white in.
--------------------------------------------------------------------------- */
.ap-mc-ctx {
  border: 0.5px solid #e0e0dc;
  border-left: 2px solid #185FA5;
  background: #f9f9f7;
  margin: 4px 0;
}
.ap-mc-portal-coach .ap-mc-ctx { border-left-color: #0F6E56; }

.ap-mc-ctx-hdr {
  padding: 7px 12px;
  border-bottom: 0.5px solid #e0e0dc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ap-mc-ctx-ref { display: flex; align-items: center; gap: 5px; min-width: 0; }
.ap-mc-ctx-ref-icon { font-size: 12px; color: #185FA5; }
.ap-mc-portal-coach .ap-mc-ctx-ref-icon { color: #0F6E56; }
.ap-mc-ctx-ref-type {
  font-size: 10px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: #185FA5;
}
.ap-mc-portal-coach .ap-mc-ctx-ref-type { color: #0F6E56; }
.ap-mc-ctx-ref-name {
  font-size: 11px; color: #666;
  margin-left: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ap-mc-ctx-reply-link {
  font-size: 11px; color: #185FA5; cursor: pointer;
  background: none; border: none; font-family: inherit;
  flex-shrink: 0;
}
.ap-mc-portal-coach .ap-mc-ctx-reply-link { color: #0F6E56; }

.ap-mc-ctx-messages {
  padding: 8px 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.ap-mc-ctx-msg-out { display: flex; flex-direction: column; align-items: flex-end; }
.ap-mc-ctx-msg-in  { display: flex; flex-direction: column; align-items: flex-start; }

/* Bubble colours — identical on both portals per wireframe spec. */
.ap-mc-ctx-bubble-out {
  background: #14b8a6;
  padding: 6px 10px;
  max-width: 85%;
  font-size: 12px;
  color: #fff;
  line-height: 1.5;
}
.ap-mc-ctx-bubble-in {
  background: #fff;
  border: 0.5px solid #e0e0dc;
  padding: 6px 10px;
  max-width: 85%;
  font-size: 12px;
  color: #1a1a18;
  line-height: 1.5;
}
.ap-mc-ctx-time { font-size: 10px; color: #999; margin-top: 2px; }

.ap-mc-ctx-compose {
  border-top: 0.5px solid #e0e0dc;
  display: flex;
}
.ap-mc-ctx-input {
  flex: 1;
  padding: 7px 10px;
  border: none;
  font-size: 12px;
  font-family: inherit;
  background: transparent;
  outline: none;
  color: #1a1a18;
}
.ap-mc-ctx-input:focus { background: #fff; }
.ap-mc-ctx-send {
  padding: 7px 12px;
  background: #185FA5;
  color: #fff;
  border: none;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
}
.ap-mc-portal-coach .ap-mc-ctx-send { background: #0F6E56; }

/* Mobile slide-in briefs panel — uses transform: translateX, NOT position: fixed.
   Hidden by default; only the mobile media query + the .ap-mc-open class show it. */
.ap-mc-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 10;
}
.ap-mc-overlay.ap-mc-visible { display: block; }
.ap-mc-mob-panel {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 80%;
  max-width: 280px;
  background: #fff;
  border-left: 0.5px solid #e0e0dc;
  z-index: 11;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
.ap-mc-mob-panel.ap-mc-open { transform: translateX(0); }
.ap-mc-mob-hdr {
  padding: 10px 12px;
  border-bottom: 0.5px solid #e0e0dc;
  background: #f5f5f3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.ap-mc-mob-title {
  font-size: 12px;
  font-weight: 500;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.ap-mc-mob-close {
  padding: 4px 8px;
  font-size: 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #666;
}

/* Desktop/mobile breakpoint — the two layouts are mutually exclusive */
@media (min-width: 768px) {
  .ap-mc-mob-panel { display: none !important; }
  .ap-mc-overlay { display: none !important; }
  .ap-mc-briefs-btn { display: none !important; }
}
@media (max-width: 767px) {
  .ap-mc { margin: 0; max-width: 100%; height: calc(100vh - 200px); }
  .ap-mc-sidebar { display: none !important; }
  .ap-mc-briefs-btn { display: block; }
  .ap-mc-mob-panel { display: flex; }
}
