/* =============================================================
   CLEARR v2 — Design system des espaces applicatifs
   Partagé par l'espace client, enquêteur et admin.
   Reprend les tokens de clearr.css, qui doit être chargé avant.
   ============================================================= */

:root {
  --app-sidebar: 244px;
  --app-topbar: 62px;
  --app-bg: #F7F9FC;
  --app-radius: 12px;
}

body.app {
  background: var(--app-bg);
  font-size: 15px;
}

/* -------------------------------------------------------------
   1. STRUCTURE
   ------------------------------------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--app-sidebar) 1fr;
  min-height: 100vh;
}

.app-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-content {
  padding: var(--s-4) var(--s-4) var(--s-6);
  flex: 1;
  max-width: 1360px;
  width: 100%;
}


/* -------------------------------------------------------------
   2. BARRE LATÉRALE
   ------------------------------------------------------------- */
.app-sidebar {
  background: var(--c-black);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 60;
}

.app-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
}
.app-sidebar__brand img { height: 24px; }

.app-sidebar__space {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--c-mint);
  padding: 3px 8px;
  border-radius: var(--r-pill);
  background: rgba(46,204,113,.14);
}

.app-nav { padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }

.app-nav__label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #5B6577;
  padding: 16px 10px 6px;
}

.app-nav__link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 11px;
  border-radius: 9px;
  font-size: 14.5px;
  color: rgba(255,255,255,.72);
  transition: background-color var(--t-fast), color var(--t-fast);
}
.app-nav__link:hover { background: rgba(255,255,255,.06); color: #fff; }

.app-nav__link.is-active {
  background: rgba(46,204,113,.14);
  color: #fff;
  font-weight: 500;
}
.app-nav__link.is-active svg { color: var(--c-green); }

.app-nav__link svg { width: 18px; height: 18px; flex: none; color: #7A8496; }

.app-nav__count {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  background: var(--c-green);
  color: var(--c-black);
  font-size: 11px;
  font-weight: 600;
}
.app-nav__count--muted { background: rgba(255,255,255,.14); color: #fff; }

.app-sidebar__foot {
  margin-top: auto;
  padding: 14px 12px 18px;
  border-top: 1px solid var(--c-line-dark);
}

.app-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  transition: background-color var(--t-fast);
}
.app-user:hover { background: rgba(255,255,255,.06); }
.app-user__avatar {
  width: 32px; height: 32px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--g-brand);
  color: var(--c-black);
  font-size: 12px;
  font-weight: 600;
}
.app-user__name { font-size: 13.5px; font-weight: 500; line-height: 1.3; }
.app-user__mail {
  font-size: 11.5px; color: #7A8496;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 148px;
}


/* -------------------------------------------------------------
   3. BARRE SUPÉRIEURE
   ------------------------------------------------------------- */
.app-topbar {
  height: var(--app-topbar);
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--c-line);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 var(--s-4);
  position: sticky;
  top: 0;
  z-index: 50;
}
.app-topbar h1 { font-size: 18px; letter-spacing: -.02em; }
.app-topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.app-burger { display: none; width: 38px; height: 38px; place-items: center; border-radius: 9px; }
.app-burger:hover { background: var(--c-snow); }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 9px;
  color: var(--c-muted);
  position: relative;
  transition: background-color var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { background: var(--c-snow); color: var(--c-ink); }
.icon-btn__dot {
  position: absolute;
  top: 7px; right: 7px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--c-danger);
  border: 2px solid #fff;
}


/* -------------------------------------------------------------
   4. EN-TÊTE DE PAGE
   ------------------------------------------------------------- */
.page-head {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: var(--s-4);
}
.page-head h2 { font-size: clamp(22px, 2.4vw, 28px); margin-bottom: 5px; }
.page-head p { color: var(--c-muted); font-size: 14.5px; }
.page-head__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }


/* -------------------------------------------------------------
   5. CARTES & PANNEAUX
   ------------------------------------------------------------- */
.panel {
  background: #fff;
  border: 1px solid var(--c-line);
  border-radius: var(--app-radius);
}
.panel__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-line);
}
.panel__head h3 { font-size: 15.5px; font-weight: 500; }
.panel__head .panel__actions { margin-left: auto; display: flex; gap: 8px; }
.panel__body { padding: 20px; }
.panel__foot {
  padding: 14px 20px;
  border-top: 1px solid var(--c-line);
  background: var(--c-snow);
  border-radius: 0 0 var(--app-radius) var(--app-radius);
}

