/* 1·2·3 GED — web interface.
   Helvetica (clear licence), light weights: 400 for text, 500 for labels,
   600 for titles. Light and dark themes; the agency's background and colour
   (--agency-bg-light, --agency-accent…, set by app.js) only apply to the
   light theme: the dark one keeps its own, readable palette. */

:root {
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --accent: var(--agency-accent, #2563eb);
  --accent-dark: var(--agency-accent-dark, #1d4ed8);
  --accent-light: var(--agency-accent-light, #eff6ff);
  --green: #15803d;
  --green-light: #f0fdf4;
  --amber: #b45309;
  --amber-light: #fffbeb;
  --doubt: #eab308;
  --doubt-light: #fefce8;
  --red: #dc2626;
  --red-light: #fef2f2;
  --ink: #0f172a;
  --text: #334155;
  --muted: #64748b;
  --border: #e2e8f0;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --bg: #f1f5f9;
  --agency-bg: var(--agency-bg-light, var(--bg));
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #60a5fa; --accent-dark: #3b82f6; --accent-light: #172554;
    --green: #4ade80; --green-light: #052e16; --amber: #fbbf24; --amber-light: #2a1d05;
    --doubt: #facc15; --doubt-light: #2a2405;
    --red: #f87171; --red-light: #2a0b0b;
    --ink: #f1f5f9; --text: #cbd5e1; --muted: #94a3b8; --border: #1e293b;
    --surface: #0f172a; --surface-2: #111c33; --bg: #020617; --agency-bg: var(--bg);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent: #60a5fa; --accent-dark: #3b82f6; --accent-light: #172554;
  --green: #4ade80; --green-light: #052e16; --amber: #fbbf24; --amber-light: #2a1d05;
  --doubt: #facc15; --doubt-light: #2a2405;
  --red: #f87171; --red-light: #2a0b0b;
  --ink: #f1f5f9; --text: #cbd5e1; --muted: #94a3b8; --border: #1e293b;
  --surface: #0f172a; --surface-2: #111c33; --bg: #020617; --agency-bg: var(--bg);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.5; font-weight: 400;
  color: var(--text); background: var(--agency-bg);
}
h1, h2, h3 { color: var(--ink); font-weight: 600; margin: 0; line-height: 1.25; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }

/* ---------- icons (js/icons.js): a line drawing the colour of the text */
.ic { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
.menu button .ic, .menu a .ic, .note .ic, .badge .ic, .reason .ic, .doc-row .meta .ic, .status .ic, .empty .ic,
.file-name .ic, .banner p .ic { margin-right: 6px; }
.badge .ic, .reason .ic, .doc-row .meta .ic { width: 1.1em; height: 1.1em; margin-right: 4px; }
.file-name .ic { color: var(--muted); }

/* ---------- buttons, fields */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); padding: 7px 14px; border-radius: 8px;
  font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-danger { color: var(--red); }
.btn-link { border: none; background: none; color: var(--accent); padding: 0; cursor: pointer; font-weight: 500; }
.icon-btn { border: none; background: none; cursor: pointer; font-size: 18px; padding: 6px; border-radius: 8px; color: var(--text); }
.icon-btn:hover { background: var(--surface-2); }
input[type="text"], input[type="search"], input[type="email"], input[type="password"], select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--ink);
}
input:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- login */
.login { max-width: 380px; margin: 12vh auto; background: var(--surface); padding: 32px;
  border-radius: var(--radius); box-shadow: var(--shadow); display: grid; gap: 14px; }
.login .brand { font-size: 22px; }
.login label { display: grid; gap: 4px; font-weight: 500; color: var(--ink); font-size: 14px; }
.error { color: var(--red); font-size: 14px; }

/* ---------- header */
.header {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 500; color: var(--ink); font-size: 18px; white-space: nowrap; }
.brand strong { color: var(--accent); font-weight: 600; }
.tabs { display: flex; gap: 4px; margin: 0 auto; }
.tab { border: none; background: none; padding: 7px 14px; border-radius: 8px; cursor: pointer;
  font-weight: 500; color: var(--text); display: inline-flex; gap: 6px; align-items: center; }
.tab:hover { background: var(--surface-2); }
.tab.active { background: var(--accent-light); color: var(--accent); }
.count-badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red);
  color: #fff; font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.right { display: flex; align-items: center; gap: 8px; }
.bell { position: relative; }
.bell .count-badge { position: absolute; top: 0; right: 0; }
.menu-anchor { position: relative; }
.agency-logo { height: 32px; max-width: 140px; object-fit: contain; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 260px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; z-index: 30; }
.menu button, .menu a { display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--text); text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--surface-2); }
.menu .title { padding: 8px 10px 4px; font-weight: 600; color: var(--ink); }
.menu .note { padding: 8px 10px; color: var(--muted); }

