/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #000000;
    --primary-dark: #000000;
    --text-color: #333;
    --text-light: #666;
    --border-color: #ddd;
    --background: #fff;
    --background-light: #f8f9fa;
    --error-color: #dc3545;
    --success-color: #28a745;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background: var(--background-light);
    padding: 20px 0;
}

/* Container */
.container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--background);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 2px solid var(--border-color);
}

.logo-link {
    display: inline-block;
    margin-bottom: 20px;
}

.logo {
    height: 60px;
    width: auto;
}

.header h1 {
    color: var(--primary-color);
    font-size: 2rem;
    margin-bottom: 10px;
}

.subtitle {
    color: var(--text-light);
    font-size: 1rem;
}

/* Form Sections */
.form-section {
    margin-bottom: 40px;
}

.form-section h2 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

/* Form Layout */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-row .form-group {
    min-width: 0; /* Prevents grid items from overflowing */
    overflow: visible; /* Allow native datepicker to display properly */
}

/* Ensure date inputs in form-row have full width */
.form-row .form-group input[type="date"] {
    width: 100%;
    min-width: 100%;
}

.form-group {
    margin-bottom: 20px;
}

.form-group-small {
    max-width: 150px;
}

/* Labels */
label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-color);
}

.required {
    color: var(--error-color);
}

/* Input Fields */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
textarea {
    width: 100%;
    max-width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s, box-shadow 0.3s;
    box-sizing: border-box;
}

/* Ensure date inputs don't overflow on mobile */
input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    overflow: visible; /* Allow native datepicker to show properly on iOS */
    background-color: var(--background); /* Remove gray background on iOS */
    color: var(--text-color);
    min-width: 0; /* Allow proper sizing in grid */
    min-height: 44px; /* Ensure consistent height even when empty */
    height: 44px; /* Fixed height to match other inputs */
    line-height: 1.5; /* Better vertical alignment */
    vertical-align: middle; /* Better vertical alignment */
}

/* Remove iOS gray background and ensure proper styling */
input[type="date"]::-webkit-datetime-edit {
    color: var(--text-color);
    padding: 0;
    min-height: 22px; /* Ensure datetime-edit has proper height */
    line-height: 22px; /* Match height for vertical centering */
    vertical-align: middle;
}

input[type="date"]::-webkit-datetime-edit-fields-wrapper {
    padding: 0;
    min-height: 22px;
    vertical-align: middle;
}

input[type="date"]::-webkit-datetime-edit-text {
    padding: 0 2px;
}

input[type="date"]::-webkit-datetime-edit-month-field,
input[type="date"]::-webkit-datetime-edit-day-field,
input[type="date"]::-webkit-datetime-edit-year-field {
    padding: 0 2px;
    min-height: 20px;
}

input[type="date"]::-webkit-inner-spin-button,
input[type="date"]::-webkit-clear-button {
    display: none;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 1;
    cursor: pointer;
    padding-right: 5px;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="date"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 178, 0.1);
}

input.error,
textarea.error {
    border-color: var(--error-color);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* Radio and Checkbox Groups */
.radio-group,
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 8px;
}

.radio-label,
.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    font-weight: normal;
}

.radio-label input[type="radio"],
.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
}

/* Range Slider */
.range-container {
    margin-top: 10px;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: var(--text-light);
}

input[type="range"] {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
    border: none;
}

.range-value {
    text-align: center;
    margin-top: 10px;
}

.range-value span {
    display: inline-block;
    padding: 5px 15px;
    background: var(--primary-color);
    color: white;
    border-radius: 4px;
    font-weight: 600;
    min-width: 40px;
}

/* Conditional Fields */
.conditional-field {
    margin-top: 10px;
    animation: slideDown 0.3s ease-out;
}

/* Wahrheits-Checkbox Styling */
.checkbox-wahrheit {
    display: flex;
    align-items: center;
    padding: 15px;
    background: var(--background-light);
    border-radius: 4px;
    font-weight: 500;
    min-height: 56px;
}

.checkbox-wahrheit input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    flex-shrink: 0;
    margin-top: 0;
}

.checkbox-wahrheit ~ .error-message {
    margin-top: 10px;
    margin-left: 0;
    padding-left: 0;
}

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

/* Submit Button */
.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid var(--border-color);
}

.checkbox-group-submit {
    flex: 1;
    margin-bottom: 0;
}

.checkbox-group-submit .checkbox-wahrheit {
    margin-bottom: 0;
}

.btn-submit {
    background: #d8232a;
    color: white;
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 56px;
}

.btn-submit i {
    font-size: 1rem;
}

.btn-submit:hover {
    background: #b71c22;
}

.btn-submit:active {
    transform: scale(0.98);
}

.btn-submit:disabled {
    background: var(--border-color);
    cursor: not-allowed;
}

/* Form Messages */
.form-message {
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 4px;
    text-align: center;
    font-weight: 500;
}

.form-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.form-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.new-submission-link {
    text-align: center;
    margin-top: 15px;
    font-size: 0.9rem;
}

.new-submission-link a {
    color: #666;
    text-decoration: none;
    transition: color 0.3s;
}

.new-submission-link a:hover {
    color: #000;
    text-decoration: underline;
}

/* Loading State */
.btn-submit.loading {
    position: relative;
    color: transparent;
}

.btn-submit.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid white;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
}

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

/* Validation Styles */
.error-message {
    color: var(--error-color);
    font-size: 0.875rem;
    margin-top: 5px;
    display: none;
}

.form-group.has-error .error-message {
    display: block;
}

.form-group.has-error input,
.form-group.has-error textarea {
    border-color: var(--error-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 20px;
        margin: 0 10px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .logo {
        height: 50px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Ensure date inputs in form-row are full width on mobile */
    .form-row .form-group input[type="date"] {
        width: 100%;
        min-width: 100%;
    }

    .form-group-small {
        max-width: 100%;
    }

    .radio-group,
    .checkbox-group {
        flex-direction: column;
        gap: 10px;
    }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .checkbox-group-submit {
        order: 1;
    }
    
    .btn-submit {
        width: 100%;
        padding: 15px 20px;
        justify-content: center;
        order: 2;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px 0;
    }

    .container {
        padding: 15px;
        margin: 0 5px;
    }

    .header {
        margin-bottom: 25px;
        padding-bottom: 20px;
    }

    .logo {
        height: 40px;
    }

    .header h1 {
        font-size: 1.3rem;
    }

    .form-section h2 {
        font-size: 1.2rem;
    }

    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="date"],
    textarea {
        padding: 10px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Ensure date inputs have proper spacing on mobile */
    input[type="date"] {
        padding: 10px;
        padding-right: 40px; /* Extra padding for datepicker icon */
        background-color: var(--background); /* Ensure white background on iOS */
        width: 100%;
        min-width: 100%;
        min-height: 44px; /* Ensure consistent height on mobile */
        height: 44px; /* Fixed height to match other inputs */
        line-height: 1.5;
        vertical-align: middle;
    }
    
    input[type="date"]::-webkit-datetime-edit {
        min-height: 24px;
        line-height: 24px;
        vertical-align: middle;
    }

    .radio-label,
    .checkbox-label {
        min-height: 44px; /* Touch-friendly size */
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }

    .container {
        box-shadow: none;
        max-width: 100%;
    }

    .form-actions,
    .btn-submit {
        display: none;
    }
}

