/* iDoc — interface */
:root {
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
}
* { box-sizing: border-box; }
/* Correctif : l'attribut hidden doit toujours gagner, même face aux règles
display:flex/grid des vues (sinon l'onglet « Utilisateurs » semble inopérant). */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: #0f172a; color: #fff; padding: 10px 20px;
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 18px; }
.brand.big { font-size: 30px; text-align: center; }
.userbox { display: flex; align-items: center; gap: 12px; }
.userbox span { color: #cbd5e1; }

/* ---------- onglets ---------- */
.tabs { display: flex; gap: 4px; padding: 10px 20px 0; background: #0f172a; }
.tab {
  border: none; background: transparent; color: #cbd5e1;
  padding: 8px 14px; border-radius: 8px 8px 0 0; cursor: pointer; font-size: 14px;
}
.tab.active { background: var(--bg); color: var(--text); font-weight: 600; }

/* ---------- layout ---------- */
main { display: block; }
#view-espaces { display: flex; min-height: calc(100vh - 90px); }
.sidebar {
  width: 280px; background: var(--card); border-right: 1px solid var(--border);
  padding: 16px; overflow-y: auto;
}
.sidebar-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sidebar-head h2 { margin: 0; font-size: 16px; }
#spaceList { list-style: none; margin: 0; padding: 0; }
.space-item {
  padding: 10px 12px; border-radius: 8px; cursor: pointer; margin-bottom: 4px;
  border: 1px solid transparent;
}
.space-item:hover { background: #f8fafc; }
.space-item.active { background: #eff6ff; border-color: #bfdbfe; }
.space-name { font-weight: 600; }
.space-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

.content { flex: 1; padding: 20px; max-width: 1100px; }
.content-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.content-head h2 { margin: 0; }

/* ---------- cartes & tableaux ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px; margin-bottom: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 15px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.table tr:last-child td { border-bottom: none; }
.table .actions { white-space: nowrap; text-align: right; }
.center { text-align: center; }

/* ---------- formulaires ---------- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin-bottom: 12px; }
.grid .full { grid-column: 1 / -1; }
label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
input, select, textarea {
  width: 100%; margin-top: 4px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
  background: #fff; color: var(--text); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
textarea { resize: vertical; }

/* ---------- boutons ---------- */
.btn {
  display: inline-block; border: 1px solid var(--border); background: #fff;
  color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer;
  font-size: 13px; text-decoration: none; font-weight: 600;
}
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; border-color: #334155; color: #cbd5e1; }
.btn.ghost:hover { background: #1e293b; }
.btn.small { padding: 4px 8px; font-size: 12px; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.block { width: 100%; margin-top: 6px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: #e2e8f0; color: #334155; font-size: 12px; font-weight: 600;
}
.st-non-lu { background: #fef3c7; color: #92400e; }
.st-lu { background: #dbeafe; color: #1e40af; }
.st-traité { background: #dcfce7; color: #166534; }
.st-actif { background: #dcfce7; color: #166534; }
.st-inactif { background: #fee2e2; color: #991b1b; }

/* ---------- messages ---------- */
.msg-list { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.msg { max-width: 75%; padding: 8px 12px; border-radius: 10px; background: #f1f5f9; }
.msg.mine { align-self: flex-end; background: #dbeafe; }
.msg.admin .msg-head { color: var(--primary-dark); font-weight: 700; }
.msg-head { font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.msg-body { white-space: pre-wrap; }
.msg-form { display: flex; gap: 8px; }
.msg-form input { margin: 0; flex: 1; }

/* ---------- modales ---------- */
dialog.modal {
  border: none; border-radius: 12px; padding: 0; width: 520px; max-width: 94vw;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
dialog.modal.wide { width: 780px; }
dialog.modal::backdrop { background: rgba(15, 23, 42, .5); }
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; }
.modal-body { padding: 16px 18px; max-height: 62vh; overflow-y: auto; }
.modal-body h4 { margin: 14px 0 8px; font-size: 13px; text-transform: uppercase; color: var(--muted); }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px; border-top: 1px solid var(--border);
}
.close { border: none; background: transparent; font-size: 16px; cursor: pointer; color: var(--muted); }

/* ---------- login ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(135deg, #0f172a, #1e3a8a);
}
.login-card {
  background: #fff; border-radius: 14px; padding: 34px 30px; width: 380px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.tagline { color: var(--muted); text-align: center; margin: 6px 0 20px; }

/* ---------- divers ---------- */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--danger); font-weight: 600; margin: 8px 0; }
.empty {
  text-align: center; color: var(--muted); padding: 60px 20px;
  border: 2px dashed var(--border); border-radius: 12px; background: #fff;
}
#toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 100; max-width: 80vw;
}
#toast.show { opacity: 1; }
#toast.err { background: var(--danger); }
@media (max-width: 760px) {
  #view-espaces { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .grid { grid-template-columns: 1fr; }
}
