/* ═══════════════════════════════════════════════════════════
   KONTAKTFORMULAR – Wiederverwendbare Komponente
   Einbinden: <link rel="stylesheet" href="kontaktformular.css">
   ═══════════════════════════════════════════════════════════ */

/* hidden-Attribut schlägt immer durch, auch gegen display:flex/grid */
.cf-wrapper [hidden] { display: none !important; }

/* ── Wrapper ─────────────────────────────────────────────── */
.cf-wrapper {
    max-width: 660px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(30, 77, 107, 0.15);
    border: 3px solid #f4a261;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ── Header ──────────────────────────────────────────────── */
.cf-header {
    background: linear-gradient(135deg, #fff8f0 0%, #fef5ed 100%);
    padding: 2rem 2.5rem 1.5rem;
    border-bottom: 2px solid #fef5ed;
    text-align: center;
}

.cf-title {
    color: #1e4d6b;
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 0.4rem;
    letter-spacing: -0.02em;
}

.cf-subtitle {
    color: #718096;
    font-size: 0.95rem;
    margin: 0;
}

/* ── Form Body ───────────────────────────────────────────── */
.cf-form {
    padding: 2.25rem 2.5rem 2.5rem;
}

/* Honeypot – für Bots unsichtbar, für Menschen nicht erreichbar */
.cf-honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    tab-index: -1;
}

/* ── Grid Row ────────────────────────────────────────────── */
.cf-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

/* ── Field Group ─────────────────────────────────────────── */
.cf-group {
    margin-bottom: 1.4rem;
}

.cf-group label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: #2d3748;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.55rem;
    line-height: 1;
}

.cf-group label svg {
    width: 15px;
    height: 15px;
    fill: #f4a261;
    flex-shrink: 0;
}

.cf-required {
    color: #f4a261;
    font-weight: 700;
}

/* ── Inputs ──────────────────────────────────────────────── */
.cf-group input,
.cf-group textarea,
.cf-group select {
    width: 100%;
    padding: 0.85rem 1.1rem;
    border: 2px solid #fef5ed;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    color: #2d3748;
    background: #ffffff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    outline: none;
    line-height: 1.5;
}

.cf-group input::placeholder,
.cf-group textarea::placeholder {
    color: #a0aec0;
}

.cf-group input:focus,
.cf-group textarea:focus,
.cf-group select:focus {
    border-color: #f4a261;
    box-shadow: 0 0 0 4px rgba(244, 162, 97, 0.12);
    transform: translateY(-1px);
}

/* Valide */
.cf-group input.cf-valid,
.cf-group textarea.cf-valid {
    border-color: #48bb78;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%2348bb78' d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    background-size: 16px;
    padding-right: 2.5rem;
}

/* Invalide */
.cf-group input.cf-invalid,
.cf-group textarea.cf-invalid,
.cf-group select.cf-invalid {
    border-color: #fc8181;
    box-shadow: 0 0 0 4px rgba(252, 129, 129, 0.1);
}

.cf-group textarea {
    min-height: 140px;
    resize: vertical;
}

.cf-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%23f4a261' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 3rem;
}

/* Fehlermeldung unter Feldern */
.cf-error-msg {
    display: block;
    color: #e53e3e;
    font-size: 0.78rem;
    font-weight: 500;
    margin-top: 0.35rem;
    min-height: 1.1rem;
    line-height: 1.4;
}

/* Hinweistext */
.cf-hint {
    color: #a0aec0;
    font-size: 0.78rem;
    margin-top: 0.35rem;
    font-style: italic;
    line-height: 1.4;
}

/* ── Datenschutz Checkbox ────────────────────────────────── */
.cf-privacy {
    margin-bottom: 1.75rem;
    background: #fef5ed;
    padding: 1.1rem 1.25rem;
    border-radius: 10px;
}

.cf-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: #2d3748;
    line-height: 1.6;
    user-select: none;
}

