/* ============================================================================
   SSH Hub Dashboard — Thème sombre technique, zéro IP, zéro télémétrie
   ============================================================================ */

:root {
  --bg: #020617;
  --surface: #0f172a;
  --surface-elev: #1e293b;
  --border: #334155;
  --border-hover: #475569;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent: #38bdf8;
  --accent-hover: #22d3ee;
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.1);
  --success-border: rgba(34, 197, 94, 0.2);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --danger-border: rgba(239, 68, 68, 0.2);
  --warning: #f59e0b;

  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.2s ease;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scrollbar-gutter: stable;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
}

svg {
  stroke-width: 2;
  flex-shrink: 0;
}

/* ============================================================================
   Layout principal
   ============================================================================ */

.dashboard {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 28px 24px;
  flex-shrink: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 44px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 30px;
  height: 30px;
  color: var(--accent);
}

.brand-name {
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition);
  border: 1px solid transparent;
  white-space: nowrap;
}

.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--surface-elev);
  color: var(--text);
  border-color: var(--border-hover);
}

.nav-item.active {
  background: rgba(56, 189, 248, 0.08);
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.25);
}

/* ---------- Statut serveur ---------- */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 20px;
  font-size: 0.85rem;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all var(--transition);
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2);
}

.status-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2);
}

/* ---------- Contenu principal ---------- */
.main-content {
  background: var(--bg);
  overflow-y: auto;
  padding: 36px 40px;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
}

.main-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.header-actions {
  display: flex;
  gap: 10px;
}

.btn-refresh,
.btn-add {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-refresh svg,
.btn-add svg {
  width: 16px;
  height: 16px;
}

.btn-refresh:hover,
.btn-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface-elev);
}

/* ============================================================================
   Statistiques
   ============================================================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 20px;
  margin-bottom: 44px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all var(--transition);
}

.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.stat-value {
  font-size: 2.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  margin-bottom: 6px;
}

.stat-trend {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.stat-trend.positive {
  color: var(--success);
}

/* ============================================================================
   Liste des postes
   ============================================================================ */

.devices-section {
  margin-top: 8px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.section-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

.search-box {
  position: relative;
  width: 300px;
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 42px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.88rem;
  transition: all var(--transition);
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ---------- Cards ---------- */
.devices-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.device-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.device-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.device-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--success);
  opacity: 0.9;
}

.device-card.revoked::before {
  background: var(--danger);
}

.device-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.device-alias {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.device-hostname {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  word-break: break-all;
}

.device-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.device-badge.active {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.device-badge.revoked {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.device-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.meta-value {
  font-size: 0.88rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text);
  word-break: break-all;
}

.meta-item.full {
  grid-column: 1 / -1;
}

.device-actions {
  margin-top: auto;
  display: flex;
  gap: 10px;
}

.btn-revoke {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--danger);
  background: transparent;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-revoke svg {
  width: 15px;
  height: 15px;
}

.btn-revoke:hover:not(:disabled) {
  background: var(--danger);
  color: #ffffff;
}

.btn-revoke:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ============================================================================
   État vide
   ============================================================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 56px;
  height: 56px;
  margin-bottom: 20px;
  opacity: 0.4;
}

.empty-state p {
  margin-bottom: 8px;
  font-size: 1rem;
  color: var(--text);
}

.empty-state .hint {
  font-size: 0.85rem;
  opacity: 0.65;
  max-width: 360px;
}

/* ============================================================================
   Modal
   ============================================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 440px;
  max-width: 92vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.25s ease;
}

.modal-overlay.visible .modal {
  transform: translateY(0);
  opacity: 1;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: all var(--transition);
}

.btn-close:hover {
  background: var(--surface-elev);
  color: var(--text);
}

.btn-close svg {
  width: 20px;
  height: 20px;
}

.modal-body {
  padding: 28px 24px;
  overflow-y: auto;
  max-height: 40vh;
}

.modal-body p {
  margin-bottom: 12px;
  color: var(--text);
  font-size: 0.95rem;
}

.modal-body strong {
  color: var(--accent);
}

.modal-body p small {
  display: block;
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 20px 24px;
  border-top: 1px solid var(--border);
}

.btn-cancel {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-cancel:hover {
  background: var(--surface-elev);
}

.btn-confirm {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--danger);
  background: var(--danger);
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-confirm:hover {
  background: #dc2626;
  border-color: #dc2626;
}

/* ============================================================================
   Scrollbar
   ============================================================================ */

::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================================================
   Utilitaires
   ============================================================================ */

.hidden {
  display: none !important;
}

/* ============================================================================
   Vues du dashboard
   ============================================================================ */

.view {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

#view-dashboard {
  display: block;
}

/* ============================================================================
   Panneau info
   ============================================================================ */

.info-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 40px;
  margin-top: 24px;
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.info-icon {
  flex-shrink: 0;
}

.info-icon svg {
  width: 48px;
  height: 48px;
  color: var(--accent);
  background: rgba(56, 189, 248, 0.1);
  padding: 14px;
  border-radius: 16px;
}

.info-text {
  flex: 1;
}

.info-text h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.info-text p {
  color: var(--text-muted);
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.info-text p code {
  background: var(--surface-elev);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.info-text .hint {
  margin-top: 12px;
  font-size: 0.85rem;
  opacity: 0.65;
}

/* ============================================================================
   Liste postes (vue postes)
   ============================================================================ */

#devices-list-postes {
  margin-top: 24px;
}
