/* ============================================================
   app/css/app.css — PWA Copropriétaire
   Même système "Registre" que l'admin, en version simplifiée
   mobile-first (onglets en bas, cartes plus grandes, moins dense).
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,340..600&family=Archivo:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #E7E9E4;
  --surface: #FBFAF8;
  --border: #D7D9D3;
  --border-strong: #C3C6BE;
  --text: #1C2333;
  --text-muted: #5B6472;
  --accent: #4B7A6E;
  --accent-deep: #35594F;
  --accent-tint: #E3ECE9;
  --brass: #B98A3E;
  --brass-tint: #F3EADA;
  --brick: #B5503E;
  --brick-tint: #F6E4E0;
  --font-display: 'Fraunces', serif;
  --font-body: 'Archivo', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
  --header-h: 56px;
  --nav-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; overscroll-behavior-y: contain; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; margin: 0; }
a { color: var(--accent-deep); text-decoration: none; }
button { font-family: var(--font-body); }
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.w-full { width: 100%; }

/* ---- SPLASH ---- */
.splash {
  position: fixed; inset: 0; background: var(--text);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; z-index: 999;
}
.splash-icon { font-size: 48px; }
.splash-title { font-family: var(--font-display); color: #fff; font-size: 22px; font-weight: 500; }
.splash-loader { width: 120px; height: 3px; background: rgba(255,255,255,0.15); border-radius: 3px; overflow: hidden; }
.loader-bar { height: 100%; width: 40%; background: var(--accent); border-radius: 3px; animation: loading 1.1s ease-in-out infinite; }
@keyframes loading { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }

/* ---- APP SHELL ---- */
.app { display: flex; flex-direction: column; height: 100%; }

.app-header {
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  padding-left: 12px; padding-right: 12px;
  flex-shrink: 0;
  position: sticky; top: 0; z-index: 50;
}
.header-back {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: transparent; font-size: 18px; cursor: pointer; color: var(--text);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.header-center { flex: 1; min-width: 0; }
.header-title { font-size: 17px; font-weight: 600; font-family: var(--font-display); }
.copro-selector {
  margin-top: 2px; font-size: 11.5px; font-family: var(--font-mono); color: var(--text-muted);
  border: none; background: transparent; padding: 0; max-width: 100%;
}
.header-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.notif-btn {
  position: relative; width: 38px; height: 38px; border-radius: 50%; border: none;
  background: var(--accent-tint); font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.notif-badge {
  position: absolute; top: -2px; right: -2px; background: var(--brick); color: #fff;
  font-family: var(--font-mono); font-size: 9px; font-weight: 600;
  min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}

.app-main {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
}
.view-padding { padding: 16px; }

/* ---- BOTTOM NAV ---- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; z-index: 50;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; border: none; background: none; cursor: pointer; color: var(--text-muted);
  padding: 6px 0;
}
.nav-icon { font-size: 20px; line-height: 1; }
.nav-label { font-size: 10px; font-weight: 600; font-family: var(--font-mono); letter-spacing: 0.01em; }
.nav-item.active { color: var(--accent-deep); }

/* ---- WELCOME / HOME ---- */
.welcome-banner { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.welcome-sub { font-size: 13px; color: var(--text-muted); margin: 0; }
.welcome-name { font-size: 22px; margin: 2px 0 0; }
.welcome-date { font-size: 11.5px; color: var(--text-muted); text-align: right; max-width: 120px; text-transform: capitalize; }

.home-screen { padding: 16px; }
.home-hero { margin-bottom: 20px; }
.home-avatar {
  width: 52px; height: 52px; border-radius: 50%; background: var(--accent);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 18px; font-weight: 600; margin-bottom: 10px;
}
.home-welcome .home-sub { font-size: 13px; color: var(--text-muted); }
.home-name { font-size: 21px; margin: 2px 0 0; }
.home-logout { font-size: 12px; color: var(--brick); background: none; border: none; cursor: pointer; padding: 0; margin-top: 6px; }

.home-global { background: var(--text); color: #fff; border-radius: 14px; padding: 18px; margin-bottom: 18px; }
.home-global-title { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.7; margin-bottom: 10px; }
.home-global-kpis { display: flex; gap: 20px; }
.home-kpi-val { font-family: var(--font-mono); font-size: 19px; font-weight: 600; }
.home-kpi-label { font-size: 10.5px; opacity: 0.7; margin-top: 2px; }
.home-kpi-warn .home-kpi-val { color: #E3B563; }
.home-kpi-danger .home-kpi-val { color: #E08872; }
.home-kpi-info .home-kpi-val { color: #8FC4B4; }

.home-section-title { font-size: 12.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 20px 0 10px; }

.home-cards { display: flex; flex-direction: column; gap: 10px; }
.home-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; cursor: pointer;
}
.home-card-header { display: flex; align-items: center; gap: 10px; }
.home-card-icon { font-size: 22px; }
.home-card-info { flex: 1; min-width: 0; }
.home-card-name { font-size: 15px; font-weight: 600; margin: 0; }
.home-card-meta { font-size: 12px; color: var(--text-muted); margin: 1px 0 0; }
.home-card-status { flex-shrink: 0; }
.home-arrow { color: var(--text-muted); font-size: 16px; }
.home-card-charges { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.home-charge-mini { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; }
.home-charge-name { color: var(--text); }
.home-no-charges { font-size: 12.5px; color: var(--text-muted); }
.home-card-footer { display: flex; justify-content: flex-end; }
.home-count { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.home-notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brick); display: inline-block; }
.home-role-president, .home-role-tresorier { background: var(--accent-tint); color: var(--accent-deep); }
.home-role-coproprietaire { background: #EAEAE6; color: var(--text-muted); }
.home-meta-tag { font-family: var(--font-mono); font-size: 10.5px; padding: 2px 8px; border-radius: 5px; }

/* ---- KPI ROW (dashboard) ---- */
.kpi-row { display: flex; gap: 8px; margin-bottom: 20px; }
.kpi-pill { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.kpi-pill-label { display: block; font-size: 10.5px; color: var(--text-muted); margin-bottom: 4px; }
.kpi-pill-value { font-family: var(--font-mono); font-size: 15px; font-weight: 600; }
.kpi-pill-warn { background: var(--brass-tint); border-color: #D9C08A; }
.kpi-pill-ok { background: var(--accent-tint); border-color: #9CC4B8; }

/* ---- SECTION HEADER / LINKS ---- */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.section-header h3 { font-size: 15px; font-weight: 600; }
.section-title { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.link-btn { background: none; border: none; color: var(--accent-deep); font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 0; }

/* ---- CHARGES ---- */
.charges-summary { display: flex; gap: 8px; margin-bottom: 16px; }
.summary-pills { display: flex; gap: 8px; flex: 1; }
.sum-pill { flex: 1; text-align: center; padding: 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.summary-amount { display: block; font-family: var(--font-mono); font-weight: 600; font-size: 14px; }
.summary-label { font-size: 10px; color: var(--text-muted); }
.sum-en_attente .summary-amount { color: var(--brass); }
.sum-en_retard .summary-amount { color: var(--brick); }

.filter-tabs { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; }
.filter-tab {
  flex-shrink: 0; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--text); cursor: pointer;
}
.filter-tab.active { background: var(--accent-deep); border-color: var(--accent-deep); color: #fff; }

.charges-list, .list-item { display: flex; flex-direction: column; gap: 10px; }
.charge-card, .charge-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; cursor: pointer;
}
.charge-card-left, .charge-item-body { display: flex; align-items: center; gap: 10px; min-width: 0; }
.charge-item-icon { font-size: 20px; flex-shrink: 0; }
.charge-type-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--accent); }
.charge-type-tantiemes { background: var(--accent); }
.charge-type-groupe { background: var(--brass); }
.charge-type-consommation { background: var(--brick); }
.charge-name, .charge-item-name { font-size: 14.5px; font-weight: 600; margin: 0; }
.charge-meta, .charge-item-meta { font-size: 12px; color: var(--text-muted); margin: 2px 0 0; }
.charge-card-right, .charge-item-right { text-align: right; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.charge-amount, .charge-item-amount { font-family: var(--font-mono); font-weight: 600; font-size: 14.5px; margin: 0; }
.charge-paid { opacity: 0.6; }
.charge-late { border-color: var(--brick); }
.conso-badge {
  font-size: 10.5px; font-weight: 600; background: var(--brick-tint); color: var(--brick);
  padding: 3px 8px; border-radius: 6px; cursor: pointer;
}
.inline-btn-warn { color: var(--brass); font-weight: 600; }

/* ---- STATUS / BADGES ---- */
.status-pill, .badge {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600; text-transform: uppercase;
  padding: 3px 8px; border-radius: 5px; letter-spacing: 0.02em;
}
.status-en_attente, .badge-en_attente { background: var(--brass-tint); color: #8A6526; }
.status-paye, .badge-paye { background: var(--accent-tint); color: var(--accent-deep); }
.status-en_retard, .badge-en_retard { background: var(--brick-tint); color: var(--brick); }

/* ---- EMPTY / ERROR STATES ---- */
.empty-state, .error-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 60px 24px; font-size: 32px;
}
.empty-state p, .error-state p { font-size: 15px; color: var(--text); margin: 12px 0 0; font-family: var(--font-body); }
.empty-card { text-align: center; padding: 24px; color: var(--text-muted); font-size: 13px; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: 10px; }
.loading-spinner {
  width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite; margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- DOCUMENTS ---- */
.docs-preview { display: flex; flex-direction: column; gap: 8px; }
.doc-mini { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.doc-mini-icon { font-size: 18px; }
.doc-mini-name { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-group { margin-bottom: 18px; }
.doc-group-title { font-size: 12.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; margin-bottom: 8px; }
.doc-group-list { display: flex; flex-direction: column; gap: 8px; }
.doc-item { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.doc-item-icon { font-size: 22px; flex-shrink: 0; }
.doc-item-body { flex: 1; min-width: 0; }
.doc-item-name { font-size: 14px; font-weight: 600; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-item-meta { font-size: 11.5px; color: var(--text-muted); margin: 2px 0 0; }
.doc-item-action { flex-shrink: 0; font-size: 18px; }

/* ---- SEARCH ---- */
.search-bar { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
.search-icon { color: var(--text-muted); }
.search-input { flex: 1; border: none; background: none; font-size: 14px; font-family: var(--font-body); outline: none; color: var(--text); }

/* ---- VOTES ---- */
.vote { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.vote-btn {
  flex: 1; padding: 10px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); font-weight: 600; font-size: 13px; cursor: pointer;
}
.vote-pour.active, .vote-pour:active { background: var(--accent-tint); border-color: var(--accent); color: var(--accent-deep); }
.vote-contre.active, .vote-contre:active { background: var(--brick-tint); border-color: var(--brick); color: var(--brick); }
.vote-abst.active, .vote-abst:active { background: #EAEAE6; border-color: var(--border-strong); }

/* ---- NOTIFICATIONS ---- */
.notif-item { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.notif-item.unread { background: var(--accent-tint); }
.notif-icon { font-size: 18px; flex-shrink: 0; }
.notif-title { font-size: 14px; font-weight: 600; margin: 0; }
.notif-msg { font-size: 12.5px; color: var(--text-muted); margin: 3px 0 0; }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; display: block; }
.notif-body { flex: 1; }

/* ---- MY SHARE / DETAIL ---- */
.my-share-card { background: var(--text); color: #fff; border-radius: 14px; padding: 18px; margin-bottom: 16px; }
.my-share-top { display: flex; justify-content: space-between; align-items: baseline; }
.my-share-label { font-size: 12px; opacity: 0.7; }
.my-share-amount { font-family: var(--font-mono); font-size: 26px; font-weight: 600; }
.my-share-paid { color: #8FC4B4; font-size: 12px; margin-top: 6px; }
.my-share-paid-date { opacity: 0.7; }

.detail-header { margin-bottom: 16px; }
.detail-title { font-size: 19px; margin: 0 0 6px; }
.detail-type-badge { display: inline-block; }
.detail-meta-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.detail-desc { font-size: 13.5px; color: var(--text-muted); line-height: 1.6; margin-top: 10px; }

.calc-formula { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-top: 12px; }
.calc-method { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.calc-row { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 0; }
.calc-row-total { font-weight: 700; border-top: 1px solid var(--border-strong); margin-top: 4px; padding-top: 8px; }

/* ---- CONSOMMATION ---- */
.conso-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.conso-input-row { display: flex; align-items: center; gap: 8px; }
.input-with-unit { position: relative; flex: 1; }
.conso-unit, .input-unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13px; }

/* ---- PROFIL ---- */
.profile-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; text-align: center; margin-bottom: 16px; }
.profile-avatar { width: 64px; height: 64px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 22px; font-weight: 600; margin: 0 auto 12px; }

/* ---- AUTH SCREEN ---- */
.auth-screen { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 24px; }
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo-icon { font-size: 44px; }
.auth-app-name { font-family: var(--font-display); font-size: 22px; font-weight: 600; margin-top: 8px; }
.auth-tagline { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.auth-form { width: 100%; max-width: 360px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-muted); }
.password-wrap { position: relative; }
.toggle-password { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--text-muted); }
.password-strength { font-size: 11.5px; margin-top: 6px; color: var(--text-muted); }

/* ---- FORMS ---- */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.form-card-icon { font-size: 28px; margin-bottom: 8px; }
.form-group { margin-bottom: 14px; }
.form-row { display: flex; gap: 10px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-input {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border-strong);
  font-size: 15px; font-family: var(--font-body); background: var(--surface); color: var(--text);
}
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.form-feedback { font-size: 12.5px; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.form-feedback.error { background: var(--brick-tint); color: var(--brick); }
.form-feedback.approuve { background: var(--accent-tint); color: var(--accent-deep); }

/* ---- BUTTONS ---- */
.btn-block {
  display: block; width: 100%; text-align: center; padding: 14px; border-radius: 10px;
  font-size: 15px; font-weight: 600; cursor: pointer; border: none;
}
.btn-primary-sm, button.btn-primary-sm {
  background: var(--accent-deep); color: #fff; padding: 8px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 600; border: none; cursor: pointer;
}
.btn-secondary {
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
}
.btn-danger { background: var(--brick); color: #fff; }
.card-header-sm { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.card-body-sm { font-size: 13px; color: var(--text-muted); }

/* ---- CARD generic ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }

/* ---- MODAL ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(28,35,51,0.5); z-index: 200; }
.modal {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 201;
  background: var(--surface); border-radius: 16px; padding: 20px;
  max-height: 80vh; overflow-y: auto;
}

/* ---- PAGINATION ---- */
.pagination-info { text-align: center; font-size: 12px; color: var(--text-muted); padding: 16px 0; }