/* Native Checkbox verstecken */
.cf-checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Custom Checkbox Box */
.cf-checkbox-custom {
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: 2px solid #f4a261;
    border-radius: 5px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
    transition: all 0.2s ease;
    position: relative;
}

.cf-checkbox-label input:checked + .cf-checkbox-custom {
    background: #f4a261;
    border-color: #f4a261;
}

.cf-checkbox-label input:checked + .cf-checkbox-custom::after {
    content: '';
    display: block;
    width: 5px;
    height: 9px;
    border: 2px solid white;
    border-top: none;
    border-left: none;
    transform: rotate(45deg) translateY(-1px);
}

.cf-checkbox-label input:focus + .cf-checkbox-custom {
    box-shadow: 0 0 0 3px rgba(244, 162, 97, 0.25);
}

.cf-checkbox-label a {
    color: #f4a261;
    text-decoration: underline;
    font-weight: 600;
}

.cf-checkbox-label a:hover {
    color: #e89450;
}

/* ── Submit Button ───────────────────────────────────────── */
.cf-submit {
    width: 100%;
    padding: 1.05rem 2rem;
    background: linear-gradient(135deg, #f4a261, #e89450);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(244, 162, 97, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-family: inherit;
    margin-top: 0.25rem;
    letter-spacing: 0.01em;
}

.cf-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(244, 162, 97, 0.45);
}

.cf-submit:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(244, 162, 97, 0.35);
}

.cf-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.cf-submit-icon {
    width: 18px;
    height: 18px;
    fill: white;
    flex-shrink: 0;
}

/* ── Spinner ─────────────────────────────────────────────── */
.cf-spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-top-color: white;
    border-radius: 50%;
    animation: cf-spin 0.7s linear infinite;
    flex-shrink: 0;
}

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

/* ── Erfolgs-State ───────────────────────────────────────── */
.cf-success {
    padding: 4rem 2.5rem;
    text-align: center;
    animation: cf-fadein 0.4s ease;
}

@keyframes cf-fadein {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.cf-success-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #48bb78, #38a169);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    box-shadow: 0 8px 25px rgba(72, 187, 120, 0.3);
    animation: cf-pop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes cf-pop {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

.cf-success-icon svg {
    width: 38px;
    height: 38px;
    fill: white;
}

.cf-success h3 {
    color: #1e4d6b;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.75rem;
}

.cf-success p {
    color: #718096;
    font-size: 0.95rem;
    line-height: 1.7;
    margin: 0 0 2rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.cf-reset-btn {
    background: none;
    border: 2px solid #f4a261;
    color: #f4a261;
    padding: 0.7rem 1.75rem;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
}

.cf-reset-btn:hover {
    background: #f4a261;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(244, 162, 97, 0.3);
}

/* ── Fehler-Banner (globaler Fehler) ─────────────────────── */
.cf-error-banner {
    margin: 0 2.5rem 1.25rem;
    padding: 0.9rem 1.1rem;
    background: #fff5f5;
    border: 2px solid #fc8181;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: #c53030;
    font-size: 0.875rem;
    line-height: 1.5;
    animation: cf-fadein 0.3s ease;
}

.cf-error-banner svg {
    width: 18px;
    height: 18px;
    fill: #c53030;
    flex-shrink: 0;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 620px) {
    .cf-form {
        padding: 1.75rem 1.5rem 2rem;
    }

    .cf-header {
        padding: 1.5rem 1.5rem 1.25rem;
    }

    .cf-title {
        font-size: 1.45rem;
    }

    .cf-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .cf-success {
        padding: 3rem 1.5rem;
    }

    .cf-error-banner {
        margin: 0 1.5rem 1.25rem;
    }
}

@media (max-width: 400px) {
    .cf-form {
        padding: 1.25rem 1rem 1.5rem;
    }

    .cf-header {
        padding: 1.25rem 1rem 1rem;
    }

    .cf-error-banner {
        margin: 0 1rem 1rem;
    }
}
