@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Fond */
  --ink: #f4f5f7;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-hover: #f0f2f5;
  --border: #e1e4ea;

  /* Texte */
  --text: #1a2030;
  --text-muted: #5b6472;
  --text-faint: #98a0ad;

  /* Signal (accent de marque) */
  --signal: #6d5ef5;
  --signal-soft: rgba(109, 94, 245, 0.09);

  /* États de ticket */
  --etat-ouvert: #e8622f;
  --etat-en-cours: #1a8fd1;
  --etat-en-attente: #c99a13;
  --etat-resolu: #1fa974;
  --etat-ferme: #98a0ad;

  --font-display: 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'Inter', sans-serif;

  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

.mono { font-family: var(--font-mono); }

button, input, select, textarea { font-family: var(--font-body); font-size: 14px; }

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

/* ---------- Layout ---------- */

.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-brand {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
}

.sidebar-brand .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 12px var(--signal);
}

.recherche-rapide {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-faint);
  background: var(--ink);
}

.recherche-rapide input {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--text);
  width: 100%;
}

.recherche-rapide input:focus-visible { outline: none; }
.recherche-rapide:focus-within { border-color: var(--signal); }

.nav-section { display: flex; flex-direction: column; gap: 8px; }

.nav-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  padding: 0 10px;
}

.nav-section-disabled .nav-section-label { opacity: 0.6; }

.nav-group { display: flex; flex-direction: column; gap: 2px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-link svg { flex-shrink: 0; opacity: 0.75; }

.nav-link:hover { background: var(--surface-hover); color: var(--text); }
.nav-link.active { background: var(--signal-soft); color: var(--signal); }
.nav-link.active svg { opacity: 1; }

.nav-link-disabled {
  color: var(--text-faint);
  cursor: default;
  opacity: 0.55;
}

.nav-badge {
  margin-left: auto;
  background: var(--signal);
  color: white;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.compte-bloc {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.compte-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--signal-soft);
  color: var(--signal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.compte-nom {
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main {
  padding: 28px 36px;
  max-width: 1200px;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h1 { font-size: 22px; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 6px;
}

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text);
  font-weight: 500;
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.btn:hover { border-color: var(--signal); }

.btn-primary {
  background: var(--signal);
  border-color: var(--signal);
  color: white;
}

.btn-primary:hover { background: #7d70ff; border-color: #7d70ff; }

.btn-succes {
  background: var(--etat-resolu);
  border-color: var(--etat-resolu);
  color: white;
}

.btn-succes:hover { filter: brightness(1.08); }

.btn-danger {
  background: transparent;
  border-color: var(--etat-ouvert);
  color: var(--etat-ouvert);
}

.btn-danger:hover { background: rgba(232, 98, 47, 0.08); }

/* ---------- Signal board (dashboard) ---------- */

.signal-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 28px;
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.08);
}

.signal-cell {
  background: var(--surface);
  padding: 18px 20px;
  position: relative;
}

.signal-cell::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--cell-color, var(--text-faint));
}

.signal-cell .valeur {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 500;
  color: var(--text);
}

.signal-cell .label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---------- Barre de statut segmentée (signature) ---------- */

.statut-bar {
  display: flex;
  gap: 4px;
  align-items: center;
}

.statut-bar form { display: contents; }

.statut-segment {
  height: 22px;
  padding: 0 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.12s ease;
  display: flex;
  align-items: center;
}

.statut-segment.actif {
  color: #ffffff;
  background: var(--segment-color);
  border-color: var(--segment-color);
  font-weight: 600;
}

.statut-segment:not(.actif):hover {
  border-color: var(--segment-color);
  color: var(--text);
}

/* ---------- Tables ---------- */

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.08);
}

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 500;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-size: 13.5px;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-hover); }

.ticket-id { color: var(--text-faint); font-family: var(--font-mono); font-size: 12px; }

.ligne-menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius);
  color: var(--text-faint);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.ligne-menu:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* ---------- Priorité (petit indicateur, pas un badge pilule) ---------- */

.priorite {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.priorite::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: var(--prio-color, var(--text-faint));
  transform: rotate(45deg);
}

/* ---------- Filtres ---------- */

.filtres { display: flex; gap: 8px; margin-bottom: 18px; }

.filtres-barre {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  align-items: center;
}

.filtres-barre select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--text);
  min-width: 200px;
}

.filtres-barre input[type=text] {
  flex: 1;
  max-width: 320px;
}

.filtre-chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
}

.filtre-chip.actif { border-color: var(--signal); color: var(--signal); background: var(--signal-soft); }

/* ---------- Formulaires ---------- */

.form-grid { display: flex; flex-direction: column; gap: 16px; max-width: 480px; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

input[type=text], input[type=email], input[type=tel], input[type=password], select, textarea {
  background: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text);
}

textarea { resize: vertical; min-height: 90px; font-family: var(--font-body); }

.combo { position: relative; }

.combo input {
  padding-right: 34px;
  width: 100%;
}

.combo::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-faint);
  border-bottom: 2px solid var(--text-faint);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}

.combo-liste {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12);
  z-index: 20;
}

.combo-option {
  padding: 8px 12px;
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
}

.combo-option:hover {
  background: var(--signal-soft);
  color: var(--signal);
}

/* ---------- Login ---------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: center;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px;
  width: 100%;
  max-width: 360px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
}

.login-brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--signal); box-shadow: 0 0 14px var(--signal);
}

.erreur-msg {
  background: rgba(255, 107, 74, 0.12);
  border: 1px solid var(--etat-ouvert);
  color: var(--etat-ouvert);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ---------- Détail ticket : trace d'activité (signature) ---------- */

.ticket-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 28px;
  align-items: start;
}

.trace {
  position: relative;
  padding-left: 20px;
}

.trace::before {
  content: '';
  position: absolute;
  left: 5px; top: 6px; bottom: 6px;
  width: 1px;
  background: linear-gradient(var(--border), var(--border) 60%, transparent);
}

.trace-item {
  position: relative;
  padding-bottom: 18px;
}

.trace-item::before {
  content: '';
  position: absolute;
  left: -20px; top: 4px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--surface-raised);
  border: 2px solid var(--signal);
}

.trace-item .meta {
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  margin-bottom: 4px;
}

.trace-item .contenu {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13.5px;
}

.trace-item.interne .contenu { border-color: var(--etat-en-attente); background: rgba(245, 201, 74, 0.06); }

.panneau {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.08);
}

.panneau h3 { font-size: 13px; margin-bottom: 14px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-family: var(--font-body); font-weight: 600; }

.panneau dl { margin: 0; }
.panneau dt { font-size: 11px; color: var(--text-faint); margin-top: 12px; }
.panneau dt:first-child { margin-top: 0; }
.panneau dd { margin: 2px 0 0; font-size: 13.5px; }

.vide {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-faint);
}

.vide h3 { color: var(--text-muted); margin-bottom: 8px; }
