/* Dynamic Form Builder - Frontend Styles */

.dfb-form {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.dfb-form-title {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
}

.dfb-form-description {
    margin: 0 0 25px 0;
    color: #666;
    font-size: 1rem;
    line-height: 1.5;
    text-align: center;
}

.dfb-form-fields {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Layout-Klassen für horizontale Anordnung */
.dfb-form.dfb-form-layout-flex .dfb-form-fields {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 15px;
}

.dfb-form.dfb-form-layout-inline-block .dfb-form-fields {
    display: block;
}

.dfb-form.dfb-form-layout-inline-block .dfb-field {
    display: inline-block;
    vertical-align: top;
    margin-right: 15px;
    margin-bottom: 15px;
}

.dfb-field {
    position: relative;
    box-sizing: border-box;
}

.dfb-field-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
}

.dfb-required {
    color: #e74c3c;
    margin-left: 4px;
}

.dfb-input,
.dfb-textarea,
.dfb-select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e8ed;
    border-radius: 6px;
    font-size: 1rem;
    background: #fff;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.dfb-input:focus,
.dfb-textarea:focus,
.dfb-select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0,115,170,0.1);
}

.dfb-textarea {
    min-height: 100px;
    resize: vertical;
    overflow: hidden; /* verhindert Scrollbars beim Auto-Resize */
}

.dfb-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
    appearance: none;
}

/* Checkbox Styles */
.dfb-checkbox-default {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.dfb-checkbox-default input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: #0073aa;
}

.dfb-checkbox-default label {
    font-size: 1rem;
    color: #333;
    cursor: pointer;
    user-select: none;
}

