/* ============================================================
   Livasta Host Dashboard — Messages Page Styles
   ============================================================ */

/* ---------- Messages Layout ---------- */
.messages-layout {
  display: grid;
  grid-template-columns: 1fr;
  background: var(--white);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(220, 232, 223, 0.7);
  overflow: hidden;
  min-height: 560px;
}

@media (min-width: 1024px) {
  .messages-layout {
    grid-template-columns: 340px 1fr;
  }
}

/* ---------- Conversations Sidebar ---------- */
.msg-sidebar {
  border-bottom: 1px solid var(--sage);
  display: flex;
  flex-direction: column;
  max-height: 560px;
}

@media (min-width: 1024px) {
  .msg-sidebar {
    border-bottom: none;
    border-right: 1px solid var(--sage);
    max-height: none;
  }
}

.msg-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(220, 232, 223, 0.5);
}

.msg-sidebar-header h3 {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--pine);
}

.msg-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px 12px;
}

.msg-search input {
  flex: 1;
  background: var(--canvas);
  border: 1px solid var(--sage);
  border-radius: var(--radius-full);
  padding: 8px 14px;
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition-fast);
}

.msg-search input:focus {
  border-color: var(--pine);
}

.msg-filter-tabs {
  display: flex;
  gap: 4px;
  padding: 0 20px 12px;
}

.msg-filter-tab {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-full);
  color: var(--muted);
  transition: all var(--transition-fast);
  cursor: pointer;
  border: none;
  background: none;
}

.msg-filter-tab.active {
  background: var(--pine);
  color: var(--cream);
}

.msg-filter-tab:hover:not(.active) {
  background: rgba(220, 232, 223, 0.5);
}

.msg-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
}

/* ---------- Message Item ---------- */
.msg-item {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(220, 232, 223, 0.4);
  cursor: pointer;
  transition: background var(--transition-fast);
  width: 100%;
  text-align: left;
  align-items: flex-start;
  background: none;
  border-left: 3px solid transparent;
}

.msg-item:hover {
  background: rgba(220, 232, 223, 0.2);
}

.msg-item.active {
  background: rgba(220, 232, 223, 0.35);
  border-left-color: var(--coral);
}

.msg-item.unread {
  background: rgba(235, 111, 74, 0.04);
}

.msg-item .msg-avatar {
  position: relative;
  flex-shrink: 0;
}

.msg-item .msg-avatar img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}

.msg-item .msg-avatar .online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #2F7D4F;
  border: 2px solid var(--white);
}

.msg-item .msg-preview {
  flex: 1;
  min-width: 0;
}

.msg-item .msg-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.msg-item .msg-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-item .msg-time {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

.msg-item .msg-property {
  font-size: 12px;
  color: var(--coral);
  font-weight: 500;
  margin-top: 1px;
}

.msg-item .msg-text {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 3px;
}

.msg-item .msg-unread-badge {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--coral);
  color: var(--cream);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ---------- Chat Panel ---------- */
.chat-panel {
  display: none;
  flex-direction: column;
}

.chat-panel.active {
  display: flex;
}

@media (min-width: 1024px) {
  .chat-panel {
    display: flex;
  }
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(220, 232, 223, 0.5);
}

.chat-header img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-header .chat-info {
  flex: 1;
}

.chat-header .chat-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.chat-header .chat-context {
  font-size: 12px;
  color: var(--muted);
}

.chat-header .chat-actions {
  display: flex;
  gap: 8px;
}

.chat-header .chat-actions button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--sage);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.chat-header .chat-actions button:hover {
  border-color: var(--pine);
  background: rgba(220, 232, 223, 0.3);
}

.chat-back-btn {
  display: flex;
}

@media (min-width: 1024px) {
  .chat-back-btn { display: none; }
}

/* ---------- Chat Messages ---------- */
.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
}

.chat-bubble {
  max-width: 72%;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
}

.chat-bubble.incoming {
  background: rgba(220, 232, 223, 0.5);
  border-radius: var(--radius-xl) var(--radius-xl) var(--radius-xl) 4px;
  align-self: flex-start;
  color: var(--ink);
}

.chat-bubble.outgoing {
  background: var(--pine);
  color: var(--cream);
  border-radius: var(--radius-xl) var(--radius-xl) 4px var(--radius-xl);
  align-self: flex-end;
}

.chat-bubble .bubble-time {
  font-size: 10px;
  opacity: 0.6;
  margin-top: 4px;
  display: block;
}

.chat-date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.chat-date-divider::before,
.chat-date-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--sage);
}

.chat-typing {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(220, 232, 223, 0.3);
  border-radius: var(--radius-xl);
  align-self: flex-start;
  font-size: 13px;
  color: var(--muted);
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-bounce 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* ---------- Chat Input ---------- */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid rgba(220, 232, 223, 0.5);
}

.chat-input-area .attach-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
  flex-shrink: 0;
}

.chat-input-area .attach-btn:hover {
  background: rgba(220, 232, 223, 0.5);
}

.chat-input-area input {
  flex: 1;
  background: var(--canvas);
  border: 1px solid var(--sage);
  border-radius: var(--radius-full);
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition-fast);
}

.chat-input-area input:focus {
  border-color: var(--pine);
}

.chat-input-area .send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--coral);
  color: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.chat-input-area .send-btn:hover {
  background: var(--coral-dark);
  transform: scale(1.05);
}

/* ---------- Empty Chat State ---------- */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  text-align: center;
}

.chat-empty .empty-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--sage);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.chat-empty h3 {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--pine);
  margin-bottom: 8px;
}

.chat-empty p {
  font-size: 14px;
  color: var(--muted);
  max-width: 280px;
}

/* ---------- Quick Replies ---------- */
.quick-replies {
  display: flex;
  gap: 8px;
  padding: 0 20px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.quick-replies::-webkit-scrollbar { display: none; }

.quick-reply-chip {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--sage);
  border-radius: var(--radius-full);
  white-space: nowrap;
  color: var(--pine);
  transition: all var(--transition-fast);
  cursor: pointer;
  background: none;
}

.quick-reply-chip:hover {
  border-color: var(--coral);
  color: var(--coral);
  background: rgba(235, 111, 74, 0.05);
}
