/*
 * Tests psychologiques : /psychologue/tests et /psychologue/tests/{slug}.
 * Utilisé par : psy-tests.jsp, psy-test.jsp (avec psy-motifs.css).
 */

/* ---------- Police arabe : Tajawal (police de siladoc.com) ----------
 * Les pages arabes utilisent font-family "tajawal", qui n'était déclaré nulle part
 * (tajawal.css déclare "Tajawal bold/Regular/light" et pointe vers fonts/Tajawal/,
 * alors que le dossier est fonts/tajawal/) : le navigateur prenait une police système.
 * On déclare ici la famille "tajawal" avec ses trois graisses. */
@font-face {
    font-family: "tajawal";
    src: url("../fonts/tajawal/Tajawal-Light.woff2") format("woff2"),
         url("../fonts/tajawal/Tajawal-Light.woff") format("woff");
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "tajawal";
    src: url("../fonts/tajawal/Tajawal-Regular.woff2") format("woff2"),
         url("../fonts/tajawal/Tajawal-Regular.woff") format("woff");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "tajawal";
    src: url("../fonts/tajawal/Tajawal-Bold.woff2") format("woff2"),
         url("../fonts/tajawal/Tajawal-Bold.woff") format("woff");
    font-weight: 600 900;
    font-style: normal;
    font-display: swap;
}

/* Toute la page arabe (titres, cartes, questions, résultat) en Tajawal */
html:lang(ar) body,
html:lang(ar) h1, html:lang(ar) h2, html:lang(ar) h3,
html:lang(ar) h4, html:lang(ar) h5, html:lang(ar) h6,
html:lang(ar) .psy-topic,
html:lang(ar) .psy-motifs {
    font-family: "tajawal", sans-serif;
}

/* ---------- Liste des tests ---------- */
.psy-tests-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.psy-motifs-heading h1 {
    font-size: clamp(1.75rem, 3.2vw, 2.6rem);
    font-weight: 800;
    line-height: 1.3;
    margin-bottom: 16px;
}

.psy-test-card-meta {
    font-size: .88rem;
    font-weight: 700;
    color: #00666a;
    margin: 8px 0 0;
}

/* ---------- En-tête du test ---------- */
.psy-test-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    list-style: none;
    padding: 0;
    margin: 14px 0 0;
    font-weight: 700;
    color: #39425a;
}

.psy-test-facts i {
    color: #008D93;
    margin-inline-end: 4px;
}

/* ---------- Étapes ---------- */
.psy-test-stepper {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 20px;
}

.psy-test-stepper span {
    padding: 6px 14px;
    border-radius: 999px;
    background: #f1f3f7;
    color: #6b7489;
    font-size: .88rem;
    font-weight: 700;
}

.psy-test-stepper span.is-active {
    background: #008D93;
    color: #fff;
}

.psy-test-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 24px;
    max-width: 760px;
}

/* Indépendant de Bootstrap : le rendu ne dépend pas du chargement du CDN */
.psy-test-form .btn-check {
    position: absolute;
    clip: rect(0, 0, 0, 0);
    pointer-events: none;
}

.psy-test-fields .form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
    color: #39425a;
}

.psy-test-fields .form-control {
    display: block;
    width: 100%;
    border: 1px solid #d9dee8;
}

.psy-test-fields fieldset {
    border: 0;
    padding: 0;
    margin: 0;
}

.psy-test-fields .form-control {
    border-radius: 12px;
    padding: 10px 14px;
}

.psy-test-fields .form-control:focus {
    border-color: #008D93;
    box-shadow: 0 0 0 .2rem rgba(0, 141, 147, .18);
}

.psy-test-sex {
    display: flex;
    gap: 10px;
}

.psy-test-sex .psy-test-choice {
    flex: 1;
}

/* Bouton de choix (sexe, réponses) */
.psy-test-choice {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 10px 14px;
    border: 1.5px solid #d9dee8;
    border-radius: 14px;
    background: #fff;
    color: #39425a;
    text-align: center;
    line-height: 1.35;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}

.psy-test-choice:hover {
    border-color: #008D93;
}

.btn-check:checked + .psy-test-choice {
    background: #008D93;
    border-color: #008D93;
    color: #fff;
}

.btn-check:focus-visible + .psy-test-choice {
    outline: 2px solid #00666a;
    outline-offset: 2px;
}

.psy-test-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 28px;
}