/* Carte statistique */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}
.kpi {
  background: #fff;
  border: 1px solid var(--c-line);
  border-radius: var(--app-radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.kpi__label {
  font-size: 12.5px;
  color: var(--c-muted);
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
}
.kpi__label svg { width: 15px; height: 15px; }
.kpi__value {
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -.03em;
  line-height: 1;
}
.kpi__meta { font-size: 12.5px; color: var(--c-muted); margin-top: 7px; }
.kpi__meta b { color: var(--c-green-700); font-weight: 500; }
.kpi--accent::after {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--g-brand);
}


/* -------------------------------------------------------------
   6. TABLEAUX
   ------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 13px 20px; text-align: left; vertical-align: middle; }
.table thead th {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--c-muted);
  background: var(--c-snow);
  border-bottom: 1px solid var(--c-line);
  white-space: nowrap;
}
.table tbody tr + tr td { border-top: 1px solid var(--c-line); }
.table tbody tr { transition: background-color var(--t-fast); }
.table tbody tr:hover { background: #FBFCFE; }
.table td b { font-weight: 500; }
.table__sub { display: block; font-size: 12.5px; color: var(--c-muted); margin-top: 2px; }
.table__actions { display: flex; gap: 6px; justify-content: flex-end; }
.table td:last-child, .table th:last-child { text-align: right; }

.table-empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--c-muted);
}
.table-empty svg { width: 34px; height: 34px; color: #C3CBD7; margin-bottom: 14px; }
.table-empty b { display: block; color: var(--c-ink); font-weight: 500; margin-bottom: 5px; font-size: 15px; }


/* -------------------------------------------------------------
   7. BADGES DE STATUT
   ------------------------------------------------------------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
}
.tag::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.tag--success { background: rgba(46,204,113,.1);  color: #0E7A42; border-color: rgba(46,204,113,.24); }
.tag--info    { background: rgba(18,217,196,.1);  color: #0B7F73; border-color: rgba(18,217,196,.24); }
.tag--warning { background: rgba(255,176,32,.11); color: #96620A; border-color: rgba(255,176,32,.26); }
.tag--danger  { background: rgba(255,90,90,.09);  color: #C22B2B; border-color: rgba(255,90,90,.24); }
.tag--neutral { background: var(--c-snow);        color: var(--c-muted); border-color: var(--c-line); }
.tag--plain::before { display: none; }


/* -------------------------------------------------------------
   8. FORMULAIRES APPLICATIFS
   ------------------------------------------------------------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-2);
}
.form-grid .field--full { grid-column: 1 / -1; }

.input, .select, .textarea { font-size: 14.5px; padding: 11px 13px; }

.field-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
}
.field-inline + .field-inline { border-top: 1px solid var(--c-line); }
.field-inline__body { flex: 1; min-width: 0; }
.field-inline__body b { display: block; font-size: 14.5px; font-weight: 500; }
.field-inline__body span { font-size: 13px; color: var(--c-muted); }

/* Case à cocher / radio en carte */
.choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 15px 16px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color var(--t-fast), background-color var(--t-fast);
}
.choice:hover { border-color: #C9D3E0; }
.choice input { margin-top: 2px; accent-color: var(--c-green); width: 17px; height: 17px; flex: none; }
.choice__body b { display: block; font-size: 14.5px; font-weight: 500; margin-bottom: 2px; }
.choice__body span { font-size: 13px; color: var(--c-muted); line-height: 1.45; }
.choice:has(input:checked) {
  border-color: var(--c-green);
  background: rgba(46,204,113,.05);
}

/* Interrupteur */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch__slider {
  position: absolute;
  inset: 0;
  background: #CBD3DE;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background-color var(--t-fast);
}
.switch__slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--t-fast);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .switch__slider { background: var(--c-green); }
.switch input:checked + .switch__slider::before { transform: translateX(18px); }


