/* ========================================================
   TrailTrack Stories — Direct Messages Styles
   ======================================================== */

/* ---- DM Page Layout ---- */
.dm-page {
  display: flex;
  height: 100%;
}

.dm-sidebar {
  width: 320px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.dm-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.dm-sidebar-header h3 {
  font-size: 1rem;
}

.dm-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.dm-search input {
  padding: 8px 12px;
  font-size: 0.85rem;
}

/* ---- Conversation List ---- */
.dm-conversation-list {
  flex: 1;
  overflow-y: auto;
}

.dm-conversation-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid transparent;
}

.dm-conversation-item:hover {
  background: var(--surface-hover);
}

.dm-conversation-item.active {
  background: var(--surface-active);
  border-left: 3px solid var(--green-light);
}

.dm-conversation-item.unread {
  background: rgba(5, 150, 105, 0.05);
}

.dm-conversation-info {
  flex: 1;
  min-width: 0;
}

.dm-conversation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.dm-conversation-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.unread .dm-conversation-name {
  color: var(--text);
  font-weight: 700;
}

.dm-conversation-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.dm-conversation-preview {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unread .dm-conversation-preview {
  color: var(--text-secondary);
  font-weight: 500;
}

.dm-conversation-badge {
  flex-shrink: 0;
}

/* ---- DM Main Area ---- */
.dm-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* DM Header */
.dm-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

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

.dm-header-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.dm-header-status {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.dm-header-online {
  color: var(--green-light);
}

/* ---- DM Messages ---- */
.dm-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dm-msg {
  display: flex;
  gap: 8px;
  max-width: 75%;
  animation: fade-in 0.2s ease;
}

.dm-msg-incoming {
  align-self: flex-start;
}

.dm-msg-outgoing {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.dm-msg-bubble {
  padding: 8px 14px;
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  line-height: 1.5;
  position: relative;
}

.dm-msg-incoming .dm-msg-bubble {
  background: var(--bg);
  color: var(--text);
  border-bottom-left-radius: var(--radius-sm);
}

.dm-msg-outgoing .dm-msg-bubble {
  background: var(--green);
  color: white;
  border-bottom-right-radius: var(--radius-sm);
}

.dm-msg-photo {
  max-width: 280px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.dm-msg-photo:hover {
  opacity: 0.9;
}

.dm-msg-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.dm-msg-outgoing .dm-msg-time {
  justify-content: flex-end;
}

/* Read receipts */
.dm-read-check {
  font-size: 0.7rem;
}

.dm-read-check.read {
  color: var(--blue);
}

.dm-read-check.unread {
  color: var(--text-muted);
}

/* ---- DM Input ---- */
.dm-input-area {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.dm-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 6px 10px;
  transition: border-color var(--transition-fast);
}

.dm-input-wrap:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 2px var(--green-glow);
}

.dm-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.9rem;
  resize: none;
  outline: none;
  max-height: 100px;
  line-height: 1.4;
  padding: 6px 4px;
}

.dm-input::placeholder {
  color: var(--text-muted);
}

/* ---- DM Empty State ---- */
.dm-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
}

.dm-empty-icon {
  font-size: 3rem;
  opacity: 0.3;
}

@media (max-width: 768px) {
  .dm-page {
    flex-direction: column;
  }

  .dm-sidebar {
    width: 100%;
    max-height: 35vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .dm-msg {
    max-width: 85%;
  }

  .dm-msg-bubble {
    font-size: 0.85rem;
  }

  .dm-msg-photo {
    max-width: 200px;
  }

  /* Input pinned to bottom */
  .dm-input-area {
    position: sticky;
    bottom: 0;
    z-index: 10;
  }

  .dm-messages {
    padding: 10px;
  }

  /* Touch targets for conversation list */
  .dm-conversation-item {
    padding: 12px;
    min-height: 60px;
  }

  .dm-header {
    padding: 10px 12px;
  }
}

@media (max-width: 480px) {
  .dm-sidebar {
    max-height: 30vh;
  }

  .dm-msg {
    max-width: 90%;
  }

  .dm-msg-photo {
    max-width: 160px;
  }
}
