/**
 * Form Styles
 * 
 * Input fields, textareas, selects, checkboxes, radio buttons
 * WooCommerce checkout forms, contact forms, search
 * Dark Mode Compatible
 * 
 * @package Commerce_Elite
 */

/* ============================================
   BASE FORM STYLES
   ============================================ */

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text);
}

label abbr[title] {
    color: var(--color-error);
    text-decoration: none;
    border: none;
}

/* Required field indicator */
.required {
    color: var(--color-error);
    margin-left: 0.25rem;
}

/* Form field wrapper */
.form-field,
.form-row {
    margin-bottom: 1.5rem;
}

/* Form description / help text */
.form-description,
.description {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: 0.375rem;
    line-height: var(--line-height-normal);
}

/* ============================================
   TEXT INPUTS & TEXTAREA
   ============================================ */

input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="tel"],
input[type="date"],
input[type="month"],
input[type="week"],
input[type="time"],
input[type="datetime"],
input[type="datetime-local"],
textarea,
select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: var(--font-size-base);
    font-family: inherit;
    line-height: var(--line-height-normal);
    color: var(--color-text);
    background-color: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    appearance: none;
}

/* Focus state */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
input[type="tel"]:focus,
input[type="date"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.1);
}

/* Hover state */
input[type="text"]:hover,
input[type="email"]:hover,
input[type="url"]:hover,
input[type="password"]:hover,
input[type="search"]:hover,
input[type="number"]:hover,
input[type="tel"]:hover,
textarea:hover,
select:hover {
    border-color: var(--color-primary);
}

/* Disabled state */
input:disabled,
textarea:disabled,
select:disabled {
    background-color: var(--color-surface);
    color: var(--color-text-muted);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Placeholder */
input::placeholder,
textarea::placeholder {
    color: var(--color-text-muted);
    opacity: 0.7;
}

/* Textarea specific */
textarea {
    min-height: 120px;
    resize: vertical;
}

/* ============================================
   SELECT DROPDOWN
   ============================================ */

select {
    padding-right: 2.5rem;
    background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg width="12" height="8" viewBox="0 0 12 8" fill="none" xmlns="http://www.w3.org/2000/svg"%3e%3cpath d="M1 1l5 5 5-5" stroke="%238c8f94" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/%3e%3c/svg%3e');
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 12px;
}

select:focus {
    background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg width="12" height="8" viewBox="0 0 12 8" fill="none" xmlns="http://www.w3.org/2000/svg"%3e%3cpath d="M1 1l5 5 5-5" stroke="%232271b1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/%3e%3c/svg%3e');
}

/* ============================================
   CHECKBOX & RADIO BUTTONS
   ============================================ */

input[type="checkbox"],
input[type="radio"] {
    width: 1.125rem;
    height: 1.125rem;
    margin-right: 0.5rem;
    border: 2px solid var(--color-border);
    background-color: var(--color-background);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

input[type="checkbox"] {
    border-radius: var(--radius-sm);
}

input[type="radio"] {
    border-radius: 50%;
}

/* Checked state */
input[type="checkbox"]:checked,
input[type="radio"]:checked {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg width="12" height="10" viewBox="0 0 12 10" fill="none" xmlns="http://www.w3.org/2000/svg"%3e%3cpath d="M1 5l3 3 7-7" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/%3e%3c/svg%3e');
    background-repeat: no-repeat;
    background-position: center;
}

input[type="radio"]:checked {
    background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg width="8" height="8" viewBox="0 0 8 8" fill="none" xmlns="http://www.w3.org/2000/svg"%3e%3ccircle cx="4" cy="4" r="4" fill="white"/%3e%3c/svg%3e');
}

/* Focus state */
input[type="checkbox"]:focus,
input[type="radio"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.1);
}

/* Checkbox/Radio label wrapper */
.checkbox-wrapper,
.radio-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.checkbox-wrapper label,
.radio-wrapper label {
    margin: 0;
    cursor: pointer;
    user-select: none;
}

/* ============================================
   VALIDATION STATES
   ============================================ */

/* Error state */
.form-field.error input,
.form-field.error textarea,
.form-field.error select,
input.error,
textarea.error,
select.error {
    border-color: var(--color-error);
}

.form-field.error input:focus,
.form-field.error textarea:focus,
.form-field.error select:focus {
    box-shadow: 0 0 0 3px rgba(214, 54, 56, 0.1);
}

/* Error message */
.error-message,
.woocommerce-error,
.form-error {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: var(--font-size-sm);
    color: var(--color-error);
}

.error-message::before {
    content: "⚠";
}

/* Success state */
.form-field.success input,
.form-field.success textarea,
.form-field.success select {
    border-color: var(--color-success);
}

.form-field.success input:focus,
.form-field.success textarea:focus,
.form-field.success select:focus {
    box-shadow: 0 0 0 3px rgba(0, 163, 42, 0.1);
}

/* Success message */
.success-message {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: var(--font-size-sm);
    color: var(--color-success);
}

.success-message::before {
    content: "✓";
}

/* ============================================
   SEARCH FORM
   ============================================ */

.search-form {
    position: relative;
    display: flex;
    gap: 0.5rem;
}

.search-form input[type="search"] {
    flex: 1;
    padding-right: 2.5rem;
}

.search-form button,
.search-form .search-submit {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color var(--transition-fast);
}

.search-form button:hover {
    color: var(--color-primary);
}

/* ============================================
   WOOCOMMERCE FORMS
   ============================================ */

/* Checkout form fields */
.woocommerce-checkout .form-row {
    margin-bottom: 1.5rem;
}

.woocommerce-checkout .form-row-first,
.woocommerce-checkout .form-row-last {
    width: calc(50% - 0.75rem);
    float: left;
}

.woocommerce-checkout .form-row-first {
    margin-right: 1.5rem;
}

.woocommerce-checkout .form-row-wide {
    clear: both;
}

/* Clear floats */
.woocommerce-checkout::after {
    content: "";
    display: table;
    clear: both;
}

/* Billing/Shipping fields */
.woocommerce-billing-fields,
.woocommerce-shipping-fields {
    background: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
}

.woocommerce-billing-fields h3,
.woocommerce-shipping-fields h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
}