/* -------------------------------------------------------------
   9. PAGES D'AUTHENTIFICATION
   ------------------------------------------------------------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.auth__form {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px var(--s-4);
  background: #fff;
}
.auth__inner { width: 100%; max-width: 400px; }
.auth__logo { margin-bottom: 34px; display: inline-block; }
.auth__logo img { height: 26px; }
.auth h1 { font-size: 27px; margin-bottom: 8px; }
.auth__lede { color: var(--c-muted); font-size: 14.5px; margin-bottom: 28px; }
.auth__foot { margin-top: 26px; font-size: 14px; color: var(--c-muted); text-align: center; }
.auth__foot a { color: var(--c-green-700); font-weight: 500; }

.auth__aside {
  background: var(--c-black);
  color: #fff;
  padding: 56px var(--s-5);
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.auth__aside::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(70% 50% at 30% 10%, rgba(46,204,113,.2), transparent 70%);
}
.auth__aside > * { position: relative; }
.auth__aside h2 { font-size: clamp(26px, 2.6vw, 36px); margin-bottom: 16px; }
.auth__aside p { color: var(--c-muted-dark); max-width: 42ch; }
.auth__points { margin-top: 32px; display: flex; flex-direction: column; gap: 16px; }
.auth__points li { display: flex; gap: 12px; align-items: flex-start; font-size: 14.5px; }
.auth__points svg { width: 18px; height: 18px; color: var(--c-green); flex: none; margin-top: 2px; }

.auth__mock { margin-top: 40px; border-radius: var(--r-md); overflow: hidden; }
.auth__mock img { width: 100%; box-shadow: var(--shadow-float); }

/* Champ mot de passe avec bouton d'affichage */
.password-field { position: relative; }
.password-field .input { padding-right: 44px; }
.password-field button {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 7px;
  color: var(--c-muted);
}
.password-field button:hover { background: var(--c-snow); }


/* -------------------------------------------------------------
   10. ONBOARDING
   ------------------------------------------------------------- */
.onboarding__steps {
  display: flex;
  gap: 6px;
  margin-bottom: 26px;
}
.onboarding__steps span {
  height: 3px;
  flex: 1;
  border-radius: var(--r-pill);
  background: var(--c-line);
  transition: background-color .4s var(--ease);
}
.onboarding__steps span.is-done { background: var(--g-brand); }

.onboarding__q { font-size: 21px; margin-bottom: 6px; }
.onboarding__hint { font-size: 14px; color: var(--c-muted); margin-bottom: 22px; }

.url-row { display: flex; gap: 8px; align-items: flex-start; }
.url-row .input { flex: 1; }
.url-row__remove {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--c-line);
  color: var(--c-muted);
  flex: none;
}
.url-row__remove:hover { border-color: var(--c-danger); color: var(--c-danger); }


/* -------------------------------------------------------------
   11. FIL D'ACTIVITÉ
   ------------------------------------------------------------- */
