/* ============================================================================
   用户消息编辑：操作栏、内联编辑器、删除确认弹窗
   ============================================================================ */

/* ── 用户消息操作栏 ── */

.msg-user-actions {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--ds-duration) var(--ds-ease);
}

.msg-row--user:hover .msg-user-actions,
.msg-row--user:focus-within .msg-user-actions {
    opacity: 1;
    pointer-events: auto;
}

.msg-user-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: var(--ds-radius);
    background: transparent;
    color: var(--ds-text-muted);
    cursor: pointer;
    transition: background var(--ds-duration) var(--ds-ease),
        color var(--ds-duration) var(--ds-ease);
}

.msg-user-action svg {
    width: 15px;
    height: 15px;
    fill: currentColor;
}

.msg-user-action:hover {
    background: var(--ds-surface-hover);
    color: var(--ds-text);
}

.msg-user-action:focus-visible {
    outline: none;
    box-shadow: var(--ds-focus-ring);
}

.msg-user-action[hidden] {
    display: none;
}

/* ── 内联编辑器 ── */

.msg-edit {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface);
}

.msg-edit-input {
    width: 100%;
    min-height: 24px;
    max-height: 320px;
    padding: 0;
    border: none;
    outline: none;
    background: transparent;
    color: var(--ds-text);
    font: inherit;
    font-size: 15px;
    line-height: 1.6;
    resize: none;
    overflow-y: auto;
}

.msg-edit-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
}

.msg-edit-hint {
    font-size: 11.5px;
    color: var(--ds-text-muted);
}

.msg-edit-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.msg-edit-btn-ghost,
.msg-edit-btn-danger {
    min-height: 34px;
    padding: 0 16px;
    border-radius: var(--ds-radius);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--ds-duration) var(--ds-ease),
        color var(--ds-duration) var(--ds-ease),
        opacity var(--ds-duration) var(--ds-ease);
}

.msg-edit-btn-ghost {
    border: 1px solid var(--ds-border);
    background: transparent;
    color: var(--ds-text-secondary);
}

.msg-edit-btn-ghost:hover {
    background: var(--ds-surface-hover);
    color: var(--ds-text);
}

.msg-edit-btn-danger {
    border: 1px solid transparent;
    background: var(--c-danger, #e5484d);
    color: #ffffff;
}

.msg-edit-btn-danger:hover {
    background: var(--c-danger-hover, #d93a3f);
}

.msg-edit-btn-ghost:disabled,
.msg-edit-btn-danger:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ── 确认弹窗 ── */

.msg-edit-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.msg-edit-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.msg-edit-dialog {
    position: relative;
    width: min(420px, 100%);
    padding: 22px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-bg-subtle);
    box-shadow: var(--ds-shadow-lg);
}

.msg-edit-dialog-title {
    margin: 0 0 10px;
    color: var(--ds-text);
    font-size: 16px;
    font-weight: 600;
}

.msg-edit-dialog-text {
    margin: 0;
    color: var(--ds-text-secondary);
    font-size: 13.5px;
    line-height: 1.65;
    text-wrap: pretty;
}

.msg-edit-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* ── 侧栏头像 ── */

.user-avatar--img {
    overflow: hidden;
}

.user-avatar--img img {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
}

/* ── 移动端 ── */

@media (max-width: 768px) {
    .msg-user-actions {
        opacity: 1;
        pointer-events: auto;
    }

    .msg-user-action {
        width: 36px;
        height: 36px;
    }

    .msg-user-action svg {
        width: 17px;
        height: 17px;
    }

    .msg-edit {
        padding: 12px;
    }

    .msg-edit-hint {
        display: none;
    }

    .msg-edit-btn-ghost,
    .msg-edit-btn-danger {
        min-height: 40px;
    }

    .msg-edit-overlay {
        padding: 16px;
    }
}

/* ── 减少动态效果 ── */

@media (prefers-reduced-motion: reduce) {
    .msg-user-actions,
    .msg-user-action,
    .msg-edit-btn-ghost,
    .msg-edit-btn-danger {
        transition: none;
    }
}
