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

:root {
  --bg:          #f7f7fa;
  --surface:     #ffffff;
  --border:      #e5e7eb;
  --text:        #1f2937;
  --text-muted:  #6b7280;
  --primary:     #232351;
  --primary-light:#3d3d7a;
  --radius:      12px;
  --shadow:      0 2px 8px rgba(0,0,0,.08);
  --shadow-hover:0 6px 24px rgba(0,0,0,.14);

  --c-framework: #232351;
  --c-concept:   #fd3994;
  --c-outil:     #04d89c;
  --c-principe:  #f1be52;
  --c-question:  #818cf8;
  --c-pattern:   #e67e22;
  --c-reference: #6b7280;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ─── Header ────────────────────────────────────────────────────────────────── */
.header {
  background: #232351;
  
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 64px;
}
.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  text-decoration: none;
}
.search-bar {
  flex: 1;
  position: relative;
}
.search-bar input {
  width: 100%;
  padding: .55rem 1rem .55rem 2.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
  background: var(--bg);
  color: var(--text);
  transition: border .2s, box-shadow .2s;
}
.search-bar input:focus {
  outline: none;
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(35,35,81,.12);
}
.search-bar .icon {
  position: absolute;
  left: .75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: .9rem;
}
.header-actions { display: flex; gap: .75rem; align-items: center; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .2s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }

/* ─── Stats bar ─────────────────────────────────────────────────────────────── */
.stats-bar {
  background: var(--primary);
  color: rgba(255,255,255,.85);
  text-align: center;
  padding: .5rem 2rem;
  font-size: .83rem;
  letter-spacing: .02em;
}
.stats-bar strong { color: #fff; }

/* ─── Filters ───────────────────────────────────────────────────────────────── */
.filters {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .75rem 2rem;
}
.filters-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
}
.filter-group { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.filter-label { font-size: .8rem; color: var(--primary); font-weight: 700; }
.filter-btn {
  padding: .35rem .85rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: .82rem;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active {
  background: var(--primary);
  border-color: #fff;
  color: #fff;
  font-weight: 500;
}
.filter-select {
  padding: .35rem .85rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: .82rem;
  cursor: pointer;
  outline: none;
}
.filter-select:focus { border-color: var(--primary); }

/* ─── Grid ──────────────────────────────────────────────────────────────────── */
.main { max-width: 1400px; margin: 0 auto; padding: 1.5rem 2rem; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.empty-state {
  grid-column: 1/-1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-state .big { font-size: 3rem; margin-bottom: .75rem; }
.loading {
  grid-column: 1/-1;
  display: flex;
  justify-content: center;
  padding: 3rem;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Card ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  cursor: pointer;
  transition: box-shadow .2s, transform .15s, border-color .2s;
  position: relative;
  overflow: hidden;
}
.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
  border-color: transparent;
}
.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: .75rem;
  gap: .5rem;
}
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 12px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #fff;
  white-space: nowrap;
}
.badge-framework { background: var(--c-framework); }
.badge-concept   { background: var(--c-concept); }
.badge-outil_coaching { background: var(--c-outil); color: #0a4a35; }
.badge-principe  { background: var(--c-principe); color: #5a3e00; }
.badge-question  { background: var(--c-question); }
.badge-pattern   { background: var(--c-pattern); color: #fff; }
.badge-reference { background: var(--c-reference); }

.badge-univers {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: .2rem .6rem;
  border-radius: 12px;
  font-size: .7rem;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .5rem;
  line-height: 1.3;
}
.card-def {
  font-size: .84rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: .75rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  border-top: 1px solid var(--border);
  padding-top: .7rem;
  margin-top: auto;
}
.card-meta-row {
  display: flex;
  align-items: flex-start;
  gap: .4rem;
  font-size: .78rem;
  color: var(--text-muted);
}
.card-meta-row .icon { flex-shrink: 0; }
.card-accent {
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
  border-radius: var(--radius) 0 0 var(--radius);
}

/* ─── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,.2);
  transform: translateY(16px) scale(.98);
  transition: transform .25s ease, opacity .2s;
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-header {
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.modal-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: .75rem;
}
.modal-title { font-size: 1.3rem; font-weight: 700; color: var(--text); line-height: 1.3; }
.modal-close {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-muted);
  padding: .3rem .6rem;
  flex-shrink: 0;
  transition: background .15s;
}
.modal-close:hover { background: var(--border); }
.modal-badges { display: flex; flex-wrap: wrap; gap: .4rem; }
.modal-body { padding: 1.5rem; display: flex; flex-direction: column; gap: 1.1rem; }
.modal-section label {
  display: block;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: .3rem;
}
.modal-section p, .modal-section a {
  font-size: .92rem;
  line-height: 1.6;
  color: var(--text);
}
.modal-section a { color: var(--primary); text-decoration: none; }
.modal-section a:hover { text-decoration: underline; }
.alert-box {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  padding: .75rem 1rem;
}
.alert-box label { color: #c2410c !important; }
.alert-box p { color: #9a3412; }

/* ─── Login page ────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #232351 0%, #3d3d7a 100%);
}
.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: .5rem;
}
.login-title {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: .25rem;
}
.login-sub {
  text-align: center;
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: .4rem;
}
.form-group input {
  width: 100%;
  padding: .65rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
  transition: border .2s, box-shadow .2s;
}
.form-group input:focus {
  outline: none;
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(35,35,81,.12);
}
.login-btn {
  width: 100%;
  padding: .75rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: .5rem;
  transition: background .2s;
}
.login-btn:hover { background: var(--primary-light); }

/* ─── Admin page ────────────────────────────────────────────────────────────── */
.admin-wrap { max-width: 900px; margin: 2rem auto; padding: 0 1.5rem; }
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}
.admin-card h2 { font-size: 1rem; font-weight: 700; color: var(--primary); margin-bottom: 1rem; }
.sync-result {
  background: var(--bg);
  border-radius: 8px;
  padding: 1rem;
  font-size: .85rem;
  color: var(--text);
  margin-top: 1rem;
  white-space: pre-wrap;
  font-family: monospace;
  display: none;
}
.sync-result.visible { display: block; }
.entries-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.entries-table th {
  text-align: left;
  padding: .5rem .75rem;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
}
.entries-table td {
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.entries-table tr:hover td { background: var(--bg); }

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .header-inner { gap: .75rem; }
  .logo-text { display: none; }
  .main { padding: 1rem; }
  .filters { padding: .75rem 1rem; }
  .grid { grid-template-columns: 1fr; }
}

/* Pagination */
.pagination {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 0 8px;
  font-size: .9rem;
  color: var(--text-muted);
}
.pagination button {
  padding: 8px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}
.pagination button:disabled { background: var(--border); color: var(--text-muted); cursor: default; }

/* ─── Police mono + Nunito ──────────────────────────────────────────────────── */
body { font-family: 'Courier New', 'Lucida Console', monospace; }
h1, h2, h3, .card-name, .modal-title, .section-title { font-family: 'Nunito', sans-serif; }
.logo { font-family: 'Nunito', sans-serif !important; font-weight: 900 !important; }

/* Badge figure */
.badge-figure { background: #7c3aed; color: #fff; }

.search-bar input { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.2); color: #fff; }
.search-bar input::placeholder { color: rgba(255,255,255,.5); }
.search-bar input:focus { background: rgba(255,255,255,.15); border-color: #04d89c; box-shadow: none; }
.search-bar .icon { color: rgba(255,255,255,.5); }
.btn-ghost { color: rgba(255,255,255,.7); border-color: rgba(255,255,255,.2); }
.btn-ghost:hover { background: rgba(255,255,255,.1); color: #fff; }

/* Boutons univers colorés */
.filter-univ {
  border-color: var(--univ-color, var(--border));
  color: var(--univ-color, var(--text-muted));
}
.filter-univ:hover {
  background: var(--univ-color, var(--border));
  color: #fff;
  border-color: var(--univ-color, var(--border));
}
.filter-univ.active {
  background: var(--univ-color, var(--primary));
  border-color: var(--univ-color, var(--primary));
  color: #fff;
  font-weight: 600;
}

/* Boutons type colorés selon leur couleur propre */
.filter-btn[data-type="framework"]:hover,
.filter-btn[data-type="framework"].active { background: var(--c-framework); border-color: var(--c-framework); color: #fff; }
.filter-btn[data-type="framework"] { border-color: var(--c-framework); color: var(--c-framework); }

.filter-btn[data-type="concept"]:hover,
.filter-btn[data-type="concept"].active { background: var(--c-concept); border-color: var(--c-concept); color: #fff; }
.filter-btn[data-type="concept"] { border-color: var(--c-concept); color: var(--c-concept); }

.filter-btn[data-type="outil_coaching"]:hover,
.filter-btn[data-type="outil_coaching"].active { background: var(--c-outil); border-color: var(--c-outil); color: #0a4a35; }
.filter-btn[data-type="outil_coaching"] { border-color: var(--c-outil); color: #059669; }

.filter-btn[data-type="question"]:hover,
.filter-btn[data-type="question"].active { background: var(--c-question); border-color: var(--c-question); color: #fff; }
.filter-btn[data-type="question"] { border-color: var(--c-question); color: var(--c-question); }

.filter-btn[data-type="pattern"]:hover,
.filter-btn[data-type="pattern"].active { background: var(--c-pattern); border-color: var(--c-pattern); color: #fff; }
.filter-btn[data-type="pattern"] { border-color: var(--c-pattern); color: var(--c-pattern); }

.filter-btn[data-type="reference"]:hover,
.filter-btn[data-type="reference"].active { background: var(--c-reference); border-color: var(--c-reference); color: #fff; }
.filter-btn[data-type="reference"] { border-color: var(--c-reference); color: var(--c-reference); }

.filter-btn[data-type="figure"]:hover,
.filter-btn[data-type="figure"].active { background: #7c3aed; border-color: #7c3aed; color: #fff; }
.filter-btn[data-type="figure"] { border-color: #7c3aed; color: #7c3aed; }

/* Placeholder blanc dans le header */
header input::placeholder { color: rgba(255,255,255,.5); }