.psy-test-actions button {
    border: 0;
    cursor: pointer;
}

.psy-test-actions .psy-btn-outline {
    border: 1.5px solid #008D93;
    background: transparent;
}

.psy-test-error {
    margin: 18px 0 0;
    padding: 12px 16px;
    border-radius: 12px;
    background: #fff4f2;
    color: #a3301b;
    font-weight: 700;
}

.psy-test-privacy {
    margin: 22px 0 0;
    font-size: .92rem !important;
    color: #6b7489 !important;
}

.psy-test-privacy i {
    color: #008D93;
}

/* ---------- Questions ---------- */
.psy-test-patient-banner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    margin-bottom: 22px;
    border-radius: 14px;
    background: #e1f5f0;
    color: #20473f;
}

.psy-test-link {
    border: 0;
    background: none;
    padding: 0;
    color: #00666a;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

.psy-test-instructions {
    border-inline-start: 4px solid #008D93;
    padding-inline-start: 14px;
}

.psy-test-progress {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    background: #fff;
    font-weight: 700;
    color: #39425a;
}

.psy-test-progress-bar {
    flex: 1;
    height: 8px;
    border-radius: 999px;
    background: #eef0f5;
    overflow: hidden;
}

.psy-test-progress-bar span {
    display: block;
    height: 100%;
    width: 0;
    background: #008D93;
    transition: width .2s ease;
}

.psy-test-items {
    list-style: none;
    padding: 0;
    margin: 10px 0 0;
}

.psy-test-item {
    padding: 20px 0;
    border-bottom: 1px solid #eef0f5;
}

.psy-test-item fieldset {
    border: 0;
    margin: 0;
    padding: 0;
}

.psy-test-item legend {
    float: none;
    font-size: 1.06rem;
    font-weight: 700;
    line-height: 1.5;
    color: #202747;
    margin-bottom: 14px;
}

.psy-test-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-inline-end: 8px;
    border-radius: 50%;
    background: #eae7fb;
    color: #3d3378;
    font-size: .9rem;
}

.psy-test-options {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.psy-test-item.is-missing .psy-test-choice {
    border-color: #e8a596;
}

.psy-test-item.is-missing legend::after {
    content: " — réponse manquante";
    color: #a3301b;
    font-size: .9rem;
}

.psy-test-item.is-missing legend:lang(ar)::after {
    content: " — إجابة ناقصة";
}

/* Version arabe : police Tajawal pour les champs et boutons */
[dir="rtl"] .psy-test-form,
[dir="rtl"] .psy-test-form button,
[dir="rtl"] .psy-test-form input,
[dir="rtl"] .psy-test-form select,
[dir="rtl"] .psy-test-form textarea,
html:lang(ar) .btn,
html:lang(ar) button {
    font-family: "tajawal", sans-serif;
}

/* ---------- Résultat ---------- */
.psy-print-header {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 18px;
}

.psy-print-logo {
    display: none;
    height: 34px;
}

.psy-test-patient-table,
.psy-test-answers {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
}

.psy-test-patient-table {
    max-width: 520px;
}

.psy-test-patient-table th,
.psy-test-patient-table td,
.psy-test-answers th,
.psy-test-answers td {
    padding: 8px 10px;
    border-bottom: 1px solid #eef0f5;
    text-align: start;
    vertical-align: top;
}

.psy-test-patient-table th {
    width: 40%;
    color: #6b7489;
    font-weight: 700;
}

.psy-test-answers th {
    background: #f6f7fa;
    color: #39425a;
    font-size: .9rem;
}

.psy-test-answers td:first-child,
.psy-test-answers td:last-child,
.psy-test-answers th:first-child,
.psy-test-answers th:last-child {
    width: 60px;
    text-align: center;
}

.psy-test-score-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
}

.psy-test-score {
    padding: 22px;
    border-radius: 20px;
    border: 1.5px solid;
}