/* Ship to different address */
.shipping_address {
    display: none;
}

.shipping_address.show {
    display: block;
    animation: slide-down 0.3s ease;
}

@keyframes slide-down {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Order review / Payment */
.woocommerce-checkout-review-order {
    background: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
}

/* Payment methods */
.woocommerce-checkout-payment {
    background: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    margin-top: 1.5rem;
}

.payment_methods {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
}

.payment_methods li {
    margin-bottom: 1rem;
}

.payment_methods label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--color-background);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.payment_methods label:hover {
    border-color: var(--color-primary);
}

.payment_methods input[type="radio"]:checked + label {
    border-color: var(--color-primary);
    background: rgba(34, 113, 177, 0.05);
}

/* ============================================
   EMAIL VERIFICATION (Custom Checkout Field)
   ============================================ */

.email-verification-wrapper {
    background: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    border: 2px solid var(--color-border);
}

.email-verification-wrapper.verified {
    border-color: var(--color-success);
    background: rgba(0, 163, 42, 0.05);
}

.email-verification-wrapper h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.email-verification-description {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: 1rem;
}

.email-verification-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.verification-status {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
}

.verification-status .success {
    color: var(--color-success);
}

.verification-status .error {
    color: var(--color-error);
}

.verification-status .warning {
    color: var(--color-warning);
}

.verification-code-field {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.verification-code-field input {
    flex: 1;
    max-width: 200px;
}

/* ============================================
   LOGIN / REGISTER FORMS
   ============================================ */

.woocommerce-form-login,
.woocommerce-form-register {
    background: var(--color-surface);
    padding: 2rem;
    border-radius: var(--radius-lg);
    max-width: 450px;
    margin: 0 auto;
}

.woocommerce-form-login h2,
.woocommerce-form-register h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}

/* Lost password link */
.lost_password {
    text-align: right;
    margin-top: 0.5rem;
}

.lost_password a {
    font-size: var(--font-size-sm);
    color: var(--color-primary);
}

/* Remember me checkbox */
.woocommerce-form-login .form-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.woocommerce-form-login .form-row label {
    margin: 0;
    cursor: pointer;
}

/* ============================================
   CONTACT FORM 7 (If used)
   ============================================ */

.wpcf7-form {
    max-width: 600px;
}

.wpcf7-form .form-group {
    margin-bottom: 1.5rem;
}

.wpcf7-not-valid {
    border-color: var(--color-error) !important;
}

.wpcf7-not-valid-tip {
    color: var(--color-error);
    font-size: var(--font-size-sm);
    margin-top: 0.5rem;
}

.wpcf7-response-output {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: var(--radius-md);
}

.wpcf7-mail-sent-ok {
    background: rgba(0, 163, 42, 0.1);
    color: var(--color-success);
    border: 1px solid var(--color-success);
}

.wpcf7-validation-errors {
    background: rgba(214, 54, 56, 0.1);
    color: var(--color-error);
    border: 1px solid var(--color-error);
}

/* ============================================
   FILE UPLOAD
   ============================================ */

input[type="file"] {
    padding: 0.5rem;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
}

input[type="file"]:hover {
    border-color: var(--color-primary);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .woocommerce-checkout .form-row-first,
    .woocommerce-checkout .form-row-last {
        width: 100%;
        float: none;
        margin-right: 0;
    }
    
    .verification-code-field {
        flex-direction: column;
        align-items: stretch;
    }
    
    .verification-code-field input {
        max-width: 100%;
    }
    
    .email-verification-controls {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ============================================
   DARK MODE ADJUSTMENTS
   ============================================ */

body.dark-mode select {
    background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg width="12" height="8" viewBox="0 0 12 8" fill="none" xmlns="http://www.w3.org/2000/svg"%3e%3cpath d="M1 1l5 5 5-5" stroke="%23e5e5e5" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/%3e%3c/svg%3e');
}

body.dark-mode input[type="checkbox"]:checked,
body.dark-mode input[type="radio"]:checked {
    background-color: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}