/**********************************************************************************
 *                       AR AFFAIRES — COMPOSANTS
 *
 *  Règle : toute zone touchable fait au moins 56 px de haut, et les actions
 *  principales vivent en bas de l'écran, dans la zone du pouce.
 **********************************************************************************/


/**********************************************************************************
 *                                  BOUTONS
 **********************************************************************************/

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: var(--touche);
    padding: 0 22px;
    border-radius: var(--r-m);
    font-size: 17px;
    font-weight: 600;
    transition: transform .12s ease, background-color .15s ease, opacity .15s ease;
    user-select: none;
}

.btn:active { transform: scale(.97); }

.btn[disabled] {
    opacity: .5;
    pointer-events: none;
}

.btn-plein {
    background: var(--terracotta);
    color: #FFF;
    box-shadow: var(--ombre-s);
}

.btn-plein:hover { background: var(--terracotta-fonce); }

.btn-contour {
    background: var(--surface);
    color: var(--texte);
    border: 1.5px solid var(--bordure);
}

.btn-fantome {
    background: transparent;
    color: var(--texte-doux);
}

.btn-bloc {
    display: flex;
    width: 100%;
}

/* Bouton rond à grosse icône : appeler, écrire, itinéraire */
.btn-rond {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    min-width: 68px;
    color: var(--texte-doux);
    font-size: 12px;
    font-weight: 600;
}

.btn-rond .pastille {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    border-radius: var(--r-rond);
    background: var(--terracotta-clair);
    color: var(--terracotta);
    transition: transform .12s ease;
}

.btn-rond:active .pastille { transform: scale(.92); }


/**********************************************************************************
 *                                  CHAMPS
 **********************************************************************************/

.champ { margin-bottom: 16px; }

.champ label {
    display: block;
    margin-bottom: 7px;
    font-size: 14px;
    font-weight: 600;
    color: var(--texte-doux);
}

.champ input,
.champ select,
.champ textarea {
    width: 100%;
    min-height: var(--touche);
    padding: 14px 16px;
    border: 1.5px solid var(--bordure);
    border-radius: var(--r-m);
    background: var(--surface);
    font-size: 16px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.champ input:focus,
.champ select:focus,
.champ textarea:focus {
    outline: none;
    border-color: var(--terracotta);
    box-shadow: 0 0 0 4px var(--terracotta-clair);
}

.champ textarea {
    min-height: 110px;
    resize: vertical;
}


/**********************************************************************************
 *                                  CARTES
 **********************************************************************************/

.carte {
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--r-l);
    padding: 20px;
    box-shadow: var(--ombre-s);
}

/* Carte d'affaire : bandeau de couleur à gauche = statut, lisible d'un coup d'œil */
.carte-affaire {
    position: relative;
    display: block;
    width: 100%;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--r-m);
    padding: 16px 16px 16px 22px;
    margin-bottom: 10px;
    overflow: hidden;
    transition: transform .12s ease;
}

.carte-affaire:active { transform: scale(.99); }

.carte-affaire::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 6px;
    background: var(--st-nouvelle);
}

.carte-affaire[data-statut="contactee"]::before     { background: var(--st-contactee); }
.carte-affaire[data-statut="rdv"]::before           { background: var(--st-rdv); }
.carte-affaire[data-statut="devis_en_cours"]::before{ background: var(--st-devis); }
.carte-affaire[data-statut="devis_envoye"]::before  { background: var(--st-envoye); }
.carte-affaire[data-statut="gagnee"]::before        { background: var(--st-gagnee); }
.carte-affaire[data-statut="perdue"]::before        { background: var(--st-perdue); }


/**********************************************************************************
 *                          TUILES DE FILTRE (grosses icônes)
 **********************************************************************************/

.tuiles {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 22px;
}

@media (max-width: 380px) {
    .tuiles { grid-template-columns: repeat(2, 1fr); }
}

.tuile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 8px 13px;
    background: var(--surface);
    border: 1.5px solid var(--bordure);
    border-radius: var(--r-m);
    transition: transform .12s ease, border-color .15s ease;
}

.tuile:active { transform: scale(.96); }

.tuile[aria-pressed="true"] {
    border-color: var(--terracotta);
    background: var(--terracotta-clair);
}

.tuile .icone { color: var(--ardoise); }

.tuile[aria-pressed="true"] .icone { color: var(--terracotta); }

.tuile .compteur {
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
}

.tuile .libelle {
    font-size: 12px;
    font-weight: 600;
    color: var(--texte-doux);
    text-align: center;
}


