/* Little Bot — design system partagé (app-shell, sidebar, cartes, tableaux) */

:root {
  --bg-canvas: #05060d;
  --bg-base: #0a0c16;
  --sidebar-bg: #0a0b14;
  --surface-1: #131526;
  --surface-2: #1a1d33;
  --surface-3: #21243d;
  --border-hair: rgba(255,255,255,0.055);
  --border-strong: #363a5c;

  --accent: #ffbb00;
  --accent-ink: #14110a;
  --accent-dim: #cc9600;
  --accent-glow: rgba(255, 187, 0, 0.28);

  --text-primary: #e5e7eb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --ok: #34d399;
  --ok-bg: rgba(52, 211, 153, 0.12);
  --warn: #fbbf4d;
  --warn-bg: rgba(251, 191, 77, 0.12);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;

  --shadow-card: 0 1px 0 rgba(255,255,255,0.03) inset, 0 12px 32px rgba(0,0,0,0.4);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { background: var(--bg-canvas); margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, "Segoe UI", ui-sans-serif, sans-serif;
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.55;
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- app shell ---------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: 12px 28px; border-bottom: 1px solid var(--border-hair);
  background: var(--bg-base); position: sticky; top: 0; z-index: 6;
}
.app-logo { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; color: var(--text-primary); text-decoration: none; }
.app-account { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--text-secondary); }
.app-account button {
  background: transparent; border: 1px solid var(--border-hair); color: var(--text-secondary);
  border-radius: 8px; padding: 6px 12px; font-family: inherit; font-size: 13px; cursor: pointer;
}
.app-account button:hover { border-color: var(--accent); color: var(--accent); }

/* header identity block (avatar + name + role) — right side of the header, on every page */
.header-user { display: flex; align-items: center; gap: 11px; }
.header-user .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--accent-glow); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: var(--accent);
}
.header-user .u-text { min-width: 0; }
.header-user .u-name { font-size: 13px; font-weight: 700; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-user .u-role { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.header-user .u-logout {
  flex-shrink: 0; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--text-muted); text-decoration: none; background: none; border: 1px solid var(--border-hair);
  border-radius: 8px; cursor: pointer; font-family: inherit; transition: color 0.14s var(--ease), border-color 0.14s var(--ease);
}
.header-user .u-logout:hover { color: var(--accent); border-color: var(--accent-dim); }

.app-body { display: flex; flex: 1; min-height: 0; }
.app-sidebar { width: 224px; flex-shrink: 0; background: var(--sidebar-bg); box-shadow: 1px 0 0 rgba(255,255,255,0.03); padding: 0 0 var(--sp-5); }

.sidebar-scroll { padding-top: var(--sp-4); }

.grp-label { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); padding: 0 22px; margin: 18px 0 8px; font-weight: 700; }
.grp-label:first-child { margin-top: 0; }
.nav-item {
  display: flex; align-items: center; gap: 11px; margin: 2px 12px; padding: 9px 12px; font-size: 13.5px; border-radius: 10px;
  color: var(--text-secondary); position: relative; cursor: pointer; text-decoration: none;
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
}
.nav-item .ic { width: 16px; text-align: center; opacity: 0.85; }
.nav-item:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.nav-item.active { color: var(--accent-ink); background: var(--accent); font-weight: 700; }
.nav-item.active .ic { opacity: 1; }
.nav-sub { display: flex; align-items: center; gap: 9px; margin: 1px 12px 1px 26px; padding: 7px 12px; border-radius: 9px; font-size: 12.5px; color: var(--text-muted); cursor: pointer; text-decoration: none; }
.nav-sub:hover { color: var(--text-secondary); background: rgba(255,255,255,0.04); }
.nav-sub.active { color: var(--accent-ink); background: var(--accent); font-weight: 700; }
.nav-sub .ic { font-size: 12px; opacity: 0.7; }
.admin-only { display: none; }
.nav-sub.admin-only::after { content: "admin"; margin-left: auto; font-size: 9.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); background: var(--surface-3); padding: 1px 6px; border-radius: 4px; }

