/* Site des proches de la visio Facilotab (Mantis 42504) : grands caracteres, grands boutons, contrastes forts. */

:root {
    --rouge: #DC5C5C;
    --rouge-fonce: #B03A3A;
    --texte: #1F2328;
    --texte-doux: #57606A;
    --fond: #FFFFFF;
    --fond-doux: #F6F3F1;
    --bord: #D0D7DE;
    --succes-fond: #E6F4EA;
    --succes-texte: #1E5E2F;
    --info-fond: #EAF2FB;
    --info-texte: #1D4F86;
    --erreur-fond: #FDECEC;
    --erreur-texte: #A12B2B;
    --focus: #1D4F86;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --rouge: #E9787A;
        --rouge-fonce: #F19C9D;
        --texte: #E6EDF3;
        --texte-doux: #A9B4BF;
        --fond: #15181C;
        --fond-doux: #1E2227;
        --bord: #3A424B;
        --succes-fond: #173823;
        --succes-texte: #9BD9AE;
        --info-fond: #172C44;
        --info-texte: #A6C8F0;
        --erreur-fond: #3E1C1C;
        --erreur-texte: #F3A9A9;
        --focus: #A6C8F0;
    }
}

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

html {
    -webkit-text-size-adjust: 100%;
}

/* hidden doit l'emporter sur les display des classes (.bouton, .menu) */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--fond-doux);
    color: var(--texte);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 1.125rem;
    line-height: 1.5;
}

a {
    color: var(--rouge-fonce);
}

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.entete {
    background: var(--fond);
    border-bottom: 1px solid var(--bord);
    padding: 12px max(16px, env(safe-area-inset-left));
}

.marque {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--texte);
    text-decoration: none;
    font-size: 1.25rem;
}

.marque strong {
    color: var(--rouge);
}

.bandeau-dev {
    margin: 0;
    padding: 6px 16px;
    background: #FFE08A;
    color: #3D2E00;
    font-weight: 600;
    text-align: center;
}

.page {
    flex: 1;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: 24px 16px 40px;
}

h1 {
    font-size: 1.75rem;
    line-height: 1.25;
    margin: 0 0 16px;
}

h1:focus {
    outline: none;
}

h2 {
    font-size: 1.3rem;
    margin: 24px 0 12px;
}

.intro {
    font-size: 1.25rem;
}

.note {
    color: var(--texte-doux);
    font-size: 1rem;
}

.chargement {
    color: var(--texte-doux);
}

/* Formulaires */

form {
    background: var(--fond);
    border: 1px solid var(--bord);
    border-radius: 12px;
    padding: 20px 16px;
    margin: 16px 0;
}

.champ {
    margin-bottom: 18px;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

input {
    width: 100%;
    min-height: 52px;
    padding: 10px 14px;
    font: inherit;
    color: var(--texte);
    background: var(--fond);
    border: 2px solid var(--bord);
    border-radius: 10px;
}

input:focus {
    border-color: var(--focus);
}

input[name="code"] {
    font-size: 1.6rem;
    letter-spacing: 0.3em;
    text-align: center;
    max-width: 14rem;
}

.aide {
    margin: 6px 0 0;
    font-size: 0.95rem;
    color: var(--texte-doux);
}

.mot-de-passe {
    display: flex;
    gap: 8px;
}

.bouton-afficher {
    flex: none;
    min-width: 6.5rem;
    padding: 0 12px;
    font: inherit;
    font-size: 1rem;
    color: var(--texte);
    background: var(--fond-doux);
    border: 2px solid var(--bord);
    border-radius: 10px;
    cursor: pointer;
}

.erreur {
    color: var(--erreur-texte);
    font-weight: 600;
    margin: 0 0 12px;
}

.erreur:empty {
    display: none;
}

/* Boutons */

.bouton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 56px;
    padding: 10px 20px;
    font: inherit;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    color: var(--rouge-fonce);
    background: var(--fond);
    border: 2px solid var(--rouge);
    border-radius: 12px;
    cursor: pointer;
}

.bouton-principal {
    color: #FFFFFF;
    background: var(--rouge-fonce);
    border-color: var(--rouge-fonce);
}

@media (prefers-color-scheme: dark) {
    .bouton-principal {
        color: #15181C;
        background: var(--rouge);
        border-color: var(--rouge);
    }
}

.bouton:disabled {
    opacity: 0.6;
    cursor: wait;
}

.actions {
    display: grid;
    gap: 12px;
    margin: 20px 0;
}

.liens {
    margin: 10px 0;
}

.lien {
    padding: 0;
    font: inherit;
    color: var(--rouge-fonce);
    background: none;
    border: none;
    text-decoration: underline;
    cursor: pointer;
}

.lien:disabled {
    color: var(--texte-doux);
    cursor: default;
}

/* Messages */

.annonce {
    padding: 12px 16px;
    border-radius: 10px;
    margin: 0 0 16px;
}

.annonce-succes {
    background: var(--succes-fond);
    color: var(--succes-texte);
}

