/**
 * WooCommerce Custom Product Fields - Frontend Styles (FINAL FIX)
 */

/* Main container for custom fields */
.wccpf-custom-fields {
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
}

.wccpf-custom-fields h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 18px;
    color: #333;
}

/* Form field styling */
.wccpf-field {
    margin-bottom: 15px;
}

.wccpf-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.wccpf-field label .required {
    color: #dc3232;
    font-weight: bold;
}

.wccpf-field input[type="text"],
.wccpf-field input[type="email"],
.wccpf-field input[type="number"],
.wccpf-field input[type="date"],
.wccpf-field textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 14px;
    box-sizing: border-box;
}

.wccpf-field textarea {
    min-height: 100px;
    resize: vertical;
}

.wccpf-field input[type="text"]:focus,
.wccpf-field input[type="email"]:focus,
.wccpf-field input[type="number"]:focus,
.wccpf-field input[type="date"]:focus,
.wccpf-field textarea:focus {
    outline: none;
    border-color: var(--e-global-color-uicore_primary);
}

/* Character counter for textarea */
.wccpf-char-count {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: #666;
    text-align: right;
}

/* Error messages */
.wccpf-error {
    color: #dc3232;
    font-size: 13px;
    margin-top: 5px;
    display: block;
}

/* Date picker styling */
.ui-datepicker {
    z-index: 9999 !important;
}

/* ============================================
   VISIBILITY RULES
   ============================================ 
   
   Strategy: 
   - Field sets WITH data-field-set are for variable products → hide by default
   - Field sets WITHOUT data-field-set are for simple products → always show
   - JavaScript adds .wccpf-active class to show specific field sets
*/

/* Simple products: Show field sets WITHOUT data-field-set attribute */
.wccpf-custom-fields:not([data-field-set]) {
    display: block !important;
}

/* Variable products: Hide ALL field sets WITH data-field-set by default */
.wccpf-custom-fields[data-field-set] {
    display: none !important;
}

/* Variable products: Show when JavaScript adds the wccpf-active class */
.wccpf-custom-fields[data-field-set].wccpf-active {
    display: block !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .wccpf-custom-fields {
        padding: 15px;
    }
    
    .wccpf-field input[type="text"],
    .wccpf-field input[type="email"],
    .wccpf-field input[type="number"],
    .wccpf-field input[type="date"],
    .wccpf-field textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Date field specific styling */
.wccpf-field-hint {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: #666;
    font-style: italic;
}

.wccpf-date-field.wccpf-invalid {
    border-color: #dc3232 !important;
    background-color: #ffebe8;
}

.wccpf-date-error {
    color: #dc3232;
    font-size: 13px;
    margin-top: 5px;
    display: block;
}

/* Checkbox field styling */
.wccpf-field-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.wccpf-field-checkbox label {
    display: inline;
    margin-bottom: 0;
    cursor: pointer;
}

.wccpf-field-checkbox .wccpf-checkbox {
    width: auto;
    margin-top: 4px;
    flex-shrink: 0;
}

