/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:   #0f2041;
  --gold:   #b48c3c;
  --slate:  #5a697d;
  --light:  #f5f7fa;
  --white:  #ffffff;
  --red:    #a02323;
  --green:  #1a7a4a;
  --orange: #c06010;
  --border: #dde2ea;
  --shadow: 0 2px 8px rgba(15,32,65,.10);
  --radius: 8px;
  --font:   'Inter', system-ui, -apple-system, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--light);
  color: #1a2235;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, #1a3a6e 100%);
}

.login-card {
  background: var(--white);
  border-radius: 12px;
  padding: 48px 40px;
  width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: .04em;
}

.login-logo .tagline {
  font-size: 11px;
  color: var(--gold);
  letter-spacing: .08em;
  margin-top: 4px;
}

.login-logo .bar {
  width: 40px; height: 3px;
  background: var(--gold);
  margin: 12px auto 0;
  border-radius: 2px;
}

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

.sidebar {
  width: 220px;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo h1 {
  font-size: 13px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: .05em;
  margin-top: 8px;
}

.sidebar-logo .tagline {
  font-size: 8.5px;
  color: var(--gold);
  letter-spacing: .05em;
  margin-top: 4px;
  line-height: 1.4;
}

.sidebar nav { flex: 1; padding: 16px 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
  border-left: 3px solid transparent;
}

.nav-item:hover { color: var(--white); background: rgba(255,255,255,.06); }
.nav-item.active { color: var(--white); border-left-color: var(--gold); background: rgba(255,255,255,.08); }

.nav-icon { font-size: 16px; width: 18px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-footer a {
  display: flex; align-items: center; gap: 8px;
  color: rgba(255,255,255,.5);
  font-size: 12px;
  text-decoration: none;
  transition: color .15s;
}
.sidebar-footer a:hover { color: rgba(255,255,255,.8); }

.main-content {
  margin-left: 220px;
  flex: 1;
  padding: 32px;
  max-width: 1100px;
}

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
}

.page-header .subtitle {
  font-size: 13px;
  color: var(--slate);
  margin-top: 2px;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ── KPI cards ───────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}

.kpi-card .kpi-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}

.kpi-card .kpi-label {
  font-size: 11px;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: 6px;
}

.kpi-card.green .kpi-value { color: var(--green); }
.kpi-card.red   .kpi-value { color: var(--red); }
.kpi-card.gold  .kpi-value { color: var(--gold); }

/* ── Tableau ─────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 2px solid var(--border);
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8f9fc; }

/* ── Badges statut ───────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
}

.badge-pending    { background: #fef3cd; color: #856404; }
.badge-generated  { background: #d1ecf1; color: #0c5460; }
.badge-submitted  { background: #d4edda; color: #155724; }
.badge-sent       { background: #cce5ff; color: #004085; }
.badge-delivered  { background: #d4edda; color: #155724; }
.badge-failed     { background: #f8d7da; color: #721c24; }
.badge-returned   { background: #fff3cd; color: #856404; }

/* ── API status dots ─────────────────────────────────────────────────────── */
.api-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.api-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 12px;
}

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot.ok  { background: var(--green); }
.dot.nok { background: var(--red); }
.dot.warn { background: var(--gold); }

/* ── Formulaires ─────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font);
  background: var(--white);
  color: #1a2235;
  transition: border-color .15s, box-shadow .15s;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(15,32,65,.1);
}

input[type="file"] { padding: 8px; }

textarea { resize: vertical; font-family: 'Fira Code', monospace; font-size: 12px; }

.form-hint { font-size: 11px; color: var(--slate); margin-top: 4px; }

.checkbox-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; cursor: pointer;
}

input[type="checkbox"] { width: auto; cursor: pointer; }

/* ── Boutons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all .15s;
}

.btn-primary {
  background: var(--navy);
  color: var(--white);
}
.btn-primary:hover { background: #1a3a6e; }

.btn-gold {
  background: var(--gold);
  color: var(--white);
}
.btn-gold:hover { background: #9a7830; }

.btn-outline {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--light); }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-danger { background: var(--red); color: var(--white); }

/* ── Alertes ─────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 20px;
}
.alert-error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ── Progress bar ────────────────────────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--border);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 4px;
  transition: width .4s ease;
}

/* ── Country flags ───────────────────────────────────────────────────────── */
.flag { font-size: 16px; }

/* ── Éditeur JSON ────────────────────────────────────────────────────────── */
.json-editor-wrap { position: relative; }

.json-toolbar {
  display: flex; gap: 8px;
  padding: 8px 12px;
  background: #f0f2f5;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
}

.json-editor-wrap textarea {
  border-radius: 0 0 6px 6px;
  border-top: none;
  min-height: 420px;
}

.validate-result {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  display: none;
}

/* ── Spinner ─────────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── Responsive mini-fixes ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 100%; height: auto; position: relative; }
  .main-content { margin-left: 0; padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
