/* ============================================================
   ATTESTO — Design System v2
   Pro · Corporate · Sobre · Moderne · Coloré
   ============================================================ */

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

:root {
  color-scheme: light;

  /* Brand — Vert Sapin */
  --primary:        #1A4731;
  --primary-dark:   #143326;
  --primary-light:  #2C7A54;
  --primary-subtle: #EBF7F1;
  --accent:         #236042;

  /* Neutrals */
  --bg:     #F0F4F8;
  --panel:  #FFFFFF;
  --text:   #1E293B;
  --muted:  #64748B;
  --border: #CBD5E1;
  --border-soft: #E2E8F0;

  /* Status */
  --conforme-bg:        #ECFDF5;
  --conforme-fg:        #059669;
  --conforme-border:    #A7F3D0;
  --renouvellement-bg:  #FFFBEB;
  --renouvellement-fg:  #D97706;
  --renouvellement-border: #FDE68A;
  --non-conforme-bg:    #FEF2F2;
  --non-conforme-fg:    #DC2626;
  --non-conforme-border:#FECACA;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.04);

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Navigation ───────────────────────────────────────────── */

header {
  background: var(--primary);
  border-bottom: none;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 56px;
  box-shadow: 0 2px 8px rgba(26,71,49,.3);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  color: #fff;
  letter-spacing: -0.3px;
}

header h1 span {
  color: #93C5FD;
}

header nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

header nav a {
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: var(--r-sm);
  transition: background .15s, color .15s;
}

header nav a:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}

header nav a.active {
  background: rgba(255,255,255,.15);
  color: #fff;
}

.logout-link {
  color: rgba(255,255,255,.6) !important;
  font-size: 0.8rem !important;
  text-decoration: none;
  margin-left: 0.5rem;
  padding: 0.3rem 0.65rem !important;
  border: 1px solid rgba(255,255,255,.2) !important;
  border-radius: var(--r-sm) !important;
  transition: background .15s !important;
}

.logout-link:hover {
  background: rgba(255,255,255,.1) !important;
  color: rgba(255,255,255,.9) !important;
}

/* nav separator */
header nav span.sep {
  color: rgba(255,255,255,.25);
  user-select: none;
}

/* ── Layout ───────────────────────────────────────────────── */

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 1.5rem;
  color: var(--text);
  letter-spacing: -0.4px;
}

/* ── Summary cards ────────────────────────────────────────── */

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.summary .stat {
  background: var(--panel);
  border-radius: var(--r-lg);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-soft);
  position: relative;
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
}

.summary .stat:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.summary .stat::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: var(--r-lg) 0 0 var(--r-lg);
}

.summary .stat:nth-child(1)::before { background: var(--conforme-fg); }
.summary .stat:nth-child(2)::before { background: var(--renouvellement-fg); }
.summary .stat:nth-child(3)::before { background: var(--non-conforme-fg); }
.summary .stat:nth-child(4)::before { background: var(--primary-light); }

.summary .stat .count {
  font-size: 2rem;
  font-weight: 700;
  display: block;
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 0.3rem;
}

.summary .stat:nth-child(1) .count { color: var(--conforme-fg); }
.summary .stat:nth-child(2) .count { color: var(--renouvellement-fg); }
.summary .stat:nth-child(3) .count { color: var(--non-conforme-fg); }
.summary .stat:nth-child(4) .count { color: var(--primary-light); }

.summary .stat .label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Table ────────────────────────────────────────────────── */

.table-wrapper {
  background: var(--panel);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-soft);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
  border: none;
  border-radius: 0;
}

thead {
  background: #F8FAFC;
  border-bottom: 1px solid var(--border-soft);
}

th {
  text-align: left;
  padding: 0.7rem 1rem;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: none;
  white-space: nowrap;
}

td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.875rem;
  color: var(--text);
}

tr:last-child td { border-bottom: none; }

tbody tr {
  transition: background .1s;
}

