.floating-button-container {
    position: absolute;
    right: 0px;
    z-index: 1000; /* Adjust the z-index as needed to ensure the button is on top of other elements within the container */
    transition: all 0.3s ease;
}

/* 浮動按鈕容器動畫 */
.floating-button-container .btn-group-vertical {
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

/* 浮動按鈕顯示/隱藏動畫 */
.floating-button {
    transition: all 0.3s ease;
    opacity: 1;
    transform: translateY(0);
}

.floating-button.notShow {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    max-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
}


.left-align {
    display: flex;
    justify-content: flex-end;
}


.btn-primary.disabled, .btn-primary:disabled {
    color: #8b8b8b;
    background-color: #0e3f7f;
    border-color: #0e3f7f;
}

/* 移除動畫相關樣式 */
.removing-item {
    transition: all 0.3s ease;
    transform: scale(0.95);
    opacity: 0.7;
}

.removing-item .btn {
    pointer-events: none;
}

/* 統一按鈕基礎樣式和動畫 */
.smaller-button {
    transition: all 0.3s ease;
    cursor: pointer;
    user-select: none;
    position: relative;
    overflow: hidden;
}

/* 按鈕 Hover 效果 */
.smaller-button:hover:not(:disabled):not(.disabled) {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* 按鈕 Active 狀態動畫 */
.smaller-button:active:not(:disabled):not(.disabled) {
    transform: translateY(0) scale(0.98);
    transition: transform 0.1s ease;
}

/* 移除按鈕點擊動畫 */
.removePcsBtn:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

/* 按鈕容器改進 - 統一間距 */
.card-body .d-flex > .smaller-button:not(:last-child) {
    margin-right: 0.5rem;
}

/* 預購商品區域按鈕樣式統一 */
.sendToSPingCart {
    margin-top: 0.5rem;
    width: 100%;
}

/* 卡片移除動畫 */
.card.removing-item {
    animation: removeCard 0.3s ease-out;
}

@keyframes removeCard {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(0.9) rotate(2deg);
        opacity: 0.5;
    }
    100% {
        transform: scale(0.8) rotate(5deg);
        opacity: 0;
    }
}

/* 成功移除後的閃爍效果 */
.card-removed {
    animation: removedFlash 0.5s ease-out;
}

@keyframes removedFlash {
    0% {
        background-color: #fff;
    }
    50% {
        background-color: #d4edda;
    }
    100% {
        background-color: #fff;
    }
}

/* 移除提示樣式 */
.remove-notification {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 1000;
    animation: notificationFadeIn 0.3s ease-in;
}

.remove-notification.success {
    background-color: rgba(40, 167, 69, 0.9);
    animation: notificationSuccess 0.5s ease-out;
}

@keyframes notificationFadeIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes notificationSuccess {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.2);
    }
}

/* 卡片容器相對定位 */
.card {
    position: relative;
    transition: all 0.3s ease;
}

/* 購物籃整體動畫 */
.shoppingCartContainer {
    transition: all 0.5s ease;
}

/* 空購物車動畫 */
.cart-emptying {
    animation: cartEmpty 1s ease-out;
}

@keyframes cartEmpty {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(0.95);
        opacity: 0.8;
    }
    100% {
        transform: scale(0.9);
        opacity: 0.6;
    }
}

/* 空購物車提示 */
.empty-cart-notification {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 40px;
    border-radius: 25px;
    font-size: 18px;
    font-weight: bold;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: emptyCartNotification 1.5s ease-out;
}

@keyframes emptyCartNotification {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* 重新排列動畫 */
.reordering {
    animation: reorderCard 0.6s ease-in-out;
}

@keyframes reorderCard {
    0% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-15px) scale(1.02);
    }
    100% {
        transform: translateY(0) scale(1);
    }
}

/* 購物車載入動畫 */
.shoppingCartContainer.loading {
    position: relative;
}

.shoppingCartContainer.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* 購物車項目計數動畫 */
.cart-item-count {
    display: inline-block;
    animation: countPulse 0.5s ease-out;
}

@keyframes countPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* 購物車總計更新動畫 */
#orderTotailAmount,
#subTotalAmount,
#taxAmount {
    transition: all 0.3s ease;
}

.amount-updating {
    animation: amountUpdate 0.5s ease-out;
}

@keyframes amountUpdate {
    0% {
        background-color: #fff;
    }
    50% {
        background-color: #d4edda;
    }
    100% {
        background-color: #fff;
    }
}

/* 購物車按鈕狀態動畫 */
.btn:disabled {
    animation: buttonDisabled 0.3s ease-out;
}

@keyframes buttonDisabled {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}

/* 購物車區域顯示/隱藏動畫 */
#shoppingCartTag {
    transition: all 0.5s ease;
}

