/**
 * WQM Custom Quantity Box Styles
 * Matches the Studio Wombat plugin styling
 */

/* Target the br element that appears before our box */
.wqm-qty + br,
.wqm-qty ~ br {
    display: block !important;
    margin-bottom: 20px !important;
    content: '' !important;
}

/* Main container */
.wqm-custom-qty-box {
    margin: 0 !important;
    padding-top: 0;
    border: 1px solid #b9b9b9;
    border-radius: 0px;
    background: #fff;
    overflow: hidden;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 694px;
    clear: both;
    display: block;
    position: relative;
}

/* Fallback: spacing via adjacent sibling */
br + .wqm-custom-qty-box {
    margin-top: 20px !important;
}

.wqm-custom-qty-box.active {
    border-color: #2e7d32;
    background: #f5faf5;
}

.wqm-custom-qty-box:hover {
    border-color: #888;
}

.wqm-custom-qty-box.active:hover {
    border-color: #2e7d32;
}

/* Header section */
.wqm-custom-qty-header {
    display: flex;
    align-items: center;
    padding: 20px 17px;
    cursor: pointer;
    gap: 15px;
}

/* Radio button styling - Modern ring + dot design */
/* Apply to both our custom box and original WQM swatches */

/* Our custom radio button */
.wqm-custom-qty-radio {
    position: relative;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.wqm-custom-qty-radio input[type="radio"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 100%;
    width: 100%;
    z-index: 2;
    margin: 0;
}

.wqm-radio-checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 18px;
    width: 18px;
    background-color: #fff;
    border: 2px solid #ccc;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.wqm-custom-qty-radio input[type="radio"]:checked ~ .wqm-radio-checkmark {
    border-color: #333;
}

.wqm-radio-checkmark:after {
    content: "";
    position: absolute;
    display: none;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #333;
}

.wqm-custom-qty-radio input[type="radio"]:checked ~ .wqm-radio-checkmark:after {
    display: block;
}

/* Override original WQM radio buttons to match modern design */
.wqm-swatch .wqm-radio {
    position: relative;
    width: 18px !important;
    height: 18px;
    margin-right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wqm-swatch .wqm-inner {
    padding: 20px 17px;
}

.wqm-swatch .wqm-radio input[type="radio"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 100%;
    width: 100%;
    z-index: 2;
    margin: 0;
}

.wqm-swatch .wqm-radio span {
    position: absolute;
    top: 0;
    left: 0;
    height: 18px;
    width: 18px;
    background-color: #fff;
    border: 2px solid #ccc;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.wqm-swatch .wqm-radio input[type="radio"]:checked ~ span,
.wqm-swatch.selected .wqm-radio span {
    border-color: #333;
}

.wqm-swatch .wqm-radio span:after {
    content: "";
    position: absolute;
    display: none;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #333;
}

.wqm-swatch .wqm-radio input[type="radio"]:checked ~ span:after,
.wqm-swatch.selected .wqm-radio span:after {
    display: block;
}

/* Title */
.wqm-custom-qty-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    flex-grow: 1;
}

/* Content section */
.wqm-custom-qty-content {
    padding: 0 20px 20px;
    display: none;
}

.wqm-custom-qty-box.active .wqm-custom-qty-content {
    display: block;
}

/* Input groups container */
.wqm-custom-qty-inputs {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

/* Individual input group */
.wqm-custom-qty-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 150px;
}

.wqm-custom-input {
    width: 100px;
    padding: 12px 15px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    text-align: center;
    transition: border-color 0.2s ease;
    -moz-appearance: textfield;
}

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

.wqm-custom-input:focus {
    outline: none;
    border-color: #2e7d32;
}

.wqm-input-label {
    font-size: 14px;
    color: #666;
    white-space: nowrap;
}

/* Separator */
.wqm-custom-qty-separator {
    font-size: 14px;
    color: #999;
    padding: 0 5px;
}

/* Result section */
.wqm-custom-qty-result {
    background: #f8f8f8;
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
}

/* Minimum quantity error message */
.wqm-custom-qty-min-error {
    color: #d32f2f;
    font-size: 14px;
    margin-top: 10px;
    padding: 0 5px;
}

.wqm-result-highlight {
    display: inline-block;
    background: #333;
    color: #fff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.wqm-result-details {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}

.wqm-result-quantity {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.wqm-result-pieces-label {
    font-weight: 400;
    color: #666;
    margin-left: 5px;
}

.wqm-result-total {
    font-size: 18px;
    font-weight: 600;
    color: #2e7d32;
}

.wqm-result-meters {
    font-size: 14px;
    color: #666;
    text-align: right;
}

/* Active state for the whole box */
.wqm-custom-qty-box.active .wqm-custom-qty-header {
    background: #e8f5e9;
}

/* Responsive */
@media (max-width: 600px) {
    .wqm-custom-qty-content {
        padding: 0 5px 10px;
    }
    
    .wqm-custom-qty-inputs {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: space-evenly;
        gap: 8px;
    }
    
    .wqm-custom-qty-input-group {
        flex: 0 1 auto;
        max-width: 135px;
        min-width: auto;
        justify-content: center;
    }
    
    .wqm-custom-input {
        width: 50px;
        padding: 10px 6px;
        font-size: 14px;
    }
    
    .wqm-input-label {
        font-size: 12px;
    }
    
    .wqm-custom-qty-separator {
        flex: 0 0 auto;
        padding: 0 4px;
        min-width: 20px;
        text-align: center;
    }
    
    .wqm-result-details {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        text-align: left;
    }
    
    .wqm-result-meters {
        text-align: right;
    }
}

@media (max-width: 495px) {
    .wqm-swatch .wqm-radio {
        margin-top: 4px;
    }
}

/* Animation for showing/hiding content */
.wqm-custom-qty-content {
    animation: slideDown 0.3s ease;
}

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

/* Loading state */
.wqm-custom-qty-box.loading .wqm-custom-qty-result {
    opacity: 0.6;
    pointer-events: none;
}

/* Highlight animation when price updates */
.wqm-result-highlight.updated {
    animation: pulse 0.3s ease;
}

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