/* ==========================================================================
   CONSO — habillage mobile

   Cette feuille est chargée avec media="(max-width: 880px)" (voir
   includes/pwa_head.php) : sur PC, le navigateur ne l'applique jamais.
   Elle s'ajoute à style.css, qui gère déjà la barre de navigation basse.
   ========================================================================== */

html {
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

body {
    /* Zones sûres des téléphones à encoche (utile une fois installée en plein écran) */
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* --- Navigation basse ------------------------------------------------------ */

.sidebar {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    background: var(--bg-panel, #1b1f26);   /* opaque : rien ne doit transparaître */
}

/* Le slogan de la barre latérale n'a pas sa place dans la barre du bas : il
   n'était pas masqué, occupait la gauche et rétrécissait la navigation. */
.sidebar__brand-sub { display: none; }

.nav { flex: 1; min-width: 0; }

.nav__link {
    min-height: 52px;
    justify-content: flex-start;   /* icônes toutes à la même hauteur, même si un libellé passe sur 2 lignes */
    flex: 1 1 0;
    min-width: 0;
    padding: 7px 2px 6px;
    border-radius: 10px;
    text-align: center;
    line-height: 1.15;
    font-size: 10px;
}

.nav__link .icone { width: 22px; height: 22px; }

.main {
    padding: 16px 14px calc(96px + env(safe-area-inset-bottom));
}

/* --- En-tête de page ------------------------------------------------------- */

.topbar {
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
}

.topbar > div:first-child { min-width: 0; flex: 1; }
.topbar__subtitle { font-size: 12.5px; }

.mobile-only {
    display: inline-flex;
    flex-shrink: 0;
}

/* --- Tableau de bord : 2 colonnes de chiffres clés -------------------------- */

.grid { gap: 12px; }
.grid--kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--2, .grid--3 { grid-template-columns: minmax(0, 1fr); }

.kpi { padding: 12px 13px; }
.kpi__label { font-size: 11.5px; margin-bottom: 5px; }
.kpi__value { font-size: 21px; }
.kpi__value small { font-size: 12px; }
.kpi__delta { font-size: 11.5px; }

.panel { padding: 16px 14px; border-radius: 14px; }
.panel + .panel { margin-top: 14px; }

.chart-box { height: 230px; }

.odometre__roue { width: 27px; height: 38px; font-size: 20px; }

/* --- Formulaires : gros champs, pas de zoom automatique sur iPhone ----------- */

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=file], select, textarea {
    font-size: 16px;            /* en dessous, iOS zoome sur le champ */
    min-height: 48px;
    padding: 12px 14px;
}

textarea { min-height: 90px; }

.champ { margin-bottom: 16px; }
.champ label { font-size: 13.5px; }

.btn { min-height: 46px; padding: 11px 18px; font-size: 15px; }
.btn--sm { min-height: 38px; padding: 7px 13px; font-size: 13.5px; }
.btn--block { min-height: 50px; font-size: 16px; }

.checkbox-row { padding: 14px; min-height: 52px; }
.checkbox-row input { width: 22px; height: 22px; min-height: 0; }

.form-actions { flex-wrap: wrap; }

/* --- Tableaux : actions faciles à toucher ----------------------------------- */

th, td { padding-left: 10px; padding-right: 10px; }
.row-actions .btn { min-height: 40px; min-width: 40px; justify-content: center; }
.row-actions .icone { width: 18px; height: 18px; }

/* --- Page de connexion ------------------------------------------------------ */

.ecran-plein { padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.carte-connexion { padding: 30px 22px; }

/* --- Bandeau d'invitation à installer (créé par pwa.js, mobile uniquement) -- */

.pwa-banner {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-left: 3px solid var(--fioul);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    animation: pwa-apparition 0.35s ease;
}

/* Au-dessus de la barre de navigation basse quand elle existe */
.pwa-banner--au-dessus-nav {
    bottom: calc(80px + env(safe-area-inset-bottom));
}

.pwa-banner__texte { margin: 0; font-size: 14px; line-height: 1.45; color: var(--text); }

.pwa-banner__actions { display: flex; gap: 8px; justify-content: flex-end; }

.pwa-banner__btn {
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    min-height: 42px;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
}

.pwa-banner__btn--principal {
    background: var(--fioul);
    border-color: var(--fioul);
    color: #1c1305;
    font-weight: 600;
}

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

@media (prefers-reduced-motion: reduce) {
    .pwa-banner { animation: none; }
}
