/**
 * KB Quick Buy - Frontend CSS
 *
 * @author    starter
 * @copyright 2024
 * @license   Commercial
 */

/* Button Container */
.kbqb-button-container {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 10px 0;
}

/* Position Variants */
.kbqb-button-container[data-position="before_price"] {
    margin-bottom: 15px;
}

.kbqb-button-container[data-position="after_price"] {
    margin-top: 15px;
}

.kbqb-button-container[data-position="after_cart"] {
    margin-top: 10px;
}

.kbqb-button-container[data-position="replace_cart"] {
    margin: 0;
}

/* Quantity Selector */
.kbqb-quantity-selector {
    display: inline-flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.kbqb-qty-btn {
    width: 36px;
    height: 36px;
    background: #f5f5f5;
    border: none;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.kbqb-qty-btn:hover {
    background: #e0e0e0;
}

.kbqb-qty-btn:active {
    background: #d5d5d5;
}

.kbqb-quantity-input {
    width: 50px;
    height: 36px;
    border: none;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
    text-align: center;
    font-size: 14px;
    -moz-appearance: textfield;
}

.kbqb-quantity-input::-webkit-outer-spin-button,
.kbqb-quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Button Base Styles */
.kbqb-button {
    position: relative;
    overflow: hidden;
}

.kbqb-button-spinner {
    display: inline-flex;
    align-items: center;
}

.kbqb-button-spinner .rotating {
    animation: kbqb-rotate 1s linear infinite;
}

@keyframes kbqb-rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Loading State */
.kbqb-button.loading {
    pointer-events: none;
}

.kbqb-button.loading .kbqb-button-text {
    opacity: 0.5;
}

/* Attribute Warning */
.kbqb-attribute-warning {
    width: 100%;
    padding: 8px 12px;
    background: #fff3cd;
    color: #856404;
    border-radius: 4px;
    font-size: 12px;
    margin-top: 5px;
}

/* Success Animation */
.kbqb-button.success {
    animation: kbqb-pulse 0.5s ease-out;
}

@keyframes kbqb-pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* Listing Page Styling */
.product-miniature .kbqb-button-container {
    margin: 5px 0;
    justify-content: center;
}

.product-miniature .kbqb-quantity-selector {
    display: none;
}

.product-miniature .kbqb-button {
    width: 100%;
    justify-content: center;
}

/* Quick View Modal Styling */
.quickview .kbqb-button-container {
    margin: 15px 0;
}

/* Responsive */
@media (max-width: 767px) {
    .kbqb-button-container {
        flex-direction: column;
        align-items: stretch;
    }

    .kbqb-quantity-selector {
        justify-content: center;
    }

    .kbqb-button {
        width: 100%;
        justify-content: center;
    }
}

/* RTL Support */
[dir="rtl"] .kbqb-button-container {
    flex-direction: row-reverse;
}

[dir="rtl"] .kbqb-quantity-selector {
    flex-direction: row-reverse;
}

/* Accessibility */
.kbqb-button:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.kbqb-qty-btn:focus {
    outline: 2px solid #2196F3;
    outline-offset: -2px;
}

/* Theme Compatibility - Classic Theme */
.product-actions .kbqb-button-container {
    width: 100%;
}

/* Theme Compatibility - Dark Mode */
@media (prefers-color-scheme: dark) {
    .kbqb-attribute-warning {
        background: #3d3a2d;
        color: #ffc107;
    }
}
