/* ============================================================
   Chat UI — Message bubbles, input bar, platform badges
   ============================================================ */

.chat-container {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* height set dynamically via JS — _setChatHeight() */
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) 0;
}

/* --- Message bubble --- */
.chat-msg {
    max-width: 85%;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    line-height: var(--line-height-normal);
    font-size: var(--text-base);
    word-break: break-word;
    position: relative;
}

.chat-msg--in {
    align-self: flex-start;
    background: var(--secondary-bg);
    color: var(--text-color);
    border-bottom-left-radius: var(--radius-xs);
}

.chat-msg--out {
    align-self: flex-end;
    background: var(--button-color);
    color: var(--button-text-color);
    border-bottom-right-radius: var(--radius-xs);
}

/* Platform badge inside inbound messages */
.chat-msg__platform {
    font-size: var(--text-2xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    opacity: 0.7;
    margin-bottom: 2px;
}

/* Media type indicator */
.chat-msg__media {
    font-size: var(--text-sm);
    opacity: 0.8;
    font-style: italic;
}

/* Footer with time and sender */
.chat-msg__footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: var(--spacing-xs);
    margin-top: 2px;
}

.chat-msg__time {
    font-size: var(--text-2xs);
    opacity: 0.6;
}

.chat-msg__sender {
    font-size: var(--text-2xs);
    opacity: 0.6;
}

/* --- Date separator --- */
.chat-date-sep {
    text-align: center;
    font-size: var(--text-xs);
    color: var(--hint-color);
    margin: var(--spacing-sm) 0;
    font-weight: var(--weight-medium);
}

/* --- Input bar --- */
.chat-input-bar {
    position: relative;
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm);
    background: var(--bg-color);
    border-top: 1px solid var(--separator-color);
}

.chat-input-bar textarea {
    flex: 1;
    min-height: 36px;
    max-height: 100px;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--separator-color-opaque);
    border-radius: var(--radius-lg);
    background: var(--secondary-bg);
    color: var(--text-color);
    font-size: var(--text-base);
    font-family: var(--font-family);
    resize: none;
    outline: none;
    line-height: var(--line-height-normal);
}

.chat-input-bar textarea:focus {
    border-color: var(--button-color);
    box-shadow: var(--input-shadow-focus);
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-round);
    background: var(--button-color);
    color: var(--button-text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity var(--transition-fast);
}

.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.chat-send-btn:active:not(:disabled) {
    opacity: 0.7;
}

/* --- Channel selector (when multiple channels) --- */
.chat-channel-select {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 0 var(--spacing-sm) var(--spacing-xs);
    font-size: var(--text-xs);
    color: var(--hint-color);
}

.chat-channel-select select {
    font-size: var(--text-xs);
    padding: 2px var(--spacing-xs);
    border: 1px solid var(--separator-color-opaque);
    border-radius: var(--radius-xs);
    background: var(--secondary-bg);
    color: var(--text-color);
}

/* --- Empty chat state --- */
.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl) var(--spacing-md);
    color: var(--hint-color);
    text-align: center;
}

.chat-empty svg {
    margin-bottom: var(--spacing-sm);
    opacity: 0.4;
}

.chat-empty p {
    font-size: var(--text-sm);
}

/* --- Channel icon button (left of textarea) — shows colored logo --- */
.chat-channel-icon {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-round);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: default;
    padding: 0;
}

.chat-channel-icon--switch {
    cursor: pointer;
}

.chat-channel-icon--switch:active {
    opacity: 0.7;
}

/* --- Channel picker popup — horizontal icon circles --- */
.chat-channel-picker {
    flex-direction: row;
    justify-content: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--secondary-bg);
    border-top: 1px solid var(--separator-color);
}

.chat-channel-picker__item {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px solid transparent;
    padding: 2px;
    -webkit-tap-highlight-color: transparent;
}

.chat-channel-picker__item:active {
    opacity: 0.7;
}

.chat-channel-picker__item--active {
    border-color: var(--button-color);
}

.chat-channel-picker__blocked {
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: 14px;
    line-height: 1;
}

.chat-channel-picker__item {
    position: relative;
}

.chat-blocked-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    background: var(--secondary-bg);
    border-top: 1px solid var(--separator-color);
    color: var(--hint-color);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
}
