/* css/messages.css - Classic Windows Messenger + Modern Chat */

.messenger-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  height: calc(100vh - 54px);
  display: flex;
  flex-direction: column;
}

.messenger-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.messenger-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  min-height: 0;
}

/* Left Conversations Pane */
.conv-sidebar {
  background: var(--win-grey);
  border-right: 2px solid var(--win-dark);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.conv-toolbar {
  padding: 8px;
  border-bottom: 1px solid var(--win-dark);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.conv-list {
  flex: 1;
  overflow-y: auto;
  background: var(--win-white);
  border-top: 2px solid var(--win-dark);
  border-left: 2px solid var(--win-dark);
  margin: 0 6px 6px;
}

.conv-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid var(--win-light);
  cursor: pointer;
  background: var(--win-white);
  transition: background-color 0.12s ease;
}

.conv-item:hover {
  background: #F0F4FF;
}

.conv-item.active {
  background: var(--win-navy);
  color: var(--win-white);
}

.conv-item.active .conv-preview,
.conv-item.active .conv-time {
  color: #D8E0FF;
}

.conv-item-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
}

.conv-meta {
  min-width: 0;
  flex: 1;
}

.conv-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.conv-name {
  font-weight: bold;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-preview {
  font-size: 12px;
  color: var(--win-darker);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-right-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.conv-time {
  font-size: 10px;
  color: var(--win-darker);
}

.conv-unread-badge {
  background: var(--win-danger);
  color: var(--win-white);
  font-size: 10px;
  font-weight: bold;
  padding: 1px 6px;
  border: 1px solid var(--win-white);
}

/* Right Active Chat Pane */
.chat-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--win-light);
}

.chat-header {
  background: var(--win-grey);
  border-bottom: 2px solid var(--win-dark);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chat-header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--win-black);
}

.chat-messages-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: var(--win-white);
  border-top: 2px solid var(--win-dark);
  border-left: 2px solid var(--win-dark);
  margin: 6px 6px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-empty-placeholder {
  margin: auto;
  text-align: center;
  color: var(--win-darker);
  max-width: 320px;
}

/* Message Bubbles */
.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 74%;
}

.msg-row.mine {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-row.theirs {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-bubble {
  padding: 8px 11px;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
}

.msg-row.mine .msg-bubble {
  background: #DCE8FF;
  border-top: 2px solid var(--win-white);
  border-left: 2px solid var(--win-white);
  border-right: 2px solid var(--win-navy);
  border-bottom: 2px solid var(--win-navy);
}

.msg-row.theirs .msg-bubble {
  background: var(--win-light);
  border-top: 2px solid var(--win-white);
  border-left: 2px solid var(--win-white);
  border-right: 2px solid var(--win-dark);
  border-bottom: 2px solid var(--win-dark);
}

.msg-reply-quote {
  font-size: 11px;
  background: rgba(0, 0, 128, 0.08);
  border-left: 3px solid var(--win-navy);
  padding: 4px 7px;
  margin-bottom: 6px;
  color: var(--win-darker);
}

.msg-attachment-img {
  max-width: 240px;
  max-height: 220px;
  display: block;
  margin-top: 6px;
  border: 1px solid var(--win-dark);
  cursor: pointer;
}

.msg-attachment-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 5px 8px;
  background: var(--win-white);
  border: 1px solid var(--win-dark);
  font-size: 12px;
  color: var(--win-navy);
  text-decoration: none;
  font-weight: bold;
}

.msg-footer-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: var(--win-darker);
  margin-top: 3px;
}

.msg-hover-actions {
  display: inline-flex;
  gap: 6px;
}

.msg-action-link {
  background: none;
  border: none;
  padding: 0;
  font-size: 10px;
  color: var(--win-navy);
  cursor: pointer;
  font-family: inherit;
}

.msg-action-link:hover {
  text-decoration: underline;
}

/* Typing Indicator & Reply Preview Bar */
.typing-bar {
  min-height: 20px;
  padding: 2px 10px;
  font-size: 11px;
  font-style: italic;
  color: var(--win-navy);
}

.reply-banner {
  background: #FFFFE1;
  border-top: 1px solid var(--win-dark);
  padding: 5px 10px;
  display: none;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.reply-banner.active {
  display: flex;
}

/* Chat Input Bar */
.chat-composer {
  padding: 8px;
  background: var(--win-grey);
  border-top: 1px solid var(--win-dark);
  display: flex;
  align-items: center;
  gap: 6px;
}

.mobile-back-btn {
  display: none;
}

@media (max-width: 760px) {
  .messenger-shell {
    padding: 8px 8px 60px;
    height: calc(100vh - 54px);
  }

  .messenger-grid {
    grid-template-columns: 1fr;
  }

  .messenger-grid.chat-open .conv-sidebar {
    display: none;
  }

  .messenger-grid:not(.chat-open) .chat-pane {
    display: none;
  }

  .mobile-back-btn {
    display: inline-flex;
  }

  .msg-row {
    max-width: 86%;
  }
}

/* Phase 5: live typing and chat presence */
.typing-bar.is-typing { font-weight: 700; animation: ccTypingPulse 1.15s ease-in-out infinite; }
#chatPartnerLink .online-dot.is-online { background: #008000; box-shadow: 0 0 0 2px #d8ead8; }
#chatPartnerLink .online-dot.is-offline { background: #888; box-shadow: 0 0 0 2px #e2e2e2; }
@keyframes ccTypingPulse { 50% { opacity: .45; } }


/* ConnectChat shortcut beside the Messages page global search */
.messages-search-wrap {
  max-width: 560px;
}
.messages-search-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}
.messages-search-row .header-search-box {
  flex: 1;
  min-width: 0;
}
.messenger-redirect-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 0 auto;
  white-space: nowrap;
  text-decoration: none;
  padding: 5px 10px;
}
.messenger-redirect-btn:focus-visible {
  outline: 2px dotted var(--win-navy);
  outline-offset: 2px;
}
@media (max-width: 520px) {
  .messages-search-wrap {
    max-width: none;
  }
  .messenger-redirect-btn {
    padding: 5px 7px;
    gap: 4px;
    font-size: 12px;
  }
}
