/* ============================================================
   Personalfragebogen — WordPress Plugin CSS
   Alle Selektoren unter .pf-wrap gescooped
   ============================================================ */

/* --- CSS-Variablen auf .pf-wrap --- */
.pf-wrap {
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-light: #dbeafe;
    --color-success: #16a34a;
    --color-success-light: #dcfce7;
    --color-error: #dc2626;
    --color-error-light: #fef2f2;
    --color-warning: #f59e0b;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-border: #bbb;
    --color-border-focus: #2563eb;
    --color-bg: #f5f7fa;
    --color-card: #ffffff;
    --color-input-bg: #ffffff;
    --radius: 6px;
    --radius-lg: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
    --transition: 0.2s ease;

    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 15px;
    line-height: 1.7;
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
    box-sizing: border-box;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 16px 60px;
}

.pf-wrap *, .pf-wrap *::before, .pf-wrap *::after {
    box-sizing: border-box;
}

/* --- Container --- */
.pf-wrap .container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 16px 60px;
}

/* --- Header --- */
.pf-wrap .form-header {
    text-align: center;
    margin-bottom: 16px;
}

.pf-wrap .form-header h1 {
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 4px;
}

.pf-wrap .form-header .subtitle {
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

/* --- Fortschrittsbalken --- */
.pf-wrap .progress-bar-container {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--color-bg);
    padding: 12px 0 8px;
    margin-bottom: 16px;
}

/* Admin-Bar Fix */
.admin-bar .pf-wrap .progress-bar-container {
    top: 32px;
}

.pf-wrap .progress-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.pf-wrap .progress-fill {
    height: 100%;
    background: var(--color-success);
    border-radius: 3px;
    width: 0%;
    transition: width 0.4s ease;
}

.pf-wrap .progress-steps {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--color-text-muted);
    gap: 2px;
    overflow-x: auto;
}

.pf-wrap .progress-step {
    cursor: pointer;
    padding: 6px 8px 4px;
    white-space: nowrap;
    transition: var(--transition);
    border-bottom: 2px solid transparent;
}

.pf-wrap .progress-step:hover {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary-light);
}

.pf-wrap .progress-step.active {
    color: var(--color-primary);
    font-weight: 600;
    border-bottom-color: var(--color-primary);
}

.pf-wrap .progress-step.completed {
    color: var(--color-success);
    border-bottom-color: var(--color-success);
}

/* --- Cards (Sektionen) --- */
.pf-wrap .card {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 28px 28px;
    margin-bottom: 20px;
    border: 1px solid var(--color-border);
    transition: border-color var(--transition);
}

.pf-wrap .card:target,
.pf-wrap .card:focus-within {
    border-color: var(--color-primary-light);
}

.pf-wrap .card h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--color-border);
}

.pf-wrap .section-hint {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    margin-bottom: 16px;
}

/* --- Form Layout --- */
.pf-wrap .form-group {
    margin-bottom: 18px;
}

.pf-wrap .form-row {
    display: flex;
    gap: 16px;
}

.pf-wrap .form-row.two-col > .form-group {
    flex: 1;
}

.pf-wrap .form-row.three-col > .form-group {
    flex: 1;
}

.pf-wrap .arbeitszeit-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.pf-wrap .arbeitszeit-grid .form-group {
    text-align: center;
    margin-bottom: 8px;
}

.pf-wrap .arbeitszeit-grid label {
    font-size: 0.85rem;
    font-weight: 600;
}

.pf-wrap .arbeitszeit-grid input {
    text-align: center;
    padding: 8px 4px;
}

/* --- Labels --- */
.pf-wrap label {
    display: block;
    font-weight: 500;
    margin-bottom: 4px;
    font-size: 0.9rem;
    color: var(--color-text);
}

.pf-wrap .required {
    color: var(--color-error);
    font-weight: 700;
}

.pf-wrap .hint {
    display: block;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 3px;
}

