/* ════════════════════════════════════════════════════════════
   Compass Messages
   ════════════════════════════════════════════════════════════ */

.compass-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ── New thread form ─────────────────────────────────────────── */
.cmsgs-new-thread-form {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 24px;
}

.cmsgs-new-thread-form h3 {
    margin: 0 0 20px;
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
}

.cmsgs-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.compass-btn-secondary {
    background: #f3f4f6;
    color: #374151;
}

.compass-btn-secondary:hover {
    background: #e5e7eb;
}

.cmsgs-error {
    margin-top: 12px;
    padding: 10px 14px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    border-radius: 6px;
    font-size: 0.875rem;
}

/* ── Thread list ─────────────────────────────────────────────── */
.cmsgs-thread-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cmsgs-thread-item {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px 20px;
    cursor: pointer;
    transition: box-shadow .15s, transform .15s;
    position: relative;
}

.cmsgs-thread-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
    transform: translateY(-1px);
}

.cmsgs-thread-item.is-unread {
    border-left: 3px solid #4f46e5;
}

.cmsgs-thread-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.cmsgs-thread-subject {
    font-weight: 700;
    font-size: 0.95rem;
    color: #111827;
}

.cmsgs-unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4f46e5;
    flex-shrink: 0;
}

.cmsgs-thread-client {
    font-size: 0.78rem;
    color: #6b7280;
    margin-bottom: 4px;
}

.cmsgs-thread-preview {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cmsgs-thread-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #9ca3af;
}

/* ── Thread view ─────────────────────────────────────────────── */
.cmsgs-thread-view-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.cmsgs-back-btn {
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.875rem;
    cursor: pointer;
    color: #374151;
    transition: background .15s;
    white-space: nowrap;
}

.cmsgs-back-btn:hover { background: #f9fafb; }

.cmsgs-thread-view-title {
    flex: 1;
    font-size: 1.1rem;
    font-weight: 700;
    color: #111827;
    margin: 0;
}

.cmsgs-delete-btn {
    background: none;
    border: 1px solid #fecaca;
    color: #dc2626;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background .15s;
}

.cmsgs-delete-btn:hover { background: #fef2f2; }

/* ── Messages ────────────────────────────────────────────────── */
.cmsgs-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
    max-height: 500px;
    overflow-y: auto;
    padding: 4px 2px;
}

.cmsgs-message {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cmsgs-message.is-mine {
    align-self: flex-end;
    align-items: flex-end;
}

.cmsgs-message.is-theirs {
    align-self: flex-start;
    align-items: flex-start;
}

.cmsgs-message-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #9ca3af;
}

.cmsgs-message-sender {
    font-weight: 600;
    color: #6b7280;
}

.cmsgs-admin-badge {
    background: #dbeafe;
    color: #1d4ed8;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
}

.cmsgs-message-body {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #1f2937;
}

.cmsgs-message.is-mine .cmsgs-message-body {
    background: #4f46e5;
    color: #fff;
    border-color: #4f46e5;
}

.cmsgs-message-atts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.cmsgs-att-link {
    font-size: 0.78rem;
    color: #4f46e5;
    text-decoration: none;
    background: #eef2ff;
    padding: 3px 8px;
    border-radius: 4px;
    transition: background .15s;
}

.cmsgs-att-link:hover { background: #e0e7ff; }

/* ── Reply form ──────────────────────────────────────────────── */
.cmsgs-reply-form {
    border-top: 1px solid #e5e7eb;
    padding-top: 20px;
}

.cmsgs-reply-form textarea {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 12px;
    font-size: 0.9rem;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color .15s;
}

.cmsgs-reply-form textarea:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}

.cmsgs-reply-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}

.cmsgs-attach-label {
    font-size: 0.82rem;
    color: #6b7280;
    cursor: pointer;
    transition: color .15s;
}

.cmsgs-attach-label:hover { color: #374151; }

.cmsgs-attach-names {
    font-size: 0.78rem;
    color: #9ca3af;
    flex: 1;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 640px) {
    .cmsgs-message { max-width: 90%; }
    .cmsgs-reply-actions { flex-wrap: wrap; }
}