/* MiniChat UI — Pet Shop green + Lucide icons + avatars */
:root {
    --chat-primary: #7AB730;
    --chat-primary-dark: #5f9222;
    --chat-danger: #e25555;
    --chat-warn: #d97706;
    --chat-surface: #ffffff;
    --chat-muted: #8a8f98;
    --chat-line: #ebecef;
    --chat-bg-soft: #f4f7f0;
}

.chat-join-panel {
    background: linear-gradient(135deg, #f7faf3 0%, #eef5e6 100%);
    border: 1px solid var(--chat-line);
    border-radius: 16px;
    padding: 1.5rem;
}

.chat-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    border-radius: 999px;
    font-weight: 600;
    background: #fff;
    border: 1px solid #ddd;
}

.chat-status.online {
    border-color: var(--chat-primary);
    color: var(--chat-primary);
}

.chat-status.offline {
    color: #888;
}

.chat-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #bbb;
}

.chat-status.online .chat-status-dot {
    background: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(122, 183, 48, 0.25);
}

.chat-shell {
    border: 1px solid var(--chat-line);
    border-radius: 18px;
    overflow: hidden;
    background: var(--chat-surface);
    box-shadow: 0 16px 40px rgba(33, 33, 33, 0.08);
    min-height: 640px;
}

.chat-shell-inner {
    min-height: 640px;
}

.chat-sidebar {
    background: #fbfbfb;
    border-right: 1px solid var(--chat-line);
    display: flex;
    flex-direction: column;
    max-height: 640px;
}

.chat-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--chat-line);
    background: #fff;
}

.chat-me-block {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.chat-sidebar-section {
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--chat-line);
    overflow-y: auto;
    flex: 1;
}

.chat-section-title {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #444;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
}

.chat-section-title svg {
    width: 16px;
    height: 16px;
    color: var(--chat-primary);
}

.chat-create-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.chat-input-with-icon {
    position: relative;
    flex: 1;
}

.chat-input-with-icon .chat-field-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--chat-muted);
    pointer-events: none;
}

.chat-input-with-icon .form-control {
    padding-left: 2.4rem;
    border-radius: 12px;
    border-color: var(--chat-line);
}

.chat-input-sm .form-control {
    height: 40px;
    font-size: 0.9rem;
}

.chat-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
}

.chat-btn-icon svg {
    width: 18px;
    height: 18px;
}

.chat-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--chat-line);
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #555;
    transition: all 0.18s ease;
    flex-shrink: 0;
}

.chat-icon-btn svg {
    width: 18px;
    height: 18px;
}

.chat-icon-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
}

.chat-icon-btn-primary {
    background: var(--chat-primary);
    border-color: var(--chat-primary);
    color: #fff;
}

.chat-icon-btn-primary:hover {
    background: var(--chat-primary-dark);
    color: #fff;
}

.chat-icon-btn-danger {
    color: var(--chat-danger);
    border-color: rgba(226, 85, 85, 0.35);
    background: #fff5f5;
}

.chat-icon-btn-danger:hover {
    background: var(--chat-danger);
    border-color: var(--chat-danger);
    color: #fff;
}

.chat-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.chat-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.55rem 0.65rem;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
    margin-bottom: 0.3rem;
}

.chat-list-item:hover {
    background: rgba(122, 183, 48, 0.12);
}

.chat-list-item.active {
    background: var(--chat-primary);
    color: #fff;
}

.chat-list-item-main {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    flex: 1;
}

.chat-list-item-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.chat-list-item-text .name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-list-item-text .meta {
    font-size: 0.7rem;
    opacity: 0.75;
}

.chat-list-item .badge-joined,
.chat-list-item .badge-owner {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    opacity: 0.9;
    margin-left: 0.25rem;
}

.chat-list-item .badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4em;
    padding: 0.12em 0.4em;
    margin-left: 0.3rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    background: rgba(33, 33, 33, 0.1);
    color: inherit;
}

.chat-list-item.active .badge-count {
    background: rgba(255, 255, 255, 0.28);
}

.chat-list-item .chat-item-actions {
    display: flex;
    gap: 0.25rem;
}

.chat-list-item .btn-join {
    font-size: 0.72rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    border: 1px solid rgba(122, 183, 48, 0.5);
    background: #fff;
    color: var(--chat-primary);
    font-weight: 600;
}

.chat-list-item.active .btn-join {
    border-color: rgba(255, 255, 255, 0.55);
    background: transparent;
    color: #fff;
}

.chat-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.chat-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #e25555;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    line-height: 1;
}