#shoppingCartTag.showing {
    animation: cartShow 0.5s ease-out;
}

#shoppingCartTag.hiding {
    animation: cartHide 0.3s ease-in;
}

@keyframes cartShow {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes cartHide {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* AJAX 操作動畫樣式 */
.processing-item {
    animation: processingItem 1s ease-in-out infinite;
    opacity: 0.7;
}

@keyframes processingItem {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }
    50% {
        transform: scale(1.02);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 0.7;
    }
}

/* 購物車更新通知樣式 */
.cart-update-notification {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: bold;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    animation: notificationSlideIn 0.5s ease-out;
}

.cart-update-notification.success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
}

.cart-update-notification.error {
    background: linear-gradient(135deg, #dc3545 0%, #fd7e14 100%);
    color: white;
}

/* 批量操作通知樣式 */
.batch-remove-notification,
.add-to-order-notification {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 15px 30px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: bold;
    z-index: 1000;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    animation: notificationPopIn 0.6s ease-out;
}

.batch-remove-notification {
    background: linear-gradient(135deg, #6f42c1 0%, #e83e8c 100%);
    color: white;
}

.add-to-order-notification {
    background: linear-gradient(135deg, #fd7e14 0%, #ffc107 100%);
    color: white;
}

@keyframes notificationSlideIn {
    0% {
        opacity: 0;
        transform: translateX(100px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes notificationPopIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* AJAX 載入狀態樣式 */
.shoppingCartContainer.loading {
    position: relative;
    pointer-events: none;
}

.shoppingCartContainer.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 999;
}

.shoppingCartContainer.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1000;
}

/* 按鈕載入狀態 */
.btn.loading {
    position: relative;
    pointer-events: none;
    color: transparent;
}

.btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* 卡片選擇狀態動畫 */
.selectable-card {
    transition: all 0.3s ease;
}

.selectable-card.selectable {
    cursor: pointer;
}

.selectable-card.selected-card {
    transform: scale(0.98);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.5);
    border: 2px solid #007bff;
}

/* 多選模式切換動畫 */
#shoppingCartFloatingBtn {
    transition: all 0.3s ease;
}

#shoppingCartFloatingBtn.btn-warning {
    animation: modeSwitch 0.3s ease;
}

@keyframes modeSwitch {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/* 按鈕狀態切換動畫 */
.btn-group-vertical .btn {
    transition: all 0.3s ease;
}

/* 卡片按鈕組容器改進 */
.card-body .mt-auto > .d-flex {
    gap: 0.5rem;
    align-items: center;
}

/* 預購商品卡片按鈕樣式 */
.card-body .btn-primary.smaller-button {
    transition: all 0.3s ease;
}

/* 按鈕點擊波紋效果（可選） */
.smaller-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.smaller-button:active::before {
    width: 300px;
    height: 300px;
}

/* 按鈕禁用狀態 */
.smaller-button:disabled,
.smaller-button.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 卡片內按鈕組統一間距 */
.card-body .mt-auto {
    margin-top: auto;
    padding-top: 0.75rem;
}


/* 按鈕文字不可選 */
.smaller-button {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* 空狀態樣式 */
.empty-cart-state,
.empty-preorder-state {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.5s ease-in;
}

.empty-cart-state i,
.empty-preorder-state i {
    display: inline-block;
}

/* Spin + Bounce 組合動畫 */
@keyframes spin-bounce {
    0% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(-10px) rotate(90deg);
    }
    50% {
        transform: translateY(0) rotate(180deg);
    }
    75% {
        transform: translateY(-5px) rotate(270deg);
    }
    100% {
        transform: translateY(0) rotate(360deg);
    }
}

/* 確保動畫優先級高於 Font Awesome 的預設樣式 */
.empty-cart-state .fa-spin-bounce,
.empty-preorder-state .fa-spin-bounce,
.fa-spin-bounce {
    animation: spin-bounce 2s ease-in-out infinite;
    transform-origin: center center;
    will-change: transform;
}

/* 覆蓋 Font Awesome 可能存在的動畫樣式 - 使用更具體的選擇器 */
.empty-cart-state i.fa-solid.fa-inbox.fa-spin-bounce,
.empty-preorder-state i.fa-solid.fa-inbox.fa-spin-bounce {
    animation: spin-bounce 2s ease-in-out infinite;
    transform-origin: center center;
    will-change: transform;
    display: inline-block;
}

/* 確保動畫不會被其他樣式覆蓋 */
i.fa-solid.fa-inbox.fa-spin-bounce {
    animation: spin-bounce 2s ease-in-out infinite;
    transform-origin: center center;
    will-change: transform;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
