/* RASA Dashboard — Global Styles */

:root {
  --color-bg: #faf9f7;
  --color-surface: #ffffff;
  --color-border: #e0ddd8;
  --color-text: #1a1a1a;
  --color-muted: #5a5a5a;
  --color-brand: #2a3d2a;
  --color-accent: #c97c1f;
  --color-nav-bg: #1e2d1e;
  --color-nav-text: #f0ece4;
  --color-sidebar-bg: #f5f2ee;
  --color-image-bg: #f5f0eb;
  --score-green: #2a7d4f;
  --score-orange: #c97c1f;
  --score-red: #b03030;
  --radius: 6px;
  --shadow-card: 0 2px 8px rgba(0,0,0,0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
}

/* ---- Top nav ---- */
.top-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--color-nav-bg);
  color: var(--color-nav-text);
  padding: 0 20px;
  height: 48px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.top-nav .brand { font-weight: 700; font-size: 16px; color: var(--color-nav-text); text-decoration: none; letter-spacing: 2px; }
.top-nav .nav-links { display: flex; gap: 16px; }
.top-nav .nav-links a { text-decoration: none; }
/* Liens de section : dropdowns (trigger) ET liens plats (.nav-link, ex. Corpus,
   Glossaire) partagent le même traitement de couleur — affichage harmonisé. */
.top-nav .nav-links .nav-dropdown-trigger,
.top-nav .nav-links .nav-link { color: rgba(240,236,228,0.88); }
.top-nav .nav-links .nav-dropdown-trigger.active,
.top-nav .nav-links .nav-dropdown-trigger:hover,
.top-nav .nav-links .nav-link.active,
.top-nav .nav-links .nav-link:hover { color: var(--color-nav-text); }
.top-nav .nav-user { margin-left: auto; font-size: 13px; color: rgba(240,236,228,0.75); display: flex; align-items: center; gap: 12px; }
.btn-link { background: none; border: none; color: rgba(240,236,228,0.75); cursor: pointer; font-size: 13px; text-decoration: underline; }

/* ---- Layout ---- */
.layout { display: grid; grid-template-columns: 1fr; min-height: calc(100vh - 48px); }
.layout:has(.sidebar) { grid-template-columns: 240px 1fr; }
.sidebar { background: var(--color-sidebar-bg); border-right: 1px solid var(--color-border); overflow-y: auto; padding-bottom: 40px; }
.main-content { padding: 24px; overflow-y: auto; }

/* ---- Page header ---- */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; }

/* ---- Data table (generic) ---- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; border-bottom: 1px solid var(--color-border); padding: 8px; color: var(--color-muted); font-weight: 600; white-space: nowrap; }
.data-table td { padding: 8px; border-bottom: 1px solid var(--color-border); vertical-align: top; }
.data-table tbody tr:hover { background: rgba(0,0,0,0.04); }

/* ---- Sidebar ---- */
.sidebar-header { padding: 14px 16px 8px; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--color-muted); display: flex; align-items: center; justify-content: space-between; }
.sidebar-item { display: block; padding: 10px 16px; text-decoration: none; color: var(--color-text); border-left: 3px solid transparent; }
.sidebar-item:hover { background: rgba(0,0,0,0.04); }
.sidebar-item.active { border-left-color: var(--color-brand); background: rgba(42,61,42,0.06); }
.sidebar-item-title { font-weight: 500; font-size: 13px; }
.sidebar-item-meta { font-size: 11px; color: var(--color-muted); margin-top: 2px; }
.sidebar-empty { padding: 16px; font-size: 13px; color: var(--color-muted); }

