/* ============================================================
   Recherche intelligente des Codes juridiques français
   Stylesheet: light + dark themes, responsive
   ============================================================ */

/* ─── Theme tokens ─────────────────────────────────────────── */
:root {
  --bg:           #f7f8fa;
  --surface:      #ffffff;
  --surface-2:    #f1f3f7;
  --border:       #e3e7ee;
  --border-strong:#c9d1dc;
  --primary:      #0f2a4a;   /* navy */
  --primary-2:    #1b3a63;
  --accent:       #0f766e;   /* emerald */
  --accent-soft:  #d1fae5;
  --gold:         #b08d57;
  --text:         #1a2233;
  --text-muted:   #6b7280;
  --text-faint:   #9aa3b2;
  --shadow:       0 1px 3px rgba(15, 42, 74, 0.06), 0 4px 16px rgba(15, 42, 74, 0.05);
  --shadow-sm:    0 1px 2px rgba(15, 42, 74, 0.05);
  --radius:       12px;
  --radius-sm:    8px;
  --header-bg:    #0f2a4a;
  --header-text:  #ffffff;
  --btn-bg:       #0f2a4a;
  --btn-bg-hover: #1b3a63;
  --btn-text:     #ffffff;
  --mark-bg:      #fbe96b;
  --mark-text:    #1a2233;
  --vig-bg:       #d1fae5;
  --vig-text:     #065f46;
  --abr-bg:       #fee2e2;
  --abr-text:     #991b1b;
  --bar-track:    #e3e7ee;
  --bar-h:        #0f2a4a;
  --bar-l:        #0f766e;
  --bar-s:        #b08d57;
}

