/* ═══════ App5 — Explorateur INIES ═══════ */

.ex { max-width: 960px; margin: 0 auto; padding: 0 1.25rem 4rem; min-height: calc(100vh - 120px); }

/* ── Search ── */
.ex-search-wrap { padding: 1.5rem 0 1.25rem; }
.ex-search { position: relative; max-width: 640px; margin: 0 auto; }
.ex-search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: #94a3b8; pointer-events: none; }
.ex-search-input {
  width: 100%; padding: .8rem 1rem .8rem 2.6rem; font-size: .95rem;
  border: 2px solid #e2e8f0; border-radius: 10px; background: #fff; color: #1e293b;
  transition: border-color .2s; box-sizing: border-box;
}
.ex-search-input:focus { outline: none; border-color: #c4704b; box-shadow: 0 0 0 3px rgba(196,112,75,.12); }
.ex-search-input::placeholder { color: #94a3b8; }
.ex-spinner { display: none; }
.htmx-request .ex-spinner,
.htmx-request.ex-spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid #e2e8f0; border-top-color: #c4704b; border-radius: 50%; animation: spin .6s linear infinite; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); }
@keyframes spin { to { transform: translateY(-50%) rotate(360deg); } }

/* ── Tree home (expandable) ── */
.ex-tree-header { margin-bottom: 1.25rem; }
.ex-tree-title { font-size: 1.15rem; font-weight: 700; color: #1e293b; margin: 0; }
.ex-tree-subtitle { font-size: .82rem; color: #64748b; }

.ex-tree-l0 { margin-bottom: .25rem; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
.ex-tree-l0-row {
  display: flex; align-items: center; gap: .5rem; padding: .65rem .85rem;
  background: #f8fafc; cursor: pointer; user-select: none;
}
.ex-tree-l0-title { font-size: .85rem; font-weight: 600; color: #334155; margin: 0; flex: 1; }
.ex-tree-l0-count { font-size: .72rem; color: #94a3b8; font-weight: 600; }
.ex-tree-l0-children { display: none; padding: 0 .5rem .5rem; }
.ex-tree-l0.open .ex-tree-l0-children { display: block; }

.ex-tree-arrow { font-size: .6rem; color: #94a3b8; transition: transform .15s; display: inline-block; width: 12px; }
.ex-tree-l0.open > .ex-tree-l0-row .ex-tree-arrow { transform: rotate(90deg); }

.ex-tree-l1 { margin-top: .15rem; }
.ex-tree-l1-row { display: flex; align-items: center; gap: .4rem; padding: .35rem .5rem; border-radius: 5px; }
.ex-tree-l1-row:hover { background: #f1f5f9; }
.ex-tree-arrow-sm { font-size: .5rem; color: #cbd5e1; cursor: pointer; transition: transform .15s; display: inline-block; width: 10px; }
.ex-tree-arrow-hidden { visibility: hidden; }
.ex-tree-l1.open > .ex-tree-l1-row .ex-tree-arrow-sm { transform: rotate(90deg); }
.ex-tree-l1-name { font-size: .82rem; color: #334155; cursor: pointer; flex: 1; text-decoration: none; }
.ex-tree-l1-name:hover { color: #c4704b; }
.ex-tree-l1-count { font-size: .7rem; color: #94a3b8; font-weight: 600; }
.ex-tree-l2-children { display: none; padding-left: 1.5rem; }
.ex-tree-l1.open .ex-tree-l2-children { display: block; }
.ex-tree-l2-row { display: flex; align-items: center; gap: .3rem; padding: .2rem .4rem; border-radius: 4px; text-decoration: none; color: inherit; font-size: .78rem; }
.ex-tree-l2-row:hover { background: #f1f5f9; }
.ex-tree-l2-name { color: #475569; flex: 1; }
.ex-tree-l2-count { font-size: .68rem; color: #94a3b8; }

/* ── Breadcrumb ── */
.ex-crumb { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin-bottom: 1rem; font-size: .82rem; }
.ex-crumb-link { color: #c4704b; text-decoration: none; cursor: pointer; }
.ex-crumb-link:hover { text-decoration: underline; }
.ex-crumb-sep { color: #cbd5e1; }
.ex-crumb-current { color: #475569; font-weight: 500; }

/* ── Browse stats ── */
.ex-browse-stats, .ex-search-stats { display: flex; gap: 1.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.ex-stat { font-size: .82rem; color: #64748b; }
.ex-stat strong { color: #1e293b; }

/* ── Subcategory cards ── */
.ex-sub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .5rem; margin-bottom: 1.5rem; }
.ex-sub-card {
  display: flex; justify-content: space-between; align-items: center;
  padding: .55rem .75rem; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px;
  cursor: pointer; transition: all .15s; text-decoration: none; color: inherit;
}
.ex-sub-card:hover { border-color: #c4704b; background: #fef7f4; }
.ex-sub-name { font-size: .82rem; color: #334155; line-height: 1.3; }
.ex-sub-count { font-size: .72rem; color: #94a3b8; font-weight: 600; flex-shrink: 0; margin-left: .5rem; }

/* ── Fiches list ── */
.ex-fiches-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.ex-fiches-title { font-size: .85rem; font-weight: 600; color: #475569; }
.ex-sort { padding: .3rem .5rem; border: 1px solid #e2e8f0; border-radius: 5px; font-size: .78rem; color: #475569; background: #fff; }

/* ── Fiche row ── */
.ex-fiche { display: flex; gap: .5rem; align-items: flex-start; padding: .6rem .75rem; border-bottom: 1px solid #f1f5f9; transition: background .1s; }
.ex-fiche:hover { background: #fafbfc; }
.ex-fiche:last-child { border-bottom: none; }

.ex-fiche-check { flex-shrink: 0; padding-top: .2rem; }
.ex-fiche-check input { accent-color: #c4704b; }

.ex-fiche-body { flex: 1; min-width: 0; cursor: pointer; }
.ex-fiche-top { display: flex; justify-content: space-between; align-items: flex-start; gap: .4rem; }
.ex-fiche-name { font-size: .85rem; font-weight: 500; color: #1e293b; line-height: 1.3; }
.ex-fiche-name:hover { color: #c4704b; }
.ex-fiche-unite { font-size: .68rem; color: #94a3b8; }
.ex-fiche-meta { font-size: .75rem; color: #94a3b8; margin-top: .15rem; display: flex; gap: .75rem; }
.ex-fiche-fab { color: #64748b; }

.ex-fiche-indicators { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .35rem; }
.ex-ind { font-size: .75rem; color: #64748b; }
.ex-ind strong { color: #1e293b; }
.ex-ind-good { color: #059669; font-weight: 500; }
.ex-ind-bad { color: #dc2626; font-weight: 500; }
.ex-ind-fr { color: #2563eb; font-weight: 500; }
.ex-ind-stockc { color: #059669; font-weight: 500; background: #d1fae5; padding: .1rem .35rem; border-radius: 3px; }

/* ── Badges ── */
.ex-badge { display: inline-block; padding: .1rem .4rem; border-radius: 3px; font-size: .68rem; font-weight: 600; flex-shrink: 0; }
.ex-badge-ind { background: #d1fae5; color: #047857; }
.ex-badge-col { background: #dbeafe; color: #1e40af; }
.ex-badge-ded { background: #f1f5f9; color: #64748b; }

/* ── Search result groups ── */
.ex-group { margin-bottom: .75rem; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
.ex-group-header {
  display: flex; align-items: center; gap: .5rem; padding: .6rem .85rem;
  background: #f8fafc; cursor: pointer; user-select: none;
}
.ex-group-toggle { font-size: .7rem; color: #94a3b8; transition: transform .2s; }
.ex-group.collapsed .ex-group-toggle { transform: rotate(-90deg); }
.ex-group.collapsed .ex-group-body { display: none; }
.ex-group-path { font-size: .82rem; font-weight: 500; color: #334155; flex: 1; }
.ex-group-count { font-size: .72rem; color: #94a3b8; font-weight: 600; background: #e2e8f0; padding: .1rem .45rem; border-radius: 10px; }

/* ── Boxplot ── */
.ex-boxplot-wrap { margin-bottom: 1.25rem; padding: .75rem; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; }
.ex-boxplot-label { font-size: .75rem; color: #64748b; margin-bottom: .5rem; }
.ex-boxplot { position: relative; height: 20px; background: #f1f5f9; border-radius: 4px; margin-bottom: .3rem; }
.ex-bp-whisker { position: absolute; top: 8px; height: 4px; background: #cbd5e1; border-radius: 2px; }
.ex-bp-box { position: absolute; top: 2px; height: 16px; background: #93c5fd; border: 1px solid #60a5fa; border-radius: 3px; opacity: .8; }
.ex-bp-median { position: absolute; top: 0; width: 2px; height: 20px; background: #dc2626; border-radius: 1px; }
.ex-bp-dot { position: absolute; top: 4px; width: 12px; height: 12px; background: #c4704b; border: 2px solid #fff; border-radius: 50%; transform: translateX(-50%); z-index: 2; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: left .2s; }
.ex-bp-ticks { display: flex; justify-content: space-between; font-size: .68rem; color: #94a3b8; }

/* ── Detected filters ── */
.ex-detected { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: 1rem; }
.ex-detected-label { font-size: .78rem; color: #64748b; }
.ex-detected-tag { font-size: .75rem; padding: .2rem .55rem; background: #fef3c7; color: #92400e; border-radius: 4px; font-weight: 500; }

/* ── Empty state ── */
.ex-empty { text-align: center; padding: 3rem 1rem; color: #64748b; }
.ex-empty p { margin: .25rem 0; }
.ex-empty-hint { font-size: .82rem; color: #94a3b8; }

/* ── Buttons ── */
.ex-btn-accent { padding: .4rem 1rem; border-radius: 6px; font-size: .82rem; font-weight: 500; border: none; cursor: pointer; background: #c4704b; color: #fff; }
.ex-btn-accent:hover { background: #a85d3d; }
.ex-btn-ghost { padding: .4rem .8rem; border-radius: 6px; font-size: .82rem; border: none; cursor: pointer; background: rgba(255,255,255,.15); color: #e2e8f0; }
.ex-btn-secondary { display: block; margin: 1rem auto; padding: .5rem 1.5rem; border-radius: 6px; font-size: .82rem; border: 1px solid #e2e8f0; cursor: pointer; background: #fff; color: #475569; }
.ex-btn-secondary:hover { background: #f8fafc; }
.ex-btn-close { background: none; border: none; font-size: 1.4rem; color: #94a3b8; cursor: pointer; padding: .2rem; line-height: 1; }

.ex-load-more { margin-top: .75rem; }

/* ── Detail panel (slide-in right) ── */
.ex-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 90; }
.ex-detail {
  position: fixed; top: 0; right: 0; width: 480px; max-width: 92vw; height: 100vh;
  background: #fff; z-index: 100; overflow-y: auto; padding: 1.5rem;
  box-shadow: -4px 0 20px rgba(0,0,0,.1);
}
.ex-detail-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: .75rem; }
.ex-detail-name { font-size: 1.05rem; font-weight: 700; color: #1e293b; margin: 0; padding-right: .75rem; line-height: 1.3; }
.ex-detail-meta { display: flex; flex-wrap: wrap; gap: .6rem; font-size: .78rem; color: #64748b; margin-bottom: 1rem; align-items: center; }

.ex-detail-section { margin-bottom: 1.25rem; }
.ex-detail-section h3 { font-size: .75rem; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: .03em; margin: 0 0 .5rem; border-bottom: 1px solid #f1f5f9; padding-bottom: .3rem; }
.ex-detail-desc { font-size: .82rem; color: #475569; line-height: 1.5; margin: 0; }

.ex-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.ex-detail-item { display: flex; flex-direction: column; }
.ex-detail-val { font-size: 1rem; font-weight: 700; color: #1e293b; }
.ex-detail-lbl { font-size: .7rem; color: #94a3b8; }

.ex-detail-pos { margin-bottom: .6rem; }
.ex-detail-pos-label { font-size: .75rem; color: #64748b; display: block; margin-bottom: .2rem; }
.ex-pos-bar { height: 6px; background: #f1f5f9; border-radius: 3px; position: relative; overflow: hidden; }
.ex-pos-fill { height: 100%; border-radius: 3px; max-width: 100%; }
.ex-pos-fill.good { background: #34d399; }
.ex-pos-fill.bad { background: #f87171; }
.ex-detail-pos-pct { font-size: .78rem; font-weight: 600; }
.ex-detail-pos-pct.good { color: #059669; }
.ex-detail-pos-pct.bad { color: #dc2626; }

.ex-detail-specs { display: flex; flex-direction: column; }
.ex-detail-spec-row { display: flex; justify-content: space-between; padding: .25rem 0; border-bottom: 1px solid #fafbfc; font-size: .78rem; }
.ex-detail-spec-label { color: #94a3b8; }
.ex-detail-spec-value { color: #1e293b; font-weight: 500; }

.ex-bc { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; font-size: .75rem; }
.ex-bc-item { color: #64748b; }
.ex-bc-sep { color: #e2e8f0; }

/* ── Comparator ── */
.ex-comparator {
  position: fixed; bottom: 56px; left: 50%; transform: translateX(-50%);
  width: 88vw; max-width: 1000px; max-height: 55vh; background: #fff;
  border-radius: 10px; box-shadow: 0 -4px 24px rgba(0,0,0,.12);
  z-index: 85; overflow: auto; padding: 1.25rem;
}
.ex-cmp-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.ex-cmp-header h2 { font-size: .95rem; margin: 0; color: #1e293b; }

.ex-cmp-table { width: 100%; border-collapse: collapse; font-size: .78rem; }
.ex-cmp-table th, .ex-cmp-table td { padding: .4rem .6rem; text-align: left; border-bottom: 1px solid #f1f5f9; }
.ex-cmp-table th { background: #f8fafc; font-weight: 600; vertical-align: top; max-width: 180px; }
.ex-cmp-label { font-weight: 500; color: #64748b; white-space: nowrap; }
.ex-cmp-best { font-weight: 700; color: #059669; }
.ex-cmp-warning { background: #fef3c7; color: #92400e; font-size: .78rem; padding: .5rem .75rem; border-radius: 6px; margin-bottom: .75rem; border: 1px solid #fde68a; }
.ex-tag { font-size: .68rem; display: inline-block; padding: .05rem .3rem; background: #f1f5f9; color: #475569; border-radius: 3px; margin: .1rem; }

/* ── Selection bar ── */
.ex-sel-bar {
  position: fixed; bottom: 0; left: 0; right: 0; background: #1e293b; color: #fff;
  padding: .6rem 1.25rem; display: flex; align-items: center; gap: .75rem;
  justify-content: center; z-index: 80;
}
#sel-count { font-size: .82rem; }

/* ── Error ── */
.ex-error { color: #dc2626; text-align: center; padding: 1rem; font-size: .85rem; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .ex-tree-grid { grid-template-columns: 1fr; }
  .ex-sub-grid { grid-template-columns: 1fr; }
  .ex-detail { width: 100vw; max-width: 100vw; }
  .ex-detail-grid { grid-template-columns: 1fr; }
}
