/* ========================================
   KARIR HUB - Progressive Form Wizard
   Mobile-first, Typeform-style Design
   ======================================== */

:root {
    --color-primary: #00a651;
    --color-primary-dark: #008f4f;
    --color-accent: #ff8c42;
    --color-text: #334155;
    --color-text-muted: #64748b;
    --color-border: #e2e8f0;
    --color-bg: #f8fafc;
    --color-error: #dc2626;
    --color-success: #16a34a;
    --radius: 12px;
    --wizard-safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    min-height: 100%;
    min-height: 100dvh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    color: var(--color-text);
    background: white;
    margin: 0;
}

/* Admin/HRD: pratinjau form tanpa mengirim data */
.wizard-preview-banner {
    flex-shrink: 0;
    padding: 0.65rem 1rem;
    text-align: center;
    font-size: 0.88rem;
    background: #fef3c7;
    color: #92400e;
    border-bottom: 1px solid #f59e0b;
}

/* Intro sebelum wizard (mobile-first) */
.lamaran-intro-screen {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1rem 5rem;
    max-width: 560px;
    margin: 0 auto;
    width: 100%;
}
.lamaran-intro-screen h2 {
    font-size: 1.15rem;
    color: var(--color-primary);
    margin: 0 0 0.75rem;
}
.lamaran-intro-screen ul {
    margin: 0 0 1rem;
    padding-left: 1.2rem;
    color: var(--color-text);
    font-size: 0.95rem;
    line-height: 1.55;
}
.lamaran-intro-actions {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-top: 1.25rem;
}
.lamaran-intro-actions .btn-full {
    width: 100%;
    justify-content: center;
}
.draft-hint {
    background: #e0f2fe;
    border: 1px solid #38bdf8;
    color: #0369a1;
    padding: 0.75rem;
    border-radius: var(--radius);
    font-size: 0.88rem;
    margin-bottom: 1rem;
}
.upload-status {
    font-size: 0.85rem;
    color: var(--color-success);
    margin-top: 0.35rem;
    display: none;
}
.upload-status.show {
    display: block;
}

.form-textarea-lg {
    min-height: 140px;
    resize: vertical;
}
.conditional-block {
    margin-top: 1rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}
.psych-frame-wrap {
    margin: 1rem 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    min-height: 200px;
}
.psych-frame-wrap iframe {
    width: 100%;
    min-height: 220px;
    border: 0;
}

/* Container: pakai dvh agar tidak ada scroll halaman sisa di mobile (sticky menempel viewport dan menutupi form) */
.wizard-container {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    /* Satu offset notch/status bar untuk seluruh layar (banner pratinjau + header tidak dobel) */
    padding-top: env(safe-area-inset-top, 0px);
}

/* Header: alur normal di kolom flex (bukan sticky/fixed ke viewport), supaya tidak menutupi isian */
.wizard-header {
    flex-shrink: 0;
    box-sizing: border-box;
    padding-top: 0.65rem;
    padding-left: 1rem;
    padding-right: 1rem;
    padding-bottom: 0.65rem;
    border-bottom: 2px solid #cbd5e1;
    position: relative;
    z-index: 2;
    background: #ffffff;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

.wizard-header-inner {
    max-width: 500px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem 0.75rem;
}

.wizard-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-text);
}

.wizard-logo img {
    height: 36px;
    width: auto;
    display: block;
}

.wizard-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.wizard-progress-bar {
    width: 50px;
    height: 3px;
    background: var(--color-border);
    border-radius: 999px;
    overflow: hidden;
}

.wizard-progress-fill {
    height: 100%;
    background: var(--color-primary);
    transition: width 300ms ease-out;
}

/* Main content: latar sedikit kontras agar jelas bukan bagian header */
.wizard-body {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 1.35rem 1rem 1.5rem;
    padding-bottom: calc(1.5rem + var(--wizard-safe-bottom));
    background: #f1f5f9;
    scroll-padding-top: 0.75rem;
    scroll-padding-bottom: calc(5.5rem + var(--wizard-safe-bottom));
}

.wizard-body-inner {
    width: 100%;
    max-width: 500px;
    flex-shrink: 0;
    background: #ffffff;
    border-radius: 14px;
    padding: 1.15rem 1rem 0.25rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    border: 1px solid #e2e8f0;
}

@media (max-width: 480px) {
    .wizard-body-inner {
        padding: 1rem 0.85rem 0.15rem;
        border-radius: 12px;
    }
}

/* Draf: di alur konten (bukan sticky), ringan, selaras lebar form */
.wizard-draft-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.45rem 0.65rem;
    padding: 0.5rem 0.7rem;
    margin-bottom: 1rem;
    background: #f8fafc;
    border: 1px solid var(--color-border);
    border-left: 3px solid #f59e0b;
    border-radius: 10px;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    line-height: 1.45;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.wizard-draft-bar[hidden] {
    display: none !important;
}

.wizard-draft-bar__icon {
    color: #d97706;
    margin-top: 0.12rem;
    flex-shrink: 0;
}

.wizard-draft-bar__text {
    flex: 1;
    min-width: 140px;
}

.wizard-draft-bar__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    margin-left: auto;
}

.btn-draft-secondary,
.btn-draft-danger {
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.2;
    white-space: nowrap;
}

.btn-draft-secondary {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
}

.btn-draft-secondary:hover {
    background: #f1f5f9;
}

.btn-draft-danger {
    border: 1px solid #fecaca;
    background: #fff;
    color: #b91c1c;
}

.btn-draft-danger:hover {
    background: #fef2f2;
}

@media (max-width: 420px) {
    .wizard-draft-bar__actions {
        width: 100%;
        margin-left: 0;
        justify-content: flex-start;
    }
}

