/* messages.css - dark/magenta theme for Messages UI
   Updated: refined scrollbar styling + small padding so bubbles don't butt up to the bar.
*/

/* Page layout - viewport-locked, no page scroll */
.messages-page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
  height: calc(100vh - 72px); /* subtract navbar height */
  display: flex;
  flex-direction: column;
  color: #ffd9f7;
  overflow: hidden;
}

.messages-card {
  background: rgba(12,12,12,0.85);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 8px 40px rgba(255,0,160,0.08);
  border: 1px solid rgba(255,255,255,0.03);
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* Grid layout - left column fixed at 320px, right column flexible.
   Both columns fill remaining height and scroll independently. */
.messages-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  flex: 1;
  min-height: 0; /* critical for flex children to shrink */
  overflow: hidden;
}

.messages-left {
  /* inbox column - let grid control sizing */
  min-width: 280px;
}

.messages-side {
  /* this column will be sized by the grid; avoid hard width here */
  width: auto;
  max-width: 100%;
}

/* Card/panel styles */
.messages-card {
  background: #111;
  border: 1px solid rgba(255,105,180,0.15);
  border-radius: 14px;
  padding: 16px;
}

/* Gradient text for headings */
.gradient-text {
  background: linear-gradient(90deg, #ff69b4, #8b00ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
  display: inline-block;
}

/* Thread feed (card style) */
.thread-feed {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.thread-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border-radius: 14px;
  padding: 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: transform .12s ease, box-shadow .12s ease;
  cursor: pointer;
}
.thread-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
}

/* Avatar */
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  flex: 0 0 48px;
  display: inline-block;
  background: #222;
  border: 2px solid rgba(255,105,180,0.08);
}

/* Thread metadata */
.thread-meta {
  flex: 1;
  min-width: 0;
}
.thread-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: #fff;
}
.thread-preview {
  color: #bbb;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Unread badge */
.unread-badge {
  background: var(--color-accent);
  color: #000;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.8rem;
  font-weight: 700;
}

/* Conversation (thread) view - fills available height, scrolls internally */
.thread-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 12px;
  padding: 16px;
  background: #0f0f0f;
  border: 1px solid rgba(255,105,180,0.06);
  margin-bottom: 16px;
  min-height: 0; /* allow flex shrink */

  /* Reserve space for scrollbar so layout doesn't shift */
  scrollbar-gutter: stable both-edges;
  padding-right: 14px;
  position: relative;
}

/* Inner thread content box — this keeps conversation centered and narrower */
.thread-inner {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Message row and bubble - using template styles as base */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
  margin: 12px 0;
}
.msg-row--me {
  justify-content: flex-end;
}
.msg-row--other {
  justify-content: flex-start;
}

.msg-bubble {
  display: inline-block;
  max-width: 70%;
  padding: 10px 12px;
  border-radius: 18px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
  line-height: 1.25;
  position: relative;
}

.msg-me {
  background: #1d9bf0;
  color: #fff;
  margin-right: 0;
}

.msg-other {
  background: #e5e5e5;
  color: #333;
  margin-left: 0;
}

/* ensure outgoing bubble aligns to the right edge of thread-inner */
.msg-row--me .msg-bubble { align-self: flex-end; }

/* content inside bubble: limit height and allow internal scroll for very long messages */
.msg-bubble .content {
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}

/* timestamp */
.msg-meta {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.55);
  text-align: right;
}
.msg-row--me .msg-meta { text-align: left; }

/* Input form - using template styles as base */
.thread-input {
  display:flex;
  gap:8px;
  align-items:center;
}
.thread-input input[type="text"], .thread-input textarea {
  flex:1;
  padding:10px 12px;
  border-radius:8px;
  background:#0f0f0f;
  border:1px solid rgba(255,255,255,0.04);
  color:#fff;
}

/* Glow/pill helpers */
.glow {
  box-shadow:
    0 0 6px rgba(255,105,180,0.6),
    0 0 18px rgba(139,0,255,0.25);
  border-radius: 999px;
}

.gradient-border {
  border: 2px solid transparent;
  border-radius: 12px;
  background-image: linear-gradient(#0b0b0b, #0b0b0b), linear-gradient(90deg, #ff69b4, #8b00ff);
  background-origin: border-box;
  background-clip: padding-box, border-box;
}

/* Responsive */
@media (max-width: 900px) {
  .messages-side { display: none; }
}

/* ---------- Inbox sidebar scrollbar (thin, subtle) ---------- */
.inbox-section {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,100,180,0.3) transparent;
}
.inbox-section::-webkit-scrollbar { width: 4px; }
.inbox-section::-webkit-scrollbar-track { background: transparent; }
.inbox-section::-webkit-scrollbar-thumb { background: rgba(255,100,180,0.35); border-radius: 4px; }
.inbox-section::-webkit-scrollbar-thumb:hover { background: rgba(255,100,180,0.6); }

/* ---------- Improved neon scrollbar (consistent with template) ---------- */

/* Firefox */
.thread-messages {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,110,180,0.95) rgba(0,0,0,0.25);
}

/* Webkit-based browsers (Chrome, Edge, Safari) */
.thread-messages::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.thread-messages::-webkit-scrollbar-track {
  background: linear-gradient(180deg, rgba(0,0,0,0.06), rgba(0,0,0,0.04));
  border-radius: 12px;
  margin: 6px 2px;
  box-shadow: inset 0 0 6px rgba(0,0,0,0.35);
}

.thread-messages::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #ff6ac6, #ff2f9a);
  border-radius: 12px;
  border: 2px solid rgba(0,0,0,0.18);
  box-shadow: 0 4px 14px rgba(255,50,130,0.18);
  min-height: 36px;
}

/* Hover/focus state for the thumb */
.thread-messages::-webkit-scrollbar-thumb:hover,
.thread-messages::-webkit-scrollbar-thumb:active {
  transform: scale(1.03);
  box-shadow: 0 6px 22px rgba(255,50,130,0.25);
}

/* Corners */
.thread-messages::-webkit-scrollbar-corner {
  background: transparent;
}

/* Optional: a subtle overlay shadow on the right edge of the thread area so scrollbar feels inset */
.thread-messages::after {
  content: "";
  position: absolute;
  right: 6px;
  top: 0;
  bottom: 0;
  width: 8px;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,0), rgba(0,0,0,0.12));
  border-radius: 8px;
}

/* Small-screen tweak: reduce right padding when scrollbar may be overlaying content */
@media (max-width:560px) {
  .thread-messages { padding-right: 8px; }
  .thread-messages::-webkit-scrollbar { width: 8px; }
}

/* ---------- Optional stronger overrides (uncomment only if another stylesheet overrides your rules) ----------
.messages-card .thread-messages::-webkit-scrollbar { width: 10px !important; }
.messages-card .thread-messages::-webkit-scrollbar-thumb { background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(220,220,220,0.95)) !important; border-radius:10px !important; }
----------------------------------------------------------------------------------------------- */