/* style.css — refonte mobile-first, en conservant vos composants existants */

/* ========== Variables ========== */
:root{
  --bg: #f2f2f2;
  --text: #111827;
  --muted: #666;
  --primary: #0056b3;
  --primary-dark: #003f7f;
  --accent: #0056b3;
  --surface: #ffffff;

  --nav-bg: #1a1a1a;
  --nav-bg-2: #222;
  --nav-text: #fff;
  --nav-border: #2e2e2e;

  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 16px;

  --shadow: 0 4px 14px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.07);
}

/* ========== Base ========== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
img { max-width: 100%; height: auto; }

/* ========== Navbar responsive ========== */
.navbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--nav-bg);
  color: var(--nav-text);
  padding: 10px 14px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--nav-border);
}
.navbar-left {
  display: flex; align-items: center; gap: 10px;
  min-width: 0;
}
.navbar-logo img { height: 40px; display: block; }
.navbar-title { font-weight: 700; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Burger (si utilisé par certaines pages) */
.nav-toggle {
  display: none;
  width: 40px; height: 36px;
  border: 1px solid rgba(255,255,255,.2);
  background: transparent; color: inherit; cursor: pointer;
  border-radius: var(--radius-sm);
  align-items: center; justify-content: center;
  padding: 6px;
}
.nav-toggle-bar {
  display: block; width: 20px; height: 2px; background: #fff; margin: 3px auto;
}

/* Nav panel */
.nav-panel { justify-self: center; }
.nav-links { display: flex; align-items: center; gap: 12px; list-style: none; margin: 0; padding: 0; }
.nav-links a { color: #ddd; text-decoration: none; padding: 6px 8px; border-radius: var(--radius-sm); }
.nav-links a:hover { background: rgba(255,255,255,.08); }

.user-info {
  display: flex; gap: 8px; align-items: center; justify-self: end;
  flex-wrap: wrap;
}
.user-info a, .user-info button, .user-info span { color: #fff; }

/* ========== Contenu générique ========== */
.content {
  /* élargi pour réduire les marges latérales sur écran large */
  padding: clamp(12px, 2vw, 20px);
  max-width: min(1600px, 96vw);
  margin: 0 auto;
}

/* ========== Hero (landing non connecté) ========== */
.hero-top{
  display:grid;
  grid-template-columns:auto 1fr auto;
  align-items:center; gap:14px;
}
.hero-left{ display:flex; align-items:center; gap:10px }
.hero-right{ text-align:right }
.hero-img{
  height:86px; width:auto; border-radius:999px;
  border:3px solid #e5e7eb; box-shadow:0 2px 6px rgba(0,0,0,.15);
}

/* Justification des textes de la landing non connectée */
.landing-card p{ text-align: justify; }

/* ========== Profil connecté ========== */
.cta-bar{ display:flex; justify-content:center; margin-top:12px; }
.btn-cta{
  display:inline-flex; align-items:center; gap:8px; font-weight:800;
  background: var(--primary); color:#fff; text-decoration:none;
  padding:12px 18px; border-radius:12px; box-shadow: var(--shadow);
}
.btn-cta:hover{ background: var(--primary-dark); }
.btn-cta.disabled{ background:#9ca3af; pointer-events:none; text-decoration: line-through; }
.btn-cta.disabled:hover{ background:#9ca3af; }
.profile-grid{
  display:grid; grid-template-columns:auto 1fr; gap:16px; align-items:center;
}
.degree-box{ display:flex; align-items:center; gap:12px; }
.avatar-wrap{ position:relative; display:inline-block; }
.profile-avatar{
  width:128px; height:128px; border-radius:999px; object-fit:cover;
  border:3px solid #e5e7eb; box-shadow:0 6px 16px rgba(0,0,0,.12);
}
.deg-medal{
  position:absolute; top:-8px; right:-8px; width:40px; height:40px;
  border-radius:999px; display:grid; place-items:center; color:#fff;
  box-shadow:0 6px 16px rgba(0,0,0,.18), inset 0 0 0 2px rgba(255,255,255,.5);
}
.deg-medal .deg-num{ font-weight:800; font-size:18px; line-height:1; text-shadow:0 1px 2px rgba(0,0,0,.35); }
.degree-badge{
  width:96px; height:96px; border-radius:999px; display:grid; place-items:center; color:#fff;
  box-shadow:0 8px 20px rgba(0,0,0,.12), inset 0 0 0 3px rgba(255,255,255,.35);
}
.deg-num{ font-size:34px; font-weight:800; line-height:1; text-shadow:0 1px 2px rgba(0,0,0,.3); }
.deg-label{ font-weight:700; }
.deg-sub{ font-size:.9rem; }

/* Palettes par tranche de degrés */
.degree-lv-0{ background:linear-gradient(135deg,#6b7280,#9ca3af); }
.degree-lv-1{ background:linear-gradient(135deg,var(--primary-dark,#003f7f),var(--primary,#0056b3)); }
.degree-lv-2{ background:linear-gradient(135deg,#7c3aed,#a855f7); }
.degree-lv-3{ background:linear-gradient(135deg,#d97706,#f59e0b); }
.degree-lv-4{ background:linear-gradient(135deg,#b91c1c,#ef4444); }

.role-chips{ align-items:center; }
.role-chip{ display:inline-flex; align-items:center; gap:6px; padding:4px 10px; border-radius:999px; font-weight:700; }
.role-chip svg{ width:16px; height:16px; display:block; }
.role-chip.modo{ background:#eef2ff; color:#3730a3; }
.role-chip.admin{ background:#fee2e2; color:#991b1b; }
.display-input{ max-width:420px; }

/* ========== Mise en page “admin” & sidebar ========== */
.admin-container {
  display: flex; gap: 16px; align-items: flex-start;
  /* élargi aussi ici */
  max-width: min(1600px, 96vw);
  margin: 16px auto; padding: 0 16px;
  min-height: 80vh;
}
.sidebar {
  width: 240px; background: var(--nav-bg-2); color: #eee; padding: 16px;
  border-radius: var(--radius); position: sticky; top: 70px;
}
.sidebar h3 { margin-top: 0; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a { color: #ddd; text-decoration: none; display: block; padding: 6px 8px; border-radius: var(--radius-sm); }
.sidebar a:hover, .sidebar a.active { background: rgba(255,255,255,.08); }
.main-content {
  flex: 1; min-width: 0; background: transparent; padding: 8px;
}

/* ========== Cartes & composants réutilisables ========== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 16px 0;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}
.main-content section h3 { margin-top: 0; }
.main-content section input, .main-content section select, .main-content section button {
  margin-top: 8px;
}
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-space { justify-content: space-between; }
.muted { color: var(--muted); font-size: .9rem; }
.block-label { display: block; margin: 8px 0 6px; }
.no-margin { margin: 0; }
.tag {
  display: inline-block; background: #eef2ff; color: #3730a3;
  padding: 2px 8px; border-radius: 999px; font-size: .8rem;
}
.alert {
  padding: 10px 12px; border-radius: 8px; background: #fff7ed;
  border: 1px solid #fed7aa; color: #7c2d12;
}
details summary { cursor: pointer; }

/* Inputs & boutons */
button {
  background: var(--primary); color: #fff;
  border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-weight: bold;
}
button:hover { background: var(--primary-dark); }
.admin-btn { padding: 8px 12px; border-radius: 10px; }
.btn-secondary { background: #555; }
.btn-secondary:hover { background: #3f3f3f; }
textarea, select, input[type="text"], input[type="number"], input[type="file"], input[type="range"]{
  width: 100%; border: 1px solid #ddd; border-radius: 8px; padding: 10px; font: inherit; background: #fff;
}

/* Tables */
.styled-table { width: 100%; border-collapse: collapse; }
.styled-table th, .styled-table td { padding: 8px 12px; border: 1px solid #e5e7eb; text-align: left; }
.styled-table th { background: #f9fafb; }
.table-responsive { width: 100%; overflow-x: auto; }

/* ========== Upload form (shared) ========== */
.form-card{ background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 24px; margin-top: 12px; }
.form-grid{ display: grid; grid-template-columns: 220px 1fr; gap: 14px 18px; align-items: center; }
.form-row.full{ grid-column: 1 / -1; }
.form-grid label{ font-weight: 600; color: #1e293b; }
.range-row{ display: flex; flex-direction: column; gap: 8px; }
.range-header{ display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.badge{ display: inline-block; padding: 3px 8px; border-radius: 999px; background: #f1f5f9; font-size: .85rem; color: #334155; }
.hint{ font-size: .85rem; color: #475569; }
.actions{ margin-top: 18px; display: flex; justify-content: flex-end; }
@media (max-width: 700px){ .form-grid{ grid-template-columns: 1fr; } .form-grid label{ margin-top: 6px; } }

/* ========== Consulter (shared) ========== */
.page-container{ max-width: 1200px; margin: 24px auto; padding: 0 16px; }
.legend{ font-size: .95rem; color: #475569; margin-bottom: 14px; }

/* ========== Toasts (notifications) ========== */
.toast-container{
  position: fixed;
  top: 14px; right: 14px;
  width: min(360px, 92vw);
  display: flex; flex-direction: column; gap: 10px;
  z-index: 9999;
  pointer-events: none; /* laisse cliquer les éléments en dessous */
}
.toast{
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 10px 12px;
  border-left: 4px solid var(--primary);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start; gap: 8px;
  pointer-events: auto; /* pour permettre fermer au clic */
  animation: toast-slide-in .18s ease-out;
}
.toast .toast-close{
  border: none; background: transparent; color: inherit; cursor: pointer;
  font-size: 18px; line-height: 1; padding: 4px; border-radius: 6px;
}
.toast .toast-close:hover{ background: #f1f5f9; }

.toast.success { border-left-color: #16a34a; }
.toast.error   { border-left-color: #dc2626; }
.toast.info    { border-left-color: #2563eb; }
.toast.warn    { border-left-color: #d97706; }

@keyframes toast-slide-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

#documentsTable{ width: 100%; table-layout: fixed; }
#documentsTable th, #documentsTable td{ vertical-align: middle; overflow: hidden; text-overflow: ellipsis; }
.actions-cell{ white-space: nowrap; text-align: center; }
/* Ne pas tronquer les icônes dans la colonne Actions */
#documentsTable th.actions-cell,
#documentsTable td.actions-cell{
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
  min-width: 210px; /* 4 icônes + marges */
}
/* Colonne Deg (5) ultra-compacte */
#documentsTable th:nth-child(5),
#documentsTable td:nth-child(5){
  width: 1%;
  min-width: 48px;
  white-space: nowrap;
  text-align: center;
}
/* Colonne Etat (6) compacte */
#documentsTable th:nth-child(6),
#documentsTable td:nth-child(6){
  width: 1%;
  white-space: nowrap;
  text-align: center;
}
.icon-btn{ display:inline-flex; align-items:center; justify-content:center; width:34px; height:34px; border-radius:10px; border:1px solid #e2e8f0; background:#fff; margin-right:6px }
.icon-btn svg{ width:18px; height:18px }
.icon-btn:hover{ background:#f8fafc }
.icon-btn[disabled]{ opacity:.5; cursor:not-allowed }
.icon-dl svg{ stroke:#22c55e }
.icon-ck svg{ stroke:#0ea5e9 }
.icon-del svg{ stroke:#ef4444 }
.icon-edit svg{ stroke:#6366f1 }
.badge.success{ background:#e7f9f0; color:#0f5132 }
th.none, td.none { display: none; }
/* DataTables responsive control centering */
@media (max-width: 99999px){
  table.dataTable.dtr-inline.collapsed>tbody>tr>td.dtr-control:before,
  table.dataTable.dtr-inline.collapsed>tbody>tr>th.dtr-control:before { top: 50%; transform: translateY(-50%); }
}

/* ========== Docs list (tags) ========== */
.docs-list{ display:flex; flex-direction:column; gap:10px; }
.doc-tag{ display:block; background:#fff; border:1px solid #e5e7eb; border-radius:12px; padding:10px 12px; box-shadow: var(--shadow); }
.doc-header{ display:flex; align-items:center; justify-content:space-between; gap:12px; }
.doc-title{ font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.doc-actions{ display:flex; align-items:center; gap:8px; flex:0 0 auto; }
.doc-meta{ display:flex; flex-wrap:wrap; gap:6px; margin-top:6px; }
.doc-meta .badge{ background:#eef2ff; color:#3730a3; }
.doc-meta .badge.muted{ background:#f1f5f9; color:#334155; }
.status-badge{ display:inline-block; padding:.2rem .5rem; border-radius:999px; font-size:.8rem; }
.status-badge.ok{ background:#e7f9f0; color:#0f5132; }
.status-badge.wait{ background:#fff7ed; color:#7c2d12; }
@media (max-width: 600px){ .doc-title{ white-space:normal; } }

/* ========== Modal (shared) ========== */
.modal-backdrop{ position:fixed; inset:0; background:rgba(15,23,42,.55); display:none; z-index:60 }
.modal{ position:fixed; inset:40px 5%; background:#fff; border-radius:16px; box-shadow:0 25px 70px rgba(0,0,0,.25); display:none; z-index:70; overflow:hidden; max-width:1200px; margin:0 auto }
.modal-header{ display:flex; align-items:center; justify-content:space-between; padding:10px 14px; border-bottom:1px solid #e2e8f0 }
.modal-title{ font-weight:600 }
.modal-close{ border:0; background:transparent; cursor:pointer; padding:6px }
.modal-body{ height:calc(100% - 46px) }
.modal-body iframe, .modal-body img{ width:100%; height:100%; border:0; display:block }
@media (max-width: 700px){ .modal{ inset:20px 2% } }

/* Chat */
pre.mono {
  white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  background: #f7f7f7; border: 1px solid #e6e6e6; border-radius: 8px; padding: 10px;
}
.rag-item {
  background: #fafafa; border: 1px solid #eee; border-radius: 8px; padding: 12px; margin: 8px 0;
}

/* ========== Breakpoints ========== */

/* <= 1024px : sidebar en haut, horizontale */
@media (max-width: 1024px){
  .admin-container { flex-direction: column; }
  .sidebar {
    width: 100%; position: static; top: auto; display: flex; align-items: center; gap: 10px;
    overflow-x: auto; white-space: nowrap;
  }
  .sidebar ul { display: flex; gap: 8px; }
}

/* <= 900px : nav “burger” (si utilisé par certaines pages) */
@media (max-width: 900px){
  .navbar {
    grid-template-columns: auto auto auto;
  }
  .navbar-title { display: none; }
  .nav-toggle { display: inline-flex; }
  .nav-panel {
    position: absolute; left: 0; right: 0; top: 100%;
    background: var(--nav-bg-2);
    border-bottom: 1px solid var(--nav-border);
    display: none;
  }
  .nav-panel.open { display: block; }
  .nav-links { flex-direction: column; align-items: stretch; padding: 8px 10px; }
  .nav-links a { padding: 10px; }
  .user-info { justify-self: end; max-width: 50vw; overflow-x: auto; }
}

/* <= 768px : resserrer paddings */
@media (max-width: 768px){
  .content { padding: 12px; }
  .card { padding: 14px; }
  button { padding: 6px 10px; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* <= 600px : plus compact */
@media (max-width: 600px){
  .user-info { font-size: .9rem; gap: 6px; }
  .row { gap: 10px; }
  .main-content section button{ width:100%; }
  /* Sidebar: passer en puces claires sans bloc sombre */
  .sidebar{ background: transparent; padding: 0; border-radius: 0; box-shadow: none; overflow-x: visible; white-space: normal; }
  .sidebar h3{ display:none }
  .sidebar ul{ flex-wrap: wrap; }
  .sidebar a{ background:#fff; color:#111; border:1px solid #e5e7eb; border-radius:999px; padding:8px 12px; }
  .sidebar a:hover{ background:#f9fafb }
  .sidebar a.active{ background:#111827; color:#fff; border-color:#111827 }
  /* Hero: empiler et réordonner titre -> mention -> image */
  .hero-top{ display:flex; flex-direction:column; align-items:center; text-align:center; }
  .hero-title{ order:1; margin-top:4px; }
  .hero-right{ order:2; margin-top:6px; text-align:center; }
  .hero-left{ order:3; margin-top:8px; }
  .hero-img{ width:88px; height:auto; border-radius:999px; }

  /* Profil: colonne unique, badge réduit et centré */
  .profile-grid{ grid-template-columns:1fr; }
  .degree-box{ justify-content:center; text-align:center; }
  .profile-avatar{ width:96px; height:96px; }
  .deg-medal{ width:36px; height:36px; top:-6px; right:-6px; }
  .deg-medal .deg-num{ font-size:16px; }
  .display-input{ max-width:100%; }
  .btn-cta{ width:100%; justify-content:center; }
}
