/* MxChat Forms Public Styles */

.mxchat-form {
    border-radius: 8px;
    padding: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    max-width: 500px;
}

.mxchat-form-field {
    margin-bottom: 16px;
}

.mxchat-form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
}

.mxchat-required {
    color: #dc3545;
    margin-left: 4px;
}

.mxchat-input,
.mxchat-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
    transition: border-color 0.2s ease;
}

.mxchat-input:focus,
.mxchat-textarea:focus {
    border-color: #2271b1;
    outline: none;
    box-shadow: 0 0 0 1px rgba(34, 113, 177, 0.2);
}

.mxchat-textarea {
    min-height: 100px;
    resize: vertical;
}

.mxchat-submit-form {
    background: #2271b1;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.mxchat-submit-form:hover {
    background: #135e96;
}

.mxchat-submit-form:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Success Message */
.mxchat-form .success {
}

/* Error Message */
.mxchat-form .error {
    color: #842029;
    background: #f8d7da;
    border: 1px solid #f5c2c7;
    border-radius: 4px;
    padding: 12px 16px;
    margin: 10px 0;
}

/* Loading State */
.mxchat-form.loading .mxchat-submit-form::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border: 2px solid #fff;
    border-radius: 50%;
    border-right-color: transparent;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* Responsive Design */
@media screen and (max-width: 600px) {
    .mxchat-form {
        padding: 15px;
        margin: 5px 0;
    }

    .mxchat-submit-form {
        width: 100%;
    }
}

/* Form Field Validation Styles */
.mxchat-form-field.error .mxchat-input,
.mxchat-form-field.error .mxchat-textarea {
    border-color: #dc3545;
}

.mxchat-form-field.error .mxchat-form-label {
    color: #dc3545;
}

.mxchat-validation-message {
    font-size: 12px;
    margin-top: 4px;
    display: none;
    color: #dc3545;
}

.mxchat-form-field.error .mxchat-validation-message {
    display: block;
}

/* ==========================================
   WIZARD STYLES
   Minimal styling - inherits from chat theme
   Uses highly specific selectors to prevent theme bleed
   ========================================== */

