/* ============================================================
   Réplicant · Fiches Produits — design simple & moderne
   ============================================================ */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e5e9f2;
  --text: #1c2333;
  --text-soft: #64708a;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --success: #16a34a;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- En-tête ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 60px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
}
.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 15px;
}
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tab {
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 600;
  color: var(--text-soft);
  white-space: nowrap;
  cursor: pointer;
  border: none;
  background: none;
  font-size: 14px;
}
.tab:hover { background: var(--bg); color: var(--text); }
.tab.active { background: var(--primary-soft); color: var(--primary); }
.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
}
.user-name { font-weight: 600; font-size: 13px; color: var(--text-soft); }
.btn-logout {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-logout:hover { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }

/* ---------- Conteneur ---------- */
.container { max-width: 1100px; margin: 24px auto; padding: 0 20px 60px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card + .card { margin-top: 18px; }
.card h2 { margin: 0 0 4px; font-size: 19px; }
.card .subtitle { color: var(--text-soft); margin: 0 0 20px; font-size: 13.5px; }

/* ---------- Formulaires ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.field input, .field select, .field textarea {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #fbfcfe;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .14);
  background: #fff;
}
.field textarea { resize: vertical; min-height: 80px; }
.field .hint { font-size: 12px; color: var(--text-soft); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 9px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: #e9edf5; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803d; }
.actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* ---------- Statut / badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-ok { background: #dcfce7; color: #15803d; }
.badge-info { background: var(--primary-soft); color: var(--primary); }
.badge-warn { background: #fef9c3; color: #a16207; }

/* ---------- Aperçu génération ---------- */
.preview { display: none; }
.preview.visible { display: block; }
.lang-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  background: #fbfcfe;
}
.lang-block h4 {
  margin: 0 0 10px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.lang-flag { font-size: 16px; }
.kv { font-size: 13.5px; margin: 3px 0; }
.kv b { color: var(--text-soft); font-weight: 600; }
.kv .val { color: var(--text); }
.meta-chip {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 6px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 6px;
}

/* ---------- Modale ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  backdrop-filter: blur(2px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  max-width: 480px;
  width: 100%;
  padding: 26px;
  animation: pop .18s ease-out;
  max-height: 92vh;
  overflow-y: auto;
}
.modal-lg { max-width: 920px; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h3 { margin: 0 0 10px; font-size: 17px; display: flex; gap: 10px; align-items: center; }
.modal p { color: var(--text-soft); font-size: 14px; margin: 0 0 6px; }
.modal .product-id {
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  color: var(--danger);
  border-radius: 9px;
  padding: 10px 14px;
  font-weight: 700;
  margin: 12px 0;
  font-size: 14.5px;
}
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ---------- Toasts ---------- */
.toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: slidein .2s ease-out;
  max-width: 360px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------- Journal ---------- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--text-soft);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data tr:hover td { background: #fafbff; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: end; }

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #eef2ff 0%, #f4f6fb 55%, #fdf2f8 100%);
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 36px;
  width: 100%;
  max-width: 400px;
}
.login-card .brand-logo { width: 44px; height: 44px; font-size: 20px; border-radius: 12px; margin-bottom: 16px; }
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card .sub { color: var(--text-soft); font-size: 13.5px; margin: 0 0 24px; }
.login-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 16px;
}
.login-card .btn { width: 100%; justify-content: center; margin-top: 6px; padding: 11px; }

/* ---------- Cases à cocher caractéristiques ---------- */
.checkbox-group {
  max-height: 190px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 12px;
  background: #fbfcfe;
}
.check-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 3px 0;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--text);
}
.check-item:hover { color: var(--primary); }
.check-item input { accent-color: var(--primary); margin-top: 2px; flex-shrink: 0; }
.check-item .cat-indent { display: inline-block; }

/* ---------- Récap éditable (modal) ---------- */
.modal-overlay.recap-open .modal { max-width: 940px; }
.recap-field { margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.recap-field label { font-size: 12.5px; font-weight: 600; color: var(--text-soft); }
.recap-input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13.5px;
  font-family: inherit;
  width: 100%;
  outline: none;
  background: #fff;
}
.recap-textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
  min-height: 90px;
  resize: vertical;
  outline: none;
  background: #fff;
  line-height: 1.5;
}
.recap-input:focus, .recap-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
#modal-body details {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: #fbfcfe;
}
#modal-body details summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  user-select: none;
}
#modal-body details summary:hover { color: var(--primary); }

/* ---------- Divers ---------- */
.spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-hint { color: var(--text-soft); font-size: 13.5px; margin: 12px 0; }
.empty { color: var(--text-soft); text-align: center; padding: 30px 0; font-size: 14px; }