/* --- Inputs, Selects, Textareas --- */
.pf-wrap input[type="text"],
.pf-wrap input[type="email"],
.pf-wrap input[type="number"],
.pf-wrap input[type="date"],
.pf-wrap input[type="tel"],
.pf-wrap select,
.pf-wrap textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-input-bg);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.pf-wrap input:focus,
.pf-wrap select:focus,
.pf-wrap textarea:focus {
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.pf-wrap textarea {
    resize: vertical;
    min-height: 60px;
}

.pf-wrap select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* --- Radio & Checkbox --- */
.pf-wrap .radio-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.pf-wrap .radio-label,
.pf-wrap .checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-weight: 400;
    cursor: pointer;
    font-size: 0.9rem;
}

.pf-wrap .radio-label input,
.pf-wrap .checkbox-label input {
    margin-top: 3px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.pf-wrap .checkbox-label {
    line-height: 1.5;
}

/* --- Validierung Feedback --- */
.pf-wrap .form-group.has-error input,
.pf-wrap .form-group.has-error select,
.pf-wrap .form-group.has-error textarea {
    border-color: var(--color-error);
    background: var(--color-error-light);
}

.pf-wrap .form-group.has-error .error-msg {
    display: block;
}

.pf-wrap .form-group.is-valid input,
.pf-wrap .form-group.is-valid select,
.pf-wrap .form-group.is-valid textarea {
    border-color: var(--color-success);
}

.pf-wrap .error-msg {
    display: none;
    color: var(--color-error);
    font-size: 0.8rem;
    margin-top: 4px;
}

/* --- Bedingte Felder --- */
.pf-wrap .conditional {
    display: none;
    animation: pfFadeIn 0.3s ease;
}

.pf-wrap .conditional.visible {
    display: block;
}

.pf-wrap .conditional.visible.form-row {
    display: flex;
}

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

/* --- Tooltip (Hover-Info) --- */
.pf-wrap .pf-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: var(--color-primary-light);
    color: var(--color-primary);
    border: 1.5px solid var(--color-primary);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: help;
    margin-left: 6px;
    vertical-align: middle;
    line-height: 1;
    transition: all var(--transition);
}

.pf-wrap .pf-tooltip:hover,
.pf-wrap .pf-tooltip:focus {
    background: var(--color-primary);
    color: #fff;
    outline: none;
}

.pf-wrap .pf-tooltip-text {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    padding: 12px 16px;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    font-size: 0.82rem;
    font-weight: 400;
    color: var(--color-text);
    line-height: 1.6;
    z-index: 50;
    white-space: normal;
    cursor: default;
}

.pf-wrap .pf-tooltip-text::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--color-border);
}

.pf-wrap .pf-tooltip-text strong {
    color: var(--color-primary-hover);
}

.pf-wrap .pf-tooltip:hover .pf-tooltip-text,
.pf-wrap .pf-tooltip:focus .pf-tooltip-text {
    display: block;
    animation: pfFadeIn 0.2s var(--ease-out-expo);
}

/* --- Upload-Bereich --- */
.pf-wrap .upload-checklist {
    list-style: none;
    columns: 2;
    gap: 16px;
    margin-bottom: 20px;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    padding: 0;
}

.pf-wrap .upload-checklist li {
    padding: 3px 0 3px 20px;
    position: relative;
}

.pf-wrap .upload-checklist li::before {
    content: '\2610';
    position: absolute;
    left: 0;
}

.pf-wrap .upload-area {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    color: var(--color-text-muted);
}

.pf-wrap .upload-area:hover,
.pf-wrap .upload-area.dragover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.pf-wrap .upload-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.pf-wrap .upload-area p {
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.pf-wrap .upload-area small {
    font-size: 0.8rem;
}

.pf-wrap .file-input-hidden {
    display: none;
}

.pf-wrap .file-preview-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pf-wrap .file-preview-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    border: 1px solid #e2e8f0;
}

.pf-wrap .file-preview-item .file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin-right: 8px;
}

.pf-wrap .file-preview-item .file-size {
    color: var(--color-text-muted);
    margin-right: 8px;
    white-space: nowrap;
}

