/* ===== Styles propres au portail de supervision ===== */

/* Hero identique au site vitrine */
.portal-hero {
  position: relative;
  background: radial-gradient(circle at 15% 20%, #123a5e 0%, var(--color-bg) 55%);
  color: var(--color-dark-text);
  padding: 56px 0 44px;
}
.portal-hero h1 { font-size: clamp(1.6rem, 3.2vw, 2.2rem); margin-bottom: 10px; }
.portal-hero p { color: var(--color-dark-muted); font-size: 0.98rem; }
.portal-hero-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}
.portal-hero-meta { text-align: right; color: var(--color-dark-muted); font-size: 0.85rem; }

/* ----- Connexion ----- */
.login-wrap {
  min-height: calc(100vh - 74px - 34px);
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 15% 20%, #123a5e 0%, var(--color-bg) 55%);
  padding: 60px 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 38px 34px;
}
.login-card h1 { font-size: 1.5rem; margin-bottom: 8px; }
.login-card .section-lead { font-size: 0.94rem; margin-bottom: 26px; }
.login-card-wide { max-width: 560px; }
.login-help { margin-top: 22px; font-size: 0.85rem; color: var(--color-text-muted); }
.login-help a { color: var(--color-primary); font-weight: 700; }
.login-account {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  margin-bottom: 18px;
  font-size: 0.9rem;
  font-weight: 700;
  word-break: break-all;
}
.eyebrow-primary { color: var(--color-primary); }

.code-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.6rem;
  letter-spacing: 0.4em;
  text-align: center;
  font-weight: 700;
}

.btn-link-center {
  display: block;
  width: 100%;
  margin: 16px 0 0;
  text-align: center;
}

/* ----- Activation ----- */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps li {
  position: relative;
  padding: 0 0 26px 46px;
  border-left: 2px solid var(--color-border);
  margin-left: 14px;
}
.steps li:last-child { border-left-color: transparent; padding-bottom: 0; }
.steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: -15px;
  top: -2px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
  display: grid;
  place-items: center;
}
.steps strong { display: block; margin-bottom: 6px; font-size: 1rem; }
.steps span { display: block; color: var(--color-text-muted); font-size: 0.9rem; }

.qr-box {
  display: inline-block;
  margin: 14px 0 10px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.manual-entry summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-primary);
}
.manual-entry p { margin: 10px 0 6px; font-size: 0.85rem; color: var(--color-text-muted); }
.secret {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  word-break: break-all;
}

.search-input {
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  min-width: 220px;
}
.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(14, 107, 168, 0.15);
}

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--color-text);
}
.field input {
  width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--color-text);
  background: var(--color-surface-alt);
}
.field input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(14, 107, 168, 0.15);
}

.form-error {
  background: #fdecea;
  color: #9c2c25;
  border: 1px solid #f5c6c2;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 18px;
}
.form-error[hidden] { display: none; }

/* ----- Cartes de statistiques ----- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 18px;
}
.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.kpi-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: transparent; }
.kpi-icon { font-size: 1.6rem; margin-bottom: 12px; }
.kpi-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.kpi-value { font-size: 2rem; font-weight: 800; letter-spacing: -0.03em; margin-top: 4px; }
.kpi-hint { font-size: 0.85rem; color: var(--color-text-muted); margin-top: 4px; }

/* ----- Panneaux ----- */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 26px;
}
.panel + .panel { margin-top: 24px; }
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}
.panel-head h2 { font-size: 1.15rem; }
.panel-head p { color: var(--color-text-muted); font-size: 0.88rem; }

.chart-box { position: relative; height: 300px; }