/**********************************************************************************
 *                                  BADGES
 **********************************************************************************/

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    border-radius: var(--r-rond);
    font-size: 12px;
    font-weight: 700;
    background: var(--surface-douce);
    color: var(--texte-doux);
}

.badge::before {
    content: '';
    width: 7px; height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.badge[data-statut="nouvelle"]      { color: var(--st-nouvelle); }
.badge[data-statut="contactee"]     { color: var(--st-contactee); }
.badge[data-statut="rdv"]           { color: var(--st-rdv); }
.badge[data-statut="devis_en_cours"]{ color: var(--st-devis); }
.badge[data-statut="devis_envoye"]  { color: var(--st-envoye); }
.badge[data-statut="gagnee"]        { color: var(--st-gagnee); }
.badge[data-statut="perdue"]        { color: var(--st-perdue); }


/**********************************************************************************
 *                                  EN-TÊTE
 **********************************************************************************/

.entete {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--bordure);
}

.entete .marque {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -.02em;
    flex: 1;
}

.entete .marque span { color: var(--terracotta); }

.entete-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px; height: 44px;
    border-radius: var(--r-rond);
    color: var(--ardoise);
}

.entete-action:active { background: var(--surface-douce); }

/* Pastille de compteur sur une icône d'en-tête (boîte de réception, cloche) */
.entete-action { position: relative; }

.entete-action .pastille-compteur {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    border-radius: var(--r-rond);
    background: var(--terracotta);
    color: #FFF;
    font-size: 11px;
    font-weight: 800;
    line-height: 19px;
    text-align: center;
    /* Léger contour de la couleur du fond : la pastille se détache de l'icône */
    box-shadow: 0 0 0 2px var(--surface);
}


/**********************************************************************************
 *                          BARRE DE NAVIGATION BASSE
 **********************************************************************************/

.nav-bas {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--bordure);
}

.nav-bas button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: var(--bas);
    color: var(--texte-faible);
    font-size: 11px;
    font-weight: 600;
}

.nav-bas button[aria-current="page"] { color: var(--terracotta); }


/**********************************************************************************
 *                            MESSAGES ET ÉTATS
 **********************************************************************************/

.message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
    border-radius: var(--r-m);
    font-size: 15px;
    margin-bottom: 16px;
}

.message-erreur {
    background: var(--erreur-fond);
    color: var(--erreur);
    font-weight: 600;
}

.vide {
    text-align: center;
    padding: 48px 24px;
    color: var(--texte-doux);
}

.vide .icone {
    color: var(--texte-faible);
    margin: 0 auto 16px;
    opacity: .5;
}

/* Chargement : trois points, sans image ni bibliothèque */
.chargement {
    display: inline-flex;
    gap: 5px;
    align-items: center;
}

.chargement i {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: rebond 1.2s infinite ease-in-out;
}

.chargement i:nth-child(2) { animation-delay: .15s; }
.chargement i:nth-child(3) { animation-delay: .3s; }

@keyframes rebond {
    0%, 60%, 100% { opacity: .25; transform: translateY(0); }
    30%           { opacity: 1;   transform: translateY(-5px); }
}


/**********************************************************************************
 *                                  CONNEXION
 **********************************************************************************/

.connexion {
    width: 100%;
    max-width: 400px;
}

.connexion .logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 34px;
    text-align: center;
}

/**
 * Logo Artisans Réno.
 *
 * Affiché à sa taille native (185 px) : c'est un PNG basse définition, tout
 * agrandissement le rendrait flou.
 */
.logo-marque {
    display: block;
    width: 185px;
    height: auto;
    max-width: 70%;
}

/**
 * Mode sombre : le texte « Artisans Reno » du logo est gris ardoise sur fond
 * transparent — il disparaîtrait purement et simplement sur fond sombre.
 *
 * invert + hue-rotate(180°) éclaircit le texte tout en ramenant le toit à son
 * rouge d'origine : l'inversion le fait passer au cyan, la rotation de teinte
 * le renvoie dans les rouges. Le résultat reste fidèle sans exiger un second
 * fichier à maintenir.
 */
@media (prefers-color-scheme: dark) {
    .logo-marque {
        filter: invert(1) hue-rotate(180deg);
    }
}

.connexion .logo .nom {
    font-size: 27px;
    font-weight: 800;
    letter-spacing: -.03em;
}

.connexion .logo .nom span { color: var(--terracotta); }

.connexion .logo .accroche {
    font-size: 14px;
    color: var(--texte-doux);
}

.connexion .carte { padding: 24px; }

.connexion .pied {
    margin-top: 22px;
    text-align: center;
    font-size: 13px;
    color: var(--texte-faible);
}
