/**
 * Auto Update Cart Frontend Styles
 * 
 * @package Auto_Update_Cart
 * @since 1.0.0
 */

/* Hide the update cart button when auto-update is enabled */
.woocommerce-cart-form__contents.auto-update-enabled button[name="update_cart"],
button[name="update_cart"] {
    display: none !important;
}

/* Loading state for quantity inputs */
.auto-update-cart-qty.auto-update-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Loading indicator */
.auto-update-cart-loading {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #0073aa;
    color: white;
    padding: 12px 20px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    font-size: 14px;
    font-weight: 500;
    animation: slideInRight 0.3s ease-out;
}

/* Messages */
.auto-update-cart-message {
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 4px;
    font-weight: 500;
    animation: slideInDown 0.3s ease-out;
}

.auto-update-cart-message--success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.auto-update-cart-message--error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.auto-update-cart-message--info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Animations */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .auto-update-cart-loading {
        top: 10px;
        right: 10px;
        left: 10px;
        text-align: center;
    }
    
    .auto-update-cart-message {
        margin-left: -10px;
        margin-right: -10px;
        border-radius: 0;
    }
}

/* Accessibility improvements */
.auto-update-cart-qty:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .auto-update-cart-loading {
        background: #000;
        color: #fff;
        border: 2px solid #fff;
    }
    
    .auto-update-cart-message--success {
        background-color: #fff;
        color: #000;
        border: 2px solid #008000;
    }
    
    .auto-update-cart-message--error {
        background-color: #fff;
        color: #000;
        border: 2px solid #ff0000;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .auto-update-cart-loading,
    .auto-update-cart-message {
        animation: none;
    }
}

/* RTL Support */
.rtl .auto-update-cart-loading {
    right: auto;
    left: 20px;
    animation: slideInLeft 0.3s ease-out;
}

.rtl .auto-update-cart-qty.auto-update-removing::after {
    right: 0;
    left: auto;
}

.rtl .woocommerce-cart-form__contents tbody tr.removing {
    transform: translateX(10px);
}

/* RTL Animations */
@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* RTL Responsive adjustments */
@media (max-width: 768px) {
    .rtl .auto-update-cart-loading {
        left: 10px;
        right: 10px;
    }
}

/* Remove action state */
.auto-update-cart-qty.auto-update-removing {
    opacity: 0.4;
    pointer-events: none;
    background-color: #f8f9fa;
}

/* Rate limit state */
.auto-update-cart-qty.auto-update-loading {
    opacity: 0.6;
    pointer-events: none;
    background-color: #fff3cd;
    border-color: #ffeaa7;
    cursor: not-allowed;
}

/* Rate limited input styling */
.auto-update-cart-qty:disabled {
    background-color: #f8f9fa;
    border-color: #dee2e6;
    color: #6c757d;
    cursor: not-allowed;
}

.auto-update-cart-qty:disabled::placeholder {
    color: #adb5bd;
}

/* Rate limit message styling */
.auto-update-cart-message--error.rate-limit {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    position: relative;
}

.auto-update-cart-message--error.rate-limit::before {
    content: "⚠️";
    margin-right: 8px;
    font-size: 16px;
}

/* Countdown styling */
.auto-update-cart-countdown {
    font-weight: bold;
    color: #dc3545;
}

/* Remove pending indicator */
.auto-update-cart-qty.auto-update-removing::after {
    content: attr(data-removing-text);
    position: absolute;
    top: -25px;
    left: 0;
    background: #dc3545;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 1000;
}

/* Position relative for the input container to show the indicator */
.woocommerce-cart-form__contents .quantity {
    position: relative;
}

/* Smooth transitions for cart rows */
.woocommerce-cart-form__contents tbody tr {
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.woocommerce-cart-form__contents tbody tr.removing {
    opacity: 0.5;
    transform: translateX(-10px);
}