/**
 * Frontend Custom Fields Styles
 *
 * Styles for custom fields in frontend forms and My Account.
 *
 * @package DatatimeClubMembership
 * @since 0.56.0
 */

/* ====================================
   Registration Form Custom Fields
   ==================================== */

.dttm-cm-field-wrapper {
    margin-bottom: 20px;
}

.dttm-cm-field-wrapper label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #2c3338;
    font-size: 14px;
}

.dttm-cm-field-wrapper label .required {
    color: #d63638;
    font-weight: bold;
    margin-left: 3px;
}

.dttm-cm-field-wrapper input[type="text"],
.dttm-cm-field-wrapper input[type="number"],
.dttm-cm-field-wrapper input[type="date"],
.dttm-cm-field-wrapper textarea,
.dttm-cm-field-wrapper select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.dttm-cm-field-wrapper input[type="text"]:focus,
.dttm-cm-field-wrapper input[type="number"]:focus,
.dttm-cm-field-wrapper input[type="date"]:focus,
.dttm-cm-field-wrapper textarea:focus,
.dttm-cm-field-wrapper select:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

.dttm-cm-field-wrapper textarea {
    min-height: 100px;
    resize: vertical;
}

.dttm-cm-field-wrapper input[type="checkbox"] {
    margin-right: 8px;
    width: auto;
}

.dttm-cm-field-wrapper .help-text {
    display: block;
    font-size: 12px;
    color: #646970;
    margin-top: 6px;
    font-style: italic;
}

/* Error state */
.dttm-cm-field-wrapper.has-error input,
.dttm-cm-field-wrapper.has-error textarea,
.dttm-cm-field-wrapper.has-error select {
    border-color: #d63638;
}

.dttm-cm-field-wrapper .error-message {
    display: block;
    color: #d63638;
    font-size: 12px;
    margin-top: 6px;
}

/* ====================================
   WooCommerce My Account Custom Fields
   ==================================== */

.dttm-cm-custom-fields-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid #e0e0e0;
}

.dttm-cm-custom-fields-section h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 600;
    color: #2c3338;
}

/* Read-only fields display */
.dttm-cm-readonly-fields {
    margin-bottom: 25px;
}

.dttm-cm-field-row {
    display: flex;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.dttm-cm-field-row:last-child {
    border-bottom: none;
}

.dttm-cm-field-row label {
    flex: 0 0 200px;
    font-weight: 600;
    color: #646970;
    font-size: 14px;
}

.dttm-cm-field-row span {
    flex: 1;
    color: #2c3338;
    font-size: 14px;
}

/* Editable fields */
.dttm-cm-editable-fields {
    margin-top: 20px;
}

.dttm-cm-editable-fields .dttm-cm-field-wrapper {
    margin-bottom: 20px;
}

/* ====================================
   Form Control Consistency
   ==================================== */

.form-control.dttm-cm-custom-field {
    width: 100%;
}

/* ====================================
   Responsive Adjustments
   ==================================== */

@media screen and (max-width: 768px) {
    .dttm-cm-field-row {
        flex-direction: column;
        gap: 5px;
    }

    .dttm-cm-field-row label {
        flex: none;
    }

    .dttm-cm-custom-fields-section h3 {
        font-size: 16px;
    }
}

/* ====================================
   Checkbox Field Styling
   ==================================== */

.dttm-cm-field-wrapper input[type="checkbox"] + label {
    display: inline;
    font-weight: normal;
    margin-bottom: 0;
    cursor: pointer;
}

.dttm-cm-checkbox-wrapper {
    display: flex;
    align-items: center;
}

.dttm-cm-checkbox-wrapper input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 10px;
}

/* ====================================
   Date Field Enhancement
   ==================================== */

.dttm-cm-field-wrapper input[type="date"] {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%23646970' d='M14 2h-1V1c0-.6-.4-1-1-1s-1 .4-1 1v1H5V1c0-.6-.4-1-1-1S3 .4 3 1v1H2C.9 2 0 2.9 0 4v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 12H2V6h12v8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

/* ====================================
   Loading State
   ==================================== */

.dttm-cm-field-wrapper.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ====================================
   Success State
   ==================================== */

.dttm-cm-field-wrapper.has-success input,
.dttm-cm-field-wrapper.has-success textarea,
.dttm-cm-field-wrapper.has-success select {
    border-color: #00a32a;
}

.dttm-cm-field-wrapper .success-message {
    display: block;
    color: #00a32a;
    font-size: 12px;
    margin-top: 6px;
}

/* ====================================
   Field Group Separator
   ==================================== */

.dttm-cm-fields-separator {
    margin: 30px 0;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
}

.dttm-cm-fields-separator h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #2c3338;
}

/* ====================================
   Accessibility Enhancements
   ==================================== */

.dttm-cm-field-wrapper input:focus-visible,
.dttm-cm-field-wrapper textarea:focus-visible,
.dttm-cm-field-wrapper select:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* Screen reader only text */
.dttm-cm-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
