/* Cockpit — shell, sidebar, dashboard, charts, ops views, Luxgap AI.
   S'appuie sur les variables :root définies dans le HTML. */

:root { --down: oklch(0.55 0.16 25); }

/* ---------------- shell ---------------- */
.shell { display: flex; align-items: stretch; min-height: 100vh; }

.sidebar {
  width: 252px; flex: none; position: sticky; top: 0; height: 100vh;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 20px 16px;
}
.sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; border-bottom: 1px solid var(--line-soft); }
.nav { flex: 1; overflow-y: auto; padding-top: 14px; display: flex; flex-direction: column; gap: 16px; }
.nav-grp { display: flex; flex-direction: column; gap: 2px; }
.nav-glabel {
  font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-faint); padding: 0 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  border: none; background: transparent; color: var(--ink-soft);
  font-size: 13.5px; font-weight: 500; padding: 9px 10px; border-radius: 8px;
  transition: background .14s, color .14s;
}
.nav-item svg { color: var(--ink-faint); transition: color .14s; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item:hover svg { color: var(--ink-soft); }
.nav-on, .nav-on:hover { background: var(--accent-soft); color: var(--accent); }
.nav-on svg, .nav-on:hover svg { color: var(--accent); }

.nav-ai {
  display: flex; align-items: center; gap: 11px; text-align: left; margin-top: 12px;
  background: var(--ink); border: none; border-radius: 12px; padding: 11px 13px; color: #fff;
  transition: transform .14s, box-shadow .14s;
}
.nav-ai:hover { transform: translateY(-1px); box-shadow: 0 6px 18px oklch(0.3 0.02 255 / 0.22); }
.nav-ai-txt { display: flex; flex-direction: column; line-height: 1.25; }
.nav-ai-txt b { font-size: 13px; }
.nav-ai-txt span { font-size: 11px; color: oklch(0.82 0.02 255); }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content-in { padding: 24px 30px 80px; max-width: 1240px; width: 100%; }

/* ---------------- banner ---------------- */
.banner {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(100deg, var(--ink), oklch(0.32 0.04 262));
  color: #fff; padding: 12px 22px;
}
.banner-mark { flex: none; }
.banner-txt { font-size: 13px; line-height: 1.5; color: oklch(0.92 0.01 255); }
.banner-txt b { color: #fff; font-weight: 600; }
.banner-em { color: oklch(0.8 0.09 200); font-weight: 600; }
.banner-x { margin-left: auto; flex: none; border: none; background: oklch(1 0 0 / 0.12); color: #fff; width: 26px; height: 26px; border-radius: 7px; font-size: 12px; }
.banner-x:hover { background: oklch(1 0 0 / 0.22); }
.banner-mini {
  display: flex; align-items: center; gap: 9px; width: 100%; border: none;
  background: var(--ink); color: #fff; font-size: 12.5px; font-weight: 500; padding: 8px 22px; text-align: left;
}
.banner-mini:hover { background: oklch(0.32 0.03 262); }

/* ---------------- view header ---------------- */
.view { animation: fade .22s ease; }
@keyframes fade { from { transform: translateY(7px); } to { transform: none; } }
.vhead { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.vtitle { font-size: 26px; font-weight: 600; letter-spacing: -0.025em; }
.vsub { font-size: 14px; color: var(--ink-soft); margin-top: 3px; }
.live-pill {
  display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono);
  font-size: 12px; font-weight: 600; color: var(--green); background: var(--green-soft);
  border: 1px solid var(--green-line); padding: 6px 13px; border-radius: 100px;
}
.live-dot { width: 7px; height: 7px; border-radius: 100px; background: var(--green); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.pill-hot { color: var(--red); background: var(--red-soft); border-color: var(--red-line); }
.pill-hot .live-dot { background: var(--red); }
.pill-static { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-line); }

/* ---------------- status strip ---------------- */
.status-strip {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; margin-bottom: 18px;
}
.stx { background: var(--surface); padding: 14px 16px; display: flex; flex-direction: column; gap: 3px; }
.stx-n { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stx span:last-child { font-size: 11.5px; color: var(--ink-faint); }

/* ---------------- KPI row ---------------- */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 15px 16px 8px; box-shadow: var(--shadow-sm);
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 12.5px; color: var(--ink-soft); }
.kpi-delta { font-family: var(--mono); font-size: 11px; font-weight: 600; }
.d-good { color: var(--green); }
.d-bad { color: var(--red); }
.kpi-val { font-size: 27px; font-weight: 600; letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-unit { font-size: 14px; color: var(--ink-faint); font-weight: 500; margin-left: 4px; }
.kpi-spark { margin: 4px -16px 0; }

/* ---------------- cards & charts ---------------- */
.dash-cols { display: grid; grid-template-columns: 1.7fr 1fr; gap: 14px; margin-bottom: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.card-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-h h3 { font-size: 14px; font-weight: 600; }
.card-meta { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.card-link { border: none; background: transparent; color: var(--accent); font-size: 12.5px; font-weight: 500; }
.card-link:hover { text-decoration: underline; }

.chart { display: block; overflow: visible; }
.chart-led { animation: pulse 1.6s ease-in-out infinite; }
.spark { display: block; }

/* donut */
.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut { position: relative; flex: none; }
.donut-seg { transition: stroke-dasharray .5s ease; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-center b { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.donut-center span { font-size: 11px; color: var(--ink-faint); }
.donut-legend { display: flex; flex-direction: column; gap: 7px; }
.dl { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-soft); }
.dl-d { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.dl b { margin-left: auto; color: var(--ink); font-variant-numeric: tabular-nums; }

/* bars */
.bars { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 56px; align-items: center; gap: 12px; }
.bar-label { font-size: 12.5px; color: var(--ink-soft); }
.bar-track { height: 8px; background: var(--surface-2); border-radius: 100px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 100px; transition: width .6s cubic-bezier(.4,0,.2,1); }
.bar-val { font-family: var(--mono); font-size: 12px; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }

/* alerts */
.alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert {
  display: flex; align-items: center; gap: 10px; text-align: left; width: 100%;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px;
  transition: border-color .14s, transform .14s;
}
.alert:hover { transform: translateX(2px); }
.alert-dot { width: 8px; height: 8px; border-radius: 100px; flex: none; }
.alert-critical { border-left: 3px solid var(--red); } .alert-critical .alert-dot { background: var(--red); }
.alert-error { border-left: 3px solid var(--amber); } .alert-error .alert-dot { background: var(--amber); }
.alert-warn { border-left: 3px solid var(--accent); } .alert-warn .alert-dot { background: var(--accent); }
.alert-txt { font-size: 13px; color: var(--ink); flex: 1; }
.alert-go { color: var(--ink-faint); font-size: 13px; }

/* ---------------- flux de données ---------------- */
.flow-list { display: flex; flex-direction: column; }
.flowrow {
  display: grid; grid-template-columns: minmax(220px, 1.4fr) 120px 1fr 96px; align-items: center; gap: 14px;
  padding: 11px 0; border-bottom: 1px solid var(--line-soft);
}
.flowrow:last-child { border-bottom: none; }
.flowrow-route { display: flex; align-items: center; gap: 8px; min-width: 0; }
.fr-node { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fr-arr { position: relative; font-size: 13px; padding-left: 18px; flex: none; }
.fr-line { position: absolute; left: 0; top: 50%; width: 16px; height: 2px; transform: translateY(-50%); border-radius: 2px; }
.flowrow-bar { height: 7px; }
.flow-anim { transition: width .7s cubic-bezier(.4,0,.2,1); position: relative; }
.flowrow-val { font-family: var(--mono); font-size: 12px; text-align: right; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* ---------------- VPN ---------------- */
.vpn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; margin-top: 14px; }
.vpn-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 15px 16px; box-shadow: var(--shadow-sm); }
.vpn-card.vpn-degraded { border-color: var(--amber-line); }
.vpn-card.vpn-down { border-color: var(--red-line); background: linear-gradient(180deg, var(--red-soft), var(--surface)); }
.vpn-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.vpn-name { font-weight: 600; font-size: 14px; display: block; }
.vpn-kind { font-size: 11.5px; color: var(--ink-faint); font-family: var(--mono); }
.vpn-bw { display: flex; align-items: center; gap: 12px; margin: 12px 0 10px; }
.vpn-bw-v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vpn-spark { flex: 1; }
.vpn-flat { height: 2px; background: var(--line); border-radius: 2px; margin-top: 15px; }
.vpn-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 11.5px; color: var(--ink-soft); border-top: 1px solid var(--line-soft); padding-top: 9px; }
.vpn-meta b { color: var(--ink); font-weight: 600; }
.st-down { color: var(--down); }
.st-down .st-dot { background: var(--down); }

/* ---------------- erreurs / log ---------------- */
.seg-sm button { font-size: 12px; padding: 5px 11px; }
.log { display: flex; flex-direction: column; font-family: var(--mono); }
.logrow {
  display: grid; grid-template-columns: 78px 110px 130px 64px 1fr 110px; align-items: center; gap: 12px;
  padding: 9px 8px; border-bottom: 1px solid var(--line-soft); font-size: 12px;
}
.logrow:last-child { border-bottom: none; }
.logrow-new { animation: logIn .5s ease; }
@keyframes logIn { from { background: var(--accent-soft); opacity: 0; transform: translateY(-4px); } to { background: transparent; opacity: 1; } }
.log-time { color: var(--ink-faint); }
.sv { font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 100px; text-align: center; }
.sv-crit { background: var(--red-soft); color: var(--red); }
.sv-err { background: var(--amber-soft); color: var(--amber); }
.sv-warn { background: var(--accent-soft); color: var(--accent); }
.log-svc { color: var(--ink); }
.log-code { color: var(--ink-faint); }
.log-msg { color: var(--ink-soft); font-family: var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-status { font-family: var(--sans); font-size: 11px; text-align: right; }
.ls-Ouvert { color: var(--red); }
.ls-Prisencompte { color: var(--amber); }
.ls-Résolu { color: var(--green); }

/* ---------------- risques ---------------- */
.risk-cols { grid-template-columns: 1fr 1.2fr; }
.matrix { display: flex; flex-direction: column; gap: 6px; }
.mx-yaxis { font-size: 11px; color: var(--ink-faint); font-family: var(--mono); }
.mx-grid { display: grid; grid-template-columns: repeat(5, 1fr); grid-auto-rows: 1fr; gap: 5px; aspect-ratio: 1 / 1; }
.mx-cell { border-radius: 7px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px; padding: 4px; border: 1px solid var(--line-soft); }
.mx-dot {
  width: 26px; height: 26px; border-radius: 100px; border: 2px solid var(--surface); color: #fff;
  font-family: var(--mono); font-size: 11px; font-weight: 600; box-shadow: var(--shadow-sm);
  transition: transform .14s;
}
.mx-dot:hover { transform: scale(1.12); }
.mx-dot-on { outline: 2px solid var(--ink); outline-offset: 1px; }
.mx-xaxis { font-size: 11px; color: var(--ink-faint); font-family: var(--mono); text-align: right; }
.mx-legend { display: flex; gap: 16px; margin-top: 12px; }

.risk-list { display: flex; flex-direction: column; gap: 7px; }
.riskrow {
  display: grid; grid-template-columns: 40px 1fr auto auto; align-items: center; gap: 12px; text-align: left;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px;
  transition: border-color .14s, transform .14s;
}
.riskrow:hover { border-color: var(--accent-line); transform: translateX(2px); }
.riskrow-on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.risk-id { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--ink-faint); }
.risk-main { min-width: 0; }
.risk-title { font-size: 13px; font-weight: 500; display: block; }
.risk-meta { font-size: 11px; color: var(--ink-faint); }
.rband { font-size: 10.5px; font-weight: 600; padding: 3px 9px; border-radius: 100px; white-space: nowrap; }
.rb-hi { background: var(--red-soft); color: var(--red); }
.rb-md { background: var(--amber-soft); color: var(--amber); }
.rb-lo { background: var(--green-soft); color: var(--green); }
.risk-status { font-size: 11px; white-space: nowrap; }
.rs-Ouvert { color: var(--red); }
.rs-Encours { color: var(--amber); }
.rs-Planifié { color: var(--ink-soft); }

.risk-detail { margin-top: 14px; background: var(--surface); border: 1px solid var(--accent-line); border-radius: 12px; padding: 16px 18px; animation: fade .2s ease; }
.rd-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.rd-head code { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--accent); }
.rd-head b { font-size: 15px; }
.rd-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.rd-grid > div, .rd-treat { font-size: 13px; }
.rd-k { display: block; font-size: 10.5px; font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); margin-bottom: 3px; }
.rd-treat { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft); }

/* ---------------- Luxgap mark ---------------- */
.lux-mark { display: inline-flex; gap: 2px; align-items: flex-end; height: 18px; }
.lux-mark span { width: 4px; border-radius: 2px; background: oklch(0.78 0.12 200); animation: bars 1.4s ease-in-out infinite; }
.lux-mark span:nth-child(1) { height: 9px; animation-delay: 0s; }
.lux-mark span:nth-child(2) { height: 16px; background: oklch(0.7 0.14 250); animation-delay: .2s; }
.lux-mark span:nth-child(3) { height: 12px; background: oklch(0.74 0.13 160); animation-delay: .4s; }
@keyframes bars { 0%, 100% { transform: scaleY(0.6); } 50% { transform: scaleY(1); } }
.lux-mark-lg { height: 24px; }
.lux-mark-lg span { width: 5px; }
.lux-mark-lg span:nth-child(1) { height: 12px; }
.lux-mark-lg span:nth-child(2) { height: 22px; }
.lux-mark-lg span:nth-child(3) { height: 16px; }

/* ---------------- Luxgap FAB + panel ---------------- */
.lux-fab {
  position: fixed; bottom: 22px; right: 22px; z-index: 60;
  display: flex; align-items: center; gap: 10px; border: none;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 100px;
  box-shadow: 0 8px 26px oklch(0.3 0.02 255 / 0.28); font-size: 14px; font-weight: 600;
  transition: transform .16s, opacity .16s;
}
.lux-fab:hover { transform: translateY(-2px); }
.lux-fab-hidden { opacity: 0; pointer-events: none; transform: translateY(10px); }

.lux-panel {
  position: fixed; top: 0; right: 0; z-index: 70; width: 400px; max-width: 92vw; height: 100vh;
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: -16px 0 40px oklch(0.3 0.02 255 / 0.14);
  display: flex; flex-direction: column; transform: translateX(105%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.lux-open { transform: translateX(0); }
.lux-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 14px; border-bottom: 1px solid var(--line-soft); }
.lux-id { display: flex; align-items: center; gap: 12px; }
.lux-name { font-weight: 600; font-size: 16px; display: block; letter-spacing: -0.01em; }
.lux-tag { font-size: 11.5px; color: var(--ink-faint); }
.lux-close { border: none; background: var(--surface-2); width: 30px; height: 30px; border-radius: 8px; color: var(--ink-soft); font-size: 13px; }
.lux-close:hover { background: var(--line); }
.lux-sov {
  display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--green);
  background: var(--green-soft); border-bottom: 1px solid var(--green-line); padding: 8px 20px;
}
.lux-sov-dot { width: 7px; height: 7px; border-radius: 100px; background: var(--green); flex: none; }

.lux-body { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.lux-msg { display: flex; gap: 9px; max-width: 100%; }
.lux-user { flex-direction: row-reverse; }
.lux-avatar { flex: none; display: inline-flex; gap: 2px; align-items: flex-end; height: 16px; padding-top: 4px; }
.lux-avatar span { width: 3px; border-radius: 2px; }
.lux-avatar span:nth-child(1) { height: 8px; background: oklch(0.78 0.12 200); }
.lux-avatar span:nth-child(2) { height: 14px; background: oklch(0.7 0.14 250); }
.lux-avatar span:nth-child(3) { height: 10px; background: oklch(0.74 0.13 160); }
.lux-bubble { padding: 11px 14px; border-radius: 13px; font-size: 13.5px; line-height: 1.55; }
.lux-ai .lux-bubble { background: var(--surface-2); border: 1px solid var(--line); border-top-left-radius: 4px; }
.lux-user .lux-bubble { background: var(--accent); color: #fff; border-top-right-radius: 4px; }
.lux-bubble p { margin: 0; }
.lux-bubble p + p { margin-top: 6px; }
.lux-typing { display: flex; gap: 4px; align-items: center; }
.lux-typing span { width: 6px; height: 6px; border-radius: 100px; background: var(--ink-faint); animation: blink 1.2s infinite; }
.lux-typing span:nth-child(2) { animation-delay: .2s; }
.lux-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.3; } 30% { opacity: 1; } }

.lux-sugg { display: flex; flex-wrap: wrap; gap: 7px; padding: 12px 20px 0; }
.lux-sugg button {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  font-size: 12px; padding: 6px 11px; border-radius: 100px; transition: all .14s;
}
.lux-sugg button:hover { border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }

.lux-input { display: flex; gap: 8px; padding: 14px 20px 18px; border-top: 1px solid var(--line-soft); }
.lux-input input {
  flex: 1; border: 1px solid var(--line); border-radius: 100px; padding: 10px 16px;
  font-family: var(--sans); font-size: 13.5px; color: var(--ink); background: var(--surface-2); outline: none;
}
.lux-input input:focus { border-color: var(--accent); background: var(--surface); }
.lux-input button {
  flex: none; width: 38px; height: 38px; border-radius: 100px; border: none;
  background: var(--ink); color: #fff; font-size: 16px;
}
.lux-input button:disabled { opacity: 0.4; }

/* ---------------- responsive ---------------- */
@media (max-width: 1080px) {
  .dash-cols, .risk-cols { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .sidebar {
    position: static; width: 100%; height: auto; flex-direction: row; align-items: center;
    flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--line); padding: 12px 16px;
  }
  .sidebar .brand { border: none; padding: 0 12px 0 0; }
  .nav { flex-direction: row; flex-wrap: wrap; padding: 0; gap: 4px; }
  .nav-grp { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .nav-glabel { display: none; }
  .nav-item span { display: none; }
  .nav-item { padding: 9px; }
  .nav-ai { margin: 0 0 0 auto; }
  .nav-ai-txt { display: none; }
  .shell { flex-direction: column; }
  .status-strip { grid-template-columns: repeat(2, 1fr); }
  .content-in { padding: 18px 16px 80px; }
}
@media (max-width: 560px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .logrow { grid-template-columns: 60px 1fr; }
  .logrow .log-svc, .logrow .log-code, .logrow .log-status { display: none; }
}
