/* =============================================================
   Custom Form Handler – Form Styles
   ============================================================= */

:root {
    --cfh-accent:       #E86401;
    --cfh-accent-dark:  #c85600;
    --cfh-border:       #d0d0d0;
    --cfh-bg:           #f9f9f9;
    --cfh-text:         #222;
    --cfh-muted:        #666;
    --cfh-radius:       6px;
    --cfh-transition:   0.2s ease;
}

/* Container */
.cfh-form-container {
    max-width: 620px;
    margin: 0 auto;
    padding: 28px 32px;
    border: 1px solid var(--cfh-border);
    border-radius: var(--cfh-radius);
    background: var(--cfh-bg);
    font-family: Arial, Helvetica, sans-serif;
    color: var(--cfh-text);
    box-sizing: border-box;
}

.cfh-intro {
    margin: 0 0 20px;
    font-size: 0.95em;
    color: var(--cfh-muted);
}

/* Steps */
.cfh-step        { display: none; }
.cfh-step.active { display: block; }

.cfh-step h2 {
    margin: 0 0 18px;
    font-size: 1.1em;
    color: var(--cfh-text);
}

/* Form groups */
.cfh-form-group {
    margin-bottom: 16px;
}

.cfh-form-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 6px;
    color: var(--cfh-text);
    font-size: 0.95em;
}

.cfh-group-label {
    margin: 0 0 8px;
    font-weight: bold;
    color: var(--cfh-text);
    font-size: 0.95em;
}

.cfh-optional {
    font-weight: normal;
    color: var(--cfh-muted);
    font-size: 0.9em;
}

.cfh-form-shell {
    position: relative;
}

.cfh-form-shell--modal[hidden] {
    display: none !important;
}

.cfh-form-shell--modal {
    position: fixed;
    inset: 0;
    z-index: 9998;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.cfh-form-shell--modal .cfh-form-container {
    position: relative;
    z-index: 9999;
    width: min(100%, 620px);
    margin-block: auto;
    max-height: none;
    overflow: visible;
    padding-top: 44px;
    animation: cfh-panel-in 0.18s ease;
}

.cfh-form-shell__close {
    position: absolute;
    top: 12px;
    right: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    font: inherit;
    font-size: 28px;
    line-height: 1;
}

.cfh-form-shell__close:hover {
    background: #f3f4f6;
    color: var(--cfh-accent);
}

.cfh-form-focus-overlay[hidden] {
    display: none !important;
}

.cfh-form-focus-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(9, 15, 26, 0.72);
    animation: cfh-overlay-in 0.18s ease;
}

.cfh-form-shell.is-focused .cfh-form-container {
    position: relative;
    z-index: 9999;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.28);
}

@keyframes cfh-overlay-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes cfh-panel-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.cfh-form-container.is-success .cfh-intro,
.cfh-form-container.is-success .cfh-multi-step-form,
.cfh-form-container.is-success .cfh-progress-bar,
.cfh-form-container.is-success .cfh-step-counter {
    display: none;
}

.cfh-form-success[hidden] {
    display: none !important;
}

.cfh-form-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 28px 12px 12px;
    text-align: center;
}

.cfh-form-success p {
    margin: 0;
    color: #25354a;
    font-size: 15px;
    line-height: 1.5;
}

.cfh-form-success__check {
    display: block;
    width: 64px;
    height: 64px;
}

.cfh-form-success__circle {
    stroke: #168a4a;
    stroke-width: 2;
    fill: none;
    stroke-dasharray: 157;
    stroke-dashoffset: 157;
    animation: cfh-success-check-circle 0.45s ease forwards;
}

.cfh-form-success__mark {
    stroke: #168a4a;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: cfh-success-check-mark 0.35s 0.35s ease forwards;
}

@keyframes cfh-success-check-circle {
    to { stroke-dashoffset: 0; }
}

@keyframes cfh-success-check-mark {
    to { stroke-dashoffset: 0; }
}

