/* ============================================================
   Welki — Design System
   Thème clair, accent orange. Épuré, professionnel, sans dégradés.
   ============================================================ */

:root {
  /* Surfaces */
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f3f4f6;

  /* Texte */
  --text: #111827;
  --text-secondary: #374151;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;

  /* Bordures */
  --border: #e5e7eb;
  --border-strong: #d1d5db;

  /* Accent orange */
  --accent: #f97316;
  --accent-hover: #ea580c;
  --accent-active: #c2410c;
  --accent-soft: #fff7ed;
  --accent-soft-2: #ffedd5;
  --accent-border: #fed7aa;
  --accent-ring: rgba(249, 115, 22, 0.18);

  /* États */
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --danger: #dc2626;
  --danger-soft: #fef2f2;

  /* Ombres (discrètes) */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);

  /* Rayons */
  --r-sm: 6px;
  --r: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-full: 999px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

/* L'attribut [hidden] doit TOUJOURS masquer, même si une classe définit un display. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }

::selection { background: var(--accent-soft-2); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--r);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  white-space: nowrap;
  line-height: 1;
}
.btn svg { width: 17px; height: 17px; flex-shrink: 0; }

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

.btn-secondary { background: var(--surface); color: var(--text-secondary); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-3); }

.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 13px 24px; font-size: 16px; }
.btn-block { width: 100%; }

/* ---------- Navbar ---------- */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: -0.03em; }
.brand .brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
}
.brand .brand-mark svg { width: 18px; height: 18px; }

.hnav { display: flex; align-items: center; gap: 4px; }
.hlink {
  padding: 8px 14px; border-radius: var(--r); font-size: 14px; font-weight: 600;
  color: var(--text-muted); transition: background-color 0.1s, color 0.1s;
}
.hlink:hover { background: var(--surface-3); color: var(--text); }
.hlink.active { color: var(--accent-active); background: var(--accent-soft); }

.nav-user { display: flex; align-items: center; gap: 12px; }
.nav-user .uname { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.avatar { width: 34px; height: 34px; border-radius: var(--r-full); object-fit: cover; border: 1px solid var(--border); }

/* ---------- Cartes ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}

/* ---------- Conteneur ---------- */
.container { max-width: 1120px; margin: 0 auto; padding: 0 28px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 600;
  background: var(--surface-3); color: var(--text-muted);
}
.badge svg { width: 13px; height: 13px; }
.badge-accent { background: var(--accent-soft); color: var(--accent-active); }
.badge-success { background: var(--success-soft); color: var(--success); }

/* ---------- Form ---------- */
.field { margin-bottom: 14px; }
.label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 6px;
}
.input, .select, .textarea {
  width: 100%;
  font-family: inherit; font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  padding: 9px 11px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.textarea { resize: vertical; min-height: 70px; }
.hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: var(--text); color: #fff;
  padding: 11px 18px; border-radius: var(--r);
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  z-index: 9999; display: flex; align-items: center; gap: 9px;
}
.toast svg { width: 17px; height: 17px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: #14532d; }
.toast.error { background: #7f1d1d; }

/* ---------- Spinner ---------- */
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.center-screen { display: grid; place-items: center; min-height: 60vh; gap: 14px; color: var(--text-muted); }

/* ---------- Grille / cartes de création ---------- */
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.ccard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  overflow: hidden; box-shadow: var(--shadow-sm); transition: box-shadow 0.12s, border-color 0.12s;
}
.ccard:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.ccard-prev { aspect-ratio: 800 / 300; background: var(--surface-3); }
.ccard-prev img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ccard-body { padding: 12px 14px; }
.ccard-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ccard-author { display: flex; align-items: center; gap: 7px; margin-top: 8px; color: var(--text-muted); font-size: 12.5px; }
.ccard-author img { width: 22px; height: 22px; border-radius: 50%; }
.ccard-actions { display: flex; align-items: center; gap: 4px; margin-top: 12px; flex-wrap: wrap; }
.cbtn {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 9px;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface);
  cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-secondary);
}
.cbtn:hover { background: var(--surface-2); }
.cbtn svg { width: 15px; height: 15px; }
.cbtn.on { color: var(--accent-active); border-color: var(--accent-border); background: var(--accent-soft); }
.cbtn.danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.cbtn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.cbtn.primary:hover { background: var(--accent-hover); }

/* ---------- Modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(17, 24, 39, 0.5); z-index: 2000;
  display: grid; place-items: center; padding: 20px;
}
.modal-bg[hidden] { display: none; }
.modal {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 440px; padding: 22px; max-height: 85vh; overflow-y: auto;
}
.modal h3 { font-size: 17px; margin-bottom: 4px; }
.modal p.sub { color: var(--text-muted); font-size: 13.5px; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
