/* ALIVE - shell applicatif (chrome) + bibliothèque de composants partagés.
   Chrome : bandeau fédéré (web component), sidebar (patron ORBIT, état actif
   recoloré en bleu ALIVE), zone de contenu. Composants : en-tête de vue, panneaux,
   cartes KPI, tableaux, badges, tags, icônes. Les vues composent ces briques
   (views.css). Hérite des jetons de alive.css. */

/* ───────────────── Shell ───────────────── */
.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* Le web component <secalys-topbar> rend sa propre barre 64px ; le slot le porte. */
#topbar-slot { flex: none; }
secalys-topbar { display: block; }

.below { flex: 1; display: flex; min-height: 0; }

/* ───────────────── Sidebar (patron ORBIT) ───────────────── */
.sidebar {
  position: relative;
  flex: none;
  width: 236px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px 14px 12px;
  overflow: visible;
  transition: width .16s ease;
}
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; overflow-y: auto; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 9px;
  color: var(--ink); text-decoration: none;
  font-size: 14px; font-weight: 500;
}
.nav-item:hover { background: var(--bg); }
.nav-item.is-active { background: var(--alive-soft); color: var(--alive-d); font-weight: 600; }
.nav-item.is-active .nav-ic { stroke: var(--alive-d); }
.nav-ic { width: 19px; height: 19px; flex: none; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-section {
  margin: 16px 0 6px; padding: 0 12px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
  color: var(--muted-2); text-transform: uppercase;
}
.nav-section-bottom { margin-top: auto; }

/* Bouton collapse - onglet chevron sur la bordure droite (façon ORBIT/SHIELD) */
.sidebar-footer { position: absolute; right: -18px; top: 50%; transform: translateY(-50%); z-index: 10; }
.btn-collapse {
  display: flex; align-items: center; justify-content: center;
  width: 18px; height: 48px; padding: 0;
  background: #fff;
  border: 1px solid var(--line); border-left: none;
  border-radius: 0 8px 8px 0;
  color: var(--muted); cursor: pointer;
  box-shadow: 3px 0 8px rgba(20, 37, 58, .08);
  transition: background .12s, color .12s;
}
.btn-collapse span { display: none; }
.btn-collapse svg { width: 12px; height: 12px; transition: transform .16s ease; }
.btn-collapse:hover { background: var(--bg); color: var(--navy); }

.app-shell.collapsed .sidebar { width: 64px; }
.app-shell.collapsed .nav-item { justify-content: center; gap: 0; font-size: 0; padding: 9px 0; }
.app-shell.collapsed .nav-section { font-size: 0; }
.app-shell.collapsed .btn-collapse svg { transform: rotate(180deg); }

/* ───────────────── Contenu ───────────────── */
.content {
  flex: 1; min-width: 0; overflow-y: auto;
  padding: 28px 34px 56px;
  background: #f6f8fa;
}
.view { display: block; }
.view[hidden] { display: none; }

/* ───────────────── En-tête de vue ───────────────── */
.view-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; margin: 0 0 22px;
}
.view-head-bare { justify-content: flex-end; }
.view-title { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.02em; color: var(--navy); }
.view-title-ic { display: inline-flex; align-items: center; gap: 10px; }
.view-title-ic svg { width: 24px; height: 24px; fill: none; stroke: var(--alive); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.view-sub { margin: 5px 0 0; font-size: 13.5px; color: var(--muted); }
.view-head-actions { display: flex; align-items: center; gap: 10px; flex: none; flex-wrap: wrap; justify-content: flex-end; }

.vh-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.vh-btn:hover { background: var(--bg); border-color: #d3dce4; }
.vh-btn .ic { width: 16px; height: 16px; stroke: var(--muted); }
.vh-btn .ic-chev { width: 14px; height: 14px; margin-left: -2px; }
.vh-btn.is-primary { background: var(--alive); border-color: var(--alive); color: #fff; }
.vh-btn.is-primary:hover { background: var(--alive-d); border-color: var(--alive-d); }
.vh-btn.is-primary .ic { stroke: #fff; }

/* ───────────────── Panneau (carte de contenu) ───────────────── */
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin: 0 0 20px;
}
.panel:last-child { margin-bottom: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 0 0 14px; }
.panel-title { margin: 0; font-size: 15.5px; font-weight: 700; color: var(--navy); }
.panel-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.panel-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 600; color: var(--alive); text-decoration: none; white-space: nowrap;
}
.panel-link:hover { text-decoration: underline; }
.panel-link .ic { width: 15px; height: 15px; }

/* ───────────────── Cartes KPI ───────────────── */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 0 0 20px; }
.kpi-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
}
.kpi-head { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
.kpi-ic { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.kpi-ic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.kpi-label { font-size: 13px; font-weight: 600; color: var(--ink); }
.kpi-body { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.kpi-value { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -.02em; color: var(--navy); line-height: 1; }
.kpi-value.n-alive { color: var(--alive); }
.kpi-spark { width: 84px; height: 32px; flex: none; }
.kpi-trend { margin: 12px 0 0; display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.kpi-trend .ic { width: 14px; height: 14px; }
.kpi-trend.is-up { color: var(--ok); }
.kpi-trend.is-down { color: var(--warn); }
.kpi-trend.is-up .ic { stroke: var(--ok); }
.kpi-trend.is-down .ic { stroke: var(--warn); }

/* ───────────────── Pastilles d'icône colorées (par famille) ───────────────── */
.n-alive  { background: rgba(37,99,235,.10);  color: var(--alive); }
.n-pulse  { background: rgba(22,163,74,.10);  color: var(--pulse); }
.n-shield { background: rgba(214,161,0,.13);  color: var(--shield); }
.n-pilot  { background: rgba(229,72,77,.10);  color: var(--pilot); }
.n-warn   { background: rgba(224,123,26,.12); color: var(--warn); }
.n-violet { background: rgba(124,92,236,.12); color: #7c5cec; }
.n-green  { background: rgba(24,169,87,.12);  color: var(--green); }
.n-gray   { background: #eef1f4; color: var(--muted); }

/* ───────────────── Badges (statut) ───────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; line-height: 1.4; white-space: nowrap;
}
.badge-green { background: rgba(24,169,87,.12);  color: var(--green-d); }
.badge-blue  { background: rgba(37,99,235,.12);  color: var(--alive-d); }
.badge-amber { background: rgba(224,123,26,.13); color: #b45f12; }
.badge-red   { background: rgba(229,72,77,.12);  color: #c0383c; }
.badge-gray  { background: #eef1f4; color: var(--muted); }

/* ───────────────── Tags (type : PCA, PRI…) ───────────────── */
.tag {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
}
.tag-blue   { background: rgba(37,99,235,.12);  color: var(--alive-d); }
.tag-violet { background: rgba(124,92,236,.14); color: #6d4fd6; }
.tag-green  { background: rgba(24,169,87,.13);  color: var(--green-d); }
.tag-gray   { background: #eef1f4; color: var(--muted); }

/* ───────────────── Tableaux de données ───────────────── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th {
  text-align: left; padding: 0 14px 10px; border-bottom: 1px solid var(--line);
  font-size: 11.5px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.data-table tbody td {
  padding: 13px 14px; border-bottom: 1px solid var(--line-2);
  color: var(--ink); vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbfc; }
.cell-lead { display: inline-flex; align-items: center; gap: 11px; font-weight: 600; color: var(--navy); }
.sq-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.sq-ic svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.row-more {
  border: 0; background: none; cursor: pointer; color: var(--muted-2);
  font-size: 18px; line-height: 1; padding: 4px 8px; border-radius: 6px;
}
.row-more:hover { background: var(--bg); color: var(--ink); }

/* Pied de tableau (compteur + pagination) */
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 14px; }
.table-count { font-size: 12.5px; color: var(--muted); }
.pager { display: inline-flex; align-items: center; gap: 4px; }
.pager-btn {
  min-width: 30px; height: 30px; padding: 0 8px;
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  font: inherit; font-size: 12.5px; color: var(--ink); cursor: pointer;
}
.pager-btn:hover { background: var(--bg); }
.pager-btn.is-active { background: var(--alive); border-color: var(--alive); color: #fff; }

/* ───────────────── Icône utilitaire ───────────────── */
.ic { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ───────────────── Onglets (sous-navigation de vue) ───────────────── */
.tabs { display: flex; gap: 26px; border-bottom: 1px solid var(--line); margin: 0 0 22px; }
.tab {
  position: relative; border: 0; background: none; cursor: pointer;
  padding: 0 0 13px; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted);
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--alive); }
.tab.is-active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--alive); border-radius: 2px;
}

/* ───────────────── Placeholder « domaine à venir » ───────────────── */
.coming { max-width: 640px; }
.coming-card {
  margin-top: 8px; padding: 30px;
  background: var(--alive-soft);
  border: 1px dashed rgba(37, 99, 235, 0.35);
  border-radius: 16px;
}
.coming-h { margin: 0 0 8px; font-size: 17px; font-weight: 700; color: var(--navy); }
.coming-p { margin: 0; line-height: 1.6; color: var(--muted); }

/* ───────────────── Responsive ───────────────── */
@media (max-width: 1180px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .content { padding: 22px 18px 48px; }
}
@media (max-width: 620px) {
  .kpi-row { grid-template-columns: 1fr; }
  .view-head { flex-direction: column; align-items: stretch; }
  .view-head-actions { justify-content: flex-start; }
}