/* ---------- collapsible sidebar groups (real accordion, not a static label) ---------- */
.nav-group { margin: 4px 0; }
.nav-group-toggle {
  width: calc(100% - 24px); margin: 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: none; border: none; padding: 9px 10px; cursor: pointer; font-family: inherit;
  font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700;
  color: var(--text-muted); transition: color 0.14s var(--ease);
}
.nav-group-toggle:hover { color: var(--text-secondary); }
.nav-group-toggle .chev { font-size: 10px; transition: transform 0.18s var(--ease); flex-shrink: 0; }
.nav-group-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
.nav-group-items { max-height: 0; overflow: hidden; transition: max-height 0.22s var(--ease); }
.nav-group-items.open { max-height: 640px; }
.nav-group-items .nav-item { margin-left: 22px; }
.nav-group-items .nav-sub { margin-left: 36px; }

.app-main { flex: 1; min-width: 0; padding: var(--sp-6); overflow-y: auto; }
.app-main.narrow { max-width: 760px; margin: 0 auto; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-5); flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 600; margin: 0 0 3px; letter-spacing: -0.01em; }
.page-head .sub { font-size: 13px; color: var(--text-secondary); }
.crumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.crumb a { color: var(--text-secondary); text-decoration: none; }
.crumb a:hover { color: var(--accent); }
.head-actions { display: flex; align-items: center; gap: 10px; }

/* ---------- buttons ---------- */
.btn {
  font-family: inherit; font-size: 13.5px; font-weight: 700; border-radius: 9px; padding: 10px 18px;
  border: 1px solid transparent; cursor: pointer; transition: background 0.16s var(--ease), border-color 0.16s var(--ease), transform 0.1s;
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #ffc933; }
.btn-secondary { background: transparent; border-color: var(--accent-dim); color: var(--accent); }
.btn-secondary:hover { border-color: var(--accent); background: rgba(255,187,0,0.06); }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text-secondary); }
.btn-ghost:hover { border-color: var(--text-secondary); color: var(--text-primary); }
.btn-danger { background: transparent; border-color: rgba(248,113,113,0.4); color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.select-btn {
  display: inline-flex; align-items: center; gap: 8px; background: transparent; border: 1px solid var(--border-strong);
  color: var(--text-secondary); font-family: inherit; font-size: 13px; font-weight: 600; padding: 9px 14px;
  border-radius: 9px; cursor: pointer;
}
.select-btn:hover { border-color: var(--text-secondary); color: var(--text-primary); }

/* ---------- pills / badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; padding: 3px 10px; border-radius: 999px; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; }
.pill-ok { background: var(--ok-bg); color: var(--ok); } .pill-ok::before { background: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); } .pill-warn::before { background: var(--warn); }
.pill-danger { background: var(--danger-bg); color: var(--danger); } .pill-danger::before { background: var(--danger); }
.pill-neutral { background: var(--surface-3); color: var(--text-secondary); } .pill-neutral::before { background: var(--text-muted); }

/* ---------- cards ---------- */
.card { background: var(--surface-1); border: 1px solid var(--border-hair); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.card-pad { padding: var(--sp-5); }

/* ---------- profile grid (portail) ---------- */
.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--sp-4); }
.profile-card {
  display: block; background: var(--surface-1); border: 1px solid var(--border-hair); border-radius: var(--radius-md);
  padding: var(--sp-4); text-decoration: none; color: inherit; transition: border-color 0.16s var(--ease), transform 0.16s var(--ease);
}
.profile-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.profile-card .top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: var(--sp-4); }
.bot-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border-hair); display: flex; align-items: center; justify-content: center; font-size: 17px; }
.profile-card .pname { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.profile-card .pmeta { font-size: 12px; color: var(--text-muted); margin-bottom: var(--sp-4); }
.profile-card .cta { font-size: 12.5px; color: var(--accent); font-weight: 700; display: flex; align-items: center; gap: 5px; }
.empty { color: var(--text-secondary); font-size: 13px; }

/* ---------- stat cards (analytics) ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.stat-card { background: var(--surface-1); border: 1px solid var(--border-hair); border-radius: var(--radius-md); padding: var(--sp-4); }
.stat-card .row1 { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-3); }
.stat-card .label { font-size: 11.5px; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.stat-card .value { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-icon {
  width: 38px; height: 38px; border-radius: 11px; background: var(--accent-glow); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0;
}
.stat-icon.neutral { background: var(--surface-3); color: var(--text-secondary); }
.stat-card .trend { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.stat-card .trend.up { background: var(--ok-bg); color: var(--ok); }
.stat-card .trend.down { background: var(--danger-bg); color: var(--danger); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted);
  font-weight: 700; background: var(--surface-2); padding: 10px 14px; white-space: nowrap;
}
table.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border-hair); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
table.data-table tbody tr:hover { background: rgba(255,255,255,0.018); }
table.data-table td.na { color: var(--text-muted); font-style: italic; }
.net-badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 11px; background: var(--surface-3); color: var(--text-secondary); }

/* ---------- alerts ---------- */
.alert-row { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border-hair); margin-bottom: 8px; }
.alert-row .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--danger); }
.alert-row .txt { font-size: 13px; flex: 1; } .alert-row .txt strong { color: var(--text-primary); }

