/* ============================================================
   S@FE Work — Design system partagé v1.0
   Usage : @import '../shared.css'; en première ligne de chaque module CSS
   Surcharger les 4 variables --accent-* pour l'identité du module
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600;700;800&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* ── TOKENS ────────────────────────────────────────────────── */
:root {
  --navy:#0a1628;    --navy-mid:#142240;
  --line:rgba(255,255,255,.08);  --line2:rgba(255,255,255,.12);
  --mut:#94a3b8;     --mut-2:#cbd5e1;
  --gold:#f59e0b;    --gold-lt:#fbbf24;
  --ok:#22c55e;      --ok-bg:rgba(34,197,94,.1);     --ok-bd:rgba(34,197,94,.3);
  --warn:#f59e0b;    --warn-bg:rgba(245,158,11,.1);  --warn-bd:rgba(245,158,11,.3);
  --alert:#ff4d5e;   --alert-bg:rgba(255,77,94,.1);  --alert-bd:rgba(255,77,94,.3);
  --r:12px;  --r-sm:8px;
  --ff-disp:'Sora',sans-serif;
  --ff-body:'IBM Plex Sans',sans-serif;
  --ff-mono:'IBM Plex Mono',monospace;

  /* Accent module — override dans chaque module CSS */
  --accent-mod:#3b82f6;
  --accent-mod-dark:#1d4ed8;
  --accent-mod-bg:rgba(59,130,246,.08);
  --accent-mod-bd:rgba(59,130,246,.25);
}

/* ── RESET ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: var(--ff-body);
  background: var(--navy);
  color: var(--mut-2);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1,h2,h3,h4 { font-family: var(--ff-disp); color: #fff; letter-spacing: -.02em; }

/* ── HELPERS ────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* ── VIEW HEADER ─────────────────────────────────────────────── */
.view-header  { margin-bottom: 18px; }
.view-title   { font-family: var(--ff-disp); font-size: 1.1rem; font-weight: 800; color: #fff; margin-bottom: 3px; }
.view-subtitle{ font-size: .78rem; color: var(--mut); font-family: var(--ff-mono); }
.eyebrow      { font-family: var(--ff-mono); font-size: .62rem; letter-spacing: .15em; color: var(--accent-mod); text-transform: uppercase; display: block; margin-bottom: 4px; }

/* ── CARDS ──────────────────────────────────────────────────── */
.card         { background: rgba(20,34,64,.7); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; }
.card-header  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 8px; flex-wrap: wrap; }
.card-title   { font-family: var(--ff-mono); font-size: .72rem; color: var(--mut); text-transform: uppercase; letter-spacing: .1em; }

/* ── STATS ──────────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card { background: rgba(20,34,64,.7); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.stat-val  { font-family: var(--ff-disp); font-size: 1.8rem; font-weight: 800; color: #fff; line-height: 1; }
.stat-lbl  { font-size: .74rem; color: var(--mut); margin-top: 3px; }

/* ── SCORE ──────────────────────────────────────────────────── */
.score-bar-wrap { height: 6px; background: rgba(255,255,255,.08); border-radius: 3px; overflow: hidden; margin: 6px 0; }
.score-bar      { height: 100%; border-radius: 3px; transition: width .5s ease; }
.score-badge    { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px; font-family: var(--ff-mono); font-size: .72rem; font-weight: 700; }
.score-ok    { background: var(--ok-bg);    color: var(--ok);    border: 1px solid var(--ok-bd); }
.score-warn  { background: var(--warn-bg);  color: var(--warn);  border: 1px solid var(--warn-bd); }
.score-alert { background: var(--alert-bg); color: var(--alert); border: 1px solid var(--alert-bd); }

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn {
  font-family: var(--ff-disp); font-weight: 700; font-size: .83rem;
  padding: 8px 18px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent; transition: .15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-pri {
  background: linear-gradient(135deg, var(--accent-mod-dark), var(--accent-mod));
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-mod-bg);
}
.btn-pri:hover { transform: translateY(-1px); }
.btn-ghost  { background: transparent; color: var(--mut); border-color: var(--line); }
.btn-ghost:hover { color: #fff; border-color: rgba(255,255,255,.2); }
.btn-danger { background: var(--alert-bg); color: var(--alert); border-color: var(--alert-bd); }
.btn-danger:hover { background: rgba(255,77,94,.2); }
.btn-ok     { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-bd); }
.btn-sm     { padding: 5px 12px; font-size: .74rem; border-radius: 8px; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none !important; }