.cfh-form-group input[type="text"],
.cfh-form-group input[type="email"],
.cfh-form-group input[type="tel"],
.cfh-form-group input[type="number"],
.cfh-form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--cfh-border);
    border-radius: var(--cfh-radius);
    box-sizing: border-box;
    font-size: 1em;
    color: var(--cfh-text);
    background: #fff;
    transition: border-color var(--cfh-transition), box-shadow var(--cfh-transition);
}

.cfh-form-group input:focus,
.cfh-form-group textarea:focus {
    outline: none;
    border-color: var(--cfh-accent);
    box-shadow: 0 0 0 3px rgba(232, 100, 1, 0.15);
}

.cfh-form-group textarea {
    min-height: 96px;
    resize: vertical;
    font: inherit;
}

.cfh-form-group input:invalid:not(:placeholder-shown) {
    border-color: #c0392b;
}

.cfh-input-wrap {
    position: relative;
}

.cfh-form-group--with-icon input[type="text"],
.cfh-form-group--with-icon input[type="email"],
.cfh-form-group--with-icon input[type="tel"] {
    padding-left: 42px;
}

.cfh-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    color: currentColor;
}

.cfh-input-wrap .cfh-icon {
    position: absolute;
    top: 50%;
    left: 13px;
    color: var(--cfh-muted);
    pointer-events: none;
    transform: translateY(-50%);
}

.cfh-input-wrap:focus-within .cfh-icon {
    color: var(--cfh-accent);
}

.cfh-invalid {
    border-color: #c0392b !important;
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.12);
}

.cfh-field-error {
    display: none;
    margin-top: 6px;
    color: #b32b2b;
    font-size: 0.84em;
    line-height: 1.4;
}

.cfh-summary {
    margin: 0 0 18px;
    padding: 14px 16px;
    border: 1px solid #e2e2e2;
    border-radius: var(--cfh-radius);
    background: #fff;
}

.cfh-summary h3 {
    margin: 0 0 10px;
    font-size: 1em;
    color: var(--cfh-text);
}

.cfh-summary dl {
    display: grid;
    gap: 8px;
    margin: 0;
}

.cfh-summary__row {
    display: grid;
    grid-template-columns: minmax(120px, 42%) 1fr;
    gap: 10px;
    align-items: start;
}

.cfh-summary dt,
.cfh-summary dd {
    margin: 0;
    font-size: 0.9em;
    line-height: 1.4;
}

.cfh-summary dt {
    color: var(--cfh-muted);
}

.cfh-summary dd {
    color: var(--cfh-text);
    font-weight: bold;
}

.cfh-completion-note {
    margin: 0 0 18px;
    padding: 14px 16px;
    border-left: 4px solid var(--cfh-accent);
    border-radius: 0 var(--cfh-radius) var(--cfh-radius) 0;
    background: #fff4ec;
    color: var(--cfh-text);
}

.cfh-completion-note strong {
    display: block;
    margin-bottom: 4px;
}

.cfh-completion-note p {
    margin: 0;
    font-size: 0.9em;
    line-height: 1.5;
}

/* Radio button groups */
.cfh-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.cfh-option-label {
    cursor: pointer;
    user-select: none;
}

.cfh-option-label input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.cfh-option-content {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 2px solid var(--cfh-border);
    border-radius: var(--cfh-radius);
    background: #fff;
    color: var(--cfh-text);
    font-size: 0.95em;
    line-height: 1.25;
    transition: border-color var(--cfh-transition), background var(--cfh-transition), color var(--cfh-transition);
}

.cfh-option-label:hover .cfh-option-content {
    border-color: var(--cfh-accent);
    background: #fff4ec;
}

.cfh-option-label input[type="radio"]:checked + .cfh-option-content {
    border-color: var(--cfh-accent);
    background: var(--cfh-accent);
    color: #fff;
    font-weight: bold;
}

.cfh-option-label input[type="radio"]:focus-visible + .cfh-option-content {
    outline: 3px solid var(--cfh-accent);
    outline-offset: 2px;
}

.cfh-btn-group.cfh-invalid {
    box-shadow: none;
}

.cfh-btn-group.cfh-invalid .cfh-option-content {
    border-color: #c0392b;
}

.cfh-option-text {
    min-width: 0;
}

/* DSGVO checkbox */
.cfh-gdpr {
    margin-top: 12px;
}

