/* ─── TRIFORMS — Components CSS ───────────────────────────────────────────── */

/* ─── Card ────────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.card-sm  { padding: 1rem; }
.card-lg  { padding: 2rem; }

/* ─── Boutons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .625rem 1.25rem;
  border-radius: var(--r);
  font-size: .875rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--t);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); border-color: var(--primary-dark); text-decoration: none; color:#fff; }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--border);
}
.btn-outline:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-light); text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-2); color: var(--text); text-decoration: none; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { opacity: .9; text-decoration: none; color:#fff; }

.btn-sm { padding: .4rem .875rem; font-size: .8125rem; }
.btn-lg { padding: .875rem 2rem;  font-size: 1rem; }
.btn-block { width: 100%; }

/* ─── Formulaires ─────────────────────────────────────────────────────────── */

.form-group {
  display: flex;
  flex-direction: column;
  gap: .375rem;
}

.form-label {
  font-size: .875rem;
  font-weight: 500;
  color: var(--text);
}
.form-label .required {
  color: var(--danger);
  margin-left: .2rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: .625rem .875rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: .9375rem;
  color: var(--text);
  background: var(--surface);
  transition: var(--t);
  outline: none;
  font-family: inherit;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-3); }

.form-textarea { resize: vertical; min-height: 100px; }

.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; background-size: 1rem; padding-right: 2.5rem; }

.form-hint  { font-size: .8125rem; color: var(--text-2); }
.form-error { font-size: .8125rem; color: var(--danger); }

.form-input.is-error,
.form-select.is-error,
.form-textarea.is-error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(239,68,68,.12); }

/* Radio + Checkbox */
.radio-group, .check-group { display: flex; flex-direction: column; gap: .5rem; }
.radio-item, .check-item {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .625rem .875rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
  transition: var(--t);
  user-select: none;
}
.radio-item:hover, .check-item:hover { border-color: var(--primary); background: var(--primary-light); }
.radio-item input, .check-item input { accent-color: var(--primary); width: 1rem; height: 1rem; flex-shrink: 0; }
.radio-item.selected, .check-item.selected { border-color: var(--primary); background: var(--primary-light); }

/* Rating */
.rating-group { display: flex; gap: .5rem; flex-wrap: wrap; }
.rating-btn {
  width: 2.75rem; height: 2.75rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--t);
  color: var(--text-2);
}
.rating-btn:hover   { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.rating-btn.active  { background: var(--primary); border-color: var(--primary); color: #fff; }
.rating-labels { display: flex; justify-content: space-between; font-size: .75rem; color: var(--text-2); margin-top: .375rem; }

/* ─── Alerts / Badges ─────────────────────────────────────────────────────── */

.alert {
  padding: .875rem 1.125rem;
  border-radius: var(--r);
  font-size: .9rem;
  border-left: 4px solid;
  display: flex;
  gap: .75rem;
  align-items: flex-start;
}
.alert-success { background: var(--success-bg); border-color: var(--success); color: #166534; }
.alert-warning { background: var(--warning-bg); border-color: var(--warning); color: #92400e; }
.alert-danger  { background: var(--danger-bg);  border-color: var(--danger);  color: #991b1b; }
.alert-info    { background: var(--primary-light); border-color: var(--primary); color: #3730a3; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .625rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-bg); color: #166534; }
.badge-warning { background: var(--warning-bg); color: #92400e; }
.badge-danger  { background: var(--danger-bg);  color: #991b1b; }
.badge-gray    { background: var(--bg-2); color: var(--text-2); }

/* ─── Table ───────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .75rem 1rem;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: .875rem 1rem;
  font-size: .9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg); }

/* ─── Modal ───────────────────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 2rem;
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-2); padding: 0; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-footer { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.5rem; }

/* ─── Toast ───────────────────────────────────────────────────────────────── */

#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: .5rem;
  z-index: 2000;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: .75rem 1.25rem;
  border-radius: var(--r);
  font-size: .875rem;
  box-shadow: var(--shadow-lg);
  animation: slideIn .2s ease;
  max-width: 340px;
}
.toast.success { background: #166534; }
.toast.error   { background: #991b1b; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── Tabs ────────────────────────────────────────────────────────────────── */

.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; }
.tab {
  padding: .625rem 1.25rem;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--t);
}
.tab:hover  { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ─── Divider ─────────────────────────────────────────────────────────────── */

.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.divider-text { display: flex; align-items: center; gap: 1rem; color: var(--text-2); font-size: .875rem; }
.divider-text::before, .divider-text::after { content: ''; flex: 1; border-top: 1px solid var(--border); }

/* ─── Spinner ─────────────────────────────────────────────────────────────── */

.spinner {
  width: 1.25rem; height: 1.25rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .65s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Sidebar admin ───────────────────────────────────────────────────────── */

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 0 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.sidebar-logo a { text-decoration: none; }
.sidebar-logo .logo-text { font-size: 1.25rem; font-weight: 800; color: var(--primary); }
.sidebar-logo .logo-sub  { font-size: .75rem; color: var(--text-2); }

.sidebar-nav { flex: 1; padding: 0 .75rem; }
.nav-section { margin-bottom: 1.5rem; }
.nav-section-label { font-size: .6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); padding: 0 .5rem; margin-bottom: .375rem; }
.nav-item {
  display: flex; align-items: center; gap: .625rem;
  padding: .5rem .75rem;
  border-radius: var(--r);
  font-size: .875rem;
  color: var(--text-2);
  text-decoration: none;
  cursor: pointer;
  transition: var(--t);
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover  { background: var(--bg-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 500; }
.nav-item svg    { width: 1.1rem; height: 1.1rem; flex-shrink: 0; }

.sidebar-footer { padding: .75rem; border-top: 1px solid var(--border); margin-top: .5rem; }

/* ─── Admin topbar ────────────────────────────────────────────────────────── */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.topbar-title { font-size: 1.125rem; font-weight: 600; }

/* ─── Empty state ─────────────────────────────────────────────────────────── */

.empty {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-2);
}
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty h3   { color: var(--text); margin-bottom: .5rem; }

/* ─── Stat cards ──────────────────────────────────────────────────────────── */

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.stat-label { font-size: .8125rem; color: var(--text-2); font-weight: 500; margin-bottom: .5rem; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--text); }
.stat-sub   { font-size: .8125rem; color: var(--text-2); margin-top: .25rem; }

/* ─── Form builder champ ──────────────────────────────────────────────────── */

.field-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  cursor: pointer;
  transition: var(--t);
}
.field-row:hover     { border-color: var(--primary); box-shadow: var(--shadow); }
.field-row.selected  { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.field-row .drag-handle { color: var(--text-3); cursor: grab; font-size: 1.1rem; }
.field-row .field-type-badge {
  font-size: .7rem;
  font-weight: 700;
  background: var(--bg-2);
  color: var(--text-2);
  padding: .2rem .5rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}
.field-row .field-label { flex: 1; font-size: .9375rem; font-weight: 500; }
.field-row .field-required { color: var(--danger); font-size: .8rem; }

/* ─── Progress bar ────────────────────────────────────────────────────────── */

.progress { background: var(--bg-2); border-radius: 99px; height: 6px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 99px; transition: width .3s ease; }

/* ─── RGPD Notice ─────────────────────────────────────────────────────────── */

.notice-block {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--r-lg);
  padding: 1.25rem;
}
.notice-block h4 { color: #92400e; margin-bottom: .75rem; }
.notice-block p  { font-size: .875rem; color: #78350f; line-height: 1.7; }
