/* ================================================================
   Carnet de Mots — Administration
   Thème sobre, épuré, distinct du thème "tableau noir" de l'app.
   ================================================================ */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --blue:    #3B82F6;
  --blue-hv: #2563EB;
  --green:   #16A34A;
  --red:     #DC2626;
  --slate:   #1E293B;
  --bg:      #F1F5F9;
  --card:    #FFFFFF;
  --border:  #E2E8F0;
  --text:    #0F172A;
  --muted:   #64748B;
  --radius:  10px;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Helvetica, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
a { color: inherit; }
code {
  background: #E2E8F0;
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: "Courier New", "Menlo", monospace;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ── Mise en page ─────────────────────────────────────────────── */
.page { display: flex; flex-direction: column; min-height: 100vh; }

.page-header {
  background: var(--slate);
  color: #F8FAFC;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.page-header-left { display: flex; align-items: center; gap: 1rem; }

.back-link {
  color: #94A3B8;
  text-decoration: none;
  font-size: 0.83rem;
  font-weight: 500;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  border: 1px solid #334155;
}
.back-link:hover { color: #F8FAFC; border-color: #475569; }

.header-title { font-weight: 700; font-size: 1rem; letter-spacing: 0.01em; }

.page-main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 2rem 1.25rem 3rem;
}

/* ── Carte centrale ───────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.07);
  padding: 2rem;
  width: 100%;
  max-width: 700px;
}

.card-title { font-size: 1.2rem; font-weight: 700; margin: 0 0 0.3rem; }
.card-subtitle { color: var(--muted); font-size: 0.88rem; margin: 0 0 1.75rem; line-height: 1.5; }

/* ── Login ────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-logo  { font-size: 2.5rem; margin-bottom: 0.5rem; }
.login-title { font-size: 1.4rem; font-weight: 700; margin: 0 0 0.25rem; }
.login-sub   { color: var(--muted); font-size: 0.88rem; margin: 0 0 1.75rem; }

/* ── Champs de formulaire ─────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 0.35rem; }

.field-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.field-hint {
  font-size: 0.8rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
}

.field-input,
.field-select {
  padding: 0.55rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.92rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field-input:focus,
.field-select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}
.field-input:disabled,
.field-select:disabled {
  background: #F8FAFC;
  color: #A0AABB;
  cursor: not-allowed;
}

/* ── Grille de sélecteurs cascadants ─────────────────────────── */
.selectors {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}
.select-wrap { position: relative; display: flex; align-items: center; gap: 0.5rem; }
.select-wrap .field-select { flex: 1; }

/* ── Spinner ──────────────────────────────────────────────────── */
.spinner { display: inline-block; animation: spin 0.7s linear infinite; opacity: 0.6; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Boutons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1.15rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.12s, opacity 0.12s;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--blue-hv); }

.btn-ghost { background: rgba(255, 255, 255, 0.1); color: #F8FAFC; }
.btn-ghost:not(:disabled):hover { background: rgba(255, 255, 255, 0.2); }

.btn-block { width: 100%; margin-top: 0.5rem; }

/* ── Zone CSV + aperçu ────────────────────────────────────────── */
.csv-section { display: flex; flex-direction: column; gap: 1.1rem; }

.csv-textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: "Courier New", "Menlo", monospace;
  font-size: 0.85rem;
  line-height: 1.65;
  resize: vertical;
  background: #FAFAFA;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.csv-textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.csv-textarea:disabled { background: #F8FAFC; color: #A0AABB; cursor: not-allowed; }
.csv-textarea::placeholder { color: #A0AABB; }

/* ── Aperçu CSV ───────────────────────────────────────────────── */
.preview {
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
}
.preview-header {
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.preview-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}
.preview-row { display: flex; align-items: baseline; gap: 0.5rem; font-size: 0.84rem; }
.preview-icon { font-size: 0.72rem; flex-shrink: 0; }
.preview-row.valid   { color: #14532D; }
.preview-row.invalid { color: #7F1D1D; }
.preview-arrow { color: var(--muted); margin: 0 0.15rem; }
.preview-note  { color: #4B5563; font-style: italic; }
.preview-err   { font-style: italic; }

/* ── Alertes résultat ─────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.55;
}
.alert-success { background: #DCFCE7; color: #14532D; border: 1px solid #BBF7D0; }
.alert-error   { background: #FEE2E2; color: #7F1D1D; border: 1px solid #FECACA; }

/* ─── Sections accordéon ──────────────────────────────────────────── */

.admin-sections {
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.collapse-wrap {
  width: 100%;
  max-width: 700px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.07);
  overflow: hidden;
}

.collapse-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--card);
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.12s;
}
.collapse-header:hover { background: #F8FAFC; }
.collapse-header:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.collapse-wrap.is-open > .collapse-header { border-bottom: 1px solid var(--border); }

.collapse-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.collapse-icon { font-size: 1rem; line-height: 1; }

.collapse-chevron {
  font-size: 0.65rem;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform 0.2s;
}
.collapse-wrap.is-open .collapse-chevron { transform: rotate(180deg); }

.collapse-body { padding: 1.5rem; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 480px) {
  .page-header { padding: 0.75rem 1rem; }
  .card { padding: 1.5rem 1.1rem; }
  .page-main { padding: 1.25rem 0.75rem 2.5rem; }
}
