/* =========================================================================
   BHP Tests - style frontu (nowoczesny slider z jednym pytaniem na ekran)
   ========================================================================= */

/* Zmienne */
.bhp-test-wrapper {
    --bhp-accent: #4f46e5;
    --bhp-accent-dark: #4338ca;
    --bhp-accent-light: #eef2ff;
    --bhp-text: #111827;
    --bhp-text-muted: #6b7280;
    --bhp-border: #e5e7eb;
    --bhp-border-strong: #d1d5db;
    --bhp-bg: #ffffff;
    --bhp-bg-alt: #f9fafb;
    --bhp-success: #059669;
    --bhp-success-bg: #ecfdf5;
    --bhp-danger: #dc2626;
    --bhp-danger-bg: #fef2f2;
    --bhp-radius: 14px;
    --bhp-radius-sm: 10px;
    --bhp-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
    --bhp-shadow-lg: 0 4px 6px rgba(15, 23, 42, 0.04), 0 20px 40px rgba(15, 23, 42, 0.12);

    max-width: 780px;
    margin: 32px auto;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--bhp-text);
    line-height: 1.55;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Neutralizacja stylów motywu (uppercase, kursywa, dziwne kolory, oraz -
   co najważniejsze - czcionka: część motywów WordPress narzuca własną
   czcionkę globalnie przez !important, np. przez ustawienia typografii
   w konfiguratorze. Bez !important nasza czcionka by przegrywała.) */
.bhp-test-wrapper,
.bhp-test-wrapper * {
    text-transform: none !important;
    font-style: normal;
    letter-spacing: normal;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif !important;
}

/* Ekrany (start / quiz) */
.bhp-screen {
    display: none;
    animation: bhpFadeIn 0.35s ease;
}
.bhp-screen.is-active { display: block; }

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

/* ============ EKRAN STARTOWY ============ */

.bhp-start-card {
    background: var(--bhp-bg);
    border: 1px solid var(--bhp-border);
    border-radius: var(--bhp-radius);
    padding: 40px;
    box-shadow: var(--bhp-shadow);
}

.bhp-start-badge {
    display: inline-block;
    background: var(--bhp-accent-light);
    color: var(--bhp-accent);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 16px;
}

.bhp-start-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--bhp-text);
    margin: 0 0 24px;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.bhp-start-meta {
    display: flex;
    gap: 32px;
    padding: 20px 0;
    margin-bottom: 20px;
    border-top: 1px solid var(--bhp-border);
    border-bottom: 1px solid var(--bhp-border);
}

.bhp-meta-item {
    display: flex;
    flex-direction: column;
}

.bhp-meta-num {
    font-size: 24px;
    font-weight: 700;
    color: var(--bhp-text);
    line-height: 1;
}

.bhp-meta-label {
    font-size: 13px;
    color: var(--bhp-text-muted);
    margin-top: 4px;
}

.bhp-start-desc {
    color: var(--bhp-text-muted);
    margin: 0 0 28px;
    font-size: 15px;
}

.bhp-test-personal { margin-bottom: 28px; }

.bhp-field-notice {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0 0 20px;
    padding: 12px 14px;
    background: var(--bhp-accent-light);
    border-left: 3px solid var(--bhp-accent);
    border-radius: 0 var(--bhp-radius-sm) var(--bhp-radius-sm) 0;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--bhp-accent-dark);
    font-weight: 500;
}

.bhp-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.bhp-field { margin-bottom: 18px; }

.bhp-field label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--bhp-text);
    margin-bottom: 8px;
}

.bhp-field .req { color: var(--bhp-danger); margin-left: 2px; }

.bhp-field input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--bhp-border-strong);
    border-radius: var(--bhp-radius-sm);
    font-size: 16px;
    font-family: inherit;
    color: var(--bhp-text);
    background: var(--bhp-bg);
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.bhp-field input:focus {
    outline: none;
    border-color: var(--bhp-accent);
    box-shadow: 0 0 0 4px var(--bhp-accent-light);
}

.bhp-field input.bhp-input-error {
    border-color: var(--bhp-danger);
    background: var(--bhp-danger-bg);
}

/* ============ EKRAN QUIZ ============ */

.bhp-screen-quiz {
    background: var(--bhp-bg);
    border: 1px solid var(--bhp-border);
    border-radius: var(--bhp-radius);
    box-shadow: var(--bhp-shadow);
    overflow: hidden;
}