.feed { display: flex; flex-direction: column; }
.feed__item {
  display: flex;
  gap: 13px;
  padding: 14px 0;
  align-items: flex-start;
}
.feed__item + .feed__item { border-top: 1px solid var(--c-line); }
.feed__icon {
  width: 32px; height: 32px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--c-snow);
  color: var(--c-muted);
}
.feed__icon svg { width: 16px; height: 16px; }
.feed__icon--success { background: rgba(46,204,113,.11); color: #0E7A42; }
.feed__icon--danger  { background: rgba(255,90,90,.09);  color: #C22B2B; }
.feed__icon--warning { background: rgba(255,176,32,.11); color: #96620A; }
.feed__body { flex: 1; min-width: 0; }
.feed__body b { font-weight: 500; font-size: 14.5px; }
.feed__body p { font-size: 13.5px; color: var(--c-muted); margin-top: 2px; }
.feed__time { font-size: 12.5px; color: var(--c-muted); white-space: nowrap; flex: none; }

.feed__item.is-unread { background: rgba(46,204,113,.035); margin-inline: -20px; padding-inline: 20px; }


/* -------------------------------------------------------------
   12. PAGINATION
   ------------------------------------------------------------- */
.pagination {
  display: flex;
  gap: 5px;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.pagination a, .pagination span {
  min-width: 34px; height: 34px;
  padding: 0 10px;
  display: grid; place-items: center;
  border-radius: 8px;
  font-size: 14px;
  color: var(--c-muted);
  border: 1px solid transparent;
}
.pagination a:hover { background: var(--c-snow); color: var(--c-ink); }
.pagination .is-current { background: var(--c-ink); color: #fff; font-weight: 500; }
.pagination .is-disabled { opacity: .4; pointer-events: none; }


/* -------------------------------------------------------------
   13. BARRE DE FILTRES
   ------------------------------------------------------------- */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--c-line);
}
.filters .input, .filters .select { width: auto; min-width: 150px; padding: 8px 12px; font-size: 13.5px; }
.filters .select { padding-right: 34px; }
.filters__search { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.filters__search .input { width: 100%; padding-left: 36px; }
.filters__search svg {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--c-muted);
  pointer-events: none;
}

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 6px 13px;
  border-radius: var(--r-pill);
  border: 1px solid var(--c-line);
  font-size: 13px;
  color: var(--c-muted);
  background: #fff;
  transition: all var(--t-fast);
}
.chip:hover { border-color: #C9D3E0; color: var(--c-ink); }
.chip.is-active { background: var(--c-ink); border-color: var(--c-ink); color: #fff; }


/* -------------------------------------------------------------
   14. BANDEAU D'INFORMATION
   ------------------------------------------------------------- */
.notice {
  display: flex;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--app-radius);
  border: 1px solid var(--c-line);
  background: #fff;
  margin-bottom: var(--s-3);
  align-items: flex-start;
}
.notice svg { width: 19px; height: 19px; flex: none; margin-top: 1px; }
.notice b { display: block; font-size: 14.5px; font-weight: 500; margin-bottom: 3px; }
.notice p { font-size: 13.5px; color: var(--c-muted); }
.notice__actions { margin-left: auto; display: flex; gap: 8px; flex: none; align-items: center; }

.notice--brand  { border-color: rgba(46,204,113,.3); background: rgba(46,204,113,.05); }
.notice--brand svg { color: var(--c-green-700); }
.notice--warning { border-color: rgba(255,176,32,.32); background: rgba(255,176,32,.06); }
.notice--warning svg { color: #96620A; }
.notice--danger { border-color: rgba(255,90,90,.3); background: rgba(255,90,90,.05); }
.notice--danger svg { color: #C22B2B; }


/* -------------------------------------------------------------
   15. ÉLÉMENTS DIVERS
   ------------------------------------------------------------- */
.avatar {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--c-snow);
  border: 1px solid var(--c-line);
  font-size: 12px;
  font-weight: 600;
  color: var(--c-ink);
  flex: none;
}
.avatar--brand { background: var(--g-brand); border-color: transparent; color: var(--c-black); }

.copyable {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--f-mono);
  font-size: 12.5px;
  background: var(--c-snow);
  border: 1px solid var(--c-line);
  border-radius: 6px;
  padding: 3px 9px;
}

.url-cell {
  display: block;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--f-mono);
  font-size: 12.5px;
  color: var(--c-muted);
}

.divider { height: 1px; background: var(--c-line); margin: var(--s-3) 0; }

.meter { height: 6px; background: var(--c-line); border-radius: var(--r-pill); overflow: hidden; }
.meter__fill { height: 100%; background: var(--g-brand); border-radius: var(--r-pill); transition: width .6s var(--ease); }


/* -------------------------------------------------------------
   16. RESPONSIVE
   ------------------------------------------------------------- */
@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 1fr; }

  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 276px;
    transform: translateX(-100%);
    transition: transform .3s var(--ease);
    box-shadow: 0 0 40px rgba(0,0,0,.3);
  }
  .app-sidebar.is-open { transform: none; }

  .app-burger { display: grid; }

  .app-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5,7,13,.5);
    z-index: 55;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--t-base), visibility var(--t-base);
  }
  .app-overlay.is-open { opacity: 1; visibility: visible; }

  .auth { grid-template-columns: 1fr; }
  .auth__aside { display: none; }
}

@media (max-width: 760px) {
  .app-content { padding: var(--s-3) var(--s-2) var(--s-5); }
  .app-topbar { padding-inline: var(--s-2); }
  .form-grid { grid-template-columns: 1fr; }
  .page-head__actions { margin-left: 0; width: 100%; }
  .table th, .table td { padding: 11px 14px; }
  .kpi__value { font-size: 26px; }
}


/* -------------------------------------------------------------
   17. IMPRESSION
   ------------------------------------------------------------- */
@media print {
  .app-sidebar, .app-topbar, .page-head__actions, .filters, .pagination { display: none !important; }
  .app-shell { grid-template-columns: 1fr; }
  .panel { border-color: #ccc; break-inside: avoid; }
}