.pf-wrap .file-preview-item .file-remove {
    background: none;
    border: none;
    color: var(--color-error);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 4px;
    line-height: 1;
}

.pf-wrap .file-preview-item .file-remove:hover {
    color: #991b1b;
}

.pf-wrap .file-preview-item.file-error {
    border-color: var(--color-error);
    background: var(--color-error-light);
    color: var(--color-error);
}

/* --- Signature Pad --- */
.pf-wrap .signature-container {
    position: relative;
}

.pf-wrap .signature-container canvas {
    width: 100%;
    max-width: 600px;
    height: 150px;
    background: #eee;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: crosshair;
    touch-action: none;
    display: block;
}

.pf-wrap .signature-container .btn-small {
    margin-top: 8px;
}

/* --- Captcha --- */
.pf-wrap .captcha-group {
    max-width: 360px;
}

.pf-wrap .captcha-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pf-wrap .captcha-question {
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
    color: var(--color-text);
}

.pf-wrap .captcha-row input {
    max-width: 120px;
}

/* --- Buttons --- */
.pf-wrap .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 28px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

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

.pf-wrap .btn-primary {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.pf-wrap .btn-primary:hover {
    background: var(--color-primary-hover);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.35);
}

.pf-wrap .btn-primary:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    box-shadow: none;
}

.pf-wrap .btn-secondary {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.pf-wrap .btn-secondary:hover {
    background: var(--color-bg);
    border-color: var(--color-text-muted);
}

.pf-wrap .btn-small {
    padding: 6px 14px;
    font-size: 0.85rem;
}

.pf-wrap .form-actions {
    text-align: center;
    margin-top: 8px;
}

/* --- Erfolgs-Meldung --- */
.pf-wrap .success-message {
    text-align: center;
    padding: 60px 24px;
    background: var(--color-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.pf-wrap .success-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--color-success-light);
    color: var(--color-success);
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.pf-wrap .success-message h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
    border-bottom: none;
    padding-bottom: 0;
}

.pf-wrap .success-message p {
    color: var(--color-text-muted);
}

/* --- Loading-Overlay --- */
.pf-wrap .pf-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.1rem;
}

.pf-wrap .pf-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: pfSpin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

/* --- Divi-Theme Fix: Full-Width wenn keine Sidebar --- */
#left-area:has(.pf-wrap) {
    float: none;
    width: 100%;
    padding-right: 0;
}

/* Divi Sidebar-Trennlinie ausblenden */
.container:has(.pf-wrap)::before {
    display: none;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 640px) {
    .pf-wrap {
        padding: 12px 10px 40px;
    }

    .pf-wrap .card {
        padding: 20px 16px;
    }

    .pf-wrap .form-row.two-col,
    .pf-wrap .form-row.three-col {
        flex-direction: column;
        gap: 0;
    }

    .pf-wrap .arbeitszeit-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .pf-wrap .radio-group {
        flex-direction: column;
        gap: 10px;
    }

    .pf-wrap .upload-checklist {
        columns: 1;
    }

    .pf-wrap .pf-tooltip-text {
        width: 240px;
        left: 0;
        transform: none;
    }

    .pf-wrap .pf-tooltip-text::after {
        left: 10px;
        transform: none;
    }

    .pf-wrap .captcha-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .pf-wrap .captcha-row input {
        max-width: 100%;
    }

    .pf-wrap .progress-steps {
        display: none;
    }

    .pf-wrap .form-header h1 {
        font-size: 1.4rem;
    }
}

@media (max-width: 480px) {
    .pf-wrap .arbeitszeit-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .pf-wrap .signature-container canvas {
        height: 120px;
    }
}

/* --- Print --- */
@media print {
    .pf-wrap .progress-bar-container,
    .pf-wrap .btn,
    .pf-wrap .upload-area,
    .pf-wrap .captcha-group,
    .pf-wrap .pf-loading-overlay {
        display: none;
    }

    .pf-wrap .card {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }

    .pf-wrap .conditional {
        display: block !important;
    }
}