/* Pasek postępu */
.bhp-quiz-header {
    padding: 20px 32px 0;
}

.bhp-progress {
    display: flex;
    align-items: center;
    gap: 14px;
}

.bhp-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--bhp-border);
    border-radius: 999px;
    overflow: hidden;
}

.bhp-progress-fill {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--bhp-accent) 0%, #6366f1 100%);
    border-radius: 999px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.bhp-progress-text {
    font-size: 13px;
    color: var(--bhp-text-muted);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.bhp-progress-text .bhp-current { color: var(--bhp-accent); }

/* Slider */
.bhp-slider {
    overflow: hidden;
    padding: 0;
}

.bhp-slider-track {
    display: flex;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.bhp-slide {
    flex: 0 0 100%;
    min-width: 0;
    padding: 32px;
    box-sizing: border-box;
}

.bhp-slide-inner {
    max-width: 640px;
    margin: 0 auto;
}

.bhp-question-tag {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    color: var(--bhp-accent);
    background: var(--bhp-accent-light);
    padding: 5px 10px;
    border-radius: 6px;
    margin-bottom: 18px;
}

.bhp-question-text {
    font-size: 22px;
    font-weight: 600;
    color: var(--bhp-text);
    margin: 0 0 24px;
    line-height: 1.4;
    letter-spacing: -0.005em;
}

/* Odpowiedzi jako karty */
.bhp-answers {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.bhp-answer {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px;
    background: var(--bhp-bg);
    border: 1.5px solid var(--bhp-border);
    border-radius: var(--bhp-radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.bhp-answer:hover {
    border-color: var(--bhp-accent);
    background: var(--bhp-accent-light);
}

/* Ukryj natywny radio */
.bhp-answer input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Marker (nasz customowy radio) */
.bhp-answer-marker {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    border: 2px solid var(--bhp-border-strong);
    border-radius: 50%;
    background: var(--bhp-bg);
    position: relative;
    margin-top: 1px;
    transition: all 0.15s ease;
}

.bhp-answer-marker::after {
    content: '';
    position: absolute;
    inset: 4px;
    background: var(--bhp-accent);
    border-radius: 50%;
    opacity: 0;
    transform: scale(0.4);
    transition: all 0.15s ease;
}

.bhp-answer input[type="radio"]:checked + .bhp-answer-marker {
    border-color: var(--bhp-accent);
}
.bhp-answer input[type="radio"]:checked + .bhp-answer-marker::after {
    opacity: 1;
    transform: scale(1);
}

/* Nowoczesne przeglądarki: :has() */
.bhp-answer:has(input:checked),
/* Fallback: klasa dodawana przez JS */
.bhp-answer.is-selected {
    border-color: var(--bhp-accent);
    background: var(--bhp-accent-light);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.bhp-answer input[type="radio"]:focus-visible + .bhp-answer-marker {
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2);
}

.bhp-answer-text {
    flex: 1;
    font-size: 15px;
    line-height: 1.5;
    color: var(--bhp-text);
    /* Wymuś zachowanie oryginalnej pisowni z panelu admina */
    text-transform: none !important;
}

/* Sygnalizacja braku odpowiedzi na pytaniu */
.bhp-slide.bhp-question-error .bhp-question-text {
    color: var(--bhp-danger);
}
.bhp-slide.bhp-question-error .bhp-answer {
    border-color: rgba(220, 38, 38, 0.3);
}

/* Nawigacja quizu */
.bhp-quiz-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 32px 28px;
    border-top: 1px solid var(--bhp-border);
    background: var(--bhp-bg-alt);
    gap: 12px;
}

.bhp-quiz-nav .bhp-btn:only-child { margin-left: auto; }
.bhp-nav-next, .bhp-nav-finish { margin-left: auto; }

.bhp-quiz-message {
    margin: 0 32px 20px;
    padding: 12px 16px;
    border-radius: var(--bhp-radius-sm);
    font-size: 14px;
    font-weight: 500;
}

.bhp-msg-error {
    background: var(--bhp-danger-bg);
    border-left: 3px solid var(--bhp-danger);
    color: #991b1b;
}

.bhp-msg-success {
    background: var(--bhp-success-bg);
    border-left: 3px solid var(--bhp-success);
    color: #065f46;
}

.bhp-screen-start .bhp-test-message {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--bhp-radius-sm);
    font-size: 14px;
    font-weight: 500;
}

/* ============ PRZYCISKI ============ */

.bhp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--bhp-radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1;
}

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

.bhp-btn-primary {
    background: var(--bhp-accent);
    color: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}
.bhp-btn-primary:hover:not(:disabled) {
    background: var(--bhp-accent-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.bhp-btn-success {
    background: var(--bhp-success);
    color: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}
.bhp-btn-success:hover:not(:disabled) {
    background: #047857;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

.bhp-btn-ghost {
    background: transparent;
    color: var(--bhp-text);
    border: 1.5px solid var(--bhp-border-strong);
}
.bhp-btn-ghost:hover:not(:disabled) {
    background: var(--bhp-bg-alt);
    border-color: var(--bhp-text-muted);
}

.bhp-start-btn { width: 100%; padding: 14px 24px; font-size: 16px; }

.bhp-btn-arrow { font-size: 16px; line-height: 1; display: inline-block; }

/* ============ STRONA WYNIKU (po zakończeniu testu) ============
   Świadomie inny styl niż reszta testu: formalny dokument/protokół
   (cienkie linie, brak zaokrągleń i cieni) zamiast karty z gradientem -
   lepiej pasuje do wydruku i do kontekstu (wynik szkolenia BHP). */

.bhp-result-page-wrapper {
    background: #fff;
    border: 1px solid #000;
    padding: 0;
}

.bhp-result-printable {
    padding: 36px 40px 28px;
}

.bhp-doc-header {
    border-bottom: 2px solid #000;
    padding-bottom: 14px;
    margin-bottom: 20px;
}

.bhp-doc-kicker {
    margin: 0 0 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase !important;
    letter-spacing: 1px;
    color: #555;
}

.bhp-doc-title {
    margin: 0;
    font-size: 21px;
    font-weight: 700;
    color: #000;
    line-height: 1.3;
}

.bhp-doc-muted { color: #666; font-weight: 400; }

/* Tabela danych - linie zamiast kart */
.bhp-result-info {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 8px;
}

.bhp-result-info th,
.bhp-result-info td {
    text-align: left;
    padding: 7px 10px;
    border-bottom: 1px solid #ddd;
    font-size: 14px;
    vertical-align: top;
}

.bhp-result-info th {
    width: 190px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.bhp-result-info tr:last-child th,
.bhp-result-info tr:last-child td {
    border-bottom: 1px solid #000;
}

.bhp-doc-status {
    font-weight: 800;
    letter-spacing: 0.5px;
    padding: 1px 8px;
    border: 1.5px solid currentColor;
}

.bhp-doc-status.is-pass { color: #0a5c36; }
.bhp-doc-status.is-fail { color: #a11414; }

/* Przegląd odpowiedzi - maksymalnie zwarty układ */
.bhp-result-review {
    margin-top: 22px;
}

.bhp-review-heading {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase !important;
    letter-spacing: 0.5px;
    color: #333;
    border-bottom: 1px solid #000;
    padding-bottom: 4px;
}

.bhp-review-q {
    margin-bottom: 9px;
    padding-bottom: 7px;
    border-bottom: 1px solid #eee;
}

.bhp-review-question {
    font-weight: 600;
    margin: 0 0 2px;
    font-size: 13px;
    line-height: 1.35;
    color: #111;
}

.bhp-review-a {
    margin: 0;
    padding-left: 14px;
    font-size: 12.5px;
    line-height: 1.35;
    color: #444;
}

.bhp-review-a.is-correct-a {
    color: #0a5c36;
    font-weight: 600;
}

.bhp-review-a.is-given-wrong {
    color: #a11414;
    text-decoration: line-through;
}

.bhp-review-a em {
    font-style: normal;
    font-size: 11px;
    color: #777;
}
.bhp-review-a.is-correct-a em,
.bhp-review-a.is-given-wrong em { color: inherit; opacity: 0.75; }

/* Przyciski akcji na stronie wyniku */
.bhp-result-actions {
    margin: 0;
    padding: 18px 40px 24px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    border-top: 1px solid #ddd;
}

.bhp-print-btn,
.bhp-retry-btn,
.bhp-toggle-answers-btn {
    display: inline-flex;
    align-items: center;
    border: none;
    padding: 11px 22px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--bhp-radius-sm);
    cursor: pointer;
    text-decoration: none !important;
    transition: all 0.15s ease;
}

.bhp-print-btn {
    background: var(--bhp-text) !important;
    color: #fff !important;
}
.bhp-print-btn:hover { background: #000 !important; }

/* .bhp-retry-btn jest linkiem <a> (pełna nawigacja, nie JS) - kolor i
   podkreślenie linku narzucane przez motyw WordPressa (często z własnym
   !important w konfiguratorach typografii) potrafią przebić zwykłą regułę
   wtyczki, dlatego kluczowe właściwości wizualne mają tu !important. */
.bhp-retry-btn {
    background: var(--bhp-accent) !important;
    color: #fff !important;
}
.bhp-retry-btn:hover { background: var(--bhp-accent-dark) !important; color: #fff !important; }

.bhp-toggle-answers-btn {
    background: #fff !important;
    color: var(--bhp-text) !important;
    border: 1.5px solid #ccc !important;
}
.bhp-toggle-answers-btn:hover { border-color: var(--bhp-text) !important; }

/* ============ RESPONSYWNOŚĆ ============ */

@media (max-width: 640px) {
    .bhp-test-wrapper { margin: 16px auto; font-size: 15px; }
    .bhp-start-card { padding: 28px 20px; }
    .bhp-start-title { font-size: 22px; }
    .bhp-start-meta { gap: 20px; }
    .bhp-field-row { grid-template-columns: 1fr; gap: 0; }
    .bhp-quiz-header { padding: 16px 20px 0; }
    .bhp-slide { padding: 24px 20px; }
    .bhp-quiz-nav { padding: 16px 20px 20px; }
    .bhp-question-text { font-size: 18px; }
    .bhp-quiz-message { margin: 0 20px 16px; }
    .bhp-result-printable { padding: 24px 20px 18px; }
    .bhp-result-info th { width: auto; }
    .bhp-result-actions { padding: 16px 20px 20px; }
    .bhp-btn { padding: 11px 16px; font-size: 14px; }
    .bhp-nav-prev { padding: 11px 14px; }
}

/* ============ DRUK KOMUNIKATU Z WYNIKIEM ============
   Cel: zmieścić cały wynik (nawet z przeglądem 20-30 pytań) na jak
   najmniejszej liczbie stron - stąd drastycznie mniejsze czcionki,
   marginesy i odstępy niż na ekranie. */

@media print {
    @page {
        margin: 12mm 14mm;
    }

    body:has(.bhp-printing) *,
    body.bhp-print-active * {
        visibility: hidden;
    }
    .bhp-printing .bhp-result-printable,
    .bhp-printing .bhp-result-printable * {
        visibility: visible;
    }
    .bhp-printing .bhp-result-page-wrapper {
        border: none !important;
    }
    .bhp-printing .bhp-result-printable {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 0 !important;
        font-size: 11.5px !important;
        line-height: 1.3 !important;
        color: #000 !important;
    }
    body.bhp-print-active {
        overflow: visible !important;
        height: auto !important;
    }

    .bhp-doc-header { margin-bottom: 10px !important; padding-bottom: 7px !important; }
    .bhp-doc-title { font-size: 15px !important; }
    .bhp-doc-kicker { font-size: 9px !important; }

    .bhp-result-info th,
    .bhp-result-info td {
        padding: 3px 7px !important;
        font-size: 11px !important;
    }
    .bhp-result-info th { width: 150px !important; }
    .bhp-result-info { margin-bottom: 6px !important; }

    .bhp-doc-status { padding: 0 5px !important; border-width: 1px !important; }

    .bhp-result-review { margin-top: 10px !important; }
    .bhp-review-heading {
        font-size: 10px !important;
        margin: 0 0 5px !important;
        padding-bottom: 3px !important;
    }
    .bhp-review-q {
        margin-bottom: 5px !important;
        padding-bottom: 3px !important;
        break-inside: avoid;
    }
    .bhp-review-question { font-size: 10.5px !important; margin: 0 0 1px !important; }
    .bhp-review-a {
        font-size: 10px !important;
        line-height: 1.3 !important;
        padding-left: 11px !important;
    }
    .bhp-review-a em { font-size: 8.5px !important; }

    .no-print { display: none !important; }
}

