/* ==========================================================================
   Espace Agent — design tokens
   Palette : encre marine (sidebar), corail (accent/CTA), papier froid (fond)
   Typo : Fraunces (titres), Inter (interface), IBM Plex Mono (données/matricule)
   ========================================================================== */

:root {
  --ink-900: #0f1b2c;
  --ink-800: #16233a;
  --navy-700: #1b2a41;
  --navy-600: #22354f;
  --navy-500: #2c4363;

  --coral-500: #ea5a3c;
  --coral-600: #d14a2d;
  --coral-100: #fde5de;

  --teal-500: #3f8f88;
  --teal-100: #e2f2f0;

  --amber-500: #e3a008;
  --amber-100: #fdf1d6;

  --green-500: #2e9e6d;
  --green-100: #e1f5ec;

  --red-500: #d13b3b;
  --red-100: #fbe4e4;

  --paper-0: #ffffff;
  --paper-50: #f6f7fa;
  --paper-100: #eef0f5;
  --paper-200: #e2e5ec;

  --text-900: #16212f;
  --text-600: #4d5a6c;
  --text-400: #8592a3;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --shadow-sm: 0 1px 2px rgba(15, 27, 44, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 27, 44, 0.08);
  --shadow-lg: 0 20px 45px rgba(15, 27, 44, 0.14);

  --sidebar-w: 288px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper-50);
  color: var(--text-900);
  font-family: "Roboto";
  /* font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; */
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: "Roboto";
  /* font-family: "Fraunces", Georgia, serif; */
  color: var(--ink-900);
  margin: 0 0 4px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.mono { 
  font-family: "Roboto";
/*   font-family: "IBM Plex Mono", monospace;  */
  letter-spacing: 0.01em; }

a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--coral-500); outline-offset: 2px; }

/* ---------- layout shell ---------- */

.app-shell { display: flex; min-height: 100vh; }

/* ---------- sidebar ---------- */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(190deg, var(--navy-700) 0%, var(--ink-900) 100%);
  color: #dfe6f0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.22) transparent;
}
.sidebar::-webkit-scrollbar { width: 7px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.22);
  border-radius: 999px;
}
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.4); }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 24px;
  font-family: "Roboto";
  font-weight: 600;
  font-size: 1.15rem;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand .brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--coral-500);
  display: flex; align-items: center; justify-content: center;
  font-family: "Roboto", monospace;
/*   font-family: "IBM Plex Mono", monospace; */
  font-weight: 700; font-size: 0.85rem; color: #fff;
}

.agent-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  margin: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}
.agent-avatar {
  position: relative;
  width: 46px; height: 46px; flex-shrink: 0;
}
.agent-avatar img, .agent-avatar .avatar-fallback {
  width: 46px; height: 46px; border-radius: 50%; object-fit: cover;
  display: block;
  background: var(--navy-500);
  color: #fff;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
  align-items: center; justify-content: center;
}
.agent-avatar .avatar-fallback { display: flex; }
.agent-avatar .status-ring {
  position: absolute; inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--green-500);
}
.agent-card .agent-name { color: #fff; font-weight: 600; font-size: 0.92rem; line-height: 1.25; }
.agent-card .agent-matricule {
  display: inline-block; margin-top: 3px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  color: var(--coral-500);
  background: rgba(234,90,60,0.14);
  padding: 2px 8px;
  border-radius: 999px;
}

.nav-group-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #7f8ea6;
  padding: 18px 24px 8px;
  font-weight: 600;
}

.nav-list { list-style: none; margin: 0; padding: 0 12px; }
.nav-list li { margin: 2px 0; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #c7d1e0;
  font-size: 0.89rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link svg { flex-shrink: 0; opacity: 0.85; }
.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-link.active {
  background: var(--coral-500);
  color: #fff;
}
.nav-link.active svg { opacity: 1; }
.nav-link .badge-count {
  margin-left: auto;
  background: rgba(255,255,255,0.16);
  color: #fff;
  font-size: 0.68rem;
  font-family: "IBM Plex Mono", monospace;
  padding: 1px 7px;
  border-radius: 999px;
}
.nav-link.active .badge-count { background: rgba(255,255,255,0.28); }

.nav-group-toggle {
  width: 100%;
  display: flex; align-items: center; gap: 6px;
  padding: 18px 24px 8px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #7f8ea6;
  font-weight: 600;
  background: none; border: none; cursor: pointer; text-align: left;
  font-family: inherit;
}
.nav-group-toggle:hover { color: #c7d1e0; }
.nav-group-toggle .chevron { margin-left: auto; transition: transform 0.15s ease; }
.nav-accordion.open .nav-group-toggle .chevron { transform: rotate(90deg); }
.nav-submenu { list-style: none; margin: 0; padding: 0 12px; display: none; }
.nav-accordion.open .nav-submenu { display: block; }
.nav-submenu li { margin: 2px 0; }

.sidebar-footer { margin-top: auto; padding: 18px 16px 24px; }
.btn-logout {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--coral-500);
  color: #fff;
  border: none;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-logout:hover { background: var(--coral-600); }

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 34px;
  background: var(--paper-0);
  border-bottom: 1px solid var(--paper-200);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar .crumb { color: var(--text-400); font-size: 0.82rem; }
.topbar .crumb strong { color: var(--text-900); }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.notif-dot {
  position: relative;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--paper-100);
  display: flex; align-items: center; justify-content: center;
}
.notif-dot .dot {
  position: absolute; top: 6px; right: 7px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--coral-500);
  border: 2px solid #fff;
}