.wizard-form {
    width: 100%;
    max-width: 500px;
    padding-bottom: 1rem;
}

/* Step */
.wizard-step {
    display: none;
    opacity: 0;
}

.wizard-step.active {
    display: block;
    animation: fadeIn 300ms ease-out forwards;
}

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

/* Judul langkah: hanya <h2>, supaya label unggah tidak “ikut” gaya judul besar */
h2.step-title {
    font-size: 1.65rem;
    font-weight: 700;
    margin-bottom: 0.85rem;
    line-height: 1.25;
    color: #0f172a;
    scroll-margin-top: 0.85rem;
}

.step-subtitle {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
}

/* Form elements */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #1e293b;
    line-height: 1.4;
}

/* Label khusus zona unggah: selalu terbaca di atas kotak */
.form-label--upload {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.55rem;
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.4rem;
}

.form-label--upload .label-tag {
    flex-shrink: 0;
}

.label-tag {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    line-height: 1.2;
}

.label-tag--required {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.label-tag--optional {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.form-hint--upload {
    font-size: 0.8125rem;
    color: #64748b;
    margin: 0 0 0.55rem;
    line-height: 1.45;
}

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

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    background: white;
    transition: all 200ms ease-out;
    font-family: inherit;
    min-height: 44px;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 166, 81, 0.1);
}

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

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23334155' d='M1 4l5 4 5-4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

/* Radio & Checkbox */
.form-radio-group,
.form-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-radio-item,
.form-checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.75rem;
    border-radius: var(--radius);
    transition: background 200ms ease-out;
}

.form-radio-item:hover,
.form-checkbox-item:hover {
    background: var(--color-bg);
}

.form-radio-item input,
.form-checkbox-item input {
    cursor: pointer;
    width: 20px;
    height: 20px;
    min-width: 20px;
    accent-color: var(--color-primary);
}

/* Persetujuan akhir (lamaran): label + checkbox satu baris, mudah di tap */
.form-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--color-text);
    margin: 0;
}

.form-checkbox-label input[type="checkbox"] {
    margin-top: 0.2rem;
    width: 1.15rem;
    height: 1.15rem;
    min-width: 1.15rem;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.consent-group:has(input.error) {
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius);
    border: 1px solid rgba(220, 38, 38, 0.45);
    background: #fef2f2;
}

.form-radio-item label,
.form-checkbox-item label,
.form-radio-item > span,
.form-checkbox-item > span {
    cursor: pointer;
    flex: 1;
    margin: 0;
}

/* Error message */
.form-error {
    display: none;
    font-size: 0.75rem;
    color: var(--color-error);
    margin-top: 0.25rem;
}

.form-error.show {
    display: block;
}

/* Pesan blok (validasi / server) di atas isian tiap langkah */
.wizard-alert {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    white-space: pre-line;
    font-size: 0.95rem;
    line-height: 1.45;
}

/* Proses kirim / unggah: info (bukan error) */
.wizard-progress-submit {
    background: #e0f2fe;
    border: 1px solid #38bdf8;
    color: #0c4a6e;
    padding: 1rem 1.05rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    white-space: pre-line;
    font-size: 0.92rem;
    line-height: 1.5;
    font-weight: 500;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

/* Character counter */
.char-counter {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.5rem;
}

.char-count {
    font-weight: 600;
}

/* File upload */
.file-upload-zone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 200ms ease-out;
    background: var(--color-bg);
}

.file-upload-zone:hover {
    border-color: var(--color-primary);
    background: rgba(0, 166, 81, 0.05);
}

.file-upload-zone.dragover {
    border-color: var(--color-primary);
    background: rgba(0, 166, 81, 0.1);
}

.file-upload-input {
    display: none;
}

.file-upload-icon {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #64748b;
    margin-bottom: 0.35rem;
}

.file-upload-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: #475569;
    margin-bottom: 0.15rem;
}

.file-upload-hint {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.file-preview {
    margin-top: 1rem;
    padding: 1rem;
    background: #dcfce7;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.file-preview-icon {
    font-size: 1.5rem;
    color: var(--color-success);
}

.file-preview-info {
    flex: 1;
}

.file-preview-name {
    font-size: 0.875rem;
    font-weight: 500;
    word-break: break-word;
}

.file-preview-size {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* Footer: tetap di bawah area scroll; latar + safe area agar tombol tidak tertutup */
.wizard-footer {
    flex-shrink: 0;
    box-sizing: border-box;
    padding: 1rem;
    padding-bottom: calc(1rem + var(--wizard-safe-bottom));
    border-top: 1px solid var(--color-border);
    background: #ffffff;
    position: relative;
    z-index: 3;
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
}

.wizard-footer .btn {
    position: relative;
    z-index: 1;
}

.wizard-footer-inner {
    max-width: 500px;
    margin: 0 auto;
    display: flex;
    gap: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 200ms ease-out;
    text-decoration: none;
    min-height: 44px;
    font-family: inherit;
    flex: 1;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 166, 81, 0.3);
}

.btn-secondary {
    background: var(--color-border);
    color: var(--color-text);
}

.btn-secondary:hover:not(:disabled) {
    background: #cbd5e1;
}

.btn-ghost {
    background: #fff;
    color: var(--color-text);
    border: 2px solid var(--color-border);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--color-bg);
}

/* Review summary */
.summary-item {
    padding: 1rem;
    background: var(--color-bg);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    border-left: 3px solid var(--color-primary);
}

.summary-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.summary-value {
    font-size: 0.875rem;
    color: var(--color-text);
    word-break: break-word;
}

/* Responsive */
@media (max-width: 480px) {
    h2.step-title {
        font-size: 1.4rem;
    }

    .wizard-footer-inner {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}