.range-tabs { display: flex; gap: 8px; }
.range-tabs button {
  border: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  border-radius: 999px;
  padding: 7px 15px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.range-tabs button.is-active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

/* ----- Tableaux ----- */
.table-scroll { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.data th {
  text-align: left;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
table.data td {
  padding: 12px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
table.data tbody tr:hover { background: var(--color-surface-alt); }
table.data td.name { font-weight: 700; white-space: normal; }
.muted { color: var(--color-text-muted); }

/* ----- Badges d'état ----- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
}
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-ok { background: rgba(22, 199, 154, 0.14); color: #0d7d61; }
.badge-off { background: rgba(226, 86, 77, 0.12); color: #a83229; }
.badge-warn { background: rgba(224, 164, 34, 0.16); color: #8a6210; }
.badge-neutral { background: rgba(14, 107, 168, 0.12); color: var(--color-primary-dark); }

/* ----- Administration ----- */
.site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px;
  margin-top: 34px;
}
.site-card {
  display: block;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.site-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: transparent; }
.site-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.site-card h3 { font-size: 1.05rem; }
.site-card-mail { font-size: 0.82rem; color: var(--color-text-muted); word-break: break-all; }
.site-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}
.site-stat-value { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; }
.site-stat-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); }
.site-card-error { margin-top: 16px; font-size: 0.85rem; color: var(--color-danger); font-weight: 600; }

.btn-secondary {
  background: var(--color-surface-alt);
  border-color: var(--color-border);
  color: var(--color-text);
  padding: 12px 20px;
}
.btn-secondary:hover { background: #e9edf5; }

.btn-link {
  background: none;
  border: none;
  padding: 0;
  margin-right: 12px;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--color-primary);
  cursor: pointer;
  white-space: nowrap;
}
.btn-link:last-child { margin-right: 0; }
.btn-link:hover { text-decoration: underline; }
.btn-link.is-danger { color: var(--color-danger); }

table.data td.col-actions { white-space: normal; text-align: right; }
.col-actions { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.84rem; }
table.data td.mono { white-space: normal; word-break: normal; overflow-wrap: anywhere; }
table.data td.col-actions .btn-link { white-space: nowrap; margin: 0 12px 4px 0; }

.notice-success { background: #e8f8f3; color: #0d7d61; border: 1px solid #b9e9db; }
.notice-info, .notice-error, .notice-success { margin-bottom: 22px; }

/* ----- Modale ----- */
.modal {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  width: min(680px, calc(100vw - 40px));
  box-shadow: var(--shadow-lg);
  color: var(--color-text);
}
.modal::backdrop { background: rgba(11, 18, 32, 0.6); backdrop-filter: blur(3px); }
.modal form { padding: 32px; }
.modal h2 { font-size: 1.3rem; margin-bottom: 22px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field-hint { display: block; margin-top: 6px; font-size: 0.78rem; color: var(--color-text-muted); }

.field select {
  width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--color-text);
  background: var(--color-surface-alt);
}
.field select:focus, .field input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(14, 107, 168, 0.15);
}
.field input:disabled { color: var(--color-text-muted); cursor: not-allowed; }

.input-group { display: flex; gap: 10px; }
.input-group input { flex: 1; }

.setup-block {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px 20px 4px;
  margin-bottom: 22px;
}
.setup-block legend {
  padding: 0 8px;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.setup-block .checkbox-field { margin-bottom: 14px; }
.setup-block .checkbox-field label { font-weight: 600; }

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  font-size: 0.9rem;
  font-weight: 600;
}
.checkbox-field input { width: 17px; height: 17px; accent-color: var(--color-primary); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--color-border);
}


/* ----- Barre de progression (CPU/RAM) ----- */
.meter { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.meter-track { flex: 1; height: 6px; border-radius: 3px; background: var(--color-border); overflow: hidden; }
.meter-fill { height: 100%; width: 0; border-radius: 3px; background: var(--color-primary); }
.meter-fill.is-high { background: var(--color-danger); }
.meter-value { font-size: 0.8rem; color: var(--color-text-muted); min-width: 34px; text-align: right; }

/* ----- États ----- */
.notice {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 0.9rem;
  font-weight: 600;
}
.notice-info { background: #eaf3fa; color: #0a4f80; border: 1px solid #cbe2f2; }
.notice-error { background: #fdecea; color: #9c2c25; border: 1px solid #f5c6c2; }
.notice[hidden] { display: none; }

.skeleton { color: var(--color-text-muted); font-weight: 600; }

.empty-state { text-align: center; padding: 34px 10px; color: var(--color-text-muted); font-size: 0.92rem; }

@media (max-width: 640px) {
  .portal-hero-meta { text-align: left; }
  .panel { padding: 20px 16px; }
  .field-row { grid-template-columns: 1fr; }
  .modal form { padding: 22px 18px; }
  .modal-actions { flex-direction: column-reverse; }
  .col-actions { text-align: left; }
}