.psy-test-score--ok   { background: #e9f7f1; border-color: #9bd8bf; --psy-level: #1f7a55; }
.psy-test-score--warn { background: #fff5e6; border-color: #f2c98a; --psy-level: #a86100; }
.psy-test-score--high { background: #fff0ed; border-color: #eeaa9b; --psy-level: #a3301b; }

.psy-test-score-name {
    margin: 0;
    font-weight: 700;
    color: #39425a !important;
}

.psy-test-score-value {
    margin: 4px 0 10px;
    color: #6b7489 !important;
}

.psy-test-score-value strong {
    font-size: 2.4rem;
    color: var(--psy-level);
}

.psy-test-gauge {
    height: 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .07);
    overflow: hidden;
}

.psy-test-gauge span {
    display: block;
    height: 100%;
    background: var(--psy-level);
}

.psy-test-score-label {
    margin: 12px 0 0;
    font-weight: 700;
    color: var(--psy-level) !important;
    line-height: 1.5 !important;
}

.psy-test-notes {
    margin: 18px 0 26px;
    padding-inline-start: 20px;
    color: #49536a;
    line-height: 1.7;
}

.psy-test-subtitle {
    font-size: 1.15rem;
    font-weight: 800;
    margin: 6px 0 14px;
}

.psy-test-disclaimer,
.psy-test-source {
    font-size: .92rem !important;
    color: #6b7489 !important;
}

.psy-test-references {
    padding-inline-start: 20px;
    color: #49536a;
    line-height: 1.7;
}

/* ---------- Consentement ---------- */
.psy-test-consent {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 760px;
    margin-top: 24px;
    padding: 16px 18px;
    border-radius: 14px;
    background: #f6f7fa;
    color: #39425a;
    line-height: 1.6;
    font-size: .95rem;
}

.psy-test-consent input {
    flex: none;
    width: 20px;
    height: 20px;
    margin-top: 3px;
    accent-color: #008D93;
}

.psy-test-consent a {
    color: #00666a;
    font-weight: 700;
}

/* ---------- Après le résultat : consulter ---------- */
.psy-test-cta {
    margin-top: 30px;
    padding: 26px;
    border-radius: 20px;
    background: #e1f5f0;
    border: 1.5px solid #9bd8bf;
}

.psy-test-cta--warn { background: #fff5e6; border-color: #f2c98a; }
.psy-test-cta--high { background: #fff0ed; border-color: #eeaa9b; }

.psy-test-cta h3 {
    font-size: 1.3rem;
    font-weight: 800;
    margin: 0 0 10px;
    color: #202747;
}

.psy-test-cta p {
    color: #39425a !important;
}

.psy-test-cta-urgent {
    font-weight: 700;
    color: #a3301b !important;
}

.psy-test-cta-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

.psy-test-cta-actions button {
    cursor: pointer;
    border: 1.5px solid #008D93;
    background: #fff;
}

.psy-test-proposal {
    margin-top: 20px;
    padding: 18px;
    border-radius: 14px;
    background: #fff;
}

.psy-test-whatsapp {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: 12px;
    background: #25D366;
    color: #fff;
    font-weight: 700;
    text-decoration: none;
}

.psy-test-whatsapp:hover,
.psy-test-whatsapp:focus-visible {
    background: #1ebe5a;
    color: #fff;
}

.psy-test-form button:disabled {
    opacity: .65;
    cursor: wait;
}

/* ---------- Responsive ---------- */
@media (max-width: 991px) {
    .psy-test-options {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575px) {
    .psy-test-fields {
        grid-template-columns: 1fr;
    }

    .psy-test-options {
        grid-template-columns: 1fr;
    }

    .psy-test-actions {
        justify-content: stretch;
    }

    .psy-test-actions > * {
        flex: 1 1 100%;
        justify-content: center;
    }
}

/* ---------- Impression : uniquement la fiche résultat ---------- */
@media print {
    @page {
        margin: 14mm;
    }

    body {
        background: #fff !important;
        margin: 0 !important;
    }

    header,
    footer,
    .navbar,
    .custom-navbar,
    .psy-no-print {
        display: none !important;
    }

    main.psy-test,
    .psy-test-step[data-step="result"] {
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 0 !important;
    }

    .psy-print-logo {
        display: block;
    }

    .psy-test-score,
    .psy-test-answers tr {
        break-inside: avoid;
    }

    .psy-test-score,
    .psy-test-gauge,
    .psy-test-gauge span {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .psy-test-answers td,
    .psy-test-answers th {
        padding: 4px 8px;
        font-size: 10.5pt;
    }
}

/* Version arabe : le score « 15 / 21 » reste en LTR mais aligné à droite comme le reste de la carte */
[dir="rtl"] .psy-test-score-value {
    text-align: right;
}

/* Boutons du test : même taille de texte que les liens-boutons */
.psy-test-form button.psy-motifs-cta,
.psy-test-form button.psy-btn-outline {
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
}
