/* =====================================================
   WC Product Options — Frontend Styles
   ===================================================== */

:root {
    --wcpo-accent: #7f54b3;
    --wcpo-accent-light: rgba(127, 84, 179, 0.08);
    --wcpo-accent-border: rgba(127, 84, 179, 0.3);
    --wcpo-text-main: #333;
    --wcpo-text-secondary: #666;
    --wcpo-border-color: #e0e0e0;
    --wcpo-bg-light: #f8f8f8;
    --wcpo-radius-sm: 6px;
    --wcpo-radius-md: 8px;
    --wcpo-transition: 0.2s ease;
}

/* Group wrapper */
.wcpo-product-options {
    margin: 20px 0;
    padding: 0;
}

.wcpo-group {
    margin-bottom: 24px;
}

.wcpo-group-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--wcpo-text-main);
    margin: 0 0 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--wcpo-accent);
    display: inline-block;
}

/* Field wrapper */
.wcpo-field-wrap {
    margin-bottom: 20px;
    transition: opacity var(--wcpo-transition), max-height 0.3s ease;
    overflow: hidden;
}

.wcpo-field-wrap.wcpo-hidden {
    opacity: 0;
    max-height: 0;
    margin: 0;
    padding: 0;
    pointer-events: none;
}

.wcpo-field-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--wcpo-text-main);
    margin-bottom: 6px;
}

.wcpo-required {
    color: #e53935;
    margin-left: 2px;
}

.wcpo-field-desc {
    font-size: 13px;
    color: var(--wcpo-text-secondary);
    margin: 0 0 8px;
}

/* ---- Radio buttons ---- */
.wcpo-radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wcpo-radio-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--wcpo-border-color);
    border-radius: var(--wcpo-radius-sm);
    cursor: pointer;
    transition: all var(--wcpo-transition);
    background: #fff;
}

.wcpo-radio-item:hover {
    border-color: var(--wcpo-accent-border);
    background: var(--wcpo-accent-light);
}

.wcpo-radio-item input[type="radio"] {
    accent-color: var(--wcpo-accent);
    width: 18px;
    height: 18px;
    margin: 0;
}

.wcpo-radio-item input[type="radio"]:checked+.wcpo-radio-label {
    color: var(--wcpo-accent);
    font-weight: 600;
}

.wcpo-radio-label {
    font-size: 14px;
    color: var(--wcpo-text-main);
    flex: 1;
}

/* ---- Checkbox ---- */
.wcpo-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wcpo-checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--wcpo-border-color);
    border-radius: var(--wcpo-radius-sm);
    cursor: pointer;
    transition: all var(--wcpo-transition);
    background: #fff;
}

.wcpo-checkbox-item:hover {
    border-color: var(--wcpo-accent-border);
    background: var(--wcpo-accent-light);
}

.wcpo-checkbox-item input[type="checkbox"] {
    accent-color: var(--wcpo-accent);
    width: 18px;
    height: 18px;
    margin: 0;
}

.wcpo-checkbox-label {
    font-size: 14px;
    color: var(--wcpo-text-main);
    flex: 1;
}

/* ---- Price badge ---- */
.wcpo-price-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    color: var(--wcpo-accent);
    background: var(--wcpo-accent-light);
    padding: 2px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

/* ---- Text & Email inputs ---- */
.wcpo-text-input,
.wcpo-email-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--wcpo-border-color);
    border-radius: var(--wcpo-radius-sm);
    font-size: 14px;
    color: var(--wcpo-text-main);
    transition: border-color var(--wcpo-transition), box-shadow var(--wcpo-transition);
    box-sizing: border-box;
    background: #fff;
}

.wcpo-text-input:focus,
.wcpo-email-input:focus {
    border-color: var(--wcpo-accent);
    box-shadow: 0 0 0 2px rgba(127, 84, 179, 0.15);
    outline: none;
}

/* ---- File upload zone ---- */
.wcpo-file-upload-zone {
    position: relative;
}

.wcpo-file-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    border: 2px dashed var(--wcpo-border-color);
    border-radius: var(--wcpo-radius-md);
    background: var(--wcpo-bg-light);
    text-align: center;
    transition: all var(--wcpo-transition);
    cursor: pointer;
}

.wcpo-file-dropzone:hover,
.wcpo-file-dropzone.wcpo-dragover {
    border-color: var(--wcpo-accent);
    background: var(--wcpo-accent-light);
}

.wcpo-file-dropzone .dashicons {
    font-size: 36px;
    width: 36px;
    height: 36px;
    color: var(--wcpo-accent);
    margin-bottom: 8px;
}

.wcpo-file-dropzone p {
    margin: 0 0 8px;
    font-size: 14px;
    color: var(--wcpo-text-secondary);
}

.wcpo-file-browse-btn {
    background: var(--wcpo-accent);
    color: #fff;
    border: none;
    padding: 8px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background var(--wcpo-transition);
}

.wcpo-file-browse-btn:hover {
    background: #6b3fa0;
}

