/* ============ 按钮点击反馈 & 交互增强 ============ */

/* 全局：所有可点击元素点击时不出现默认蓝色高亮，增加触感反馈 */
button, [role="button"], a {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* ============ 1. 基础点击反馈（所有 button 默认享受）============ */
button, .btn, [role="button"] {
    position: relative;
    cursor: pointer;
    transition: transform 0.08s cubic-bezier(.2,.8,.2,1),
                box-shadow 0.15s ease,
                filter 0.12s ease,
                background-color 0.15s ease !important;
    user-select: none;
}

/* 悬停（桌面端预览态） */
button:hover:not(:disabled), .btn:hover:not(:disabled) {
    filter: brightness(1.06);
    transform: translateY(-1px);
}

/* 按下瞬间：缩放 + 变暗 + 阴影消失 */
button:active:not(:disabled), .btn:active:not(:disabled),
button.is-pressed, .btn.is-pressed {
    transform: scale(0.96) translateY(0);
    filter: brightness(0.92);
    box-shadow: none !important;
    transition-duration: 0.05s;
}

/* 聚焦环（键盘无障碍） */
button:focus-visible, .btn:focus-visible {
    outline: 3px solid rgba(59, 130, 246, 0.5);
    outline-offset: 2px;
}

/* 禁用态 */
button:disabled, .btn:disabled,
button[disabled], button[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: 0.55;
    filter: grayscale(30%);
    transform: none !important;
    transition: none !important;
}
button:disabled:active, .btn:disabled:active {
    transform: none !important;
    filter: grayscale(30%);
}

/* ============ 2. 抖动反馈（操作确认类按钮）============ */
@keyframes btn-shake {
    0%, 100% { transform: translateX(0) scale(0.96); }
    20% { transform: translateX(-6px) scale(0.96); }
    40% { transform: translateX(6px) scale(0.96); }
    60% { transform: translateX(-4px) scale(0.96); }
    80% { transform: translateX(4px) scale(0.96); }
}
.btn-shake, .is-shaking {
    animation: btn-shake 0.32s cubic-bezier(.36,.07,.19,.97) both !important;
}

/* ============ 3. 成功弹跳反馈 ============ */
@keyframes btn-pop {
    0% { transform: scale(0.96); }
    40% { transform: scale(1.12); filter: brightness(1.15); }
    70% { transform: scale(0.98); }
    100% { transform: scale(1); }
}
.btn-pop, .is-success {
    animation: btn-pop 0.45s cubic-bezier(.34,1.56,.64,1) both !important;
}

/* ============ 4. loading 态 ============ */
.btn-loading, .is-loading {
    cursor: wait !important;
    pointer-events: none;
    opacity: 0.85;
    position: relative;
    padding-left: 2.25rem !important;
}
.btn-loading::before, .is-loading::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 50%;
    width: 14px;
    height: 14px;
    margin-top: -7px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

/* ============ 5. 危险操作的高亮（删除/结账类按钮悬停变红）============ */
.btn-danger-on-hover:hover:not(:disabled) {
    background-color: #dc2626 !important;
    border-color: #dc2626 !important;
    color: #fff !important;
    animation: pulse-danger 0.5s ease-in-out 2;
}
@keyframes pulse-danger {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

/* ============ 6. ripple 水波效果（不依赖任何库）============ */
.btn-ripple {
    overflow: hidden;
}
.btn-ripple::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--rx, 50%) var(--ry, 50%),
                rgba(255,255,255,0.35) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.btn-ripple:active::after, .btn-ripple.is-rippling::after {
    opacity: 1;
    transition: opacity 0s;
}

/* ============ 7. 确认弹窗按钮双点击防护 ============ */
.btn-pending-confirm {
    animation: confirm-pulse 0.8s ease-in-out infinite;
}
@keyframes confirm-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.5); }
    50% { box-shadow: 0 0 0 6px rgba(251, 191, 36, 0); }
}

/* ============ 8. 小按钮特殊处理 ============ */
button[class*="text-xs"], button[class*="text-sm"] {
    transition-duration: 0.06s;
}
button[class*="text-xs"]:active, button[class*="text-sm"]:active {
    transform: scale(0.9);
}
