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

:root {
  --bg:         #09090f;
  --surface:    #10111c;
  --panel:      #13142080;
  --card:       #1a1d2e;
  --card-hi:    #1e2235;
  --input:      #1f2235;
  --input-focus:#252840;
  --border:     #2a2e4a;
  --border-hi:  #3d4266;
  --text:       #cdd0f0;
  --text-dim:   #6870a8;
  --text-mute:  #363a5c;
  --accent:     #7c8dff;
  --accent-lo:  #7c8dff1a;
  --accent-hi:  #a8b4ff;
  --green:      #3ddba0;
  --green-lo:   #3ddba01a;
  --red:        #e74c3c;
  --red-lo:     #e74c3c1a;
  --orange:     #f39c12;
  --sidebar-w:  220px;
  --panel-w:    480px;
  --font-ui:    'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  --font-mono:  'Consolas', 'Courier New', monospace;
  --radius:     8px;
  --radius-sm:  5px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font-ui); font-size: 13px; overflow: hidden; }

/* ── LAYOUT ─────────────────────────────────────────────────────────── */

.app { display: flex; height: 100vh; }

/* ── SIDEBAR ─────────────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 18px;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 14px; color: #fff;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; gap: 1px; }
.brand-name { font-size: 13px; font-weight: 700; color: var(--text); letter-spacing: 0.02em; }
.brand-sub  { font-size: 10px; color: var(--text-dim); letter-spacing: 0.08em; text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border: none; background: transparent;
  color: var(--text-dim); cursor: pointer;
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  text-align: left; width: 100%;
  font-family: var(--font-ui); font-size: 13px;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.nav-item:hover { background: var(--card); color: var(--text); }

.nav-item.active {
  background: var(--accent-lo);
  color: var(--accent-hi);
  border-left-color: var(--accent);
}

.nav-icon { font-size: 14px; opacity: 0.8; width: 18px; text-align: center; }
.nav-label { font-weight: 500; }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

.server-status {
  display: flex; align-items: center; gap: 7px;
  color: var(--text-dim); font-size: 11px;
  font-family: var(--font-mono);
}

.manager-version {
  font-size: 10px;
  color: var(--text-mute);
  margin-top: 5px;
  font-family: var(--font-mono);
}

.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  flex-shrink: 0;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── MAIN ─────────────────────────────────────────────────────────────── */

.main {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.view {
  display: none;
  height: 100%;
  overflow-y: auto;
  padding: 28px 32px;
}

.view.active { display: block; }

/* Scrollbar */
.view::-webkit-scrollbar { width: 6px; }
.view::-webkit-scrollbar-track { background: transparent; }
.view::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── PAGE HEADER ─────────────────────────────────────────────────────── */

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

.page-title { font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.page-sub   { font-size: 12px; color: var(--text-dim); margin-top: 3px; }

/* ── BUTTONS ─────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font-ui); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.88; }

.btn-ghost {
  background: var(--card); color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-hi); }

.btn-danger { background: var(--red-lo); color: var(--red); border: 1px solid var(--red-lo); }
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-icon { padding: 6px; width: 28px; height: 28px; justify-content: center; }

/* ── STAT CARDS ──────────────────────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
}

.stat-card.accent::before  { background: var(--accent); }
.stat-card.green::before   { background: var(--green); }
.stat-card.red::before     { background: var(--red); }
.stat-card.orange::before  { background: var(--orange); }

.stat-label  { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; }
.stat-value  { font-size: 32px; font-weight: 800; color: var(--text); line-height: 1; letter-spacing: -0.03em; }
.stat-icon   { position: absolute; top: 16px; right: 18px; font-size: 20px; opacity: 0.15; }

/* ── TABLE ────────────────────────────────────────────────────────────── */

.section-title {
  font-size: 12px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table { width: 100%; border-collapse: collapse; }

thead tr { background: var(--surface); border-bottom: 1px solid var(--border); }

th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px; font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.06em;
  white-space: nowrap;
}

td {
  padding: 11px 14px;
  font-size: 12px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--card-hi); }

.td-mono { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); }
.td-name { font-weight: 600; }
.td-actions { display: flex; gap: 6px; align-items: center; }