/* ---------- forms (shared look) ---------- */
input, select, textarea {
  background: var(--bg-base); border: 1px solid var(--border-strong); color: var(--text-primary);
  font-family: inherit; font-size: 14px; padding: 9px 12px; border-radius: 8px; outline: none;
  transition: border-color 0.14s var(--ease), box-shadow 0.14s var(--ease);
}
input:hover, select:hover, textarea:hover { border-color: #445064; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
label { font-size: 12px; color: var(--text-secondary); font-weight: 600; }

/* ---------- settings list (label+description left, control right) ---------- */
.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-5);
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border-hair);
}
.settings-row:last-child { border-bottom: none; }
.settings-row .txt { min-width: 0; }
.settings-row .txt .t { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.settings-row .txt .d { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.settings-row .ctl { flex-shrink: 0; display: flex; align-items: center; gap: 8px; }
.settings-row .ctl input, .settings-row .ctl select { width: auto; min-width: 200px; }
.settings-section-head { padding: var(--sp-5) var(--sp-5) 0; }
.settings-section-head .t { font-size: 15px; font-weight: 700; }
.settings-section-head .d { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }

/* switch toggle for settings rows */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track { position: absolute; inset: 0; background: var(--surface-3); border-radius: 999px; transition: background 0.16s var(--ease); }
.switch .track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; background: var(--text-secondary); border-radius: 50%; transition: transform 0.16s var(--ease), background 0.16s; }
.switch input:checked + .track { background: var(--accent-dim); }
.switch input:checked + .track::after { transform: translateX(16px); background: var(--accent-ink); }

.message { margin-top: 14px; font-size: 13px; display: none; }
.message.success { display: block; color: var(--ok); }
.message.error { display: block; color: var(--danger); }

/* ---------- auth pages (login, PIN unlock) ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-canvas); padding: 24px; }
.auth-card { background: var(--surface-1); border: 1px solid var(--border-hair); border-radius: var(--radius-lg); padding: 40px; width: 100%; max-width: 380px; box-shadow: var(--shadow-card); }
.auth-mark { width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(155deg, #ffcf4d, var(--accent)); display: flex; align-items: center; justify-content: center; font-size: 22px; margin: 0 auto 20px; }
.auth-logo { display: block; max-width: 220px; width: 100%; height: auto; margin: 0 auto 24px; }
.auth-card h1 { font-size: 19px; font-weight: 700; text-align: center; letter-spacing: -0.01em; margin: 0 0 20px; }
.auth-card .sub { font-size: 13px; color: var(--text-secondary); text-align: center; margin-top: 4px; margin-bottom: 28px; }
.auth-card .field { margin-bottom: 16px; }
.auth-card label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.auth-card input { width: 100%; height: 42px; }
.auth-card button[type="submit"] { width: 100%; height: 44px; margin-top: 8px; }
.auth-back { display: block; text-align: center; margin-top: 18px; color: var(--text-secondary); font-size: 13px; text-decoration: none; }
.auth-back:hover { color: var(--accent); }
.auth-error {
  margin-top: 14px; padding: 10px 14px; background: var(--danger-bg); border: 1px solid rgba(248,113,113,0.35);
  border-radius: var(--radius-sm); color: var(--danger); font-size: 13px; display: none;
}
.auth-error.visible { display: block; }

@media (max-width: 860px) {
  .app-body { flex-direction: column; }
  .app-sidebar { width: 100%; padding: var(--sp-3) 0; }
  .header-user .u-text { display: none; }
  .sidebar-scroll { display: flex; overflow-x: auto; padding-top: 0; }
  .grp-label { display: none; }
  .nav-item, .nav-sub { white-space: nowrap; padding: 8px 14px; }
  .nav-item.active::before { display: none; }
}