.annonce-info {
    background: var(--info-fond);
    color: var(--info-texte);
}

.annonce-erreur {
    background: var(--erreur-fond);
    color: var(--erreur-texte);
}

/* Contacts */

.contacts {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--fond);
    border: 1px solid var(--bord);
    border-radius: 12px;
}

.contact {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 72px;
    padding: 10px 16px;
}

.contact + .contact {
    border-top: 1px solid var(--bord);
}

.avatar {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--rouge);
    color: #FFFFFF;
    font-weight: 700;
}

.contact-attente .avatar {
    background: var(--texte-doux);
}

.nom {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.nom small {
    display: block;
    font-weight: 400;
    color: var(--texte-doux);
}

/* sur un petit ecran, les boutons passent sous le nom plutot que de l'ecraser */
.contact {
    flex-wrap: wrap;
}

.contact .nom {
    flex: 1;
    min-width: 9rem;
}

.boutons-contact {
    margin-left: auto;
}

.avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-grand {
    width: 96px;
    height: 96px;
    font-size: 2rem;
}

.boutons-contact {
    flex: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.appel-manque .nom small {
    color: var(--erreur-texte);
    font-weight: 600;
}

/* Variantes de boutons */

.bouton-petit {
    width: auto;
    min-height: 48px;
    padding: 6px 14px;
    font-size: 1rem;
}

.bouton-discret {
    color: var(--texte-doux);
    border-color: var(--bord);
}

.bouton-secondaire {
    color: var(--rouge-fonce);
}

.bouton-danger {
    color: #FFFFFF;
    background: #A12B2B;
    border-color: #A12B2B;
}

@media (prefers-color-scheme: dark) {
    .bouton-danger {
        color: #15181C;
        background: #F3A9A9;
        border-color: #F3A9A9;
    }
}

.lien-danger {
    color: var(--erreur-texte);
}

/* Menu des pages du proche connecte */

.entete {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
}

.menu {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.menu a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 6px 12px;
    border-radius: 10px;
    color: var(--texte);
    font-weight: 600;
    text-decoration: none;
}

.menu a[aria-current="page"] {
    color: var(--rouge-fonce);
    background: var(--fond-doux);
    box-shadow: inset 0 -3px 0 var(--rouge);
}

.pastille {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 6px;
    border-radius: 0.75rem;
    background: var(--rouge-fonce);
    color: #FFFFFF;
    font-size: 0.85rem;
}

@media (max-width: 599px) {
    .menu {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
    }

    .menu a {
        justify-content: center;
        padding: 6px 4px;
        font-size: 0.95rem;
        text-align: center;
    }
}

/* Cartes (Mon compte, Aide) */

.carte {
    background: var(--fond);
    border: 1px solid var(--bord);
    border-radius: 12px;
    padding: 4px 16px 12px;
    margin: 0 0 16px;
}

.carte form {
    border: none;
    padding: 0;
    margin: 8px 0;
}

.carte h2 {
    margin: 14px 0 10px;
}

details.carte {
    padding: 12px 16px;
}

details.carte summary {
    font-weight: 600;
    cursor: pointer;
    min-height: 32px;
}

.photo-compte {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.boutons-photo {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.liste {
    padding-left: 1.4em;
}

.liste li + li {
    margin-top: 6px;
}

/* Fenetre de confirmation */

.fenetre {
    width: min(480px, calc(100% - 32px));
    padding: 20px 16px 4px;
    color: var(--texte);
    background: var(--fond);
    border: 1px solid var(--bord);
    border-radius: 14px;
}

.fenetre::backdrop {
    background: rgba(0, 0, 0, 0.5);
}

.fenetre h2 {
    margin-top: 0;
}

.pied {
    padding: 16px;
    text-align: center;
    font-size: 0.95rem;
    color: var(--texte-doux);
}

@media (min-width: 600px) {
    .actions {
        grid-template-columns: 1fr 1fr;
    }

    .actions:has(> :only-child) {
        grid-template-columns: 1fr;
    }
}

/* Ecran d'appel (assets/js/appel.js) : plein ecran sombre, video de l'autre en fond, la sienne en vignette */

body.en-appel {
    overflow: hidden;
}

.ecran-appel {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    background: #101418;
    color: #FFFFFF;
    overflow: hidden;
}

.ecran-appel :focus-visible {
    outline-color: #FFFFFF;
}

.video-distante {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    /* toujours l'image entiere, bandes noires autour si son format differe de l'ecran (tablette en paysage) */
    object-fit: contain;
    background: #000000;
    display: none;
}

.avec-video .video-distante {
    display: block;
}

.appel-identite {
    position: relative;
    z-index: 1;
    margin-top: max(12vh, env(safe-area-inset-top));
    padding: 0 16px;
    text-align: center;
}

.appel-identite h2 {
    margin: 16px 0 4px;
    font-size: 1.8rem;
}

.appel-etat {
    margin: 0;
    font-size: 1.2rem;
    color: #C9D1D9;
}

.avatar-appel {
    width: 140px;
    height: 140px;
    font-size: 3rem;
}

.ecran-appel[data-etat="entrant"] .avatar-appel {
    animation: pulsation 1.6s ease-in-out infinite;
}

@keyframes pulsation {
    50% {
        box-shadow: 0 0 0 18px rgba(220, 92, 92, 0.25);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ecran-appel[data-etat="entrant"] .avatar-appel {
        animation: none;
    }
}

/* en appel avec l'image de l'autre : nom et duree en haut, discrets */
.avec-video .appel-identite {
    margin-top: max(16px, env(safe-area-inset-top));
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.avec-video .avatar-appel {
    display: none;
}

.avec-video .appel-identite h2 {
    font-size: 1.3rem;
    margin-top: 0;
}

/* bas de l'ecran, de haut en bas : ma vignette (a droite), la reglette du volume, les boutons */
.appel-bas {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-top: auto;
    padding-top: 12px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
}

.video-locale {
    align-self: flex-end;
    margin-right: 16px;
    /* image entiere, a la forme de la camera (portrait ou paysage) : on voit comment on est cadre */
    width: auto;
    height: auto;
    max-width: min(30vw, 220px);
    max-height: 28vh;
    background: #000000;
    border: 2px solid rgba(255, 255, 255, 0.7);
    border-radius: 12px;
}

.miroir .video-locale {
    transform: scaleX(-1);
}

.sans-video-locale .video-locale,
.ecran-appel[data-etat="entrant"] .video-locale,
.ecran-appel[data-etat="fin"] .video-locale,
.ecran-appel[data-etat="preparation"] .video-locale {
    display: none;
}

/* apres le nom de l'appele, discret */
.appel-chiffre {
    font-size: 0.6em;
    font-weight: 400;
    white-space: nowrap;
}

.appel-son {
    position: absolute;
    top: 40%;
    z-index: 3;
}

/* reglette du volume de la conversation, entre ma vignette et les boutons */
.appel-volume {
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(380px, calc(100% - 32px));
    padding: 4px 14px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.45);
}

.appel-volume svg {
    display: block;
    fill: #FFFFFF;
}

.volume-petit svg {
    width: 18px;
    height: 18px;
}

.volume-grand svg {
    width: 28px;
    height: 28px;
}

.appel-volume input[type="range"] {
    flex: 1;
    width: auto;
    min-height: 44px;
    padding: 0;
    background: transparent;
    border: none;
    accent-color: #FFFFFF;
    cursor: pointer;
}

/* une seule rangee, qui ne bouge pas quand un libelle change (« Caméra » -> « Caméra coupée ») */
.appel-boutons {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 0 16px max(24px, env(safe-area-inset-bottom));
}

.bouton-appel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 0 1 84px;
    min-width: 68px;
    padding: 0;
    font: inherit;
    font-size: 0.95rem;
    color: #FFFFFF;
    background: none;
    border: none;
    cursor: pointer;
}

.bouton-appel .rond {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
}

/* libelle sur deux lignes au plus, hauteur reservee : les ronds restent alignes */
.bouton-appel .libelle {
    min-height: 2.4em;
    line-height: 1.2;
    text-align: center;
    overflow-wrap: anywhere;
}

.bouton-appel .rond {
    flex: none;
}

.bouton-appel svg {
    width: 32px;
    height: 32px;
    fill: currentColor;
}

.bouton-appel.rouge .rond {
    background: #D93025;
}

.bouton-appel.vert .rond {
    background: #1E8E3E;
}

.ecran-appel[data-etat="entrant"] .bouton-appel .rond {
    width: 84px;
    height: 84px;
}

.ecran-appel[data-etat="entrant"] .appel-boutons {
    gap: 16px 64px;
}

.bouton-appel[aria-pressed="true"] .rond {
    color: #101418;
    background: #FFFFFF;
}

.bouton-appel:disabled {
    opacity: 0.5;
    cursor: default;
}

.bouton-son .rond {
    background: #1D4F86;
}

.bouton-fermer {
    max-width: 320px;
}

/* Test de la camera et du micro */

.ecran-test {
    justify-content: center;
    padding: 16px;
}

.test-contenu {
    width: min(480px, 100%);
    max-height: 100%;
    overflow: auto;
    padding: 20px 16px;
    color: var(--texte);
    background: var(--fond);
    border-radius: 14px;
}

.test-contenu h2 {
    margin-top: 0;
}

.video-test {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    background: #000000;
    border-radius: 10px;
    transform: scaleX(-1);
}

.niveau {
    height: 14px;
    margin-top: 10px;
    overflow: hidden;
    background: var(--fond-doux);
    border: 1px solid var(--bord);
    border-radius: 7px;
}

.niveau span {
    display: block;
    width: 0;
    height: 100%;
    background: #1E8E3E;
    transition: width 0.08s linear;
}

/* Conditions d'utilisation et confidentialite */

.texte-legal p,
.texte-legal li {
    font-size: 1rem;
}

.pied p {
    margin: 4px 0;
}