/* ---------- layout: content on the left, preview on the right */
.layout { display: grid; grid-template-columns: 1fr; min-height: calc(100vh - 57px); }
.layout.with-preview { grid-template-columns: minmax(520px, 1fr) var(--preview-width, minmax(420px, 1fr)); }
.content { padding: 24px; max-width: 1100px; width: 100%; margin: 0 auto; }
.layout.with-preview .content { margin: 0; max-width: none; min-width: 0; }
.view-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }

/* ---------- preview */
.preview { border-left: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column;
  position: sticky; top: 57px; height: calc(100vh - 57px); }
.preview.fullscreen { position: fixed; inset: 0; z-index: 40; height: 100vh; border: none; }
.preview-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.preview-bar .name { flex: 1; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview iframe { flex: 1; width: 100%; border: none; background: var(--surface-2); min-height: 200px; }
.preview-info { border-top: 1px solid var(--border); height: var(--info-height, 38%); flex: none; min-height: 0;
  display: flex; flex-direction: column; font-size: 14px; }
.preview-info-head { padding: 6px 16px 2px; }
.info-toggle { border: none; background: none; padding: 2px 0; cursor: pointer; color: var(--muted); font-weight: 500; font-size: 13px; }
.info-toggle:hover { color: var(--ink); }
.preview-info-body { flex: 1; min-height: 0; overflow: auto; padding: 4px 16px 12px; }
.preview.info-folded .preview-info { height: auto; }
.preview.info-folded .preview-info-body, .preview.info-folded .splitter.horizontal { display: none; }
.splitter { position: relative; z-index: 6; }
.splitter::after { content: ""; position: absolute; background: transparent; transition: background .15s; }
.splitter:hover::after, .splitter:focus-visible::after { background: var(--accent); }
.splitter:focus-visible { outline: none; }
.splitter.vertical { position: absolute; left: -5px; top: 0; bottom: 0; width: 10px; cursor: col-resize; }
.splitter.vertical::after { left: 4px; top: 0; bottom: 0; width: 2px; }
.splitter.horizontal { flex: none; height: 9px; margin: -4px 0 -5px; cursor: row-resize; }
.splitter.horizontal::after { left: 0; right: 0; top: 4px; height: 2px; }
.preview.fullscreen .splitter.vertical { display: none; }
body.resizing { user-select: none; }
body.resizing iframe { pointer-events: none; }
.info-list { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; color: var(--ink); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text); white-space: nowrap; }
.badge.amber { background: var(--amber-light); color: var(--amber); border-color: transparent; }
.badge.green { background: var(--green-light); color: var(--green); border-color: transparent; }
.badge.red { background: var(--red-light); color: var(--red); border-color: transparent; }
.history-title { margin-top: 12px; }
.history { list-style: none; padding: 0; margin: 6px 0 0; font-size: 13px; }
.history li { padding: 3px 0; border-bottom: 1px dashed var(--border); }

