/* messages.css — Messages app page styles */

/* ── Page shell ─────────────────────────────────────────────────────────────── */
.msg-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}

/* ── Page header ──────────────────────────────────────────────────────────────── */
.msg-header {
  padding: 1.4rem 0 1.1rem;
  border-bottom: 1px solid rgba(104,137,178,0.18);
  margin-bottom: 1.6rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.msg-header h1 {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--ink, #132336);
  margin: 0;
  letter-spacing: -0.03em;
}

.msg-header-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.msg-header-unread {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: rgba(55,122,182,0.12);
  color: var(--accent-hex, #3779b6);
  border: 1px solid rgba(55,122,182,0.3);
  white-space: nowrap;
}

/* ── Two-column layout ────────────────────────────────────────────────────────── */
.msg-cols {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 1.6rem;
  align-items: start;
}

/* ── Right column: inbox — sticky so it stays visible while scrolling compose ── */
.msg-col--right {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  position: sticky;
  top: calc(var(--portal-nav-h, 40px) + 52px + 12px);
  max-height: calc(100vh - var(--portal-nav-h, 40px) - 52px - 32px);
  overflow-y: auto;
  overflow-x: visible;
  /* hide scrollbar visually but keep functional */
  scrollbar-width: thin;
  scrollbar-color: rgba(104,137,178,0.25) transparent;
}
.msg-col--right::-webkit-scrollbar { width: 5px; }
.msg-col--right::-webkit-scrollbar-thumb { background: rgba(104,137,178,0.3); border-radius: 4px; }

/* ── Override bc-cols inside messages page to single column ─────────────────── */
/* This gives the compose form the full left-column width instead of ~295px.    */
.msg-shell .bc-cols {
  grid-template-columns: 1fr;
  gap: 1.2rem;
}

/* ── Card shared styles ─────────────────────────────────────────────────────── */
.msg-card {
  background: rgba(255,255,255,0.78);
  border: 1px solid rgba(104,137,178,0.28);
  border-radius: 14px;
  padding: 1.3rem 1.4rem;
  box-shadow: 0 2px 14px rgba(12,28,50,0.07);
}

.msg-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.9rem;
}

.msg-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink, #132336);
  margin: 0 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.msg-card-head .msg-card-title { margin: 0; }

/* Accent top border on inbox card */
.msg-card--inbox {
  border-top: 3px solid var(--accent-hex, #3779b6);
}

/* Unread badge on card title */
.msg-inbox-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-hex, #3779b6);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

/* ── Inbox list ──────────────────────────────────────────────────────────────── */
.msg-inbox-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.msg-inbox-row {
  position: relative;
  padding: 0.75rem 2.2rem 0.75rem 0.9rem;
  background: rgba(255,255,255,0.65);
  border: 1px solid rgba(104,137,178,0.18);
  border-radius: 10px;
  transition: background 0.12s, box-shadow 0.12s;
  cursor: default;
}

.msg-inbox-row:hover {
  background: rgba(55,122,182,0.05);
  box-shadow: 0 2px 8px rgba(12,28,50,0.06);
}

.msg-inbox-row--unread {
  border-left: 3px solid var(--accent-hex, #3779b6);
  background: rgba(55,122,182,0.055);
}
.msg-inbox-row--unread:hover {
  background: rgba(55,122,182,0.09);
}

.msg-inbox-row-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink, #132336);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.3;
}

.msg-unread-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-hex, #3779b6);
  flex-shrink: 0;
}

.msg-inbox-row-body {
  font-size: 0.84rem;
  color: var(--ink, #132336);
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 5px;
  line-height: 1.45;
  /* collapse long messages */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.msg-inbox-row-meta {
  font-size: 0.74rem;
  color: var(--muted, #54697f);
}

/* ── Empty hint ──────────────────────────────────────────────────────────────── */
.msg-empty {
  font-size: 0.85rem;
  color: var(--muted, #54697f);
  font-style: italic;
  padding: 0.5rem 0;
}

/* ── Override bc-card inside messages for better hierarchy ───────────────────── */
.msg-shell .bc-card { box-shadow: 0 2px 14px rgba(12,28,50,0.07); }
.msg-shell #bcComposeCard { border-top: 3px solid var(--accent-hex, #3779b6); }
.msg-shell #bcHistoryCard { border-top: 3px solid rgba(104,137,178,0.4); }
.msg-shell #bcTemplatesCard { border-top: 3px solid rgba(104,137,178,0.25); }

/* ── Override bc-history-list height inside messages — keep scroll ────────── */
/* Removed: was overriding scroll on bc-history-list; scroll is now handled in admin.css */

/* ── Inbox list: scrollable with max ~7 rows visible ─────────────────────── */
#msgInboxList {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 480px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(104,137,178,0.25) transparent;
}
#msgInboxList::-webkit-scrollbar { width: 5px; }
#msgInboxList::-webkit-scrollbar-thumb { background: rgba(104,137,178,0.3); border-radius: 4px; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .msg-cols { grid-template-columns: 1fr; gap: 1.2rem; }
  .msg-col--right {
    order: -1;   /* inbox first on tablet/mobile */
    position: static;
    max-height: none;
    overflow: visible;
  }
  .msg-header-unread { display: none; } /* shown on inbox card instead */
}
