/* ================================================================
   Messaging — Unified Communication (Sprint UC)
   ================================================================ */

.messaging-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.messaging-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color, #2a2a3e);
}

.messaging-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.messaging-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.msg-search-input {
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid var(--border-color, #2a2a3e);
    border-radius: 6px;
    color: var(--text-primary, #e0e0e0);
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    width: 180px;
}

.msg-search-input::placeholder {
    color: var(--text-muted, #666);
}

/* ── Split Panel ─────────────────────────────────────────────── */

.messaging-split {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.messaging-channels {
    width: 250px;
    min-width: 200px;
    border-right: 1px solid var(--border-color, #2a2a3e);
    overflow-y: auto;
    padding: 0.5rem 0;
}

.messaging-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
}

/* ── Channel List ────────────────────────────────────────────── */

.msg-channel-section {
    margin-bottom: 0.5rem;
}

.msg-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted, #888);
    padding: 0.5rem 1rem 0.25rem;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.msg-channel-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary, #ccc);
    transition: background 0.15s;
    position: relative;
}

.msg-channel-item:hover {
    background: var(--bg-hover, rgba(255,255,255,0.05));
}

.msg-channel-item.active {
    background: var(--accent-bg, rgba(99,102,241,0.15));
    color: var(--text-primary, #fff);
}

.msg-channel-item .msg-unread-badge {
    background: var(--accent-color, #6366f1);
    color: #fff;
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    margin-left: auto;
    font-weight: 600;
}

/* ── Presence Indicators ─────────────────────────────────────── */

.msg-presence {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.msg-presence.online  { background: #22c55e; }
.msg-presence.away    { background: #f59e0b; }
.msg-presence.dnd     { background: #ef4444; }
.msg-presence.offline { background: #6b7280; }

/* ── Main Header ─────────────────────────────────────────────── */

.msg-main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border-color, #2a2a3e);
    min-height: 40px;
}

.msg-channel-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.msg-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.msg-typing {
    font-size: 0.75rem;
    color: var(--text-muted, #888);
    font-style: italic;
}

/* ── Messages List ───────────────────────────────────────────── */

.msg-messages-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.msg-message {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    transition: background 0.15s;
}

.msg-message:hover {
    background: var(--bg-hover, rgba(255,255,255,0.03));
}

.msg-message-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.msg-sender {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--accent-color, #6366f1);
}

.msg-time {
    font-size: 0.7rem;
    color: var(--text-muted, #666);
}

.msg-edited {
    font-size: 0.65rem;
    color: var(--text-muted, #888);
    font-style: italic;
}

.msg-content {
    font-size: 0.9rem;
    line-height: 1.4;
    word-break: break-word;
}

.msg-content .mention {
    color: var(--accent-color, #6366f1);
    font-weight: 600;
    cursor: pointer;
}

.msg-content.fox-ai {
    background: rgba(99,102,241,0.08);
    border-left: 3px solid var(--accent-color, #6366f1);
    padding: 0.5rem;
    border-radius: 4px;
    font-style: italic;
}

/* ── Reactions ───────────────────────────────────────────────── */

.msg-reactions {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-top: 0.2rem;
}

.msg-reaction {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid var(--border-color, #2a2a3e);
    border-radius: 12px;
    padding: 0.1rem 0.4rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: border-color 0.15s;
}

.msg-reaction:hover {
    border-color: var(--accent-color, #6366f1);
}

.msg-reaction.own {
    border-color: var(--accent-color, #6366f1);
    background: rgba(99,102,241,0.1);
}

.msg-add-reaction {
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-muted, #888);
    padding: 0.1rem 0.3rem;
}

/* ── Compose Bar ─────────────────────────────────────────────── */

.msg-compose {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color, #2a2a3e);
    align-items: flex-end;
}

.msg-input {
    flex: 1;
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid var(--border-color, #2a2a3e);
    border-radius: 8px;
    color: var(--text-primary, #e0e0e0);
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    resize: none;
    max-height: 120px;
    line-height: 1.4;
    font-family: inherit;
}

.msg-input:focus {
    outline: none;
    border-color: var(--accent-color, #6366f1);
}

/* ── Thread Indicator ────────────────────────────────────────── */

.msg-thread-info {
    font-size: 0.75rem;
    color: var(--accent-color, #6366f1);
    cursor: pointer;
    margin-top: 0.1rem;
}

.msg-thread-info:hover {
    text-decoration: underline;
}

/* ── Dialogs / Modals ────────────────────────────────────────── */

.msg-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.msg-dialog {
    background: var(--bg-primary, #0f0f23);
    border: 1px solid var(--border-color, #2a2a3e);
    border-radius: 12px;
    padding: 1.5rem;
    min-width: 350px;
    max-width: 500px;
}

.msg-dialog h3 {
    margin: 0 0 1rem;
    font-size: 1rem;
}

.msg-dialog input,
.msg-dialog textarea {
    width: 100%;
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid var(--border-color, #2a2a3e);
    border-radius: 6px;
    color: var(--text-primary, #e0e0e0);
    padding: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.msg-dialog-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.75rem;
}

/* ── Responsive ──────────────────────────────────────────────── */

@media (max-width: 768px) {
    .messaging-channels {
        width: 60px;
        min-width: 60px;
    }
    .msg-section-title,
    .msg-channel-item span:not(.msg-unread-badge):not(.msg-presence) {
        display: none;
    }
    .msg-channel-item {
        justify-content: center;
        padding: 0.5rem;
    }
}