/* CSS Custom Properties with fallbacks */
.mxchat-wizard-step {
    --mxwiz-accent: var(--mxchat-accent, #2271b1);
    --mxwiz-accent-hover: var(--mxchat-accent-hover, #135e96);
    --mxwiz-text: inherit;
    --mxwiz-text-muted: #888;
}

/* Wizard Step Container - minimal, inherits from chat */
.mxchat-wizard-step {
    position: relative;
    padding: 4px 0;
    margin: 4px 0;
    max-width: 100%;
    box-sizing: border-box;
}

.mxchat-wizard-step .mxchat-wizard-question {
    font-weight: 500;
    margin: 0 0 10px 0;
    padding: 0;
    color: var(--mxwiz-text);
    line-height: 1.4;
    background: transparent;
    border: none;
}

/* Wizard Button Options Container */
.mxchat-wizard-step .mxchat-wizard-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 8px 0;
    padding: 0;
    list-style: none;
    background: transparent;
    border: none;
}

/* Option Buttons - triple-scoped for specificity */
.mxchat-wizard-step .mxchat-wizard-options button.mxchat-wizard-option,
.mxchat-wizard-step button.mxchat-wizard-option[type="button"],
.mxchat-wizard-step .mxchat-wizard-option {
    /* Reset */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    /* Box model */
    display: inline-block;
    box-sizing: border-box;
    margin: 0;
    padding: 8px 16px;
    /* Visual */
    background-color: transparent;
    background-image: none;
    border: 2px solid var(--mxwiz-accent);
    border-radius: 20px;
    box-shadow: none;
    outline: none;
    /* Typography */
    color: var(--mxwiz-accent);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    text-align: center;
    text-decoration: none;
    text-transform: none;
    letter-spacing: normal;
    white-space: nowrap;
    /* Behavior */
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    flex: 0 0 auto;
    vertical-align: middle;
    overflow: visible;
}

.mxchat-wizard-step .mxchat-wizard-options button.mxchat-wizard-option:hover,
.mxchat-wizard-step button.mxchat-wizard-option[type="button"]:hover,
.mxchat-wizard-step .mxchat-wizard-option:hover {
    background-color: var(--mxwiz-accent);
    background-image: none;
    color: #fff;
    border-color: var(--mxwiz-accent);
    box-shadow: none;
    text-decoration: none;
}

.mxchat-wizard-step .mxchat-wizard-options button.mxchat-wizard-option:focus,
.mxchat-wizard-step button.mxchat-wizard-option[type="button"]:focus,
.mxchat-wizard-step .mxchat-wizard-option:focus {
    outline: none;
    box-shadow: none;
}

.mxchat-wizard-step .mxchat-wizard-options button.mxchat-wizard-option:disabled,
.mxchat-wizard-step button.mxchat-wizard-option[type="button"]:disabled,
.mxchat-wizard-step .mxchat-wizard-option:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.mxchat-wizard-step .mxchat-wizard-options button.mxchat-wizard-option.selected,
.mxchat-wizard-step button.mxchat-wizard-option[type="button"].selected,
.mxchat-wizard-step .mxchat-wizard-option.selected {
    background-color: var(--mxwiz-accent);
    color: #fff;
    border-color: var(--mxwiz-accent);
}

/* Cancel Button - text link style */
.mxchat-wizard-step button.mxchat-wizard-cancel,
.mxchat-wizard-step button.mxchat-wizard-cancel[type="button"] {
    /* Reset */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    /* Box model */
    display: inline-block;
    box-sizing: border-box;
    margin: 0;
    padding: 4px 0;
    /* Visual */
    background: transparent;
    background-color: transparent;
    background-image: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    outline: none;
    /* Typography */
    color: var(--mxwiz-text-muted);
    font-family: inherit;
    font-size: 12px;
    font-weight: normal;
    line-height: 1.4;
    text-align: left;
    text-decoration: underline;
    /* Behavior */
    cursor: pointer;
    transition: color 0.2s ease;
}

.mxchat-wizard-step button.mxchat-wizard-cancel:hover,
.mxchat-wizard-step button.mxchat-wizard-cancel[type="button"]:hover {
    color: var(--mxwiz-text);
    background: transparent;
    background-color: transparent;
    background-image: none;
    text-decoration: underline;
}

.mxchat-wizard-step button.mxchat-wizard-cancel:focus,
.mxchat-wizard-step button.mxchat-wizard-cancel[type="button"]:focus {
    outline: none;
    box-shadow: none;
    background: transparent;
}

.mxchat-wizard-step button.mxchat-wizard-cancel:disabled,
.mxchat-wizard-step button.mxchat-wizard-cancel[type="button"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Answer Display - shown after answering */
.mxchat-wizard-step .mxchat-wizard-answer-display {
    display: inline-block;
    box-sizing: border-box;
    margin: 6px 0 0 0;
    padding: 6px 12px;
    background-color: rgba(34, 113, 177, 0.1);
    background-image: none;
    border: 1px solid var(--mxwiz-accent);
    border-radius: 16px;
    color: var(--mxwiz-accent);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
}

/* Loading State */
.mxchat-wizard-step.loading {
    opacity: 0.7;
    pointer-events: none;
}

.mxchat-wizard-step.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    margin: 0;
    padding: 0;
    background: transparent;
    border: 2px solid var(--mxwiz-accent);
    border-radius: 50%;
    border-right-color: transparent;
    animation: spin 0.8s linear infinite;
}

/* Answered State - subtle */
.mxchat-wizard-step.answered {
    opacity: 0.8;
}

/* Error Message */
.mxchat-wizard-step .mxchat-wizard-error {
    display: block;
    box-sizing: border-box;
    margin: 8px 0 0 0;
    padding: 8px 12px;
    background-color: rgba(220, 53, 69, 0.1);
    background-image: none;
    border: 1px solid rgba(220, 53, 69, 0.3);
    border-radius: 4px;
    color: #dc3545;
    font-size: 13px;
    line-height: 1.4;
}

/* Responsive */
@media screen and (max-width: 600px) {
    .mxchat-wizard-step .mxchat-wizard-options {
        flex-direction: column;
    }

    .mxchat-wizard-step .mxchat-wizard-options button.mxchat-wizard-option,
    .mxchat-wizard-step button.mxchat-wizard-option[type="button"] {
        width: 100%;
        text-align: center;
    }
}