/* AMF Forms — Frontend Form Styles */

/* ── Wrapper ─────────────────────────────────────────────────────────────── */
.amf-form-wrapper {
    background: #fff;
    padding: 24px;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
    max-width: 640px;
}

.amf-form-wrapper *,
.amf-form-wrapper *::before,
.amf-form-wrapper *::after {
    box-sizing: border-box;
}

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.amf-progress-bar {
    width: 100%;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    margin-bottom: 20px;
    overflow: hidden;
}

.amf-progress-fill {
    height: 100%;
    background: #0073aa;
    border-radius: 3px;
    transition: width .35s ease;
}

/* ── Fields ────────────────────────────────────────────────────────────────── */
.amf-field-wrap {
    margin-bottom: 18px;
}

.amf-field-wrap label,
.amf-field-legend {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: .9em;
    color: #333;
}

.amf-required {
    color: #e00;
    margin-left: 2px;
}

.amf-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1em;
    color: #333;
    background: #f9f9f9;
    transition: border-color .2s, box-shadow .2s;
    appearance: auto;
}

.amf-input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, .15);
}

.amf-input.amf-textarea {
    resize: vertical;
    min-height: 100px;
}

.amf-select {
    cursor: pointer;
}

/* ── Button-style radio & checkbox ──────────────────────────────────────── */
.amf-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.amf-btn-option {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #f9f9f9;
    color: #333;
    font-size: .9em;
    font-weight: 500;
    cursor: pointer;
    transition: border-color .15s, background .15s, color .15s;
    user-select: none;
}

.amf-btn-option:hover {
    border-color: #0073aa;
    background: #e8f0fe;
}

/* Hide the native input but keep it accessible */
.amf-btn-option input[type="radio"],
.amf-btn-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Selected state */
.amf-btn-option:has(input:checked) {
    background: #0073aa;
    border-color: #0073aa;
    color: #fff;
}

/* Focus ring for keyboard navigation */
.amf-btn-option:has(input:focus-visible) {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* File input */
.amf-file-input {
    padding: 6px;
}

.amf-file-hint {
    display: block;
    margin-top: 4px;
    font-size: .82em;
    color: #888;
}

/* Field errors */
.amf-field-error {
    display: none;
    color: #e00;
    font-size: .82em;
    margin-top: 4px;
}

.amf-field-wrap.amf-has-error .amf-input,
.amf-field-wrap.amf-has-error .amf-select {
    border-color: #e00;
}

.amf-field-wrap.amf-has-error .amf-field-error {
    display: block;
}

/* ── Navigation buttons ───────────────────────────────────────────────────── */
.amf-step-nav {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

.amf-btn {
    padding: 10px 22px;
    font-size: 1em;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background .2s, opacity .2s;
}

.amf-prev-btn {
    background: #e0e0e0;
    color: #333;
}

.amf-prev-btn:hover { background: #ccc; }

.amf-next-btn,
.amf-submit-btn {
    background: #0073aa;
    color: #fff;
}

.amf-next-btn:hover,
.amf-submit-btn:hover { background: #005177; }

.amf-submit-btn:disabled,
.amf-next-btn:disabled {
    opacity: .6;
    cursor: not-allowed;
}

/* Loading state */
.amf-submit-btn.amf-loading::after {
    content: ' ⟳';
    display: inline-block;
    animation: amf-spin 1s linear infinite;
}

@keyframes amf-spin { to { transform: rotate(360deg); } }

/* ── Response messages ──────────────────────────────────────────────────────── */
.amf-form-response {
    padding: 14px 18px;
    border-radius: 5px;
    margin-top: 16px;
    font-size: .95em;
    line-height: 1.5;
}

.amf-form-response.amf-success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.amf-form-response.amf-error {
    background: #ffebee;
    color: #b71c1c;
    border: 1px solid #ef9a9a;
}

/* ── Policy field ────────────────────────────────────────────────────────── */
.amf-field-policy .amf-policy-heading {
    font-weight: 600;
    font-size: .9em;
    margin: 0 0 8px;
}

.amf-policy-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-weight: 400;
    cursor: pointer;
    margin-bottom: 8px;
    line-height: 1.4;
}

.amf-policy-item input[type="checkbox"] {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-top: 2px;
    accent-color: #0073aa;
    cursor: pointer;
}

.amf-required-mark { color: #e00; }

/* Accordion */
.amf-policy-accordion {
    border: none;
    background: none;
}

.amf-policy-accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0 8px;
    background: none;
    cursor: default;
}

.amf-policy-select-all {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: .9em;
    cursor: pointer;
    margin: 0;
}

.amf-policy-select-all input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: #0073aa;
    cursor: pointer;
}

.amf-policy-accordion-toggle {
    background: none;
    border: none;
    padding: 4px 6px;
    cursor: pointer;
    line-height: 1;
    color: #555;
    border-radius: 4px;
    transition: background .15s;
    flex-shrink: 0;
}

.amf-policy-accordion-toggle:hover { background: #e0e0e0; }

.amf-accordion-arrow {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #555;
    transition: transform .2s ease;
}

.amf-policy-accordion-toggle[aria-expanded="true"] .amf-accordion-arrow {
    transform: rotate(180deg);
}

.amf-policy-accordion-body {
    padding: 0;
    border: none;
    background: none;
}

/* ── Captcha ─────────────────────────────────────────────────────────────── */
.amf-captcha-wrap {
    margin-bottom: 16px;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .amf-form-wrapper {
        padding: 16px;
    }

    .amf-step-nav {
        flex-direction: column;
    }

    .amf-btn {
        width: 100%;
        text-align: center;
    }
}