.chat-list-item.has-unread .meta {
    color: var(--chat-danger, #e25555);
    font-weight: 600;
}

.chat-list-item.active .chat-unread-badge {
    border-color: var(--chat-primary, #7AB730);
}

.chat-bubble-wrap {
    display: flex;
    flex-direction: column;
    max-width: 100%;
    min-width: 0;
}

.chat-row.mine .chat-bubble-wrap {
    align-items: flex-end;
}

.chat-receipt {
    font-size: 0.7rem;
    color: var(--chat-muted, #8a8f98);
    margin-top: 0.2rem;
    padding: 0 0.25rem;
}

.chat-receipt.seen {
    color: var(--chat-primary, #7AB730);
    font-weight: 600;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: #e8f0dc;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(122, 183, 48, 0.25);
    flex-shrink: 0;
}

.chat-avatar-lg {
    width: 44px;
    height: 44px;
}

.chat-avatar-sm {
    width: 28px;
    height: 28px;
}

.chat-list-item.active .chat-avatar {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.chat-main-pane {
    display: flex;
    flex-direction: column;
    min-height: 640px;
    max-height: 640px;
    background:
        radial-gradient(circle at top right, rgba(122, 183, 48, 0.08), transparent 40%),
        linear-gradient(180deg, #ffffff 0%, var(--chat-bg-soft) 100%);
}

.chat-conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.95rem 1.25rem;
    border-bottom: 1px solid var(--chat-line);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
}

.chat-active-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.chat-header-actions {
    display: flex;
    gap: 0.45rem;
    flex-shrink: 0;
}

.chat-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border-radius: 999px;
    font-weight: 600;
    padding: 0.35rem 0.85rem;
}

.chat-action-btn svg {
    width: 15px;
    height: 15px;
}

.chat-action-leave {
    border: 1px solid rgba(217, 119, 6, 0.45);
    color: var(--chat-warn);
    background: #fffbeb;
}

.chat-action-leave:hover {
    background: var(--chat-warn);
    color: #fff;
    border-color: var(--chat-warn);
}

.chat-action-delete {
    border: 1px solid rgba(226, 85, 85, 0.4);
    color: var(--chat-danger);
    background: #fff5f5;
}

.chat-action-delete:hover {
    background: var(--chat-danger);
    color: #fff;
    border-color: var(--chat-danger);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.chat-empty {
    margin: auto;
    text-align: center;
    color: var(--chat-muted);
    padding: 2rem;
}

.chat-empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto;
    border-radius: 18px;
    background: rgba(122, 183, 48, 0.12);
    color: var(--chat-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-empty-icon svg {
    width: 30px;
    height: 30px;
}

.chat-row {
    display: flex;
    align-items: flex-end;
    gap: 0.55rem;
    max-width: min(82%, 560px);
}

.chat-row.mine {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-row.system,
.chat-row.error {
    align-self: center;
    max-width: 92%;
}

.chat-bubble {
    padding: 0.7rem 0.95rem;
    border-radius: 16px 16px 16px 6px;
    background: #fff;
    border: 1px solid var(--chat-line);
    word-break: break-word;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.chat-row.mine .chat-bubble {
    border-radius: 16px 16px 6px 16px;
    background: var(--chat-primary);
    border-color: transparent;
    color: #fff;
}

.chat-bubble.system {
    background: transparent;
    border: none;
    box-shadow: none;
    color: var(--chat-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 0.2rem 0.5rem;
}

.chat-bubble.error {
    background: #fff3f3;
    border-color: #f5c2c2;
    color: #a33;
    font-size: 0.9rem;
    border-radius: 12px;
}

.chat-bubble .meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.72rem;
    opacity: 0.75;
    margin-bottom: 0.25rem;
}

.chat-row.mine .chat-bubble .meta {
    color: rgba(255, 255, 255, 0.9);
}

.chat-composer {
    display: flex;
    gap: 0.75rem;
    padding: 0.95rem 1.15rem;
    border-top: 1px solid var(--chat-line);
    background: #fff;
    align-items: center;
}

.chat-composer-input-wrap {
    flex: 1;
}

.chat-composer .form-control {
    border-radius: 999px;
    border-color: var(--chat-line);
    padding-left: 1.15rem;
    padding-right: 1.15rem;
}

.chat-composer .form-control:focus {
    box-shadow: 0 0 0 0.2rem rgba(122, 183, 48, 0.2);
    border-color: var(--chat-primary);
}

.chat-send-btn {
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(145deg, var(--chat-primary), var(--chat-primary-dark));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 20px rgba(122, 183, 48, 0.35);
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.chat-send-btn svg {
    width: 22px;
    height: 22px;
}

.chat-send-btn:hover:not(:disabled) {
    transform: translateY(-1px) scale(1.03);
}

.chat-send-btn:disabled {
    opacity: 0.45;
    box-shadow: none;
    cursor: not-allowed;
}

@media (max-width: 991.98px) {
    .chat-sidebar {
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--chat-line);
    }

    .chat-main-pane {
        min-height: 520px;
        max-height: none;
    }

    .chat-shell,
    .chat-shell-inner {
        min-height: auto;
    }
}
