/* Charte alignée sur l'application « Plan de charge collaboratif » (DPS). */
:root {
  --bg: #f4f7fb;
  --card: #fff;
  --text: #172033;
  --muted: #64748b;
  --line: #dbe2ea;
  --primary: #1f2a44;
  --primary2: #314166;
  --surface: #eef2f7;
  --bg-header: #fff;
  --bg-sidebar: #fff;
  --border-strong: #b0b0b0;
  --accent: var(--primary);
  --danger: #b91c1c;

  --green: #dcfce7;
  --greenText: #166534;
  --orange: #ffedd5;
  --orangeText: #9a3412;
  --red: #fee2e2;
  --redText: #991b1b;
  --blue: #dbeafe;
  --blueText: #1d4ed8;
  --purple: #ede9fe;
  --purpleText: #6d28d9;
  --gray: #e2e8f0;
  --grayText: #334155;
  --teal: #ccfbf1;
  --tealText: #0f766e;
}

[data-theme="dark"] {
  --bg: #14141a;
  --card: #20212b;
  --surface: #262837;
  --text: #eef1f6;
  --muted: #94a3b8;
  --line: #333648;
  --bg-header: #1b1c25;
  --bg-sidebar: #1b1c25;
  --border-strong: #4b4f63;
  --primary: #7d97e0;
  --primary2: #5f7bc9;
  --accent: #7d97e0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ===== En-tête ===== */
.app-header {
  height: 64px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
}

.app-logo-wrap {
  background: #fff;
  border-radius: 8px;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.app-logo { height: 24px; width: auto; display: block; }

.app-title-block {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 0;
  min-width: 0;
  overflow: hidden;
}

.app-title, .app-subtitle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-title { font-weight: 700; font-size: 16px; }
.app-subtitle { font-size: 12px; color: var(--muted); }

.app-header-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.app-user { font-size: 12px; color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== Boutons ===== */
button, .fileBtn {
  font-family: inherit;
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

button:hover:not(:disabled), .fileBtn:hover { background: var(--primary2); }
button:disabled { opacity: .55; cursor: not-allowed; }

button.secondary {
  background: var(--card);
  color: var(--primary);
  border: 1px solid var(--line);
}
button.secondary:hover:not(:disabled) { background: var(--surface); }

button.danger { background: var(--danger); }
button.danger:hover:not(:disabled) { background: #991b1b; }

button.smallBtn { padding: 6px 9px; border-radius: 9px; font-size: 12px; }

.btn-toggle {
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--text);
  transition: all .15s ease;
}
.btn-toggle:hover:not(:disabled) { background: var(--card); border-color: var(--accent); color: var(--accent); }

.btn-burger {
  display: none;
  background: none;
  font-size: 22px;
  padding: 6px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 8px;
  color: var(--text);
}
.btn-burger:hover:not(:disabled) { background: var(--surface); }

/* ===== Mise en page : barre latérale + contenu ===== */
.app-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: calc(100vh - 64px);
}

.app-sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  overflow-y: auto;
}

.app-main { padding: 22px; max-width: 1700px; margin: 0 auto; width: 100%; min-width: 0; }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.sidebar-backdrop.open { opacity: 1; pointer-events: auto; }

.tabs { display: flex; flex-direction: column; gap: 3px; }

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 12px 10px 14px;
  border-radius: 0 8px 8px 0;
  border-left: 3px solid transparent;
  color: var(--text);
  text-decoration: none;
  transition: background .12s ease, border-color .12s ease;
}
.tab:hover { background: var(--surface); }
.tab.active { background: var(--surface); border-left-color: var(--accent); color: var(--accent); font-weight: 700; }
.tab-icon { width: 20px; font-size: 14px; text-align: center; flex-shrink: 0; }

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  padding: 0 12px 4px 14px;
  margin: 0;
}

/* ===== Cartes ===== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .06);
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 4px; font-size: 18px; }
.card-header { margin-bottom: 14px; }
.card-header p { margin: 0; }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.space { justify-content: space-between; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 12px; }

/* ===== Zone de dépôt ===== */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 28px 16px;
  border: 2px dashed var(--line);
  border-radius: 14px;
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); }
.dropzone.dragover { background: var(--blue); }
[data-theme="dark"] .dropzone.dragover { background: var(--card); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dropzone:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone-icon { font-size: 28px; }
.dropzone-title { font-weight: 700; }

/* ===== File d'upload ===== */
.upload-queue { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.upload-queue:empty { display: none; }
.upload-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 13px;
}
.upload-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.upload-item .status { color: var(--muted); font-weight: 600; }
.upload-item.done .status { color: var(--greenText); }
.upload-item.error .status { color: var(--redText); }
[data-theme="dark"] .upload-item.done .status { color: #86efac; }
[data-theme="dark"] .upload-item.error .status { color: #fca5a5; }
.upload-item progress { grid-column: 1 / -1; width: 100%; height: 6px; accent-color: var(--accent); }

/* ===== Tableau ===== */
.tableWrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  max-height: 680px;
  background: var(--card);
}

table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }

th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}
th {
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 13px;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface); }
td:first-child { font-weight: 700; white-space: normal; word-break: break-word; min-width: 220px; }
th.num, td.num { text-align: right; }
td:last-child, th:last-child { text-align: right; }
td.actions button + button { margin-left: 6px; }
td.empty { text-align: center; color: var(--muted); font-weight: 400; padding: 28px; }

td a { color: var(--accent); text-decoration: none; }
td a:hover { text-decoration: underline; }

/* Pastilles de type de document */
.pill {
  display: inline-flex;
  min-width: 46px;
  min-height: 24px;
  padding: 0 8px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 800;
  font-size: 11px;
}
.pill-pdf   { background: var(--red);    color: var(--redText);    border-color: #fca5a5; }
.pill-word  { background: var(--blue);   color: var(--blueText);   border-color: #93c5fd; }
.pill-excel { background: var(--green);  color: var(--greenText);  border-color: #86efac; }
.pill-ppt   { background: var(--orange); color: var(--orangeText); border-color: #fdba74; }
.pill-web   { background: var(--purple); color: var(--purpleText); border-color: #c4b5fd; }
.pill-other { background: var(--gray);   color: var(--grayText);   border-color: #cbd5e1; }

/* ===== Messages ===== */
.statusBar {
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  font-weight: 600;
  font-size: 14px;
}
.statusBar.error { background: var(--red); color: var(--redText); border-color: #fca5a5; }
.statusBar.ok { background: var(--green); color: var(--greenText); border-color: #86efac; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .app-main { padding: 14px; }
  .tableWrap { max-height: 520px; }
}

@media (max-width: 760px) {
  .app-layout { grid-template-columns: minmax(0, 1fr); }
  .app-sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    width: min(80vw, 280px);
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .25s ease, visibility .25s;
    visibility: hidden;
  }
  .app-sidebar.open { transform: translateX(0); visibility: visible; box-shadow: 4px 0 18px rgba(0, 0, 0, .18); }
  td:first-child { min-width: 160px; }
  .btn-burger { display: inline-flex; }
  .app-subtitle, .app-user { display: none; }
  .app-header { padding: 0 12px; gap: 8px; }
  .btn-toggle { padding: 8px 10px; font-size: 11px; }
}
