/* The chat page (Components/Pages/Chat/Chat.razor) and its header icon. */
.chat-layout {
    display: flex;
    height: calc(100vh - 120px);
    min-height: 420px;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    overflow: hidden;
    background: var(--background);
}

.chat-side {
    width: 290px;
    flex: 0 0 290px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--muted, #f9f9f9);
    min-height: 0;
}

.chat-side-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid var(--border);
}

.chat-side-head h1 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}

.chat-pick {
    padding: 0.5rem 0.9rem;
    border-bottom: 1px solid var(--border);
}

.chat-rooms {
    flex: 1;
    overflow-y: auto;
    padding: 0.25rem 0 0.75rem;
}

.chat-group {
    padding: 0.75rem 0.9rem 0.3rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted-foreground);
}

.chat-empty-side {
    padding: 0.25rem 0.9rem;
    font-size: 0.78rem;
    color: var(--muted-foreground);
}

.chat-room {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0.4rem;
    padding: 0.45rem 0.5rem;
    border-radius: 0.45rem;
    color: var(--foreground);
}

.chat-room:hover {
    background: color-mix(in srgb, #1b84ff 7%, transparent);
}

.chat-room.active {
    background: color-mix(in srgb, #1b84ff 14%, transparent);
}

.chat-room-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, #1b84ff 14%, transparent);
    color: #1b84ff;
}

.chat-room-icon.private {
    background: color-mix(in srgb, #7239ea 14%, transparent);
    color: #7239ea;
}

.chat-room .user-avatar {
    flex: 0 0 28px;
}

.chat-room-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.chat-room-name {
    font-size: 0.84rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-room.unread .chat-room-name {
    font-weight: 600;
}

.chat-room-last {
    font-size: 0.72rem;
    color: var(--muted-foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-unread {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #1b84ff;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

.chat-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--muted-foreground);
    font-size: 0.9rem;
}

.chat-placeholder i {
    font-size: 2.5rem;
    color: color-mix(in srgb, #1b84ff 45%, transparent);
}

.chat-placeholder.small {
    flex: 0;
    padding: 2rem 0;
}

.chat-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
}

.chat-head-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-head-text strong {
    font-size: 0.95rem;
}

.chat-head-text span {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1rem;
}

.chat-more {
    text-align: center;
    margin-bottom: 0.5rem;
}

.chat-day {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.9rem 0 0.5rem;
    color: var(--muted-foreground);
    font-size: 0.72rem;
}

.chat-day::before,
.chat-day::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--border);
}

.chat-msg {
    display: flex;
    gap: 0.5rem;
    margin-top: 2px;
}

.chat-msg.first {
    margin-top: 0.6rem;
}

.chat-msg-avatar {
    width: 28px;
    flex: 0 0 28px;
}

.chat-msg-content {
    max-width: 70%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.chat-msg.mine {
    flex-direction: row-reverse;
}

.chat-msg.mine .chat-msg-avatar {
    display: none;
}

.chat-msg.mine .chat-msg-content {
    align-items: flex-end;
}

.chat-msg-meta {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    font-size: 0.72rem;
    color: var(--muted-foreground);
    margin-bottom: 2px;
}

.chat-msg-meta strong {
    color: var(--foreground);
    font-size: 0.78rem;
}

.chat-bubble {
    padding: 0.4rem 0.7rem;
    border-radius: 0.9rem;
    background: var(--muted, #f1f1f4);
    border: 1px solid var(--border);
    font-size: 0.86rem;
    line-height: 1.4;
}

.chat-msg.mine .chat-bubble {
    background: #1b84ff;
    border-color: #1b84ff;
    color: #fff;
}

.chat-bubble.deleted,
.chat-msg.mine .chat-bubble.deleted {
    background: transparent;
    border-color: var(--border);
    color: var(--muted-foreground);
    font-style: italic;
    font-size: 0.78rem;
}

.chat-bubble.editing {
    outline: 2px solid #f6b100;
}

.chat-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chat-text.big {
    font-size: 1.8rem;
    line-height: 1.2;
}

.chat-edited {
    margin-left: 0.4rem;
    font-size: 0.68rem;
    opacity: 0.75;
}

.chat-msg-actions {
    display: none;
    gap: 0.25rem;
    margin-top: 2px;
}

.chat-msg:hover .chat-msg-actions {
    display: flex;
}

.chat-msg-actions button {
    border: none;
    background: none;
    color: var(--muted-foreground);
    font-size: 0.85rem;
    padding: 0 0.15rem;
    cursor: pointer;
}

.chat-msg-actions button:hover {
    color: #1b84ff;
}

.chat-compose {
    border-top: 1px solid var(--border);
    padding: 0.6rem 1rem 0.75rem;
}

.chat-editing {
    font-size: 0.75rem;
    color: #b88300;
    margin-bottom: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.chat-compose-row {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.chat-box {
    flex: 1;
    resize: none;
    min-height: 38px;
    max-height: 140px;
    field-sizing: content;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    font-size: 0.86rem;
    background: var(--background);
    color: var(--foreground);
    outline: none;
}

.chat-box:focus {
    border-color: #1b84ff;
}

.chat-send,
.chat-emoji-button {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 50%;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.15rem;
}

.chat-send {
    background: #1b84ff;
    color: #fff;
}

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

.chat-emoji {
    position: relative;
}

.chat-emoji-button {
    background: transparent;
    color: var(--muted-foreground);
}

.chat-emoji-button:hover {
    color: #f6b100;
}

.chat-emoji-panel {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    z-index: 50;
    width: 300px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 0.4rem;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    background: var(--background);
    box-shadow: 0 6px 20px rgb(0 0 0 / 0.12);
}

.chat-emoji-panel button {
    border: none;
    background: none;
    font-size: 1.3rem;
    line-height: 1;
    padding: 0.25rem 0;
    border-radius: 0.4rem;
    cursor: pointer;
}

.chat-emoji-panel button:hover {
    background: var(--muted, #f1f1f4);
}

.chat-readonly {
    border-top: 1px solid var(--border);
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    color: var(--muted-foreground);
}

.chat-icon {
    text-decoration: none;
}

/* The back arrow to the list: only on narrow screens, where the list and the room take turns. */
.chat-back {
    display: none;
    color: var(--muted-foreground);
    font-size: 1.1rem;
}

@media (max-width: 768px) {
    .chat-layout {
        height: calc(100vh - 100px);
    }

    .chat-side {
        width: 100%;
        flex: 1 1 auto;
        border-right: none;
    }

    .chat-layout.has-room .chat-side,
    .chat-layout.no-room .chat-main {
        display: none;
    }

    .chat-back {
        display: inline-flex;
    }

    .chat-msg-content {
        max-width: 85%;
    }

    .chat-emoji-panel {
        width: 260px;
        grid-template-columns: repeat(7, 1fr);
    }
}