tbody tr:hover { background: #F8FAFC; }

td a {
  color: var(--primary-light);
  text-decoration: none;
  font-weight: 500;
}

td a:hover { text-decoration: underline; }

.empty-row td {
  color: var(--muted);
  text-align: center;
  padding: 2.5rem 1rem;
  font-size: 0.9rem;
}

/* ── Badges ───────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-conforme {
  background: var(--conforme-bg);
  color: var(--conforme-fg);
  border: 1px solid var(--conforme-border);
}

.badge-conforme::before {
  content: '✓';
  font-size: 0.7rem;
}

.badge-en_renouvellement {
  background: var(--renouvellement-bg);
  color: var(--renouvellement-fg);
  border: 1px solid var(--renouvellement-border);
}

.badge-en_renouvellement::before {
  content: '⟳';
  font-size: 0.8rem;
}

.badge-non_conforme {
  background: var(--non-conforme-bg);
  color: var(--non-conforme-fg);
  border: 1px solid var(--non-conforme-border);
}

.badge-non_conforme::before {
  content: '✕';
  font-size: 0.7rem;
}

/* ── Credential cards ─────────────────────────────────────── */

.credential-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.credential-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.credential-card h4 {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin: 1.5rem 0 0.6rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-soft);
}

.credential-card table {
  margin-bottom: 1rem;
  border: none;
  box-shadow: none;
}

.credential-card table td {
  padding: 0.4rem 0;
  border-bottom: none;
  font-size: 0.875rem;
}

.credential-card table td:first-child {
  color: var(--muted);
  width: 160px;
  font-weight: 500;
}

.credential-card form label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  margin: 0.75rem 0 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.credential-card form input[type="text"],
.credential-card form input[type="date"],
.credential-card form input[type="file"],
.credential-card form select,
.credential-card form textarea {
  width: 100%;
  max-width: 420px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: #FAFAFA;
  transition: border-color .15s, box-shadow .15s;
}

.credential-card form input:focus,
.credential-card form select:focus,
.credential-card form textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
  background: #fff;
}

.credential-card form button {
  margin-top: 1rem;
  padding: 0.55rem 1.25rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
}

.credential-card form button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

/* ── Login page ───────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1A4731 0%, #236042 50%, #2C7A54 100%);
  padding: 1rem;
}

.login-card {
  background: var(--panel);
  border-radius: var(--r-lg);
  padding: 2.25rem 2rem;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-logo .brand {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.login-logo .tagline {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.2rem;
  font-weight: 400;
}

.login-card h1 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 1.5rem;
  text-align: center;
  color: var(--text);
}

.login-card label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.login-card input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  margin-bottom: 1rem;
  border: 1px solid #CBD5E1;
  border-radius: var(--r-sm);
  font-size: 0.95rem;
  font-family: inherit;
  color: #1E293B;
  background: #FAFAFA;
  transition: border-color .15s, box-shadow .15s;
}

.login-card input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  background: #fff;
}

.login-card button {
  width: 100%;
  padding: 0.65rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 2px 6px rgba(26,71,49,.3);
}

.login-card button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(26,71,49,.35);
}

/* ── Alerts ───────────────────────────────────────────────── */