.wcpo-file-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid var(--wcpo-border-color);
    border-radius: var(--wcpo-radius-sm);
    background: #fff;
    margin-top: 10px;
}

.wcpo-file-preview-img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--wcpo-border-color);
}

.wcpo-file-name {
    flex: 1;
    font-size: 13px;
    color: var(--wcpo-text-main);
    word-break: break-all;
}

.wcpo-file-remove {
    background: none;
    border: none;
    color: #e53935;
    font-size: 20px;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    line-height: 1;
    transition: background var(--wcpo-transition);
}

.wcpo-file-remove:hover {
    background: rgba(229, 57, 53, 0.08);
}

.wcpo-file-info {
    font-size: 11px;
    color: var(--wcpo-text-secondary);
    margin: 6px 0 0;
}

.wcpo-file-uploading {
    text-align: center;
    padding: 20px;
    color: var(--wcpo-accent);
    font-size: 13px;
}

.wcpo-file-uploading .wcpo-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--wcpo-accent-light);
    border-top-color: var(--wcpo-accent);
    border-radius: 50%;
    animation: wcpo-spin 0.6s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes wcpo-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---- Product Choice / Swatches ---- */
.wcpo-swatch-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.wcpo-swatch-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border: 2px solid var(--wcpo-border-color);
    border-radius: var(--wcpo-radius-md);
    cursor: pointer;
    transition: all var(--wcpo-transition);
    background: #fff;
    min-width: 80px;
    max-width: 120px;
    text-align: center;
    position: relative;
}

.wcpo-swatch-item:hover {
    border-color: var(--wcpo-accent-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.wcpo-swatch-item.wcpo-selected {
    border-color: var(--wcpo-accent);
    box-shadow: 0 0 0 3px rgba(127, 84, 179, 0.3), 0 6px 16px rgba(127, 84, 179, 0.2);
    transform: translateY(-4px);
}

.wcpo-swatch-item.wcpo-selected::after {
    content: '✓';
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: var(--wcpo-accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.wcpo-swatch-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 6px;
}

.wcpo-swatch-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--wcpo-text-main);
    margin-bottom: 2px;
}

/* ---- Toggle switch ---- */
.wcpo-toggle-wrap {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 10px 14px;
    border: 1px solid var(--wcpo-border-color);
    border-radius: var(--wcpo-radius-sm);
    background: #fff;
    transition: all var(--wcpo-transition);
    user-select: none;
}

.wcpo-toggle-wrap:hover {
    border-color: var(--wcpo-accent-border);
    background: var(--wcpo-accent-light);
}

.wcpo-toggle-input {
    position: absolute !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    appearance: none !important;
}

.wcpo-toggle-slider {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    background: #ccc;
    border-radius: 28px;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

.wcpo-toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.wcpo-toggle-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    transition: opacity 0.2s ease;
    z-index: 1;
}

.wcpo-toggle-off {
    right: 8px;
    color: #fff;
    opacity: 1;
}

.wcpo-toggle-on {
    left: 8px;
    color: #fff;
    opacity: 0;
}

/* Checked state */
.wcpo-toggle-input:checked+.wcpo-toggle-slider {
    background: var(--wcpo-accent);
}

.wcpo-toggle-input:checked+.wcpo-toggle-slider::after {
    transform: translateX(22px);
}

.wcpo-toggle-input:checked+.wcpo-toggle-slider .wcpo-toggle-off {
    opacity: 0;
}

.wcpo-toggle-input:checked+.wcpo-toggle-slider .wcpo-toggle-on {
    opacity: 1;
}

.wcpo-toggle-text {
    font-size: 14px;
    color: var(--wcpo-text-main);
    font-weight: 500;
}

.wcpo-toggle-input:checked~.wcpo-toggle-text {
    color: var(--wcpo-accent);
    font-weight: 600;
}

.wcpo-swatch-item .wcpo-price-badge {
    font-size: 10px;
    padding: 1px 8px;
}

/* ---- Price summary ---- */
.wcpo-price-summary {
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--wcpo-accent-light);
    border: 1px solid var(--wcpo-accent-border);
    border-radius: var(--wcpo-radius-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wcpo-price-summary-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--wcpo-text-main);
}

.wcpo-price-summary-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--wcpo-accent);
}

/* ---- Validation errors ---- */
.wcpo-field-wrap.wcpo-error .wcpo-text-input,
.wcpo-field-wrap.wcpo-error .wcpo-email-input {
    border-color: #e53935;
}

.wcpo-field-wrap.wcpo-error .wcpo-file-dropzone {
    border-color: #e53935;
}

.wcpo-field-wrap.wcpo-error .wcpo-swatch-group .wcpo-swatch-value {
    border-color: #e53935;
}

.wcpo-error-msg {
    color: #e53935;
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
    .wcpo-swatch-item {
        min-width: 70px;
    }

    .wcpo-swatch-img {
        width: 48px;
        height: 48px;
    }

    .wcpo-radio-item,
    .wcpo-checkbox-item {
        padding: 8px 10px;
    }
}

/* Utilities */
.wcpo-visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    opacity: 0 !important;
}