/* ---------- document lists */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.doc-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer; user-select: none; }
.doc-row:hover { border-color: var(--accent); }
.doc-row.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.doc-row .icon { width: 24px; display: inline-flex; justify-content: center; color: var(--muted); }
.doc-row .icon .ic { width: 20px; height: 20px; }
.doc-row .main { flex: 1; min-width: 0; }
.doc-row .name { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-row .meta { font-size: 13px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.doc-row .date { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* ---------- search */
.search-bar { position: relative; max-width: 680px; margin: 0 auto 20px; }
.search-bar input { padding: 12px 14px 12px 40px; font-size: 16px; border-radius: 12px; }
/* the search icon of js/icons.js, as a mask: it takes the muted colour */
.search-bar::before { content: ""; position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px;
  background: var(--muted); pointer-events: none;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='m20 20-4.4-4.4'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='m20 20-4.4-4.4'/%3E%3C/svg%3E") center / contain no-repeat; }

/* ---------- client folders */
.clients { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
.layout.with-preview .clients { grid-template-columns: 220px 1fr; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.client-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: calc(100vh - 220px); overflow: auto; }
.client-list button { width: 100%; display: flex; gap: 10px; align-items: center; border: none; background: none;
  padding: 7px 8px; border-radius: 8px; cursor: pointer; text-align: left; }
.client-list button:hover, .client-list button.active { background: var(--accent-light); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 600; flex: none; }
.family { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); margin-bottom: 8px; }
.family > summary { cursor: pointer; padding: 9px 12px; font-weight: 600; color: var(--ink); display: flex; gap: 8px; align-items: center; list-style: none; }
.family > summary::-webkit-details-marker { display: none; }
.family > summary .ic { color: var(--muted); width: 18px; height: 18px; }
.family > summary .count { margin-left: auto; font-weight: 500; color: var(--muted); font-size: 13px; }
.family .list { padding: 0 8px 8px; }

/* ---------- upload */
.drop-zone { border: 2px dashed var(--border); border-radius: 16px; background: var(--surface); padding: 36px;
  text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.drop-zone.drag-over { border-color: var(--accent); background: var(--accent-light); }
.drop-zone .big { color: var(--accent); }
.drop-zone .big .ic { width: 40px; height: 40px; stroke-width: 1.5; }
.card .icon { display: inline-flex; color: var(--muted); }
.card .icon .ic { width: 22px; height: 22px; }
.cards { display: grid; gap: 8px; margin: 16px 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px;
  display: flex; gap: 12px; align-items: center; }
.card.attention { border-color: var(--amber); background: var(--amber-light); }
.card.ok { border-color: var(--green); }
.card .status { font-size: 13px; color: var(--muted); }
.recent { margin-top: 28px; }
.recent h3 { font-weight: 500; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.recent .doc-row { padding: 5px 10px; border-color: transparent; background: transparent; }
.recent .doc-row:hover { background: var(--surface); }

/* ---------- review */
.table { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 0 8px; }
.table td { background: var(--surface); padding: 8px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table td:first-child { border-left: 1px solid var(--border); border-radius: 10px 0 0 10px; }
.table td:last-child { border-right: 1px solid var(--border); border-radius: 0 10px 10px 0; }
.table tr.selected td { border-color: var(--accent); }
.table .file-name { font-weight: 500; color: var(--ink); cursor: pointer; overflow-wrap: anywhere; }
.table.review tbody tr { cursor: pointer; }
.table.review tbody tr:hover td { border-color: var(--accent); }
.table.review { table-layout: fixed; }
.table.review th.field { width: 27%; }
.table.review th.actions { width: 168px; } /* « Valider » and the reject button, icons and padding included */
.table.review td.actions { white-space: nowrap; }
.reason { font-size: 12px; color: var(--amber); }
.combo { position: relative; min-width: 0; }
/* a type or a client the chain is not sure of: yellow until the person chooses */
.combo.uncertain input { border-color: var(--doubt); box-shadow: 0 0 0 1px var(--doubt); background: var(--doubt-light); }
.combo-list { position: absolute; z-index: 25; top: calc(100% + 2px); left: 0; min-width: 100%; width: max-content;
  max-width: 360px; max-height: 280px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 4px; }
.combo-list .group { padding: 6px 8px 2px; font-size: 12px; font-weight: 600; color: var(--muted); }
.combo-list .option { padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.combo-list .option.active, .combo-list .option:hover { background: var(--accent-light); }
.combo-list .new { color: var(--accent); }
.parts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- toasts, modal */
#toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: var(--surface); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow);
  max-width: 420px; font-size: 14px; }
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal { width: min(900px, 75vw); max-height: 75vh; overflow: auto; background: var(--surface); border-radius: 16px;
  box-shadow: var(--shadow); padding: 24px; display: grid; gap: 14px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; }
.banner { position: fixed; left: 20px; right: 20px; bottom: 20px; z-index: 55; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 14px 18px;
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.banner p { margin: 0; flex: 1; min-width: 260px; }

/* ---------- heat map */
.heatmap { position: relative; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.heatmap canvas { display: block; width: 100%; }

@media (max-width: 900px) {
  .layout.with-preview { grid-template-columns: 1fr; }
  .preview { position: fixed; inset: 57px 0 0 0; z-index: 35; height: auto; }
  .splitter.vertical { display: none; }
  .clients { grid-template-columns: 1fr; }
  .tab .label { display: none; }
}

/* the agency's contact details, at the foot of the menu */
.menu .contact { padding: 8px 12px 4px; border-top: 1px solid var(--border); margin-top: 4px;
  display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
.menu .contact a { color: var(--muted); text-decoration: none; overflow-wrap: anywhere; }
.menu .contact a:hover { color: var(--accent); }

/* text page (privacy) */
.text-page { max-width: 760px; margin: 0 auto; padding: 40px 24px 64px; background: var(--surface); min-height: 100%; }
.text-page h1 { margin-bottom: 16px; }
.text-page h2 { margin: 28px 0 8px; }
.text-page p, .text-page li { color: var(--text); }

/* short dialog window (new client, rejection) */
.modal.small { width: min(480px, 92vw); }
.modal.small p { color: var(--text); margin: 8px 0 16px; }
.client-form input[type="text"] { width: 100%; }
.segment-choice { display: flex; gap: 20px; margin: 12px 0 20px; }
.segment-choice label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
