/* =========================================================================
   Nouvel Afric - Gestion locative : feuille de style
   ========================================================================= */
:root {
  --brand:        #0f6e4f;
  --brand-dark:   #0b5740;
  --brand-light:  #157a59;
  --accent:       #e0a82e;
  --accent-dark:  #c8911d;

  --bg:           #eef1f4;
  --surface:      #ffffff;
  --text:         #1f2a37;
  --muted:        #64748b;
  --border:       #e2e8f0;

  --green:        #16a34a;
  --green-bg:     #dcfce7;
  --red:          #dc2626;
  --red-bg:       #fee2e2;
  --amber:        #d97706;
  --amber-bg:     #fef3c7;
  --blue:         #2563eb;
  --blue-bg:      #dbeafe;

  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-lg:    0 12px 32px rgba(16, 24, 40, .18);
  --sidebar-w:    248px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; }

/* ---------- Connexion ---------------------------------------------------- */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
  background: linear-gradient(135deg, var(--brand-dark), #073b2b 60%, #052619);
}
.login-card {
  background: var(--surface); width: 100%; max-width: 400px;
  border-radius: 16px; box-shadow: var(--shadow-lg); padding: 36px 32px;
}
.login-logo {
  display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 22px;
}
.login-logo .brand-mark { width: 92px; height: 74px; object-fit: contain; border-radius: 12px; background: #fff; }
.login-logo h1 { font-size: 22px; letter-spacing: .5px; color: var(--brand-dark); }
.login-logo p { margin: 0; color: var(--muted); font-size: 13px; }

/* ---------- Boutons ------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  background: #eef2f6; color: var(--text); transition: filter .15s, background .15s;
  white-space: nowrap; font-family: inherit;
}
.btn:hover { filter: brightness(.97); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-light); filter: none; }
.btn-accent { background: var(--accent); color: #2a2208; }
.btn-accent:hover { background: var(--accent-dark); filter: none; }
.btn-danger { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-icon { padding: 7px; width: 34px; height: 34px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Champs ------------------------------------------------------- */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; color: #344054; }
label .req { color: var(--red); }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; font-family: inherit;
  background: #fff; color: var(--text); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 110, 79, .15);
}
input[readonly] { background: #f1f5f9; color: var(--muted); }
textarea { resize: vertical; min-height: 64px; }
.field { margin-bottom: 14px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.subscription-help {
  display: flex; flex-direction: column; gap: 5px; margin-top: 18px; padding: 14px;
  border: 1px solid #cde8dc; border-radius: var(--radius-sm); background: #f0faf6;
  color: #31564a; font-size: 12.5px; line-height: 1.45;
}
.subscription-help b { color: var(--brand-dark); font-size: 13px; }
.subscription-help a { align-self: flex-start; margin-top: 3px; color: var(--brand-dark); font-weight: 800; text-decoration: underline; }

/* ---------- Mise en page (app) ------------------------------------------ */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--brand-dark);
  color: #d7e7e0; display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0; height: 100vh; z-index: 30;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 11px; padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.sidebar-brand .brand-mark { width: 48px; height: 40px; flex-shrink: 0; object-fit: contain; border-radius: 8px; background: #fff; padding: 2px; }
.sidebar-brand b { color: #fff; font-size: 16px; line-height: 1.15; letter-spacing: .4px; }
.sidebar-brand span { font-size: 11px; color: #9ec3b5; display: block; }
.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 3px;
  border-radius: var(--radius-sm); color: #cfe2da; font-weight: 600; font-size: 14px;
  cursor: pointer; transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.nav a svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav .nav-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
  color: #7faa9b; padding: 14px 12px 6px; }
.sidebar-foot { padding: 12px 14px; border-top: 1px solid rgba(255, 255, 255, .1); font-size: 12px; color: #9ec3b5; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .page-title { font-size: 18px; font-weight: 700; }
.topbar .spacer { flex: 1; }
.burger { display: none; background: none; border: none; cursor: pointer; padding: 6px; }
.user-chip {
  display: flex; align-items: center; gap: 9px; padding: 5px 8px; border-radius: 999px; background: var(--bg);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--brand);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.user-chip small { color: var(--muted); display: block; font-size: 11px; line-height: 1; }
.content { padding: 22px; flex: 1; }

/* ---------- Cartes / stats ---------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.grid { display: grid; gap: 16px; }
.stats-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px;
}
.stat .ic {
  width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat .ic svg { width: 24px; height: 24px; }
.stat .v { font-size: 23px; font-weight: 800; line-height: 1.1; }
.stat .l { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.ic-green { background: var(--green-bg); color: var(--green); }
.ic-blue  { background: var(--blue-bg);  color: var(--blue); }
.ic-amber { background: var(--amber-bg); color: var(--amber); }
.ic-red   { background: var(--red-bg);   color: var(--red); }
.ic-brand { background: #d6efe6; color: var(--brand); }

.section-title { font-size: 15px; font-weight: 700; margin: 26px 0 12px; display: flex; align-items: center; gap: 8px; }

/* ---------- Barre d'outils de liste ------------------------------------- */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .search { position: relative; flex: 1; min-width: 200px; max-width: 380px; }
.toolbar .search input { padding-left: 36px; }
.toolbar .search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); }
.toolbar .spacer { flex: 1; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters select { width: auto; min-width: 130px; }

/* ---------- Tableaux ----------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.7px; }
table.data th {
  text-align: left; padding: 12px 14px; background: #f8fafc; color: #475569;
  font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .3px;
  border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid #eef2f6; vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #f8fafc; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .actions { text-align: right; white-space: nowrap; }
.code-cell { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; color: var(--muted);
  display: inline-block; max-width: 124px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty svg { width: 46px; height: 46px; opacity: .4; margin-bottom: 10px; }

/* ---------- Badges ------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge-green { background: var(--green-bg); color: #15803d; }
.badge-red   { background: var(--red-bg);   color: #b91c1c; }
.badge-amber { background: var(--amber-bg); color: #b45309; }
.badge-gray  { background: #eef2f6; color: #475569; }
.badge-blue  { background: var(--blue-bg); color: #1d4ed8; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- Modale ------------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5); backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 60; overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; animation: pop .18s ease; margin: auto;
}
.modal.lg { max-width: 760px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; }
.modal-head .close { background: none; border: none; cursor: pointer; color: var(--muted); padding: 4px; border-radius: 6px; }
.modal-head .close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 20px 22px; max-height: 68vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .col-2 { grid-column: span 2; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } .form-grid .col-2 { grid-column: span 1; } }

/* ---------- Toasts ------------------------------------------------------- */
.toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 90; }
.toast {
  background: #fff; border-left: 4px solid var(--brand); border-radius: 10px; box-shadow: var(--shadow-lg);
  padding: 13px 18px; min-width: 260px; max-width: 380px; font-weight: 600; animation: pop .2s ease; display: flex; gap: 10px; align-items: center;
}
.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }
.toast.info { border-color: var(--blue); }

/* ---------- Divers ------------------------------------------------------- */
.muted { color: var(--muted); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600; margin-bottom: 14px; }
.alert-error { background: var(--red-bg); color: #b91c1c; }
.alert-info { background: var(--blue-bg); color: #1d4ed8; }
.checklist { border: 1px solid var(--border); border-radius: var(--radius-sm); max-height: 280px; overflow-y: auto; }
.checklist label {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: 0;
  border-bottom: 1px solid #eef2f6; cursor: pointer; font-weight: 600;
}
.checklist label:hover { background: #f8fafc; }
.checklist input { width: auto; }
.checklist .meta { margin-left: auto; color: var(--muted); font-weight: 600; font-size: 12.5px; }
.spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive --------------------------------------------------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .burger { display: inline-flex; }
  .backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 25; }
}