/* ---- Badges ---- */
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 8px; font-weight: 500; }
.badge-success { background: #e8f4ee; color: #1e5c36; }
.badge-neutral { background: #ebebeb; color: #3a3a3a; }
.badge-warning { background: #fdf0e0; color: #7a4f00; }
.badge-error   { background: #fdeaea; color: #7a1f1f; }
.badge-green { background: #e8f4ee; color: #1e5c36; font-size: 11px; padding: 1px 6px; border-radius: 8px; }
.badge-amber { background: #fdf0e0; color: #7a4f00; font-size: 11px; padding: 1px 6px; border-radius: 8px; }
.badge-signal { background: #fff3cd; color: #6b4e00; font-size: 11px; padding: 2px 8px; border-radius: 4px; margin-left: 6px; }
.badge-nouveau { position: absolute; top: 7px; left: 7px; background: rgba(170,110,0,0.9); color: white; font-size: 8px; padding: 2px 5px; border-radius: 3px; font-weight: 700; }

/* ---- Triage grid ---- */
.triage-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.triage-header h2 { font-size: 18px; }
.triage-controls a { font-size: 13px; color: var(--color-muted); margin-left: 8px; }
.triage-controls a.active { color: var(--color-brand); font-weight: 600; }

.triage-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

.lot-card { text-decoration: none; color: var(--color-text); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; transition: box-shadow 0.15s; cursor: pointer; }
.lot-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.12); }

.lot-card-image { position: relative; background: var(--color-image-bg); }
.lot-card-image::before { content: ''; display: block; padding-bottom: 100%; }
.lot-card-image img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.lot-image-placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--color-muted); font-style: italic; font-size: 11px; }

.score-badge { position: absolute; top: 8px; right: 8px; color: white; font-weight: 700; font-size: 15px; padding: 3px 10px; border-radius: 12px; box-shadow: 0 2px 6px rgba(0,0,0,0.25); }
.score-green { background: var(--score-green); }
.score-orange { background: var(--score-orange); }
.score-red { background: var(--score-red); }

.lot-card-body { padding: 8px 10px; }
.lot-meta { font-size: 11px; color: var(--color-muted); margin-bottom: 2px; }
.lot-title { font-size: 12px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lot-chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 5px; }
.chip { background: #e8f4ee; color: #2a6a4a; font-size: 10px; padding: 1px 6px; border-radius: 8px; }

/* ---- Pagination ---- */
.pagination { display: flex; align-items: center; gap: 16px; margin-top: 24px; justify-content: center; color: var(--color-muted); }
.pagination a { color: var(--color-brand); }

/* ---- Detail layout ---- */
.detail-layout { display: grid; grid-template-columns: 40% 60%; gap: 32px; }
.detail-image-wrap { cursor: zoom-in; border-radius: var(--radius); overflow: hidden; background: var(--color-image-bg); }
.detail-image-wrap img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.detail-image-placeholder { background: var(--color-image-bg); aspect-ratio: 1; display: flex; align-items: center; justify-content: center; color: var(--color-muted); border-radius: var(--radius); }
.detail-meta { margin-top: 12px; font-size: 13px; color: var(--color-muted); line-height: 1.8; }
.price-realized { color: var(--score-green); font-weight: 600; }
.img-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.85); display: flex; align-items: center; justify-content: center; z-index: 1000; cursor: zoom-out; }
.img-modal img { max-width: 90vw; max-height: 90vh; object-fit: contain; }

.score-display { display: flex; align-items: baseline; gap: 8px; margin-bottom: 20px; }
.score-big { font-size: 56px; font-weight: 700; line-height: 1; }
.score-label { font-size: 14px; color: var(--color-muted); }

.score-bars { margin-bottom: 20px; }
.score-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.score-bar-row > span:first-child { width: 160px; color: var(--color-muted); }
.score-bar { flex: 1; height: 8px; background: var(--color-border); border-radius: 4px; overflow: hidden; }
.score-bar-fill { height: 100%; background: var(--color-brand); border-radius: 4px; }

.accordion-btn { background: none; border: 1px solid var(--color-border); padding: 6px 12px; border-radius: var(--radius); cursor: pointer; font-size: 13px; color: var(--color-brand); }
.lot-description { margin-top: 20px; }
.lot-description h3 { font-size: 14px; margin-bottom: 8px; }
.lot-description p { font-size: 13px; color: var(--color-muted); line-height: 1.6; }

/* ---- Comparables table ---- */
.comparables { margin-top: 32px; }
.comparables h3 { margin-bottom: 12px; }
.comparables-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.comparables-table th { text-align: left; border-bottom: 1px solid var(--color-border); padding: 6px 8px; color: var(--color-muted); font-weight: 600; }
.comparables-table td { padding: 6px 8px; border-bottom: 1px solid var(--color-border); }

/* ---- Feed / Watchlist ---- */
.feed-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.feed-controls { display: flex; align-items: center; gap: 8px; }
.filter-btn { padding: 4px 12px; border-radius: 12px; cursor: pointer; font-size: 13px; color: var(--color-muted); }
.filter-btn.active { background: var(--color-brand); color: white; }
.lot-date { font-size: 11px; color: var(--color-muted); margin-top: 4px; }

/* ---- Rule builder ---- */
.builder-root { border: 1px solid var(--color-border); border-radius: var(--radius); padding: 16px; }
.builder-group { background: #f9f7f4; border: 1px solid var(--color-border); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.group-op { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.group-op button.op-active { background: var(--color-brand); color: white; border-color: var(--color-brand); }
.builder-condition { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.builder-condition select, .builder-condition input { border: 1px solid var(--color-border); border-radius: 4px; padding: 4px 8px; font-size: 13px; }
.btn-remove { background: none; border: 1px solid #ddd; border-radius: 4px; color: #888; cursor: pointer; font-size: 12px; padding: 3px 8px; }

/* ---- Timeline (UC3) ---- */
.timeline-header { margin-bottom: 24px; }
.timeline-header h2 { font-size: 18px; }
.timeline-meta { margin-top: 4px; font-size: 13px; color: var(--color-muted); }
.timeline { border-left: 3px solid var(--color-brand); margin-left: 24px; }
.timeline-entry { display: flex; gap: 16px; padding: 0 0 24px 20px; position: relative; }
.timeline-entry::before { content: ''; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--color-brand); }
.timeline-year { font-size: 16px; font-weight: 700; color: var(--color-brand); min-width: 48px; }
.timeline-content { flex: 1; }
.timeline-meta-row { font-size: 13px; margin-bottom: 8px; }
.timeline-lot-row { display: flex; gap: 12px; align-items: flex-start; }
.timeline-img { width: 120px; height: 120px; object-fit: contain; background: var(--color-image-bg); border-radius: 4px; flex-shrink: 0; }
.realized { color: var(--score-green); font-weight: 600; }
.invendu { color: var(--score-red); font-weight: 600; }
.review-section { margin-top: 32px; border-top: 1px solid var(--color-border); padding-top: 20px; }
.review-card { padding: 12px; border: 1px solid var(--color-border); border-radius: var(--radius); margin-bottom: 12px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---- Admin table ---- */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { text-align: left; border-bottom: 1px solid var(--color-border); padding: 8px; color: var(--color-muted); }
.admin-table td { padding: 8px; border-bottom: 1px solid var(--color-border); }

/* ---- Login ---- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--color-nav-bg); }
.login-card { background: white; border-radius: 8px; padding: 40px; width: 360px; box-shadow: 0 8px 32px rgba(0,0,0,0.3); }
.login-card h1 { font-size: 28px; letter-spacing: 4px; color: var(--color-brand); margin-bottom: 24px; text-align: center; }
.login-card label { display: block; margin-bottom: 16px; font-size: 13px; color: var(--color-muted); }
.login-card input { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--color-border); border-radius: 4px; font-size: 14px; }
.login-card .error { color: var(--score-red); font-size: 13px; margin-bottom: 16px; }

/* ---- Buttons ---- */
.btn-primary { background: var(--color-brand); color: white; border: none; padding: 8px 16px; border-radius: var(--radius); cursor: pointer; font-size: 13px; text-decoration: none; display: inline-block; }
.btn-secondary { background: none; color: var(--color-brand); border: 1px solid var(--color-brand); padding: 6px 14px; border-radius: var(--radius); cursor: pointer; font-size: 13px; text-decoration: none; display: inline-block; }
.btn-danger { background: var(--score-red); color: white; border: none; padding: 6px 12px; border-radius: var(--radius); cursor: pointer; font-size: 12px; }
.btn-small { font-size: 11px; padding: 2px 8px; border-radius: 4px; background: var(--color-brand); color: white; text-decoration: none; }
.form-actions { margin-top: 20px; display: flex; gap: 12px; align-items: center; }
label { display: block; margin-bottom: 12px; font-size: 13px; }
label input[type="text"], label input[type="password"] { display: block; margin-top: 4px; width: 100%; padding: 7px 10px; border: 1px solid var(--color-border); border-radius: 4px; font-size: 14px; }

/* ---- Misc ---- */
.empty-state { padding: 32px; text-align: center; color: var(--color-muted); font-size: 14px; }
.text-muted { color: var(--color-muted); }

/* ---- QualACR dashboard (Spec 020 / Phase 5) ---- */
.badge-info { background: #e7eef9; color: #1f3a73; }
.badge-state-discovered      { background: #fff3cd; color: #6b4e00; }
.badge-state-approved        { background: #e7eef9; color: #1f3a73; }
.badge-state-extractor_ready { background: #e3eef6; color: #1c4f78; }
.badge-state-active          { background: #e8f4ee; color: #1e5c36; }
.badge-state-paused          { background: #fdf0e0; color: #7a4f00; }
.badge-state-deprecated      { background: #ebebeb; color: #555; }
.badge-state-rejected        { background: #fdeaea; color: #7a1f1f; }
.badge-state-unknown         { background: #ebebeb; color: #555; }

.state-pills .pill {
  display: inline-block; font-size: 11px; padding: 3px 10px; border-radius: 12px;
  border: 1px solid var(--color-border); color: var(--color-text);
  text-decoration: none; background: #f7f5ef;
}
.state-pills .pill:hover { background: #ebe7d8; }
.state-pills .pill-active { background: var(--color-brand); color: #fff; border-color: var(--color-brand); }
.state-pills .pill-count { font-size: 10px; opacity: 0.85; margin-left: 3px; }

.btn-info    { background: #1c4f78; color: white; border: none; padding: 6px 12px; border-radius: var(--radius); cursor: pointer; font-size: 12px; }
.btn-success { background: #1e5c36; color: white; border: none; padding: 6px 12px; border-radius: var(--radius); cursor: pointer; font-size: 12px; }
.btn-warning { background: #7a4f00; color: white; border: none; padding: 6px 12px; border-radius: var(--radius); cursor: pointer; font-size: 12px; }
.btn-danger-outline { background: none; color: var(--score-red); border: 1px solid var(--score-red); padding: 5px 11px; border-radius: var(--radius); cursor: pointer; font-size: 12px; }

.section-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--color-muted); margin-top: 14px; }

/* ---- Favorite button (grid card overlay) ---- */
.fav-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.88);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 15px;
  line-height: 28px;
  text-align: center;
  cursor: pointer;
  color: #bbb;
  transition: color 0.15s, background 0.15s;
  z-index: 2;
}
.fav-btn:hover { color: #e5a100; background: rgba(255, 255, 255, 1); }
.fav-btn--active { color: #e5a100; }

/* ---- Favorite button (detail nav bar) ---- */
.fav-btn-detail {
  background: none;
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 3px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--charcoal, #292929);
  cursor: pointer;
  white-space: nowrap;
}
.fav-btn-detail:hover { border-color: var(--navy, #00253e); }
.fav-btn-detail.fav-btn--active { color: #e5a100; border-color: #e5a100; }

/* ---- Review button (grid card overlay) — Spec dashboard review ---- */
.review-btn {
  position: absolute;
  top: 8px;
  right: 44px;             /* à gauche du favori (right: 8px) */
  background: rgba(255, 255, 255, 0.88);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 14px;
  line-height: 28px;
  text-align: center;
  cursor: pointer;
  color: #bbb;
  transition: color 0.15s, background 0.15s;
  z-index: 2;
}
.review-btn:hover { color: #c14040; background: rgba(255, 255, 255, 1); }
.review-btn--active { color: #c14040; }

.review-btn-detail {
  background: none;
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 3px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--charcoal, #292929);
  cursor: pointer;
  white-space: nowrap;
}
.review-btn-detail:hover { border-color: var(--navy, #00253e); }
.review-btn-detail.review-btn--active { color: #c14040; border-color: #c14040; }

/* Spec 013 — chain membership badge in lot detail */
.chain-badge-detail {
  display: inline-flex;
  align-items: center;
  background: rgba(74, 63, 159, 0.08);
  border: 1px solid rgba(74, 63, 159, 0.4);
  border-radius: 3px;
  padding: 4px 10px;
  font-size: 12px;
  color: #4a3f9f;
  text-decoration: none;
  white-space: nowrap;
  font-weight: 500;
}
.chain-badge-detail:hover {
  background: rgba(74, 63, 159, 0.15);
  border-color: #4a3f9f;
}

/* Spec 013 — pending chain candidate badge in lot detail (distinct from
   confirmed chain badge above; uses an amber palette to signal "à revoir"). */
.candidate-badge-detail {
  display: inline-flex;
  align-items: center;
  background: rgba(217, 138, 28, 0.08);
  border: 1px solid rgba(217, 138, 28, 0.4);
  border-radius: 3px;
  padding: 4px 10px;
  font-size: 12px;
  color: #b8761a;
  text-decoration: none;
  white-space: nowrap;
  font-weight: 500;
}
.candidate-badge-detail:hover {
  background: rgba(217, 138, 28, 0.15);
  border-color: #b8761a;
}


/* Sortable tables (sortable-table.js) */
.sortable-table th.sortable-th { cursor: pointer; user-select: none; }
.sortable-table th.sortable-th:hover { background: #f5f5f5; }
.sortable-table th.sortable-th::after {
  content: " \2195"; opacity: 0.3; font-size: 10px;
}
.sortable-table th.sort-asc::after  { content: " \25B2"; opacity: 0.9; color: #4a3f9f; }
.sortable-table th.sort-desc::after { content: " \25BC"; opacity: 0.9; color: #4a3f9f; }