/* ---------- main content ---------- */

.main-content { flex: 1; min-width: 0; }
.page-wrap { padding: 30px 34px 60px; max-width: 980px; margin: 0 auto; }
.page-wrap-full { max-width: none; margin: 0; }

/* ---------- bande de titre en dégradé noir → rouge (espace RH + espace agent) ---------- */

.page-header {
  margin-bottom: 22px;
  background: linear-gradient(120deg, #0a0a0a 0%, #3a0e0e 55%, var(--red-500) 100%);
  padding: 24px 30px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.page-header h1 { color: #fff; }
.page-header p { color: rgba(255,255,255,0.75); margin: 0; font-size: 0.92rem; }
.page-header .btn-outline {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border-color: rgba(255,255,255,0.35);
}
.page-header .btn-outline:hover { background: rgba(255,255,255,0.18); border-color: #fff; }

/* espace agent : la bande de titre est un bloc à part (hors .page-wrap), qui s'étend sur
   toute la largeur du contenu ; le reste (.page-wrap) reste centré avec une largeur max.
   Même habillage (arrondi, ombre) que la bande de l'espace RH — juste avec des marges
   latérales pour s'aligner sur le contenu ci-dessous plutôt qu'un bord à bord brutal. */
.agent-space .page-header {
  margin: 24px 34px 22px;
}

.card {
  background: var(--paper-0);
  border: 1px solid var(--paper-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 26px 28px;
  margin-bottom: 22px;
}
.card-title {
  font-family: "Roboto", sans-serif;
  font-size: 1.02rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.card-subtitle { color: var(--text-400); font-size: 0.82rem; margin-bottom: 18px; }

/* ---------- forms ---------- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 22px; }
.form-grid .full { grid-column: 1 / -1; }
.form-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-600);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.form-control, select.form-control, textarea.form-control {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--paper-200);
  border-radius: var(--radius-sm);
  background: var(--paper-50);
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--text-900);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.form-control:focus {
  outline: none;
  border-color: var(--coral-500);
  background: #fff;
}
textarea.form-control { resize: vertical; min-height: 90px; }

/* ---------- champs fichier / photo ---------- */

input[type="file"].form-control {
  padding: 8px;
  background: var(--paper-0);
  color: var(--text-600);
  font-size: 0.85rem;
}
input[type="file"].form-control::file-selector-button {
  margin-right: 12px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--teal-100);
  color: var(--teal-500);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
input[type="file"].form-control::file-selector-button:hover {
  background: var(--teal-500);
  color: #fff;
}
.form-check { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.helptext { font-size: 0.78rem; color: var(--text-400); margin-top: 4px; }
.errorlist { list-style: none; padding: 0; margin: 4px 0 0; color: var(--red-500); font-size: 0.78rem; }

.form-actions { margin-top: 24px; display: flex; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn-primary { background: var(--coral-500); color: #fff; }
.btn-primary:hover { background: var(--coral-600); }
.btn-outline { background: transparent; color: var(--text-600); border: 1px solid var(--paper-200); }
.btn-outline:hover { border-color: var(--text-400); }
.btn-danger { background: var(--red-100); color: var(--red-500); }
.btn-danger:hover { background: var(--red-500); color: #fff; }
.btn-sm { padding: 7px 13px; font-size: 0.8rem; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: var(--teal-100); color: var(--teal-500);
  border: none; cursor: pointer; text-decoration: none;
  transition: background 0.15s ease;
}
.icon-btn:hover { background: var(--teal-500); color: #fff; }

/* ---------- data display ---------- */

.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px 28px; }
.info-item .info-label {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-400); margin-bottom: 4px; font-weight: 600;
}
.info-item .info-value { font-size: 0.95rem; color: var(--text-900); font-weight: 500; }

table.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-400); font-weight: 600;
  padding: 10px 12px; border-bottom: 1px solid var(--paper-200);
}
.data-table td {
  padding: 14px 12px; border-bottom: 1px solid var(--paper-100);
  font-size: 0.9rem; vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--paper-50); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  font-size: 0.74rem; font-weight: 600;
  font-family: "IBM Plex Mono", monospace;
}
.pill-attente { background: var(--amber-100); color: #8a6300; }
.pill-validee { background: var(--green-100); color: var(--green-500); }
.pill-refusee { background: var(--red-100); color: var(--red-500); }
.pill-cloturee { background: var(--paper-100); color: var(--text-600); }
.pill-actif { background: var(--green-100); color: var(--green-500); }
.pill-neutral { background: var(--teal-100); color: var(--teal-500); }

.empty-state {
  text-align: center;
  padding: 54px 20px;
  color: var(--text-400);
}
.empty-state .empty-icon {
  width: 54px; height: 54px; margin: 0 auto 14px;
  border-radius: 50%; background: var(--paper-100);
  display: flex; align-items: center; justify-content: center;
}
.empty-state h4 { color: var(--text-600); margin-bottom: 4px; }

.avatar-sm {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
  background: var(--navy-500); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: "IBM Plex Mono", monospace; font-size: 0.72rem;
}

.doc-row { display: flex; align-items: center; gap: 14px; }
.doc-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--teal-100); color: var(--teal-500);
  display: flex; align-items: center; justify-content: center;
  font-family: "IBM Plex Mono", monospace; font-size: 0.66rem; font-weight: 700;
}

.alert {
  padding: 13px 16px; border-radius: var(--radius-sm);
  margin-bottom: 16px; font-size: 0.88rem;
  display: flex; align-items: center; gap: 10px;
}
.alert-success { background: var(--green-100); color: #1f6b4a; }
.alert-error { background: var(--red-100); color: var(--red-500); }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 24px; }
.stat-card {
  background: var(--paper-0); border: 1px solid var(--paper-200);
  border-radius: var(--radius-lg); padding: 20px 22px;
  display: flex; flex-direction: column;
}
.stat-card.has-icon { flex-direction: row; align-items: center; gap: 14px; }
.stat-card .stat-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--teal-100); color: var(--teal-500);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-card .stat-value {
  font-family: "Roboto", "Fraunces", serif; font-size: 1.9rem; font-weight: 600; color: var(--ink-900);
}
.stat-card .stat-label { color: var(--text-400); font-size: 0.8rem; margin-top: 2px; }
.stat-card.accent { background: var(--navy-700); border-color: var(--navy-700); }
.stat-card.accent .stat-value, .stat-card.accent .stat-label { color: #fff; }
.stat-card.accent .stat-label { color: #a9b6c9; }
.stat-card.accent .stat-icon { background: rgba(255,255,255,0.12); color: #fff; }
.stat-card.warn .stat-icon { background: var(--amber-100); color: #8a6300; }
.stat-card.danger .stat-icon { background: var(--red-100); color: var(--red-500); }
.stat-row-4 { grid-template-columns: repeat(4, 1fr); }
.stat-row-6 { grid-template-columns: repeat(6, 1fr); }

/* ---------- fiche agent (détail) ---------- */

.agent-detail-layout { display: flex; align-items: flex-start; gap: 22px; }
.agent-detail-main { flex: 2; min-width: 0; }
.agent-detail-side { flex: 1; min-width: 260px; }
.agent-profile-avatar {
  width: 72px; height: 72px; border-radius: 50%; object-fit: cover;
  background: var(--navy-500); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: "IBM Plex Mono", monospace; font-size: 1.3rem;
  margin: 0 auto 14px;
}
.agent-profile-name { text-align: center; margin-bottom: 2px; }
.agent-profile-sub { text-align: center; color: var(--text-400); font-size: 0.85rem; margin-bottom: 18px; }
.detail-block + .detail-block { margin-top: 22px; }

@media (max-width: 960px) {
  .agent-detail-layout { flex-direction: column; }
  .agent-detail-side { width: 100%; }
}

/* ---------- deux colonnes égales (ex : édition agent) ---------- */

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }

@media (max-width: 960px) {
  .two-col { grid-template-columns: 1fr; }
}

.card-flex-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 18px;
}

/* ---------- login page ---------- */

.login-shell {
  min-height: 100vh;
  display: flex;
  background: var(--paper-50);
}
.login-visual {
  flex: 1.1;
  background: linear-gradient(200deg, var(--navy-700) 0%, var(--ink-900) 100%);
  color: #fff;
  display: flex; flex-direction: column; justify-content: center;
  padding: 60px 70px;
}
.login-visual .brand-mark {
  width: 46px; height: 46px; border-radius: 12px;
  background: var(--coral-500);
  display: flex; align-items: center; justify-content: center;
  font-family: "IBM Plex Mono", monospace; font-weight: 700; margin-bottom: 34px;
}
.login-visual h1 { color: #fff; font-size: 2.1rem; max-width: 420px; }
.login-visual p { color: #b7c2d4; max-width: 400px; margin-top: 12px; font-size: 0.95rem; }
.login-form-side {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px;
}
.login-form-card { width: 100%; max-width: 380px; }
.login-form-card h2 { margin-bottom: 6px; }
.login-form-card .sub { color: var(--text-400); margin-bottom: 28px; font-size: 0.88rem; }
.login-form-card input[type="text"],
.login-form-card input[type="password"],
.login-form-card input[type="email"] {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--paper-200);
  border-radius: var(--radius-sm);
  background: var(--paper-50);
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--text-900);
}
.login-form-card input:focus { outline: none; border-color: var(--coral-500); background: #fff; }

@media (max-width: 960px) {
  .login-visual { display: none; }
  .info-grid, .form-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { position: fixed; left: -100%; z-index: 40; box-shadow: var(--shadow-lg); }
  .sidebar.open { left: 0; }
  .page-wrap { padding: 22px 18px 50px; }
  .topbar { padding: 16px 18px; }
}