[data-theme="dark"] {
  --bg:           #0b1220;
  --surface:      #111a2e;
  --surface-2:    #16213a;
  --border:       #1f2b45;
  --border-strong:#2c3a5a;
  --primary:      #e8edf5;
  --primary-2:    #c7d2e4;
  --accent:       #34d399;
  --accent-soft:  #064e3b;
  --gold:         #d4af73;
  --text:         #e6ebf2;
  --text-muted:   #94a3b8;
  --text-faint:   #64748b;
  --shadow:       0 1px 3px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  --shadow-sm:    0 1px 2px rgba(0, 0, 0, 0.3);
  --radius:       12px;
  --radius-sm:    8px;
  --header-bg:    #0a1424;
  --header-text:  #e6ebf2;
  --btn-bg:       #e8edf5;
  --btn-bg-hover: #ffffff;
  --btn-text:     #0b1220;
  --mark-bg:      #8a6d00;
  --mark-text:    #fff8d6;
  --vig-bg:       #064e3b;
  --vig-text:     #6ee7b7;
  --abr-bg:       #5b1d1d;
  --abr-text:     #fca5a5;
  --bar-track:    #1f2b45;
  --bar-h:        #e8edf5;
  --bar-l:        #34d399;
  --bar-s:        #d4af73;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* ─── Header ───────────────────────────────────────────────── */
header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 1.1rem 2rem;
  border-bottom: 3px solid var(--gold);
}
.header-inner {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand { display: flex; align-items: center; gap: 0.65rem; }
.brand-mark { flex-shrink: 0; }
.brand-text h1 {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino,
               "Book Antiqua", Georgia, serif;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  line-height: 1.1;
}
.brand-text p {
  font-size: 0.74rem;
  opacity: 0.62;
  margin-top: 2px;
  font-weight: 400;
}
.theme-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--header-text);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.theme-toggle:hover { background: rgba(255, 255, 255, 0.18); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ─── Layout ───────────────────────────────────────────────── */
.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

/* ─── Search box ───────────────────────────────────────────── */
.box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.row {
  display: flex;
  gap: 1rem;
  align-items: stretch;
}
textarea {
  flex: 1;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  resize: vertical;
  min-height: 88px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  line-height: 1.5;
}
textarea::placeholder { color: var(--text-faint); }
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 42, 74, 0.1);
}
[data-theme="dark"] textarea:focus {
  box-shadow: 0 0 0 3px rgba(232, 237, 245, 0.12);
}
.kbd-hint {
  font-size: 0.72rem;
  color: var(--text-faint);
  margin-top: 0.45rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.kbd {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ─── Side controls ────────────────────────────────────────── */
.side {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 180px;
  flex-shrink: 0;
}
button#btn {
  background: var(--btn-bg);
  color: var(--btn-text);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.8rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.05s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
button#btn:hover { background: var(--btn-bg-hover); }
button#btn:active { transform: translateY(1px); }
button#btn:disabled { background: var(--text-faint); cursor: not-allowed; opacity: 0.7; }

select {
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  outline: none;
  width: 100%;
  transition: border-color 0.2s;
}
select:focus { border-color: var(--primary); }

/* ─── Alpha slider ─────────────────────────────────────────── */
.slider-row { font-size: 0.78rem; color: var(--text-muted); }
.slider-split {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}
.slider-split .pct {
  font-variant-numeric: tabular-nums;
  display: inline-block;
  min-width: 2.6em;
  text-align: right;
}
.slider-row input[type="range"] {
  width: 100%;
  margin: 4px 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-faint);
}

/* ─── Examples ─────────────────────────────────────────────── */
.examples {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.examples-label {
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-right: 0.1rem;
}

/* Example type toggle */
.ex-toggle {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
}
.ex-btn {
  background: transparent;
  border: none;
  padding: 0.32rem 0.8rem;
  font-size: 0.78rem;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.ex-btn:hover { color: var(--text); }
.ex-btn.active {
  background: var(--btn-bg);
  color: var(--btn-text);
  font-weight: 600;
}

/* Example chips list (below the toggle) */
.ex-list {
  margin-top: 0.65rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.28rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
[data-theme="dark"] .chip:hover { color: var(--accent); }

/* ─── Status ───────────────────────────────────────────────── */
.status {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
  min-height: 1.3em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.status .count { font-weight: 600; color: var(--text); }
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Result cards ─────────────────────────────────────────── */
#results { display: flex; flex-direction: column; gap: 0.8rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--primary);
  transition: box-shadow 0.2s, transform 0.05s;
}
.card:hover { box-shadow: var(--shadow); }
[data-theme="dark"] .card { border-left-color: var(--gold); }

.card-top {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.art-num {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino,
               "Book Antiqua", Georgia, serif;
  font-weight: 700;
  font-size: 1.08rem;
  color: var(--text);
}

/* Score bars */
.scores {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-left: auto;
  min-width: 220px;
  flex: 0 1 280px;
}
.score-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
}
.score-label {
  width: 64px;
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
}
.bar-track {
  flex: 1;
  height: 6px;
  background: var(--bar-track);
  border-radius: 3px;
  overflow: hidden;
}
.bar-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.bar-h { background: var(--bar-h); }
.bar-l { background: var(--bar-l); }
.bar-s { background: var(--bar-s); }
.score-val {
  width: 34px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}

/* Breadcrumb */
.bc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
  line-height: 1.4;
}
.bc .sep { color: var(--text-faint); margin: 0 5px; }

/* Article text */
.texte {
  font-size: 0.94rem;
  line-height: 1.7;
  color: var(--text);
}
.texte mark {
  background: var(--mark-bg);
  color: var(--mark-text);
  border-radius: 2px;
  padding: 0 1px;
}

/* Card footer */
.foot {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.etat {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.etat-VIGUEUR { background: var(--vig-bg); color: var(--vig-text); }
.etat-ABROGE  { background: var(--abr-bg); color: var(--abr-text); }
.etat-ABROGE_DIFFERE { background: #fef3c7; color: #92400e; }
[data-theme="dark"] .etat-ABROGE_DIFFERE { background: #78350f; color: #fcd34d; }

.legi {
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.legi:hover { text-decoration: underline; }

.copy-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  font-size: 0.76rem;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.copy-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--primary);
}
.copy-btn.copied {
  color: var(--accent);
  border-color: var(--accent);
}
.copy-btn svg { width: 13px; height: 13px; }

/* ─── Empty / no results ───────────────────────────────────── */
.no-res {
  text-align: center;
  color: var(--text-faint);
  padding: 3.5rem 1rem;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.no-res svg { width: 40px; height: 40px; margin-bottom: 0.75rem; opacity: 0.5; }
.no-res p { font-size: 0.95rem; }

.empty-state {
  text-align: center;
  color: var(--text-faint);
  padding: 2.5rem 1rem;
  font-size: 0.9rem;
}

/* ─── Footer note ──────────────────────────────────────────── */
.app-footer {
  max-width: 1040px;
  margin: 2rem auto 0;
  padding: 1.25rem;
  text-align: center;
  font-size: 0.74rem;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
}
.app-footer strong { color: var(--text-muted); font-weight: 600; }

/* ─── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  header { padding: 0.9rem 1rem; }
  .header-inner { flex-wrap: wrap; }
  .brand-text h1 { font-size: 1.15rem; }
  .brand-text p { font-size: 0.68rem; }
  .container { padding: 1.25rem 0.85rem 2rem; }
  .box { padding: 1.1rem; }
  .row { flex-direction: column; }
  .side { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: stretch; }
  .side > * { flex: 1 1 auto; }
  button#btn { flex: 1 1 100%; }
  .slider-row { flex: 1 1 100%; }
  .scores { margin-left: 0; min-width: 100%; flex-basis: 100%; order: 3; margin-top: 0.4rem; }
  .card { padding: 1rem 1.1rem; }
  .copy-btn { margin-left: 0; }
}

@media (max-width: 480px) {
  .brand-text p { display: none; }
  .container { padding: 1rem 0.7rem 1.5rem; }
  .box { padding: 0.9rem; }
  .card { padding: 0.9rem 1rem; }
  .texte { font-size: 0.9rem; }
  .side { flex-direction: column; }
  .side > * { flex: 1 1 auto; }
}
