/* Application des résidents (mobile d'abord) — couleurs du logo NextGe Connect. */
:root {
  --navy: #0b2d52;
  --teal: #13a8a8;
  --teal-dark: #0b7c7d;
  --bg: #f2f6f8;
  --surface: #ffffff;
  --text: #13253b;
  --muted: #5a6b7d;
  --border: #dbe3ea;
  --danger: #b42318;
  --ok-bg: #e3f5f4;
  --ok-text: #0b5e5f;
  --err-bg: #fdecea;
  --err-text: #8a1c12;
  --bubble-me: #e3f5f4;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1626;
    --surface: #10233a;
    --text: #e4edf5;
    --muted: #97a9bc;
    --border: #22384f;
    --teal-dark: #3cc8c8;
    --danger: #f2786d;
    --ok-bg: #0f3434;
    --ok-text: #8fe3e1;
    --err-bg: #3d1a17;
    --err-text: #ffb4ab;
    --bubble-me: #13384a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body.with-tabs { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
a { color: var(--teal-dark); }
h1 { font-size: 1.35rem; margin: .25rem 0 .75rem; }
h2 { font-size: 1.05rem; margin: .25rem 0 .5rem; }

.app-bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: calc(.7rem + env(safe-area-inset-top)) 1rem .7rem;
  background: var(--navy); color: #fff; border-bottom: 3px solid var(--teal);
}
.app-brand { font-weight: 700; font-size: 1.1rem; }
.app-brand span { color: var(--teal); }
.app-brand small { font-size: .7rem; letter-spacing: .15em; text-transform: uppercase; color: var(--teal); margin-left: .2rem; }
.app-acp { font-size: .85rem; opacity: .85; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app-main { max-width: 640px; margin: 0 auto; padding: 1rem; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1rem; margin-bottom: 1rem; }
.center { text-align: center; }
.muted { color: var(--muted); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }

.hero { text-align: center; padding: .5rem 0 1rem; }
.hero-logo { max-width: 260px; width: 80%; background: #fff; border-radius: 12px; padding: .5rem .75rem; }
.hero p { color: var(--muted); margin: .5rem 0 0; }

label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; margin-bottom: .9rem; }
label small { font-weight: 400; color: var(--muted); }
input, select, textarea {
  font: inherit; font-size: 16px; /* évite le zoom automatique sur iPhone */
  padding: .7rem .75rem; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: .5rem .9rem .7rem; margin: 0 0 .9rem; }
legend { font-weight: 600; padding: 0 .25rem; }
label.choice { flex-direction: row; align-items: center; gap: .6rem; font-weight: 400; margin: .35rem 0; }
label.choice input { width: 1.2rem; height: 1.2rem; }
.invalid input, .invalid select, fieldset.invalid { border-color: var(--danger); }
.err { color: var(--danger); font-weight: 400; font-size: .9rem; }

.btn {
  display: block; width: 100%; text-align: center; text-decoration: none; cursor: pointer;
  font: inherit; font-weight: 600; padding: .85rem 1rem; border-radius: 12px;
  border: 1px solid var(--navy); background: var(--navy); color: #fff;
}
.btn:active { background: var(--teal-dark); border-color: var(--teal-dark); }
.btn-ghost { background: transparent; color: var(--navy); }
@media (prefers-color-scheme: dark) { .btn { background: var(--teal); border-color: var(--teal); color: #06202f; } .btn-ghost { background: transparent; color: var(--teal); } }
button.link { background: none; border: none; color: var(--teal-dark); text-decoration: underline; font: inherit; cursor: pointer; padding: 0; }

.note { padding: .75rem .9rem; border-radius: 10px; margin-bottom: 1rem; }
.note-ok { background: var(--ok-bg); color: var(--ok-text); }
.note-error { background: var(--err-bg); color: var(--err-text); }

.row-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.row-head form { margin: 0; }

.item {
  display: flex; flex-direction: column; gap: .2rem; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: .85rem 1rem; margin-bottom: .6rem;
}
.item-top { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.item-sub { font-size: .82rem; color: var(--muted); }
.item-text { font-size: .92rem; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.pill { flex: none; font-size: .75rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; white-space: nowrap; }
.pill-en_attente { background: #fff4e0; color: #8a4b00; }
.pill-en_cours { background: #e3eefb; color: #0b3e7a; }
.pill-fournisseur_contacte { background: #efe6fb; color: #4b2a85; }
.pill-solutionne { background: #e3f5f4; color: #0b5e5f; }
.pill-cloturee { background: #e9edf1; color: #46566a; }

.thread { display: flex; flex-direction: column; gap: .6rem; margin: 1rem 0; }
.bubble { max-width: 88%; padding: .6rem .8rem; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.bubble-head { font-size: .78rem; color: var(--muted); margin-bottom: .2rem; }
.bubble-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble-resident { align-self: flex-end; background: var(--bubble-me); border-color: transparent; }
.bubble-gestionnaire { align-self: flex-start; border-left: 3px solid var(--teal); }
.bubble-systeme { align-self: center; background: none; border: none; font-size: .8rem; color: var(--muted); text-align: center; padding: .1rem; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .5rem 0 .55rem; font-size: .75rem; text-decoration: none; color: var(--muted); }
.tabbar a .ico { font-size: 1.25rem; line-height: 1; }
.tabbar a.on { color: var(--teal-dark); font-weight: 700; }

.confirm-note { margin: .6rem 0 0; padding: .5rem .7rem; border-radius: 8px; background: var(--err-bg); color: var(--err-text); font-size: .9rem; }

/* Pièces jointes */
.attach-btn {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; text-align: center; margin: 0;
  padding: .75rem .5rem; border: 1px dashed var(--teal); border-radius: 12px; color: var(--teal-dark);
  font-weight: 600; font-size: .92rem; cursor: pointer;
}
/* Le vrai champ fichier recouvre tout le bouton (invisible) : le doigt le touche directement. */
.attach-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 0; }
.attach-list { list-style: none; margin: 0 0 .9rem; padding: 0; font-size: .88rem; color: var(--muted); }
.attach-list li { padding: .15rem 0; overflow-wrap: anywhere; }
.files { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.thumb img { display: block; width: 96px; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.file { display: inline-flex; gap: .35rem; align-items: baseline; padding: .4rem .6rem; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--border); text-decoration: none; color: var(--text); font-size: .9rem; overflow-wrap: anywhere; }
.file small { color: var(--muted); }

/* Pastilles « nouveau » */
.tabbar a { position: relative; }
.dot { position: absolute; top: .25rem; left: calc(50% + .45rem); min-width: 1.15rem; height: 1.15rem; padding: 0 .3rem;
  border-radius: 999px; background: #d92d20; color: #fff; font-size: .7rem; font-weight: 700; line-height: 1.15rem; text-align: center; }
.new { display: inline-block; font-size: .7rem; font-weight: 700; color: #fff; background: #d92d20; border-radius: 999px; padding: .05rem .45rem; vertical-align: middle; }
.item.unread { border-color: var(--teal); box-shadow: inset 3px 0 0 var(--teal); }

.attach { display: block; margin-bottom: .9rem; }
.attach-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .5rem; }
.attach-list li { display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .35rem .5rem; margin-bottom: .3rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.attach-remove { flex: none; width: 2rem; height: 2rem; border: none; border-radius: 999px; background: var(--bg);
  color: var(--danger); font-size: 1rem; cursor: pointer; }
.attach-count { margin: 0; font-size: .85rem; }

.bubble-signature { margin-top: .45rem; padding-top: .35rem; border-top: 1px solid var(--border);
  font-size: .82rem; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
