/* ============================================================
   DISCOURSE MESSAGES
   ============================================================ */

/* ── Page overrides ── */
.discourse-messages-page .discourse-right-sidebar { display: none !important; }
.discourse-messages-main {
    padding: 0 !important;
    max-width: none !important;   /* override the feed max-width */
    width: 100%;
    overflow: hidden;
    flex: 1;                      /* fill all remaining space in the flex row */
}

/* ── Two-pane container ── */
.dm-container {
    display: flex;
    height: calc(100vh - 60px);
    overflow: hidden;
    width: 100%;
}

/* ── LEFT PANE — conversation list (420px) ── */
.dm-sidebar {
    width: 420px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #333;
    overflow: hidden;
    transition: transform 0.2s ease;
    background: #1a1a1a;
}
body:not(.dark-mode) .dm-sidebar {
    border-right-color: #e6ecf0;
    background: #f7f9f9;
}

.dm-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid #333;
    background: #1a1a1a;
    position: sticky;
    top: 0;
    z-index: 10;
}
body:not(.dark-mode) .dm-sidebar-header {
    background: #f7f9f9;
    border-bottom-color: #e6ecf0;
}

.dm-sidebar-title {
    font-size: 20px;
    font-weight: 800;
    margin: 0;
    color: #e8e8e8;
}
body:not(.dark-mode) .dm-sidebar-title { color: #0f1419; }

/* New message button */
.dm-new-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    color: #ff9801;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.dm-new-btn:hover { background: rgba(255, 152, 1,0.1); }
.dm-new-btn svg { width: 34px; height: 34px; fill: currentColor; }

.dm-conv-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #1a1a1a;
}
body:not(.dark-mode) .dm-conv-list { background: #f7f9f9; }

.dm-conv-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid #2a2a2a;
    background: #1a1a1a;
}
body:not(.dark-mode) .dm-conv-row { border-bottom-color: #e6ecf0; background: #f7f9f9; }
.dm-conv-row:hover    { background: #222; }
body:not(.dark-mode) .dm-conv-row:hover { background: #edf0f2; }
.dm-conv-row.active   { background: rgba(255, 152, 1,0.07); }
body:not(.dark-mode) .dm-conv-row.active { background: rgba(255, 152, 1,0.05); }

.dm-conv-row-avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.dm-conv-row-body   { flex: 1; min-width: 0; }
.dm-conv-row-top    { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 3px; }
.dm-conv-row-name   { font-size: 15px; font-weight: 600; color: #666; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body:not(.dark-mode) .dm-conv-row-name { color: #536471; }
.dm-conv-row-name.dm-unread { color: #e8e8e8; font-weight: 700; }
body:not(.dark-mode) .dm-conv-row-name.dm-unread { color: #0f1419; }
.dm-conv-row-time    { font-size: 12px; color: #666; flex-shrink: 0; margin-left: 8px; }
.dm-conv-row-preview { font-size: 14px; color: #666; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body:not(.dark-mode) .dm-conv-row-preview { color: #536471; }
.dm-conv-row-preview.dm-unread { color: #e8e8e8; }
body:not(.dark-mode) .dm-conv-row-preview.dm-unread { color: #0f1419; }
.dm-unread-dot { width: 10px; height: 10px; background: #ff9801; border-radius: 50%; flex-shrink: 0; align-self: center; }
.dm-empty-inbox { padding: 40px 20px; text-align: center; color: #666; font-size: 14px; line-height: 1.6; }

/* ── RIGHT PANE — conversation view ── */
.dm-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    background: #111;
}
body:not(.dark-mode) .dm-view { background: #fff; }

/* Empty state */
.dm-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    gap: 12px;
    background: #111;
}
body:not(.dark-mode) .dm-empty-state { background: #fff; }
.dm-empty-state svg { width: 60px; height: 60px; fill: #555; margin-bottom: 4px; }
.dm-empty-state h3 { font-size: 22px; font-weight: 800; margin: 0; color: #e8e8e8; }
body:not(.dark-mode) .dm-empty-state h3 { color: #0f1419; }
.dm-empty-state p { font-size: 15px; color: #666; margin: 0; max-width: 320px; line-height: 1.5; }
.dm-empty-new-btn { margin-top: 8px; padding: 10px 28px; background: #ff9801; color: #fff; border: none; border-radius: 0; font-size: 15px; font-weight: 700; cursor: pointer; transition: opacity 0.2s; }
.dm-empty-new-btn:hover { opacity: 0.85; }

/* Conversation header */
.dm-conv-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #333;
    background: #1a1a1a;
    z-index: 10;
    flex-shrink: 0;
}
body:not(.dark-mode) .dm-conv-header { background: #fff; border-bottom-color: #e6ecf0; }
.dm-back-btn { background: none; border: none; cursor: pointer; color: #666; padding: 6px; border-radius: 50%; display: none; align-items: center; justify-content: center; transition: background 0.15s, color 0.15s; }
.dm-back-btn:hover { background: rgba(255, 152, 1,0.1); color: #ff9801; }
.dm-back-btn svg { width: 20px; height: 20px; fill: currentColor; }
.dm-conv-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; cursor: pointer; transition: opacity 0.2s; }
.dm-conv-avatar:hover { opacity: 0.8; }
.dm-conv-header-info { flex: 1; display: flex; flex-direction: column; }
.dm-conv-name { font-size: 16px; font-weight: 700; color: #e8e8e8; cursor: pointer; }
body:not(.dark-mode) .dm-conv-name { color: #0f1419; }
.dm-conv-name:hover { text-decoration: underline; }
.dm-conv-handle { font-size: 13px; color: #666; }
.dm-delete-conv-btn { background: none; border: none; cursor: pointer; color: #666; padding: 8px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: background 0.15s, color 0.15s; margin-left: auto; }
.dm-delete-conv-btn:hover { background: rgba(220,53,69,0.1); color: #dc3545; }
.dm-delete-conv-btn svg { width: 20px; height: 20px; fill: currentColor; }

/* Messages area */
.dm-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #111;
}
body:not(.dark-mode) .dm-messages { background: #fff; }
.dm-loading-messages { text-align: center; color: #666; padding: 40px; font-size: 14px; }
.dm-bubble-wrap { display: flex; align-items: flex-end; gap: 8px; max-width: 72%; }
.dm-mine   { align-self: flex-end; flex-direction: row-reverse; }
.dm-theirs { align-self: flex-start; }
.dm-bubble-animate { animation: dmBubbleIn 0.18s ease both; }
@keyframes dmBubbleIn {
    from { opacity: 0; transform: translateY(8px) scale(0.96); }
    to   { opacity: 1; transform: none; }
}
.dm-bubble-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; margin-bottom: 18px; }
.dm-bubble-content { display: flex; flex-direction: column; }
.dm-bubble { padding: 10px 14px; font-size: 15px; line-height: 1.5; word-break: break-word; }
.dm-bubble-mine   { background: #ff9801; color: #fff; border-radius: 18px 18px 4px 18px; }
.dm-bubble-theirs { background: #2a2a2a; color: #e8e8e8; border-radius: 18px 18px 18px 4px; }
body:not(.dark-mode) .dm-bubble-theirs { background: #e8ecef; color: #0f1419; }
.dm-bubble-time { font-size: 11px; color: #666; margin-top: 3px; padding: 0 4px; }
.dm-mine .dm-bubble-time   { text-align: right; }
.dm-theirs .dm-bubble-time { text-align: left; }

/* Composer */
.dm-composer {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid #333;
    flex-shrink: 0;
    background: #1a1a1a;
}
body:not(.dark-mode) .dm-composer { background: #fff; border-top-color: #e6ecf0; }
.dm-textarea { flex: 1; background: #222; border: 1px solid #333; border-radius: 20px; padding: 10px 16px; font-size: 15px; color: #e8e8e8; resize: none; outline: none; line-height: 1.5; min-height: 40px; max-height: 120px; overflow-y: auto; font-family: inherit; transition: border-color 0.2s; }
body:not(.dark-mode) .dm-textarea { background: #f7f9f9; border-color: #cfd9de; color: #0f1419; }
.dm-textarea:focus { border-color: #ff9801; }
.dm-textarea::placeholder { color: #555; }
.dm-send-btn { width: 40px; height: 40px; border-radius: 50%; background: #ff9801; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: opacity 0.2s; }
.dm-send-btn:disabled { opacity: 0.4; cursor: default; }
.dm-send-btn:not(:disabled):hover { opacity: 0.85; }
.dm-send-btn svg { width: 20px; height: 20px; fill: #fff; }

/* ── New message modal ── */
.dm-new-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 100000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 60px;
}
.dm-new-modal {
    background: #1a1a1a;
    border: 1px solid #333;
    width: 100%;
    max-width: 600px;
    overflow: hidden;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}
body:not(.dark-mode) .dm-new-modal { background: #fff; border-color: #e6ecf0; }
.dm-new-modal-header { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid #333; background: #1a1a1a; }
body:not(.dark-mode) .dm-new-modal-header { background: #fff; border-bottom-color: #e6ecf0; }
.dm-new-modal-header h3 { font-size: 17px; font-weight: 800; margin: 0; color: #e8e8e8; }
body:not(.dark-mode) .dm-new-modal-header h3 { color: #0f1419; }
.dm-new-modal-close { background: none; border: none; cursor: pointer; color: #666; padding: 6px; border-radius: 50%; display: flex; transition: background 0.15s, color 0.15s; }
.dm-new-modal-close:hover { background: rgba(255,255,255,0.06); color: #e8e8e8; }
body:not(.dark-mode) .dm-new-modal-close:hover { background: rgba(0,0,0,0.05); color: #0f1419; }
.dm-new-modal-close svg { width: 20px; height: 20px; fill: currentColor; }
.dm-new-modal-search { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid #333; background: #1a1a1a; }
body:not(.dark-mode) .dm-new-modal-search { background: #fff; border-bottom-color: #e6ecf0; }
.dm-search-icon { width: 20px; height: 20px; fill: #ff9801; flex-shrink: 0; }
.dm-new-modal-search input { flex: 1; background: none; border: none; outline: none; font-size: 17px; color: #e8e8e8; font-family: inherit; }
body:not(.dark-mode) .dm-new-modal-search input { color: #0f1419; }
.dm-new-modal-search input::placeholder { color: #555; }
.dm-new-results { flex: 1; overflow-y: auto; background: #1a1a1a; }
body:not(.dark-mode) .dm-new-results { background: #fff; }
.dm-new-hint { padding: 20px 16px; font-size: 14px; color: #666; text-align: center; }
.dm-new-user-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; transition: background 0.15s; }
.dm-new-user-row:hover { background: rgba(255,255,255,0.04); }
body:not(.dark-mode) .dm-new-user-row:hover { background: rgba(0,0,0,0.03); }
.dm-new-user-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.dm-new-user-info { display: flex; flex-direction: column; }
.dm-new-user-name { font-size: 15px; font-weight: 700; color: #e8e8e8; }
body:not(.dark-mode) .dm-new-user-name { color: #0f1419; }
.dm-new-user-handle { font-size: 13px; color: #666; }

/* ── Misc ── */
.dm-loading { padding: 20px; text-align: center; color: #666; font-size: 14px; }

/* ── Mobile ── */
@media (max-width: 900px) { .dm-sidebar { width: 300px; } }
@media (max-width: 768px) {
    .dm-container { position: relative; }
    .dm-sidebar { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; z-index: 2; transition: transform 0.25s ease; }
    .dm-sidebar.dm-sidebar-hidden { transform: translateX(-100%); pointer-events: none; }
    .dm-view { position: absolute; left: 0; top: 0; bottom: 0; right: 0; z-index: 1; }
    .dm-back-btn { display: flex !important; }
}

/* ── Profile message buttons ── */
.discourse-profile-info-section { position: relative; }

.discourse-profile-msg-btn {
    position: absolute;
    top: 60px;
    right: 16px;
    background: none;
    border: none;
    border-radius: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    color: #ff9801;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
    opacity: 0.85;
}
.discourse-profile-msg-btn:hover { opacity: 1; }
.discourse-profile-msg-btn svg { width: 34px; height: 34px; }

/* Messaging disabled: entire button goes grey, strikethrough line */
#profile-messaging-toggle-btn.active {
    color: #555;
    position: relative;
}
#profile-messaging-toggle-btn.active svg rect,
#profile-messaging-toggle-btn.active svg path {
    fill: #555;
    stroke: #555;
}
#profile-messaging-toggle-btn.active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 5%;
    width: 90%;
    height: 2px;
    background: #555;
    transform: rotate(-45deg);
    pointer-events: none;
}

