@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #f4f5f7;
  --bg-card: #fff;
  --bg-input: #f8f9fb;
  --border: #e2e4e9;
  --border-focus: #4a6cf7;
  --text: #1a1d26;
  --text-sec: #5f6577;
  --text-muted: #9298a8;
  --primary: #4a6cf7;
  --primary-soft: #eef1fe;
  --success: #22a86b;
  --success-soft: #e8f8f0;
  --warning: #e5942e;
  --warning-soft: #fef5e8;
  --danger: #e54444;
  --danger-soft: #fde8e8;
  --radius: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: 'IBM Plex Sans', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── LAYOUT ── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: #1a1d26;
  color: #c5c9d6;
  padding: 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10;
}

.sidebar-brand {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand h1 {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}
.sidebar-brand small {
  font-size: 11px;
  color: #6b7088;
  font-weight: 500;
}

.sidebar-nav { padding: 12px 0; flex: 1; overflow-y: auto; }

.nav-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #4b5066;
  padding: 16px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: #fff; }
.nav-item.active {
  background: rgba(74,108,247,0.12);
  color: #8da4fc;
  border-left-color: #4a6cf7;
  font-weight: 600;
}
.nav-item svg { width: 18px; height: 18px; opacity: 0.6; flex-shrink: 0; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 11px;
  color: #4b5066;
}
.sidebar-footer .status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  margin-right: 6px;
}

.main {
  flex: 1;
  margin-left: 240px;
  padding: 0;
}

.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.topbar-actions { display: flex; gap: 8px; }

.content { padding: 24px 32px; max-width: 960px; }

/* ── CARDS ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title .icon { font-size: 18px; }
.card-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── FORMS ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-full { grid-column: span 2; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sec);
}
.field label .req { color: var(--danger); }

.field input, .field select, .field textarea {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text);
  transition: border 0.15s;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.field input.mono, .field .mono {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.5px;
}
.field .hint {
  font-size: 11px;
  color: var(--text-muted);
}
.field textarea { resize: vertical; min-height: 60px; }

.field input[type="password"] {
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 2px;
}

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #3b5de5; }
.btn-secondary { background: var(--bg); color: var(--text-sec); border-color: var(--border); }
.btn-secondary:hover { background: #eef0f4; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-test {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid rgba(34,168,107,0.2);
}
.btn-test:hover { background: #d4f0e2; }

/* ── TABLES ── */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 8px 12px;
  text-align: left;
  border-bottom: 2px solid var(--border);
}
table.data td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data .actions { display: flex; gap: 4px; }

/* ── TOGGLE ── */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  background: #d1d5db;
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle.on { background: var(--success); }
.toggle::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 2px; left: 2px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle.on::after { transform: translateX(18px); }

/* ── CODEC PILLS ── */
.codec-list { display: flex; gap: 6px; flex-wrap: wrap; }
.codec-pill {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.codec-pill.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

/* ── FILE UPLOAD ── */
.file-upload {
  border: 2px dashed var(--border);
  border-radius: 6px;
  padding: 14px;
  text-align: center;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  transition: all 0.15s;
}
.file-upload:hover { border-color: var(--primary); color: var(--primary); }
.file-upload .current { font-weight: 600; color: var(--text-sec); font-size: 11px; display: block; margin-top: 4px; }

/* ── SECTION HIDDEN ── */
.section { display: none; }
.section.active { display: block; }

/* ── SEPARATOR ── */
.sep { border-top: 1px solid var(--border); margin: 18px 0; }

/* ── ALERT BOX ── */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-info { background: var(--primary-soft); color: var(--primary); border: 1px solid rgba(74,108,247,0.15); }
.alert-warning { background: var(--warning-soft); color: #a06b1b; border: 1px solid rgba(229,148,46,0.2); }
/* ── TOAST NOTIFICATIONS ── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 280px;
}
.toast-success { background: #166534; color: #fff; }
.toast-error { background: #991b1b; color: #fff; }
.toast-info { background: #1e40af; color: #fff; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  padding: 28px;
  min-width: 400px;
  max-width: 540px;
}
.modal h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── LOADING STATES ── */
.btn.loading { opacity: 0.6; pointer-events: none; }
.btn.loading::after {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── STATUS INDICATORS ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 99px;
}
.status-badge::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
}
.status-badge.online { background: var(--success-soft); color: var(--success); }
.status-badge.online::before { background: var(--success); }
.status-badge.offline { background: var(--danger-soft); color: var(--danger); }
.status-badge.offline::before { background: var(--danger); }
.status-badge.unknown { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.status-badge.unknown::before { background: var(--text-muted); }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  font-size: 13px;
}
.empty-state .icon { font-size: 32px; display: block; margin-bottom: 8px; }


/* ── SIMULATEUR & LOGS ── */
.sim-result {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
  max-height: 400px;
  overflow-y: auto;
}
.sim-step {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.sim-step:last-child { border-bottom: none; }
.sim-step-num {
  background: var(--primary);
  color: #fff;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}
.sim-step-content { flex: 1; }
.sim-step-label { font-weight: 600; color: var(--text); }
.sim-step-detail { color: var(--text-sec); margin-top: 2px; }

.sim-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.sim-badge.ok { background: var(--success-soft); color: var(--success); }
.sim-badge.fail { background: var(--danger-soft); color: var(--danger); }
.sim-badge.warn { background: var(--warning-soft); color: var(--warning); }

.log-level {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.log-level.info { background: var(--primary-soft); color: var(--primary); }
.log-level.warn { background: var(--warning-soft); color: var(--warning); }
.log-level.error { background: var(--danger-soft); color: var(--danger); }

.log-direction {
  font-size: 11px;
  font-weight: 600;
}
.log-direction.entrant { color: var(--success); }
.log-direction.sortant { color: var(--primary); }
.log-direction.system { color: var(--text-muted); }

.log-token {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
}
.log-token:hover { color: var(--primary); text-decoration: underline; }

.log-stats-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.log-stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 120px;
  text-align: center;
}
.log-stat-card .num { font-size: 24px; font-weight: 700; }
.log-stat-card .label { font-size: 11px; color: var(--text-muted); }

.cache-table { width: 100%; }
.cache-table th { font-size: 11px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px; }
.cache-table td { font-size: 12px; padding: 6px 8px; }
.cache-table .mono { font-family: 'IBM Plex Mono', monospace; }
