/* ============================================================================
   style.css — thème commun (clair / sombre automatique), mobile + tablette
   ========================================================================== */
:root {
    --bg: #f4f1ec; --surface: #ffffff; --surface-2: #faf8f5;
    --text: #2b2622; --muted: #6b625a; --border: #ddd5cb;
    --accent: #8d5a2b; --accent-soft: rgba(141, 90, 43, .12);
    --ok: #2e8b57; --warn: #d9822b; --err: #c0392b; --info: #2c6fad;
    --radius: 10px;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #141210; --surface: #1f1c19; --surface-2: #26221e;
        --text: #ece6df; --muted: #a79d92; --border: #3a342e;
        --accent: #d49a5f; --accent-soft: rgba(212, 154, 95, .15);
    }
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 16px; }
.wrap { max-width: 760px; margin: 0 auto; background: var(--surface); min-height: 100vh;
    padding: env(safe-area-inset-top) 14px calc(env(safe-area-inset-bottom) + 80px) 14px;
    box-shadow: 0 0 20px rgba(0,0,0,.08); }

/* --- En-tête + navigation basse ---------------------------------------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 14px 0; border-bottom: 2px solid var(--border); }
.top h1 { font-size: 1.25em; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: center;
    background: var(--surface); border-top: 1px solid var(--border); z-index: 20;
    padding-bottom: env(safe-area-inset-bottom); }
.nav a { flex: 1; max-width: 190px; text-align: center; padding: 10px 4px 12px; text-decoration: none;
    color: var(--muted); font-size: .8em; font-weight: 600; }
.nav a span { display: block; font-size: 1.5em; line-height: 1.2; }
.nav a.on { color: var(--accent); }

/* --- Boutons ------------------------------------------------------------ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 14px; border: none; border-radius: 8px; font-weight: 700; font-size: .95em;
    cursor: pointer; text-decoration: none; color: #fff; background: var(--muted); white-space: nowrap; }
.btn:disabled, .btn.off { opacity: .45; pointer-events: none; }
.btn.sm { padding: 7px 10px; font-size: .82em; }
.b-accent { background: var(--accent); } .b-ok { background: var(--ok); } .b-warn { background: var(--warn); }
.b-err { background: var(--err); } .b-info { background: var(--info); } .b-sms { background: #e2b714; color: #222; }
.b-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > .btn { flex: 1; }

/* --- Bandeau RDV du jour / demain --------------------------------------- */
.bandeau { margin-top: 14px; border-radius: var(--radius); padding: 12px 14px;
    background: var(--accent-soft); border-left: 5px solid var(--accent); }
.bandeau h3 { margin: 0 0 6px; font-size: 1em; }
.bandeau .ligne { display: flex; gap: 10px; align-items: baseline; padding: 5px 0; cursor: pointer;
    border-top: 1px dashed var(--border); }
.bandeau .ligne:first-of-type { border-top: none; }
.bandeau .h { font-weight: 800; min-width: 52px; }
.bandeau .vide { color: var(--muted); font-size: .9em; }
.bandeau.urgent { border-left-color: var(--err); }

/* --- Recherche + grille clients ----------------------------------------- */
.search { width: 100%; margin-top: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.tuile { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 10px; text-align: center; cursor: pointer; font-weight: 700; }
.tuile small { display: block; font-weight: 500; color: var(--muted); margin-top: 4px; font-size: .78em; }
.tuile.rdv small { color: var(--accent); font-weight: 700; }

/* --- Panneaux / cartes -------------------------------------------------- */
.panel { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px; margin-top: 14px; }
.panel h2 { margin: 0 0 10px; font-size: 1.15em; }
.panel h3 { margin: 16px 0 8px; font-size: 1em; color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: .85em; }
.hidden { display: none !important; }

/* --- Formulaires -------------------------------------------------------- */
.form-group { margin-bottom: 12px; }
label { display: block; font-weight: 700; margin-bottom: 4px; color: var(--muted); font-size: .88em; }
input, textarea, select { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text); font-size: 1em; font-family: inherit; }
.cols { display: flex; gap: 10px; } .cols > * { flex: 1; min-width: 0; }

/* --- Liste de RDV (fiche + planning) ------------------------------------ */
.rdv { display: flex; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 8px;
    margin-bottom: 8px; background: var(--surface); }
.rdv .quand { min-width: 64px; font-weight: 800; }
.rdv .quand small { display: block; font-weight: 500; color: var(--muted); }
.rdv .quoi { flex: 1; min-width: 0; }
.rdv .quoi b { cursor: pointer; }
.rdv .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.rdv.fait { opacity: .6; } .rdv.fait .quand { text-decoration: line-through; }
.rdv.annule { opacity: .45; }
.rdv.passe-non-fait { border-color: var(--warn); }
.badge { display: inline-block; font-size: .72em; font-weight: 700; padding: 2px 7px; border-radius: 10px;
    color: #fff; background: var(--muted); margin-left: 4px; vertical-align: middle; }
.badge.ok { background: var(--ok); } .badge.err { background: var(--err); } .badge.warn { background: var(--warn); }

/* --- Planning ----------------------------------------------------------- */
.semaine { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.semaine .lib { flex: 1; text-align: center; font-weight: 800; }
.jour { margin-top: 14px; }
.jour > h3 { margin: 0 0 6px; font-size: .95em; padding: 6px 10px; border-radius: 6px;
    background: var(--surface-2); border: 1px solid var(--border); text-transform: capitalize; }
.jour.today > h3 { background: var(--accent); color: #fff; border-color: var(--accent); }
.jour .libre { color: var(--muted); font-size: .85em; padding: 2px 10px 6px; }

/* --- Photos ------------------------------------------------------------- */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.photo { position: relative; border-radius: 8px; overflow: hidden; border: 1px solid var(--border);
    background: var(--surface); }
.photo img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; cursor: zoom-in; }
.photo .cap { font-size: .75em; padding: 5px 6px; }
.photo .del { position: absolute; top: 4px; right: 4px; border: none; border-radius: 50%; width: 28px; height: 28px;
    background: rgba(0,0,0,.55); color: #fff; cursor: pointer; font-size: .9em; }
.btn-photo { display: block; width: 100%; padding: 14px; margin-bottom: 10px; text-align: center; border-radius: 8px;
    background: #7b4fa0; color: #fff; font-weight: 800; cursor: pointer; }
.visionneuse { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 50; display: flex;
    align-items: center; justify-content: center; }
.visionneuse img { max-width: 100%; max-height: 100%; }

/* --- Messages ----------------------------------------------------------- */
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 60;
    padding: 10px 16px; border-radius: 8px; color: #fff; font-weight: 700; max-width: 90%;
    box-shadow: 0 4px 16px rgba(0,0,0,.25); transition: opacity .3s; opacity: 0; pointer-events: none; }
#toast.on { opacity: 1; }
.err-box { background: rgba(192,57,43,.14); color: var(--err); padding: 10px; border-radius: 8px;
    font-weight: 700; text-align: center; margin-bottom: 14px; }

/* --- Connexion ---------------------------------------------------------- */
.login-box { max-width: 360px; margin: 12vh auto 0; background: var(--surface); padding: 24px;
    border-radius: 14px; box-shadow: 0 4px 25px rgba(0,0,0,.12); text-align: center; }
.login-box label { text-align: left; }

@media (min-width: 700px) { .wrap { padding-left: 24px; padding-right: 24px; } }
