/* Plateforme projets — feuille de style principale */

:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 15px; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .4rem; }
h2 { font-size: 1.15rem; margin: 1.2rem 0 .5rem; }
h3 { font-size: 1rem; margin: .8rem 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mt { margin-top: 1rem; }
.mb { margin-bottom: 1rem; }

/* ---------- Barre supérieure ---------- */
.topbar {
  display: flex; align-items: center; gap: .8rem;
  background: #0f172a; color: #e2e8f0;
  padding: .45rem .9rem; flex-wrap: wrap;
}
.brand { color: #fff; font-weight: 700; font-size: 1.02rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.mainnav { display: flex; gap: .1rem; align-items: center; flex-wrap: wrap; }
.mainnav > a, .navbtn {
  color: #cbd5e1; padding: .35rem .65rem; border-radius: 7px;
  background: none; border: 0; font: inherit; cursor: pointer; white-space: nowrap;
}
.mainnav > a:hover, .navbtn:hover { background: #1e293b; color: #fff; text-decoration: none; }
.mainnav > a.on { background: #1e40af; color: #fff; }
.searchform { margin-left: auto; }
.searchform input {
  background: #1e293b; border: 1px solid #334155; color: #e2e8f0;
  padding: .35rem .6rem; border-radius: 7px; width: 170px;
}
.searchform input::placeholder { color: #94a3b8; }

/* ---------- Onglets projets ---------- */
.projtabs {
  display: flex; gap: .25rem; padding: .45rem .9rem 0; background: #fff;
  border-bottom: 1px solid var(--line); overflow-x: auto; align-items: flex-end;
}
.ptab {
  padding: .42rem .8rem; border-radius: 9px 9px 0 0; color: var(--muted);
  border: 1px solid transparent; border-bottom: 0; white-space: nowrap; font-size: .92rem;
  border-top: 3px solid transparent;
}
.ptab:hover { background: var(--bg); text-decoration: none; }
.ptab.on {
  background: var(--bg); color: var(--text); font-weight: 600;
  border-color: var(--line); border-top-color: var(--pc, var(--primary));
}
.ptab-add { font-weight: 700; color: var(--primary); }

/* ---------- Page ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 1.1rem .9rem 3rem; }

.flash { padding: .6rem .9rem; border-radius: var(--radius); margin-bottom: .8rem; }
.flash-success { background: #dcfce7; color: #14532d; }
.flash-error { background: #fee2e2; color: #7f1d1d; }
.flash-info { background: #dbeafe; color: #1e3a8a; }

/* ---------- Entête projet ---------- */
.project-head {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .9rem 1rem 0; margin-bottom: 1rem; border-top: 4px solid var(--pc, var(--primary));
}
.project-head-main { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.project-head-main h1 { margin: 0; }
.modtabs { display: flex; gap: .1rem; margin-top: .6rem; overflow-x: auto; }
.mtab { padding: .45rem .7rem; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; font-size: .92rem; }
.mtab:hover { color: var(--text); text-decoration: none; }
.mtab.on { color: var(--text); font-weight: 600; border-bottom-color: var(--pc, var(--primary)); }

/* ---------- Cartes et grilles ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1rem; margin-bottom: 1rem;
}
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.card-title h2, .card-title h3 { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 860px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* ---------- Indicateurs ---------- */
.kpis { display: flex; gap: .8rem; flex-wrap: wrap; }
.kpi {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .7rem 1rem; min-width: 120px; flex: 1;
}
.kpi .kpi-num { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.kpi .kpi-label { color: var(--muted); font-size: .82rem; }
.kpi.kpi-warn .kpi-num { color: var(--warn); }
.kpi.kpi-danger .kpi-num { color: var(--danger); }
.kpi.kpi-success .kpi-num { color: var(--success); }

/* ---------- Badges, puces ---------- */
.badge {
  display: inline-block; padding: .1rem .5rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; color: #fff; background: var(--bc, #64748b);
  white-space: nowrap; vertical-align: middle;
}
.chip {
  display: inline-block; padding: .08rem .5rem; border-radius: 999px;
  font-size: .8rem; background: var(--bg); color: var(--muted); border: 1px solid var(--line);
  white-space: nowrap; vertical-align: middle;
}
.chip-late { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.chip-soon { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.reason {
  display: inline-block; font-size: .78rem; color: #7c3aed; background: #f3e8ff;
  border-radius: 999px; padding: .05rem .5rem; white-space: nowrap;
}

/* ---------- Barre de progression ---------- */
.progress {
  display: inline-block; width: 120px; height: 8px; background: var(--line);
  border-radius: 999px; overflow: hidden; vertical-align: middle;
}
.progress-bar { height: 100%; background: var(--success); }
.progress-num { font-size: .82rem; color: var(--muted); margin-left: .4rem; }

/* ---------- Listes d'items (tâches, blocs) ---------- */
.item-list { display: flex; flex-direction: column; }
.item {
  display: flex; align-items: center; gap: .6rem; padding: .55rem .3rem;
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.item:last-child { border-bottom: 0; }
.item.done .item-title { text-decoration: line-through; color: var(--muted); }
.item-main { flex: 1; min-width: 220px; }
.item-title { font-weight: 500; }
.item-meta { font-size: .82rem; color: var(--muted); display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .1rem; }
.item-actions { display: flex; gap: .3rem; flex-wrap: wrap; }

.block {
  border: 1px solid var(--line); border-left: 4px solid var(--pc, var(--primary));
  border-radius: var(--radius); margin-bottom: .9rem; background: var(--card); box-shadow: var(--shadow);
}
.block-head {
  display: flex; align-items: center; gap: .6rem; padding: .6rem .9rem;
  border-bottom: 1px solid var(--line); flex-wrap: wrap; background: #f8fafc;
  border-radius: var(--radius) var(--radius) 0 0;
}
.block-head .block-title { font-weight: 700; }
.block-body { padding: .2rem .9rem; }

/* ---------- Tableaux ---------- */
.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem;
  text-transform: uppercase; letter-spacing: .02em;
  padding: .45rem .5rem; border-bottom: 2px solid var(--line); white-space: nowrap;
}
table.data td { padding: .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:hover td { background: #f8fafc; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-block; padding: .4rem .8rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  cursor: pointer; font: inherit; font-size: .9rem; white-space: nowrap;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-sm { padding: .18rem .55rem; font-size: .82rem; border-radius: 7px; }
.btn-block { width: 100%; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }

/* ---------- Formulaires ---------- */
form label { display: block; margin-bottom: .7rem; font-size: .9rem; color: var(--text); }
form label > input, form label > select, form label > textarea {
  display: block; width: 100%; margin-top: .25rem;
}
input[type="text"], input[type="search"], input[type="email"], input[type="password"],
input[type="date"], input[type="time"], input[type="number"], input[type="url"], select, textarea {
  padding: .45rem .6rem; border: 1px solid #cbd5e1; border-radius: 8px;
  font: inherit; background: #fff; color: var(--text); max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
textarea { resize: vertical; }
.form-row { display: flex; gap: .8rem; flex-wrap: wrap; }
.form-row > label { flex: 1; min-width: 140px; }
.form-actions { display: flex; gap: .6rem; margin-top: .8rem; flex-wrap: wrap; align-items: center; }
.checkline { display: flex !important; align-items: center; gap: .45rem; }
.checkline input { width: auto !important; margin: 0 !important; display: inline-block !important; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 1rem; padding: .8rem 1rem; }
legend { font-weight: 600; padding: 0 .4rem; }

/* Filtres au-dessus des listes */
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .8rem; }
.filters select, .filters input { padding: .32rem .5rem; }
.filters .btn { padding: .32rem .7rem; }
.fchip { padding: .2rem .7rem; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: .85rem; }
.fchip:hover { text-decoration: none; background: var(--bg); }
.fchip.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Fenêtre modale ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; z-index: 50;
  overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 12px; width: 560px; max-width: 100%;
  padding: 1rem 1.2rem; box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .7rem; }
.modal-close { border: 0; background: none; font-size: 1.5rem; cursor: pointer; color: var(--muted); line-height: 1; }
.qa-tabs { display: flex; gap: .3rem; margin-bottom: .9rem; flex-wrap: wrap; }
.qa-tab {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: .25rem .8rem; cursor: pointer; font: inherit; font-size: .87rem; color: var(--muted);
}
.qa-tab.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Menus déroulants ---------- */
.dropdown { position: relative; }
.dropdown-menu {
  display: none; position: absolute; top: 100%; left: 0; z-index: 40;
  background: #fff; border: 1px solid var(--line); border-radius: 9px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .15); min-width: 180px; padding: .3rem;
}
.dropdown-right { left: auto; right: 0; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a { display: block; padding: .42rem .7rem; color: var(--text); border-radius: 6px; white-space: nowrap; }
.dropdown-menu a:hover { background: var(--bg); text-decoration: none; }

/* ---------- Calendrier ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head { font-size: .78rem; color: var(--muted); text-transform: uppercase; padding: .2rem .3rem; }
.cal-cell {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  min-height: 92px; padding: .25rem .35rem; font-size: .82rem; overflow: hidden;
}
.cal-cell.out { background: #f8fafc; color: #cbd5e1; }
.cal-cell.today { border-color: var(--primary); border-width: 2px; }
.cal-day { font-weight: 600; color: var(--muted); }
.cal-cell.today .cal-day { color: var(--primary); }
.cal-ev {
  display: block; padding: .05rem .3rem; margin-top: .15rem; border-radius: 5px;
  background: var(--bg); color: var(--text); border-left: 3px solid var(--pc, var(--primary));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .78rem;
}
.cal-ev:hover { text-decoration: none; background: #e2e8f0; }

/* ---------- Fiche / timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: .45rem 0 .45rem 1.1rem; border-left: 2px solid var(--line); position: relative; }
.timeline li::before {
  content: ''; position: absolute; left: -5px; top: .85rem;
  width: 8px; height: 8px; border-radius: 50%; background: var(--primary);
}
.timeline .tl-date { font-size: .8rem; color: var(--muted); }

.deflist { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .9rem; font-size: .92rem; }
.deflist dt { color: var(--muted); }
.deflist dd { margin: 0; }

/* ---------- Connexion ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box {
  background: var(--card); padding: 2rem; border-radius: 14px; box-shadow: var(--shadow);
  width: 360px; max-width: 92vw;
}
.login-box h1 { text-align: center; }
.login-box .muted { text-align: center; margin-top: 0; }

/* ---------- Alertes / à surveiller ---------- */
.alert-line { display: flex; gap: .5rem; align-items: baseline; padding: .35rem 0; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.alert-line:last-child { border-bottom: 0; }
.alert-ico { flex-shrink: 0; }

/* ---------- Empty state ---------- */
.empty { color: var(--muted); text-align: center; padding: 1.2rem 0; }

@media (max-width: 700px) {
  .topbar { gap: .4rem; }
  .searchform { order: 10; width: 100%; margin-left: 0; }
  .searchform input { width: 100%; }
  .page { padding: .8rem .55rem 3rem; }
  .kpi { min-width: 100px; padding: .55rem .7rem; }
}

@media print {
  .topbar, .projtabs, .item-actions, .btn, .filters { display: none !important; }
  body { background: #fff; }
  .card, .block { box-shadow: none; border: 1px solid #ddd; }
}