.dfb-checkbox-toggle {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.dfb-checkbox-toggle input[type="checkbox"] {
    display: none;
}

.dfb-checkbox-toggle label {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 25px;
    background: #ccc;
    border-radius: 25px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.dfb-checkbox-toggle label::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 21px;
    height: 21px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.dfb-checkbox-toggle input[type="checkbox"]:checked + label {
    background: #0073aa;
}

.dfb-checkbox-toggle input[type="checkbox"]:checked + label::after {
    transform: translateX(25px);
}

.dfb-checkbox-toggle span {
    font-size: 1rem;
    color: #333;
    font-weight: 500;
}

.dfb-checkbox-switch {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.dfb-checkbox-switch input[type="checkbox"] {
    display: none;
}

.dfb-checkbox-switch label {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
    background: #ccc;
    border-radius: 15px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.dfb-checkbox-switch label::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.3s ease;
}

.dfb-checkbox-switch input[type="checkbox"]:checked + label {
    background: #28a745;
}

.dfb-checkbox-switch input[type="checkbox"]:checked + label::after {
    transform: translateX(30px);
}

.dfb-checkbox-switch span {
    font-size: 1rem;
    color: #333;
    font-weight: 500;
}

.dfb-checkbox-custom {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.dfb-checkbox-custom input[type="checkbox"] {
    display: none;
}

.dfb-checkbox-custom label {
    position: relative;
    display: inline-block;
    width: 22px;
    height: 22px;
    border: 2px solid #0073aa;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.dfb-checkbox-custom label::after {
    content: '✓';
    position: absolute;
    top: -1px;
    left: 3px;
    color: #0073aa;
    font-size: 16px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.dfb-checkbox-custom input[type="checkbox"]:checked + label {
    background: #0073aa;
    border-color: #0073aa;
}

.dfb-checkbox-custom input[type="checkbox"]:checked + label::after {
    opacity: 1;
    color: #fff;
}

.dfb-checkbox-custom span {
    font-size: 1rem;
    color: #333;
    font-weight: 500;
}

/* Radio Styles */
.dfb-radio-default {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.dfb-radio-default input[type="radio"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: #0073aa;
}

.dfb-radio-default label {
    font-size: 1rem;
    color: #333;
    cursor: pointer;
    user-select: none;
}

.dfb-radio-button {
    display: inline-block;
    margin-right: 15px;
    margin-bottom: 10px;
}

.dfb-radio-button input[type="radio"] {
    display: none;
}

.dfb-radio-button label {
    display: inline-block;
    padding: 10px 20px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 1rem;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.dfb-radio-button label:hover {
    background: #e9ecef;
    border-color: #0073aa;
    transform: translateY(-1px);
}

.dfb-radio-button input[type="radio"]:checked + label {
    background: #0073aa;
    border-color: #0073aa;
    color: #fff;
    box-shadow: 0 4px 8px rgba(0,115,170,0.2);
}

.dfb-radio-card {
    display: inline-block;
    margin-right: 15px;
    margin-bottom: 10px;
}

.dfb-radio-card input[type="radio"] {
    display: none;
}

.dfb-radio-card label {
    display: inline-block;
    padding: 15px 20px;
    background: #fff;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 80px;
    text-align: center;
    font-weight: 500;
}

.dfb-radio-card label:hover {
    border-color: #0073aa;
    box-shadow: 0 4px 8px rgba(0,115,170,0.1);
    transform: translateY(-2px);
}

.dfb-radio-card input[type="radio"]:checked + label {
    border-color: #0073aa;
    background: #f0f8ff;
    color: #0073aa;
    box-shadow: 0 6px 12px rgba(0,115,170,0.2);
}

/* Form Submit */
.dfb-form-submit {
    margin-top: 30px;
    text-align: center;
    clear: both;
}

.dfb-submit-button {
    background: linear-gradient(135deg, #0073aa 0%, #005a87 100%);
    color: #fff;
    border: none;
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0,115,170,0.2);
    min-width: 200px;
}

.dfb-submit-button:hover {
    background: linear-gradient(135deg, #005a87 0%, #004466 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,115,170,0.3);
}

.dfb-submit-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,115,170,0.2);
}

.dfb-submit-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Messages */
.dfb-form-message {
    padding: 15px 20px;
    border-radius: 6px;
    margin: 20px 0;
    font-weight: 500;
    text-align: center;
}

.dfb-form-message.dfb-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.dfb-form-message.dfb-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Field Errors */
/* Fehlermeldungs-Container separat benennen, damit Inputs nicht verschwinden */
.dfb-error-msg {
    color: #e74c3c;
    font-size: 0.9rem;
    margin-top: 5px;
    display: block;
}

.dfb-input.dfb-error,
.dfb-textarea.dfb-error,
.dfb-select.dfb-error,
.dfb-file-input.dfb-error {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231,76,60,0.1);
}

/* Focus States */
.dfb-field-focused .dfb-input,
.dfb-field-focused .dfb-textarea,
.dfb-field-focused .dfb-select {
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0,115,170,0.1);
}

/* Character Counter */
.dfb-char-counter {
    font-size: 0.8rem;
    color: #666;
    text-align: right;
    margin-top: 5px;
}

/* Loading State */
.dfb-form.loading {
    opacity: 0.7;
    pointer-events: none;
}

.dfb-form.loading .dfb-submit-button {
    position: relative;
    color: transparent;
}

.dfb-form.loading .dfb-submit-button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid #fff;
    border-radius: 50%;
    animation: dfb-spin 1s linear infinite;
}

@keyframes dfb-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Animations */
.dfb-field {
    animation: dfb-fade-in 0.5s ease-out;
}

@keyframes dfb-fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dfb-form-message {
    animation: dfb-slide-in 0.3s ease-out;
}

@keyframes dfb-slide-in {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .dfb-form {
        padding: 15px;
        margin: 10px;
    }
    
    .dfb-form-title {
        font-size: 1.3rem;
    }
    
    .dfb-form-description {
        font-size: 0.9rem;
    }
    
    .dfb-input,
    .dfb-textarea,
    .dfb-select {
        padding: 10px 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .dfb-submit-button {
        width: 100%;
        padding: 12px 20px;
        font-size: 1rem;
    }
    
    /* Mobile: Felder immer untereinander */
    .dfb-form.dfb-form-layout-flex .dfb-form-fields,
    .dfb-form.dfb-form-layout-inline-block .dfb-form-fields {
        flex-direction: column !important;
    }
    
    .dfb-form.dfb-form-layout-inline-block .dfb-field {
        display: block !important;
        width: 100% !important;
        margin-right: 0 !important;
    }
    
    .dfb-radio-button,
    .dfb-radio-card {
        display: block;
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .dfb-radio-button label,
    .dfb-radio-card label {
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .dfb-form {
        padding: 10px;
        margin: 5px;
    }
    
    .dfb-form-title {
        font-size: 1.2rem;
    }
    
    .dfb-checkbox-toggle,
    .dfb-checkbox-switch,
    .dfb-checkbox-custom {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .dfb-form {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .dfb-form-title {
        color: #f7fafc;
    }
    
    .dfb-form-description {
        color: #a0aec0;
    }
    
    .dfb-field-label {
        color: #f7fafc;
    }
    
    .dfb-input,
    .dfb-textarea,
    .dfb-select {
        background: #4a5568;
        border-color: #718096;
        color: #f7fafc;
    }
    
    .dfb-input:focus,
    .dfb-textarea:focus,
    .dfb-select:focus {
        border-color: #63b3ed;
        box-shadow: 0 0 0 3px rgba(99,179,237,0.1);
    }
    
    .dfb-checkbox-default label,
    .dfb-radio-default label,
    .dfb-checkbox-toggle span,
    .dfb-checkbox-switch span,
    .dfb-checkbox-custom span {
        color: #f7fafc;
    }
    
    .dfb-radio-button label {
        background: #4a5568;
        border-color: #718096;
        color: #f7fafc;
    }
    
    .dfb-radio-card label {
        background: #4a5568;
        border-color: #718096;
        color: #f7fafc;
    }
    
    .dfb-submit-button {
        background: linear-gradient(135deg, #63b3ed 0%, #3182ce 100%);
    }
    
    .dfb-submit-button:hover {
        background: linear-gradient(135deg, #3182ce 0%, #2c5282 100%);
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .dfb-field,
    .dfb-form-message,
    .dfb-submit-button {
        animation: none;
        transition: none;
    }
}

@media (prefers-contrast: high) {
    .dfb-form {
        border: 2px solid #000;
    }
    
    .dfb-input,
    .dfb-textarea,
    .dfb-select {
        border: 2px solid #000;
    }
    
    .dfb-submit-button {
        border: 2px solid #000;
    }
}

/* Newsletter Field Styles */
.dfb-newsletter-field {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    margin: 15px 0;
}

.dfb-newsletter-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.dfb-newsletter-checkbox {
    margin: 0;
}

.dfb-newsletter-label {
    font-weight: 500;
    color: #333;
    margin: 0;
    cursor: pointer;
}

.dfb-newsletter-privacy {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 10px;
    font-size: 0.9em;
    color: #666;
}

.dfb-privacy-checkbox {
    margin: 0;
    margin-top: 2px;
}

.dfb-privacy-label {
    margin: 0;
    line-height: 1.4;
    cursor: pointer;
}

.dfb-privacy-label a {
    color: #0073aa;
    text-decoration: none;
}

.dfb-privacy-label a:hover {
    text-decoration: underline;
}

/* File Upload Field Styles */
.dfb-file-field {
    position: relative;
}

.dfb-file-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e8ed;
    border-radius: 6px;
    font-size: 1rem;
    background: #fff;
    transition: all 0.3s ease;
    box-sizing: border-box;
    cursor: pointer;
}

.dfb-file-input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0,115,170,0.1);
}

.dfb-file-input:hover {
    border-color: #0073aa;
}

.dfb-file-info {
    margin-top: 8px;
    font-size: 0.85rem;
    color: #666;
    line-height: 1.4;
}

.dfb-file-info small {
    display: block;
    margin-bottom: 2px;
}

.dfb-file-preview {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
}

.dfb-file-preview h4 {
    margin: 0 0 10px 0;
    font-size: 1rem;
    color: #333;
}

.dfb-file-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.dfb-file-list li {
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
    font-size: 0.9rem;
    color: #495057;
}

.dfb-file-list li:last-child {
    border-bottom: none;
}

.dfb-file-list li::before {
    content: "📎";
    margin-right: 8px;
}

/* File Upload Error States */
.dfb-file-input.dfb-field-error {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231,76,60,0.1);
}

.dfb-file-input.dfb-field-error:focus {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231,76,60,0.2);
}

/* Responsive Design */
@media (max-width: 768px) {
    .dfb-form-layout-flex .dfb-form-fields,
    .dfb-form-layout-inline-block .dfb-form-fields {
        flex-direction: column !important;
    }
    
    .dfb-form-layout-inline-block .dfb-field {
        display: block !important;
        width: 100% !important;
        margin-right: 0 !important;
    }
    
    .dfb-newsletter-privacy {
        margin-left: 0;
    }
}

/* Print Styles */
@media print {
    .dfb-form {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .dfb-submit-button {
        display: none;
    }
    
    .dfb-form-message {
        border: 1px solid #000;
    }
}
