/**
 * Separated Product Elements - Styles
 */

/* ========================================
   Base Styles & Resets
   ======================================== */

.spe-variations-wrapper,
.spe-add-to-cart-wrapper,
.spe-quantity-selector-wrapper {
    box-sizing: border-box;
}

.spe-variations-wrapper *,
.spe-add-to-cart-wrapper *,
.spe-quantity-selector-wrapper * {
    box-sizing: inherit;
}

/* ========================================
   Variation Swatches Widget
   ======================================== */

.spe-variations-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.spe-attribute-group {
    display: flex;
    flex-direction: column;
}

.spe-attribute-label {
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 14px;
    color: #333;
}

.spe-attribute-label.spe-label-below {
    margin-bottom: 0;
    margin-top: 10px;
}

.spe-selected-value {
    font-weight: 400;
    color: #666;
}

/* Swatches Container */
.spe-swatches-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* Individual Swatch Items */
.spe-swatch-item {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 80px;
    height: 45px;
    padding: 10px 20px;
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    text-align: center;
    line-height: 1.2;
}

.spe-swatch-item:hover {
    border-color: #1a1a2e;
    background-color: #f8f8f8;
}

.spe-swatch-item.selected {
    background-color: #1a1a2e;
    border-color: #1a1a2e;
    color: #ffffff;
}

.spe-swatch-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #f5f5f5;
    color: #999;
}

.spe-swatch-item.disabled:hover {
    border-color: #e0e0e0;
    background-color: #f5f5f5;
}

/* Swatch Label & Secondary Text */
.spe-swatch-label {
    display: block;
    white-space: nowrap;
}

.spe-swatch-secondary {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: #666;
    margin-top: 2px;
}

.spe-swatch-item.selected .spe-swatch-secondary {
    color: rgba(255, 255, 255, 0.8);
}

/* Swatch Styles - Pills */
.spe-style-pills .spe-swatch-item {
    border-radius: 25px;
    min-width: 100px;
}

/* Swatch Styles - Squares */
.spe-style-squares .spe-swatch-item {
    border-radius: 0;
    min-width: 60px;
    width: 60px;
    height: 60px;
    padding: 5px;
}

/* Variation Select Dropdown */
.spe-variation-select {
    width: 100%;
    max-width: 300px;
    padding: 12px 15px;
    font-size: 14px;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    background-color: #fff;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23333'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
    padding-right: 35px;
}

.spe-variation-select:focus {
    outline: none;
    border-color: #1a1a2e;
}

.spe-variation-select option:disabled {
    color: #ccc;
}

/* ========================================
   Add to Cart Button Widget
   ======================================== */

.spe-add-to-cart-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.spe-add-to-cart-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 15px 30px;
    background-color: #1a73e8;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.spe-add-to-cart-button:hover {
    background-color: #1557b0;
}

.spe-add-to-cart-button:disabled,
.spe-add-to-cart-button.disabled {
    background-color: #cccccc;
    color: #666666;
    cursor: not-allowed;
}

/* Loading State */
.spe-add-to-cart-button.loading {
    pointer-events: none;
}

.spe-add-to-cart-button.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid #ffffff;
    border-color: #ffffff transparent #ffffff transparent;
    border-radius: 50%;
    animation: spe-spin 1s linear infinite;
}

.spe-add-to-cart-button.loading .spe-button-text,
.spe-add-to-cart-button.loading .spe-button-icon,
.spe-add-to-cart-button.loading .spe-button-price {
    visibility: hidden;
}

@keyframes spe-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Button Icon */
.spe-button-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.spe-button-icon svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Button Price */
.spe-button-price {
    margin-left: 10px;
    padding-left: 10px;
    border-left: 1px solid rgba(255, 255, 255, 0.3);
}

/* Inline Quantity */
.spe-add-to-cart-wrapper .spe-quantity-wrapper {
    margin-right: 10px;
}

.spe-add-to-cart-wrapper .spe-quantity-input {
    width: 70px;
    height: 45px;
    padding: 10px;
    text-align: center;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    font-size: 16px;
}

/* ========================================
   Quantity Selector Widget
   ======================================== */

.spe-quantity-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.spe-qty-label {
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.spe-qty-input {
    width: 80px;
    height: 45px;
    padding: 10px;
    text-align: center;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    font-size: 16px;
    background-color: #fff;
    color: #333;
}

.spe-qty-input:focus {
    outline: none;
    border-color: #1a1a2e;
}

/* Remove spinners from number input */
.spe-qty-input::-webkit-outer-spin-button,
.spe-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.spe-qty-input[type=number] {
    -moz-appearance: textfield;
}

/* Quantity Select Dropdown */
.spe-qty-select {
    width: 80px;
    height: 45px;
    padding: 10px;
    text-align: center;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    font-size: 16px;
    background-color: #fff;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23333'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 5px center;
    background-size: 18px;
    padding-right: 25px;
}

/* Quantity Controls (with +/- buttons) */
.spe-qty-controls {
    display: inline-flex;
    align-items: center;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
}

.spe-qty-controls .spe-qty-input {
    border: none;
    border-radius: 0;
    border-left: 1px solid #e0e0e0;
    border-right: 1px solid #e0e0e0;
}

.spe-qty-button {
    width: 40px;
    height: 45px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #f5f5f5;
    border: none;
    cursor: pointer;
    font-size: 18px;
    font-weight: 400;
    color: #333;
    transition: background-color 0.2s ease;
}

.spe-qty-button:hover {
    background-color: #e8e8e8;
}

.spe-qty-button:active {
    background-color: #ddd;
}

/* ========================================
   Notice Messages
   ======================================== */

.spe-notice {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    animation: spe-slide-in 0.3s ease;
}

.spe-notice-success {
    background-color: #4caf50;
    color: #ffffff;
}

.spe-notice-error {
    background-color: #f44336;
    color: #ffffff;
}

@keyframes spe-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ========================================
   Editor Placeholder
   ======================================== */

.spe-editor-placeholder {
    background-color: #f5f5f5;
    border: 2px dashed #ccc;
    padding: 30px;
    text-align: center;
    border-radius: 5px;
}

.spe-editor-placeholder p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

/* ========================================
   Responsive Adjustments
   ======================================== */

@media screen and (max-width: 767px) {
    .spe-swatches-container {
        gap: 8px;
    }

    .spe-swatch-item {
        min-width: 70px;
        padding: 8px 15px;
        font-size: 13px;
    }

    .spe-add-to-cart-button {
        padding: 12px 20px;
        font-size: 14px;
    }

    .spe-add-to-cart-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    .spe-add-to-cart-wrapper .spe-quantity-wrapper {
        margin-right: 0;
        margin-bottom: 10px;
    }

    .spe-add-to-cart-wrapper .spe-quantity-input {
        width: 100%;
    }

    .spe-notice {
        left: 20px;
        right: 20px;
    }
}

/* ========================================
   WooCommerce Integration
   ======================================== */

/* Hide default WooCommerce variation form when using our widgets */
.spe-hide-default-form .variations_form .variations {
    display: none;
}

.spe-hide-default-form .variations_form .single_add_to_cart_button {
    display: none;
}

.spe-hide-default-form .variations_form .quantity {
    display: none;
}

/* Ensure our widgets work alongside WooCommerce */
.spe-variations-wrapper + .spe-variations-data {
    display: none;
}