/* ── BADGE ────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 20px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  white-space: nowrap;
}

.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; }

.badge-online  { background: var(--green-lo); color: var(--green); }
.badge-online::before { background: var(--green); }

.badge-offline { background: var(--red-lo); color: var(--red); }
.badge-offline::before { background: var(--red); }

.badge-unknown { background: var(--accent-lo); color: var(--text-dim); }
.badge-unknown::before { background: var(--text-dim); }

/* ── CLIENTS GRID ─────────────────────────────────────────────────────── */

.clients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.client-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}

.client-card:hover { border-color: var(--border-hi); background: var(--card-hi); }

.client-name { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 5px; }
.client-id   { font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); margin-bottom: 14px; }

.client-meta {
  display: flex; align-items: center; justify-content: space-between;
}

.client-devices-count {
  font-size: 11px; color: var(--text-dim);
  background: var(--input); border-radius: 20px;
  padding: 2px 9px;
}

.client-actions { display: flex; gap: 6px; }

/* ── EMPTY STATE ─────────────────────────────────────────────────────── */

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px;
  color: var(--text-dim); text-align: center;
  gap: 10px;
}

.empty-icon  { font-size: 36px; opacity: 0.3; }
.empty-title { font-size: 14px; font-weight: 600; color: var(--text-dim); }
.empty-sub   { font-size: 12px; color: var(--text-mute); }

/* ── SLIDE PANEL ─────────────────────────────────────────────────────── */

.panel-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  z-index: 100;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}

.panel-backdrop.visible { opacity: 1; pointer-events: all; }

.slide-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: var(--panel-w);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 101;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.slide-panel.open { transform: translateX(0); }

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

.panel-title { font-size: 15px; font-weight: 700; color: var(--text); }

.panel-close {
  background: none; border: none;
  color: var(--text-dim); cursor: pointer;
  font-size: 14px; padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
.panel-close:hover { color: var(--text); background: var(--card); }

.panel-body {
  flex: 1; overflow-y: auto; padding: 24px;
}

.panel-body::-webkit-scrollbar { width: 4px; }
.panel-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── FORM ─────────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 11px; font-weight: 700;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 7px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-ui); font-size: 13px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  background: var(--input-focus);
}

.form-textarea {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  resize: vertical;
  min-height: 320px;
}

.form-select option { background: var(--card); }

.form-error {
  margin-top: 6px;
  font-size: 11px;
  color: var(--red);
}

.form-hint {
  margin-top: 5px;
  font-size: 11px;
  color: var(--text-mute);
}

.form-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 24px;
}

/* ── CONFIRM INLINE ───────────────────────────────────────────────────── */

.confirm-wrap { display: flex; gap: 6px; align-items: center; }
.confirm-label { font-size: 11px; color: var(--red); }

/* ── TOAST ────────────────────────────────────────────────────────────── */

.toast-container {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 12px;
  min-width: 260px; max-width: 360px;
  pointer-events: all;
  animation: toastIn 0.2s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.toast-success { background: #0d2e20; border: 1px solid var(--green); color: var(--green); }
.toast-error   { background: #2e0d0d; border: 1px solid var(--red);   color: var(--red); }

.toast-msg { flex: 1; line-height: 1.4; }
.toast-close { background: none; border: none; color: inherit; cursor: pointer; opacity: 0.6; font-size: 12px; padding: 0; flex-shrink: 0; }
.toast-close:hover { opacity: 1; }

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

/* ── CONFIGURATEUR ────────────────────────────────────────────────────── */

.configurateur-view {
  padding: 0 !important;
  overflow: hidden !important;
}

#configurateur-frame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ── LOGIN ────────────────────────────────────────────────────────────── */

#login-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}

.login-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 40px;
  width: 360px;
}

.login-logo { display: flex; align-items: center; gap: 10px; }

/* ── DIVIDER ─────────────────────────────────────────────────────────── */

.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ── LAST SEEN / VERSION ─────────────────────────────────────────────── */

.text-mute  { color: var(--text-mute); font-size: 11px; }
.text-dim   { color: var(--text-dim); }
.text-accent { color: var(--accent); }
.text-mono  { font-family: var(--font-mono); font-size: 11px; }
