/* ===================== ASIITEC Parc — Dashboard ===================== */
:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --sidebar: #0f172a;
  --sidebar-ink: #cbd5e1;
  --primary: #2563eb;
  --primary-ink: #ffffff;
  --ok: #16a34a;
  --warn: #f59e0b;
  --err: #dc2626;
  --info: #0ea5e9;
  --grey: #94a3b8;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px;
}
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }
small { color: var(--muted); }

/* ---------- Login ---------- */
.login-overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a, #1e293b);
}
.login-card {
  background: var(--card); padding: 2rem; border-radius: 16px; width: 340px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35); display: flex; flex-direction: column; gap: .5rem;
}
.login-logo { font-size: 1.5rem; font-weight: 700; text-align: center; }
.login-sub { text-align: center; color: var(--muted); margin-bottom: 1rem; }
.login-card label { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; color: var(--muted); margin-top: .4rem; }
.login-card input { padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px; font-size: 1rem; }
.login-error { color: var(--err); font-size: .85rem; min-height: 1.2rem; text-align: center; margin-top: .5rem; }

/* ---------- App layout ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-ink); display: flex; flex-direction: column; padding: 1.2rem .8rem; }
.brand { font-size: 1.3rem; font-weight: 700; color: #fff; display: flex; align-items: baseline; gap: .4rem; padding: 0 .5rem 1.2rem; }
.brand small { color: #64748b; font-weight: 500; }
.nav { display: flex; flex-direction: column; gap: .2rem; }
.nav a { padding: .65rem .75rem; border-radius: 8px; color: var(--sidebar-ink); display: flex; align-items: center; gap: .2rem; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; gap: .5rem; padding-top: 1rem; }
.who { font-size: .8rem; color: #94a3b8; padding: 0 .5rem; }

.content { overflow-y: auto; }
.topbar {
  position: sticky; top: 0; z-index: 5; background: rgba(241, 245, 249, .85); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.6rem; border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.25rem; margin: 0; }
.view { padding: 1.4rem 1.6rem; }

/* ---------- Buttons ---------- */
.btn { border: 1px solid transparent; border-radius: 8px; padding: .5rem .9rem; font-size: .85rem; cursor: pointer; font-weight: 600; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; border-color: rgba(255, 255, 255, .2); color: #cbd5e1; }
.btn-ghost:hover { background: rgba(255, 255, 255, .08); }
.btn-light { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-light:hover { background: #f8fafc; }
.btn-sm { padding: .35rem .6rem; font-size: .78rem; }
.btn-block { width: 100%; margin-top: .8rem; }

/* ---------- Cards & grid ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; }
.stat { display: flex; flex-direction: column; gap: .2rem; }
.stat .n { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat .l { color: var(--muted); font-size: .82rem; }
.stat.err .n { color: var(--err); } .stat.warn .n { color: var(--warn); } .stat.ok .n { color: var(--ok); }

.section { margin-top: 1.6rem; }
.section h2 { font-size: 1rem; margin: 0 0 .8rem; color: var(--ink); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }

/* ---------- Tables ---------- */
.table-wrap { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #f8fafc; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem; border-radius: 999px; font-size: .73rem; font-weight: 600; }
.badge::before { content: "●"; font-size: .7em; }
.badge.ok { background: #dcfce7; color: #15803d; }
.badge.warning { background: #fef3c7; color: #b45309; }
.badge.error { background: #fee2e2; color: #b91c1c; }
.badge.inconnu, .badge.grey { background: #e2e8f0; color: #475569; }
.badge.critical { background: #fee2e2; color: #b91c1c; }
.badge.info { background: #e0f2fe; color: #0369a1; }

.pill { background: var(--err); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 .4rem; min-width: 1.2rem; text-align: center; }
.pill:empty { display: none; }

/* ---------- Key/value lists ---------- */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: .45rem .8rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }

/* ---------- Disk bar ---------- */
.disk { margin-bottom: .8rem; }
.disk-head { display: flex; justify-content: space-between; font-size: .82rem; margin-bottom: .25rem; }
.bar { height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ok); }
.bar.warn > span { background: var(--warn); }
.bar.err > span { background: var(--err); }

/* ---------- Alerts list ---------- */
.alert-row { display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; border-bottom: 1px solid var(--line); background: var(--card); }
.alert-row:first-child { border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }
.alert-row:last-child { border-bottom: none; border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); }
.alert-row .msg { flex: 1; }
.alert-row .msg small { display: block; }
.alert-row.resolved { opacity: .55; }

/* ---------- Misc ---------- */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; background: #0f172a; color: #7dd3fc; padding: .15rem .4rem; border-radius: 6px; font-size: .85rem; }
.codeblock { background: #0f172a; color: #e2e8f0; padding: .9rem 1rem; border-radius: 8px; font-family: ui-monospace, Consolas, monospace; font-size: .82rem; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem; }
.back { color: var(--primary); font-weight: 600; cursor: pointer; display: inline-block; margin-bottom: .8rem; }
.search { padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 8px; font-size: .85rem; min-width: 220px; }
.tag-list { display: flex; flex-wrap: wrap; gap: .35rem; }
.tag { background: #f1f5f9; border: 1px solid var(--line); border-radius: 6px; padding: .2rem .5rem; font-size: .78rem; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: flex; align-items: center; justify-content: center; z-index: 20; }
.modal { background: #fff; border-radius: var(--radius); padding: 1.5rem; width: 460px; max-width: 92vw; max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal h3 { margin-top: 0; }
.modal label { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; color: var(--muted); margin-bottom: .7rem; }
.modal input, .modal textarea { padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; font-size: .95rem; font-family: inherit; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: .7rem 1.1rem; border-radius: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); z-index: 30; }
.toast.err { background: var(--err); }
.toast.ok { background: var(--ok); }

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; height: auto; }
  .sidebar-bottom { margin: 0; flex-direction: row; }
  .nav { flex-direction: row; flex-wrap: wrap; }
}
