/* messages.css: the unread badge, the must-read modal and the inbox.
   Loaded on every page by track.html, alongside messages.js. */

/* ---- unread badge ([data-messages-badge]) --------------------------- */
/* On an icon: wrap the icon in .msg-icon and the badge sits on its corner. */
.msg-icon { position: relative; display: inline-flex; }
.msg-badge {
  position: absolute; top: -7px; right: -9px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: #f59e0b; color: #1a1a2e;
  font: 700 10px/16px -apple-system, system-ui, sans-serif;
  text-align: center; pointer-events: none;
}
/* After a label, like the account page's Messages tab. */
.msg-badge.inline { position: static; display: inline-block; margin-left: 8px; vertical-align: 1px; }
.msg-badge[hidden] { display: none; }

/* ---- buttons -------------------------------------------------------- */
.msg-btn {
  background: #f59e0b; color: #1a1a2e;
  border: none; border-radius: 6px;
  padding: 9px 22px; font: inherit; font-size: 0.875rem; font-weight: 600;
  cursor: pointer;
}
.msg-btn:hover { background: #fbbf24; }
.msg-btn:disabled { opacity: 0.5; cursor: default; }
.msg-btn.ghost { background: transparent; color: #cbd5e1; border: 1px solid #334155; }
.msg-btn.ghost:hover { background: #1e2942; color: #e0e0e0; }

/* ---- must-read modal ------------------------------------------------ */
#msg-modal {
  position: fixed; inset: 0; z-index: 100000;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  font-family: -apple-system, system-ui, sans-serif;
}
#msg-modal.open { display: flex; }
#msg-modal .msg-card {
  max-width: 540px; width: calc(100% - 32px);
  max-height: 80vh; overflow-y: auto;
  background: #16213e; border: 1px solid #0f3460; border-radius: 10px;
  padding: 24px 26px; color: #e0e0e0;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
#msg-modal h2 {
  font-size: 1.125rem; font-weight: 700; color: #e0e0e0;
  margin: 0 0 10px; letter-spacing: -0.2px;
}
#msg-modal .msg-card-body {
  font-size: 0.875rem; line-height: 1.6; color: #cbd5e1;
  white-space: pre-wrap; margin-bottom: 18px;
}
#msg-modal .msg-card-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---- inbox ([data-messages-inbox], the account page's Messages tab) - */
.msg-inbox {
  display: flex; height: 520px;
  background: #16213e; border: 1px solid #0f3460; border-radius: 8px;
  color: #e0e0e0; overflow: hidden;
}
.msg-list {
  list-style: none; margin: 0; padding: 0;
  width: 260px; flex-shrink: 0; overflow-y: auto;
  border-right: 1px solid #0f3460;
}
.msg-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 16px; cursor: pointer;
  border-bottom: 1px solid rgba(15,52,96,0.6);
}
.msg-item:hover { background: #1b2744; }
.msg-item.selected { background: #1e2942; }
.msg-dot {
  width: 8px; height: 8px; margin-top: 6px; border-radius: 50%;
  flex-shrink: 0; background: transparent;
}
.msg-item.unread .msg-dot { background: #f59e0b; }
.msg-item-text { flex: 1; min-width: 0; }
.msg-item-title { font-size: 0.875rem; color: #cbd5e1; line-height: 1.35; }
.msg-item.unread .msg-item-title { color: #e0e0e0; font-weight: 700; }
.msg-item-preview {
  font-size: 0.8125rem; color: #94a3b8; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.msg-item-date { font-size: 0.75rem; color: #64748b; margin-top: 2px; }

.msg-detail { flex: 1; min-width: 0; overflow-y: auto; padding: 20px 24px; }
.msg-back {
  display: none; background: none; border: none; color: #94a3b8;
  font: inherit; font-size: 0.8125rem; cursor: pointer; padding: 0; margin-bottom: 12px;
}
.msg-back:hover { color: #e0e0e0; }
.msg-empty { color: #64748b; font-size: 0.875rem; padding-top: 8px; }
.msg-list .msg-empty { padding: 16px; }
.msg-title { margin: 0 0 4px; font-size: 1.125rem; font-weight: 700; color: #e0e0e0; }
.msg-date { font-size: 0.75rem; color: #64748b; margin-bottom: 14px; }
.msg-text {
  font-size: 0.875rem; line-height: 1.6; color: #cbd5e1;
  white-space: pre-wrap; margin-bottom: 22px;
}
/* A conversation: the user's messages on the right, the admins' on the left. */
.msg-thread { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.msg-bubble { max-width: 85%; border-radius: 8px; padding: 8px 12px; }
.msg-bubble.mine { align-self: flex-end; background: #1e2942; border: 1px solid #334155; }
.msg-bubble.theirs {
  align-self: flex-start;
  background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.35);
}
.msg-bubble-meta { font-size: 0.6875rem; color: #64748b; margin-bottom: 2px; }
.msg-bubble-text {
  font-size: 0.875rem; line-height: 1.5; color: #e0e0e0;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg-reply label {
  display: block; font-size: 0.6875rem; font-weight: 600; color: #94a3b8;
  text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 6px;
}
.msg-reply textarea {
  width: 100%; box-sizing: border-box; min-height: 96px; resize: vertical;
  background: #0f1729; border: 1px solid #0f3460; border-radius: 6px;
  color: #e0e0e0; padding: 10px 12px; font: inherit; font-size: 0.875rem;
}
.msg-reply textarea:focus { outline: none; border-color: #f59e0b; }
.msg-reply-actions {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 12px; margin-top: 10px;
}
.msg-reply-status { font-size: 0.8125rem; color: #94a3b8; }
.msg-reply-status.ok { color: #22c55e; }
.msg-reply-status.err { color: #ef4444; }

/* Phones (the account page's own breakpoint): one pane at a time, the list
   first, growing with the page instead of scrolling in a box. */
@media (max-width: 640px) {
  .msg-inbox { height: auto; min-height: 240px; }
  .msg-list { width: 100%; border-right: none; }
  .msg-inbox.showing-detail .msg-list { display: none; }
  .msg-inbox:not(.showing-detail) .msg-detail { display: none; }
  .msg-inbox.showing-detail .msg-back { display: inline-block; }
  .msg-detail { padding: 16px; }
}