.error {
  background: var(--non-conforme-bg);
  color: var(--non-conforme-fg);
  border: 1px solid var(--non-conforme-border);
  padding: 0.6rem 0.9rem;
  border-radius: var(--r-sm);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.success {
  background: var(--conforme-bg);
  color: var(--conforme-fg);
  border: 1px solid var(--conforme-border);
  padding: 0.6rem 0.9rem;
  border-radius: var(--r-sm);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.warning {
  background: var(--renouvellement-bg);
  color: var(--renouvellement-fg);
  border: 1px solid var(--renouvellement-border);
  padding: 0.6rem 0.9rem;
  border-radius: var(--r-sm);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* ── Buttons ──────────────────────────────────────────────── */

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, transform .1s;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.button-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
  font-family: inherit;
}

.button-secondary:hover {
  background: var(--bg);
  border-color: var(--primary-light);
  color: var(--primary-light);
}

/* ── Register link ────────────────────────────────────────── */

.register-link {
  text-align: center;
  font-size: 0.82rem;
  margin-top: 0.85rem;
  color: var(--muted);
}

.register-link a {
  color: var(--primary-light);
  text-decoration: none;
  font-weight: 500;
}

.register-link a:hover { text-decoration: underline; }

/* ── Muted text ───────────────────────────────────────────── */

.muted {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: normal;
}

/* ── Page header bar ──────────────────────────────────────── */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.3px;
}

/* ── Print area ───────────────────────────────────────────── */

.print-area {
  background: var(--primary-subtle);
  border: 1px dashed var(--accent);
  border-radius: var(--r-md);
  padding: 1.25rem;
  text-align: center;
}

.print-area img {
  display: block;
  margin: 0.75rem auto;
  border-radius: var(--r-sm);
}

.print-area code {
  word-break: break-all;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Agent detail page ────────────────────────────────────── */

.agent-header {
  background: var(--panel);
  border-radius: var(--r-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.agent-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.agent-meta {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.3rem;
}

.agent-meta span {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Section divider ──────────────────────────────────────── */

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 1.5rem 0 0.75rem;
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 600px) {
  header { padding: 0 1rem; }
  main { padding: 1.25rem 0.85rem; }
  .summary { grid-template-columns: repeat(2, 1fr); }
  th, td { padding: 0.6rem 0.75rem; }
}

/* ── Alert banner (urgences) ─────────────────────────────── */

.alert-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: #FFF1F1;
  border: 1.5px solid #FECACA;
  border-left: 4px solid #DC2626;
  border-radius: var(--r-md);
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  animation: pulse-border 2s ease-in-out infinite;
}

@keyframes pulse-border {
  0%, 100% { border-left-color: #DC2626; }
  50%       { border-left-color: #F87171; }
}

.alert-icon {
  font-size: 1.1rem;
  line-height: 1.4;
  flex-shrink: 0;
}

.alert-content {
  font-size: 0.875rem;
  color: #991B1B;
  line-height: 1.5;
}

.alert-content strong {
  font-weight: 700;
}

.alert-content a {
  color: #B91C1C;
  font-weight: 600;
  text-decoration: underline;
}

.alert-content a:hover {
  color: #7F1D1D;
}

/* ── Stage badges ────────────────────────────────────────── */

.stage-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

/* Urgent — rouge vif */
.stage-badge.stage-urgent {
  background: #FEE2E2;
  color: #B91C1C;
  border: 1px solid #FECACA;
  font-weight: 700;
  animation: blink-badge 1.5s ease-in-out infinite;
}

@keyframes blink-badge {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.65; }
}

/* À prévoir / Dépôt — orange */
.stage-badge.stage-mac_a_prevoir,
.stage-badge.stage-depot_a_faire {
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FDE68A;
}

/* En instruction — bleu */
.stage-badge.stage-en_instruction {
  background: #EFF6FF;
  color: #1D4ED8;
  border: 1px solid #BFDBFE;
}

/* À jour — vert */
.stage-badge.stage-a_jour {
  background: var(--conforme-bg);
  color: var(--conforme-fg);
  border: 1px solid var(--conforme-border);
}

/* RAS — gris neutre */
.stage-badge.stage-ras {
  background: #F1F5F9;
  color: var(--muted);
  border: 1px solid var(--border-soft);
}

/* ── Row highlighting ────────────────────────────────────── */

tbody tr.row-urgent {
  background: #FFF5F5 !important;
}

tbody tr.row-urgent:hover {
  background: #FEE2E2 !important;
}

tbody tr.row-urgent td {
  border-bottom-color: #FECACA;
}

tbody tr.row-urgent td:first-child {
  border-left: 3px solid #DC2626;
  padding-left: calc(1rem - 3px);
}

tbody tr.row-warning {
  background: #FFFDF0 !important;
}

tbody tr.row-warning:hover {
  background: #FEF9E7 !important;
}

tbody tr.row-warning td:first-child {
  border-left: 3px solid #D97706;
  padding-left: calc(1rem - 3px);
}

/* ── Urgent expiry date ──────────────────────────────────── */

.text-urgent {
  color: #B91C1C;
  font-weight: 700;
}

/* ── Print ────────────────────────────────────────────────── */

@media print {
  .no-print { display: none !important; }
  header { display: none; }
  body { background: #fff; }
  .credential-card { border: none; box-shadow: none; }
  .print-area { border: none; background: none; }
}