.cfh-form-group .cfh-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-weight: normal !important;
    cursor: pointer;
    line-height: 1.5;
    font-size: 0.9em;
    color: var(--cfh-text);
}

.cfh-checkbox-label.cfh-invalid {
    box-shadow: none;
    color: #b32b2b;
}

.cfh-checkbox-icon {
    margin-top: 1px;
    color: var(--cfh-accent);
}

.cfh-checkbox-label input[type="checkbox"] {
    margin-top: 3px;
    accent-color: var(--cfh-accent);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.cfh-checkbox-label a {
    color: var(--cfh-accent);
    text-decoration: underline;
}

/* Buttons */
.cfh-nav {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.cfh-btn {
    padding: 11px 22px;
    border: none;
    border-radius: var(--cfh-radius);
    font-size: 0.95em;
    font-weight: bold;
    cursor: pointer;
    transition: background var(--cfh-transition);
}

.cfh-btn--next,
.cfh-btn--submit {
    background: var(--cfh-accent);
    color: #fff;
}

.cfh-btn--next:hover,
.cfh-btn--submit:hover {
    background: var(--cfh-accent-dark);
}

.cfh-btn:focus-visible {
    outline: 3px solid var(--cfh-accent-dark);
    outline-offset: 3px;
}

.cfh-btn--prev {
    background: #e5e5e5;
    color: var(--cfh-text);
}

.cfh-btn--prev:hover {
    background: #d0d0d0;
}

.cfh-btn--submit:disabled,
.cfh-btn--next:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Progress bar */
.cfh-progress-bar {
    width: 100%;
    height: 8px;
    background: #e5e5e5;
    border-radius: 99px;
    margin-top: 28px;
    overflow: hidden;
}

.cfh-progress-fill {
    height: 100%;
    background: var(--cfh-accent);
    width: 20%;
    border-radius: 99px;
    transition: width 0.35s ease;
}

.cfh-step-counter {
    margin: 8px 0 0;
    font-size: 0.82em;
    color: var(--cfh-muted);
    text-align: right;
}

/* Error message */
.cfh-error-msg {
    display: none;
    background: #fdecea;
    border: 1px solid #f5c6c6;
    color: #b32b2b;
    padding: 10px 14px;
    border-radius: var(--cfh-radius);
    margin-bottom: 16px;
    font-size: 0.92em;
}

/* Modal */
.cfh-modal[hidden] {
    display: none !important;
}

.cfh-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
}

.cfh-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(9, 15, 26, 0.72);
}

.cfh-modal__dialog {
    position: relative;
    width: min(92vw, 460px);
    margin: 10vh auto 0;
    background: #fff;
    border-radius: 14px;
    padding: 26px 24px 22px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
    z-index: 1;
}

.cfh-modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 999px;
    background: #f3f3f3;
    color: var(--cfh-text);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
}

.cfh-modal__title {
    margin: 0 36px 12px 0;
    font-size: 1.2rem;
    color: var(--cfh-text);
}

.cfh-modal__message {
    margin: 0 0 18px;
    color: var(--cfh-muted);
    line-height: 1.6;
}

.cfh-modal__button {
    width: 100%;
}

/* small helper text */
.cfh-step small {
    display: block;
    margin-top: 6px;
    font-size: 0.85em;
    color: var(--cfh-muted);
}

/* Honeypot: visually hidden but not display:none (defeats some bots) */
.cfh-hp-field {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    tab-index: -1;
}

/* Responsive */
@media (max-width: 480px) {
    .cfh-form-container {
        padding: 18px 16px;
    }
    .cfh-btn-group {
        flex-direction: column;
    }
    .cfh-option-content {
        display: flex;
        width: 100%;
        box-sizing: border-box;
    }
    .cfh-summary__row {
        grid-template-columns: 1fr;
        gap: 2px;
    }
    .cfh-nav {
        flex-direction: column;
    }
    .cfh-btn {
        width: 100%;
        text-align: center;
    }
    .cfh-modal__dialog {
        margin-top: 8vh;
        padding: 22px 18px 18px;
    }
    .cfh-form-shell--modal {
        padding: 12px;
    }
}