/* ── BADGES ─────────────────────────────────────────────────── */
.badge       { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: .68rem; font-weight: 700; font-family: var(--ff-mono); white-space: nowrap; }
.badge-ok    { background: var(--ok-bg);    color: var(--ok);    border: 1px solid var(--ok-bd); }
.badge-warn  { background: var(--warn-bg);  color: var(--warn);  border: 1px solid var(--warn-bd); }
.badge-alert { background: var(--alert-bg); color: var(--alert); border: 1px solid var(--alert-bd); }
.badge-blue  { background: rgba(59,130,246,.12); color: #93c5fd; border: 1px solid rgba(59,130,246,.3); }
.badge-gray  { background: rgba(148,163,184,.1);  color: var(--mut); border: 1px solid var(--line); }
.badge-mod   { background: var(--accent-mod-bg); color: var(--accent-mod); border: 1px solid var(--accent-mod-bd); }

/* ── FORMS ──────────────────────────────────────────────────── */
.form-group, .field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.form-label, .field > label {
  font-size: .7rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--mut); font-family: var(--ff-mono);
}
.form-input, .form-select, .form-textarea,
input:not([type=checkbox]):not([type=radio]):not([type=range]),
select, textarea {
  width: 100%; background: rgba(255,255,255,.04);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  color: #fff; font-family: var(--ff-body); font-size: .84rem;
  padding: 8px 12px; outline: none; transition: border-color .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus,
input:focus, select:focus, textarea:focus { border-color: var(--accent-mod); }
select option, .form-select option { background: var(--navy-mid); color: var(--mut-2); }
.form-textarea, textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
input[type=checkbox], input[type=radio] { width: auto; cursor: pointer; }

/* ── TABLE ──────────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; border-radius: var(--r); border: 1px solid var(--line); }
table     { width: 100%; border-collapse: collapse; font-size: .82rem; }
th {
  background: rgba(15,29,53,.9); color: var(--mut); font-family: var(--ff-mono);
  font-size: .65rem; letter-spacing: .1em; text-transform: uppercase;
  padding: 9px 13px; text-align: left; border-bottom: 1px solid var(--line);
}
td { padding: 10px 13px; border-bottom: 1px solid rgba(255,255,255,.035); color: var(--mut-2); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }

/* ── MODAL ──────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.7); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--navy-mid); border: 1px solid var(--line);
  border-radius: 16px; width: min(580px,96vw); max-height: 90vh;
  overflow-y: auto; display: flex; flex-direction: column;
}
.modal-head, .modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.modal-title { font-family: var(--ff-disp); font-size: 1rem; font-weight: 800; color: #fff; }
.modal-close {
  background: none; border: none; color: var(--mut); font-size: 1.2rem;
  cursor: pointer; padding: 4px 8px; border-radius: 6px; transition: .15s; line-height: 1;
}
.modal-close:hover { color: #fff; background: rgba(255,255,255,.08); }
.modal-body { padding: 18px 20px; flex: 1; overflow-y: auto; }
.modal-foot, .modal-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 14px 20px; border-top: 1px solid var(--line); flex-shrink: 0;
}

/* ── SIDEBAR CONTACTS ───────────────────────────────────────── */
.sidebar-search-wrap { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.sidebar-search {
  width: 100%; background: rgba(255,255,255,.05);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  color: #fff; font-family: var(--ff-body); font-size: .8rem;
  padding: 6px 10px; outline: none; transition: border-color .15s;
}
.sidebar-search:focus { border-color: var(--accent-mod); }
.sidebar-contact-list { flex: 1; overflow-y: auto; padding: 6px 0; }
.sidebar-contact-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: pointer; transition: .12s;
  font-size: .82rem; color: var(--mut-2);
  border: 1px solid transparent; border-radius: var(--r-sm); margin: 1px 8px;
}
.sidebar-contact-item:hover { background: rgba(255,255,255,.04); color: #fff; }
.sidebar-contact-item.active {
  background: var(--accent-mod-bg);
  border-color: var(--accent-mod-bd);
  color: #fff;
}

/* ── SUBNAV CLIENT ──────────────────────────────────────────── */
.subnav-client      { padding: 10px 14px 14px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.subnav-client-name { font-size: .82rem; font-weight: 700; color: #fff; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subnav-score       { font-family: var(--ff-mono); font-size: 1.3rem; font-weight: 800; color: var(--accent-mod); }
.subnav-menu        { list-style: none; padding: 0 8px; }
.subnav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--r-sm);
  cursor: pointer; font-size: .81rem; color: var(--mut-2);
  transition: .12s; border: 1px solid transparent; white-space: nowrap;
}
.subnav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.subnav-item.active { background: var(--accent-mod-bg); border-color: var(--accent-mod-bd); color: #fff; font-weight: 600; }

/* ── ITEM ROWS ──────────────────────────────────────────────── */
.item-list    { display: flex; flex-direction: column; gap: 8px; }
.item-row     {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: rgba(20,34,64,.7);
  border: 1px solid var(--line); border-radius: var(--r);
  cursor: pointer; transition: .13s;
}
.item-row:hover { border-color: rgba(255,255,255,.15); background: rgba(255,255,255,.04); }
.item-row-info { flex: 1; min-width: 0; }
.item-row-name { font-weight: 600; font-size: .9rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-row-meta { font-size: .74rem; color: var(--mut); font-family: var(--ff-mono); margin-top: 2px; }

/* ── FILTER ROW ─────────────────────────────────────────────── */
.filter-row { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-btn {
  background: rgba(255,255,255,.04); border: 1px solid var(--line); color: var(--mut);
  padding: 4px 11px; border-radius: 8px; cursor: pointer; font-size: .73rem; transition: .12s;
  display: inline-flex; align-items: center; gap: 5px;
}
.filter-btn:hover { color: #fff; border-color: rgba(255,255,255,.2); }
.filter-btn.active { background: var(--accent-mod-bg); border-color: var(--accent-mod-bd); color: var(--accent-mod); }

/* ── CHECKLIST / STATUS SELECT ──────────────────────────────── */
.checklist-cat      { margin-bottom: 20px; }
.checklist-cat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-radius: var(--r-sm); margin-bottom: 8px;
  background: var(--accent-mod-bg); border: 1px solid var(--accent-mod-bd);
}
.checklist-cat-label { font-weight: 700; font-size: .88rem; color: #fff; display: flex; align-items: center; gap: 8px; }
.checklist-cat-score { font-family: var(--ff-mono); font-size: .78rem; font-weight: 700; }
.checklist-items     { display: flex; flex-direction: column; gap: 6px; }
.checklist-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: rgba(255,255,255,.02);
  border: 1px solid var(--line); border-radius: var(--r-sm); transition: .15s;
}
.checklist-item:hover { background: rgba(255,255,255,.04); }
.checklist-item-label  { flex: 1; font-size: .83rem; color: var(--mut-2); }
.checklist-notes-input {
  width: 140px; font-size: .74rem; font-family: var(--ff-mono);
  background: rgba(255,255,255,.04); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 8px; color: var(--mut-2); outline: none; width: auto;
}
.checklist-notes-input:focus { border-color: var(--accent-mod); }
.status-select {
  font-family: var(--ff-mono); font-size: .72rem; font-weight: 700;
  padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line);
  background: rgba(255,255,255,.06); color: var(--mut-2); cursor: pointer; outline: none;
  width: auto;
}
.status-select.conforme     { border-color: rgba(34,197,94,.4);  color: var(--ok);    background: rgba(34,197,94,.08); }
.status-select.partiel      { border-color: rgba(245,158,11,.4); color: var(--warn);  background: rgba(245,158,11,.08); }
.status-select.non_conforme { border-color: rgba(255,77,94,.4);  color: var(--alert); background: rgba(255,77,94,.08); }
.status-select.na           { border-color: var(--line); color: var(--mut); opacity: .6; }

/* ── LOADER / SPINNER ───────────────────────────────────────── */
.loader  { display: flex; align-items: center; gap: 10px; padding: 40px 0; color: var(--mut); font-size: .85rem; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent-mod); border-radius: 50%; animation: safe-spin .7s linear infinite; flex-shrink: 0; }
@keyframes safe-spin { to { transform: rotate(360deg); } }

/* ── EMPTY STATE ────────────────────────────────────────────── */
.empty-state     { text-align: center; padding: 48px 20px; color: var(--mut); }
.empty-state .ico{ font-size: 2.2rem; margin-bottom: 10px; opacity: .4; }
.empty-state p   { font-size: .85rem; }

/* ── TOAST BASE ─────────────────────────────────────────────── */
.safe-toast {
  position: fixed; bottom: 22px; right: 22px; z-index: 9999;
  padding: 10px 18px; border-radius: 10px;
  font-size: .82rem; font-weight: 600; font-family: var(--ff-mono);
  transform: translateY(20px); opacity: 0; transition: .25s; pointer-events: none;
  background: var(--ok-bg); border: 1px solid var(--ok-bd); color: var(--ok);
}
.safe-toast.show { transform: translateY(0); opacity: 1; }
.safe-toast.err  { background: var(--alert-bg); border-color: var(--alert-bd); color: var(--alert); }
.safe-toast.warn { background: var(--warn-bg);  border-color: var(--warn-bd);  color: var(--warn); }

/* ── KANBAN ─────────────────────────────────────────────────── */
.kanban-board    { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kanban-col      { flex-shrink: 0; width: 240px; background: rgba(20,34,64,.5); border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; }
.kanban-col-head { padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.kanban-col-label{ font-family: var(--ff-mono); font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--mut-2); font-weight: 700; }
.kanban-col-count{ font-family: var(--ff-mono); font-size: .65rem; background: rgba(255,255,255,.07); padding: 1px 7px; border-radius: 10px; color: var(--mut); }
.kanban-cards    { padding: 8px; display: flex; flex-direction: column; gap: 7px; min-height: 60px; }
.kanban-card {
  background: rgba(255,255,255,.03); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 10px 12px; cursor: grab;
  transition: border-color .15s, box-shadow .15s;
}
.kanban-card:hover { border-color: rgba(255,255,255,.15); box-shadow: 0 4px 12px rgba(0,0,0,.3); }
.kanban-card.dragging { opacity: .45; cursor: grabbing; }
.kanban-card.drag-over { border-color: var(--accent-mod); box-shadow: 0 0 0 1px var(--accent-mod); }
.kanban-col.drop-target { border-color: var(--accent-mod-bd); background: var(--accent-mod-bg); }
.kanban-card-title { font-size: .82rem; font-weight: 600; color: #fff; margin-bottom: 5px; }
.kanban-card-meta  { font-size: .71rem; color: var(--mut); font-family: var(--ff-mono); display: flex; gap: 8px; flex-wrap: wrap; }
.kanban-add-card   { margin: 0 8px 8px; padding: 6px; border-radius: var(--r-sm); border: 1px dashed var(--line); background: none; color: var(--mut); font-size: .75rem; cursor: pointer; transition: .15s; width: calc(100% - 16px); text-align: left; }
.kanban-add-card:hover { border-color: var(--accent-mod); color: var(--accent-mod); }

/* ── TIMELINE ───────────────────────────────────────────────── */
.timeline-wrap      { overflow-x: auto; }
.timeline-grid      { display: grid; gap: 0; min-width: 700px; }
.timeline-row       { display: flex; align-items: center; border-bottom: 1px solid var(--line); min-height: 48px; }
.timeline-row:last-child { border-bottom: none; }
.timeline-row-label { width: 180px; flex-shrink: 0; font-size: .8rem; color: var(--mut-2); padding: 8px 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline-row-label strong { display: block; color: #fff; font-size: .82rem; }
.timeline-area      { flex: 1; position: relative; height: 48px; }
.timeline-bar {
  position: absolute; top: 50%; transform: translateY(-50%);
  height: 20px; border-radius: 4px; cursor: pointer;
  background: var(--accent-mod-bg); border: 1px solid var(--accent-mod-bd);
  display: flex; align-items: center; padding: 0 8px;
  font-size: .68rem; font-family: var(--ff-mono); color: var(--accent-mod);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: border-color .15s;
}
.timeline-bar:hover { border-color: var(--accent-mod); box-shadow: 0 0 0 1px var(--accent-mod); }
.timeline-bar.bar-ok    { background: var(--ok-bg);    border-color: var(--ok-bd);    color: var(--ok); }
.timeline-bar.bar-warn  { background: var(--warn-bg);  border-color: var(--warn-bd);  color: var(--warn); }
.timeline-bar.bar-alert { background: var(--alert-bg); border-color: var(--alert-bd); color: var(--alert); }
.timeline-header  { display: flex; border-bottom: 1px solid var(--line2); }
.timeline-header-labels { width: 180px; flex-shrink: 0; }
.timeline-header-months { flex: 1; display: flex; }
.timeline-month   { flex: 1; font-family: var(--ff-mono); font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: var(--mut); padding: 6px 4px; border-left: 1px solid var(--line); text-align: center; }
.timeline-today   { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--gold); opacity: .6; }

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .kanban-board { flex-direction: column; }
  .kanban-col { width: 100%; }
  .timeline-row-label { width: 120px; }
}
