/* ============================================================
   SecuredArea — Design System
   (mêmes tokens que ProspectIA / SiteBuilder pour cohérence visuelle)
   ============================================================ */

:root {
  --primary:        #4F46E5;
  --primary-dark:   #4338CA;
  --primary-light:  #EEF2FF;
  --accent:         #7C3AED;
  --success:        #059669;
  --success-light:  #ECFDF5;
  --warning:        #D97706;
  --warning-light:  #FFFBEB;
  --danger:         #DC2626;
  --danger-light:   #FEF2F2;
  --gray-50:        #F9FAFB;
  --gray-100:       #F3F4F6;
  --gray-200:       #E5E7EB;
  --gray-300:       #D1D5DB;
  --gray-400:       #9CA3AF;
  --gray-500:       #6B7280;
  --gray-600:       #4B5563;
  --gray-700:       #374151;
  --gray-800:       #1F2937;
  --gray-900:       #111827;
  --white:          #FFFFFF;
  --radius-sm:      6px;
  --radius:         8px;
  --radius-lg:      12px;
  --radius-xl:      16px;
  --shadow-xs:      0 1px 2px rgba(0,0,0,.05);
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:         0 4px 6px rgba(0,0,0,.05), 0 2px 4px rgba(0,0,0,.04);
  --shadow-md:      0 10px 15px rgba(0,0,0,.06), 0 4px 6px rgba(0,0,0,.04);
  --shadow-lg:      0 20px 25px rgba(0,0,0,.08), 0 8px 10px rgba(0,0,0,.04);
  --font:           'Inter', system-ui, -apple-system, sans-serif;
  --sidebar-w:      256px;
  --topbar-h:       64px;
  --transition:     .15s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; }
button { font-family: var(--font); cursor: pointer; }
input, select, textarea { font-family: var(--font); }

/* ================================================================
   BOUTONS
   ================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .5rem 1rem;
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.5;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  outline: none;
}
.btn:focus-visible { box-shadow: 0 0 0 3px rgba(79,70,229,.3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-secondary { background: var(--white); color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-outline   { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-light); }

.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }

.btn-ghost     { background: transparent; color: var(--gray-600); border-color: transparent; }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); }

.btn-sm  { padding: .375rem .75rem; font-size: .8125rem; }
.btn-lg  { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-block, .btn-full { width: 100%; }

/* ================================================================
   FORMULAIRES
   ================================================================ */
.form-group { margin-bottom: 1.25rem; }
.form-group label, label {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: .375rem;
}
input[type="text"], input[type="email"], input[type="password"], textarea, select {
  width: 100%;
  padding: .5625rem .875rem;
  background: var(--white);
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: .875rem;
  color: var(--gray-900);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
input::placeholder, textarea::placeholder { color: var(--gray-400); }
.form-inline { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.form-inline .form-group { margin-bottom: 0; min-width: 220px; }

/* ================================================================
   ALERTES
   ================================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .875rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 1.25rem;
}
.alert-error   { background: var(--danger-light);  color: var(--danger); }
.alert-success { background: var(--success-light); color: var(--success); }
.alert-warning { background: var(--warning-light); color: var(--warning); }

/* ================================================================
   CARTES
   ================================================================ */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-xs);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

/* ================================================================
   LAYOUT AUTH (login)
   ================================================================ */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--white);
}
.auth-left {
  background: linear-gradient(135deg, #312E81 0%, #4F46E5 50%, #7C3AED 100%);
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-left::before {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
  top: -100px; right: -100px;
}
.auth-left::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: rgba(255,255,255,.04);
  bottom: -80px; left: -80px;
}
.auth-brand { display: flex; align-items: center; gap: .75rem; position: relative; z-index: 1; }
.auth-brand-icon {
  width: 40px; height: 40px;
  background: rgba(255,255,255,.15);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
}
.auth-brand-icon svg { width: 22px; height: 22px; color: #fff; }
.auth-brand-name { font-size: 1.25rem; font-weight: 800; color: #fff; }

.auth-left-content { position: relative; z-index: 1; }
.auth-left-content h2 { font-size: 1.75rem; font-weight: 800; color: #fff; margin-bottom: .75rem; line-height: 1.3; }
.auth-left-content p  { color: rgba(255,255,255,.75); font-size: .9375rem; line-height: 1.7; }

.auth-features { list-style: none; margin-top: 1.5rem; }
.auth-features li {
  display: flex; align-items: center; gap: .625rem;
  color: rgba(255,255,255,.85);
  font-size: .875rem;
  padding: .4rem 0;
}
.auth-features li svg { width: 18px; height: 18px; color: #A5B4FC; flex-shrink: 0; }

.auth-right {
  padding: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
}
.auth-form-wrap { width: 100%; max-width: 400px; }
.auth-form-wrap h1 { font-size: 1.625rem; font-weight: 800; color: var(--gray-900); margin-bottom: .375rem; }
.auth-form-wrap .auth-sub { color: var(--gray-500); font-size: .9375rem; margin-bottom: 2rem; }
.auth-footer-link { text-align: center; margin-top: 1.5rem; font-size: .875rem; color: var(--gray-500); }

@media (max-width: 768px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-left  { display: none; }
  .auth-right { padding: 1.5rem; }
}

/* ================================================================
   PAGE D'ACCÈS PUBLIQUE (client, sans sidebar)
   ================================================================ */
.access-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, #312E81 0%, #4F46E5 50%, #7C3AED 100%);
}
.access-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 460px;
}
.access-brand { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.5rem; }
.access-brand-icon {
  width: 40px; height: 40px;
  background: var(--primary-light);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
}
.access-brand-icon svg { width: 22px; height: 22px; color: var(--primary); }
.access-brand-name { font-size: 1.0625rem; font-weight: 800; color: var(--gray-900); }
.access-card h1 { display: none; }
.access-card .auth-sub { color: var(--gray-700); font-size: 1rem; font-weight: 600; margin-bottom: .5rem; }
.access-note { color: var(--gray-500); font-size: .8125rem; margin-top: 1rem; }

/* ================================================================
   LAYOUT APP (sidebar + topbar)
   ================================================================ */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,.05);
}
.sidebar-logo {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
}
.sidebar-logo .logo-icon {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo .logo-icon svg { width: 18px; height: 18px; color: #fff; }
.sidebar-logo .logo-name { font-size: .9375rem; font-weight: 800; color: #fff; }

.sidebar-nav { flex: 1; padding: .75rem 0; }
.nav-section {
  padding: 1rem 1rem .375rem;
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255,255,255,.3);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5625rem 1rem;
  margin: .125rem .625rem;
  border-radius: var(--radius);
  color: rgba(255,255,255,.55);
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.85); text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item.active:hover { background: var(--primary-dark); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-user {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
}
.sidebar-user-avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8125rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-email { font-size: .8125rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role  { font-size: .75rem; color: rgba(255,255,255,.4); }

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-size: 1.0625rem; font-weight: 700; color: var(--gray-900); display: flex; align-items: center; gap: .5rem; }
.topbar-back { color: var(--gray-400); }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }

.page-content { max-width: 880px; margin: 0 auto; width: 100%; padding: 2rem 1.5rem; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; gap: 1rem; }
.page-header h1 { font-size: 1.375rem; font-weight: 800; color: var(--gray-900); margin: 0; }
.page-header .actions { display: flex; gap: .6rem; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-256px); }
  .main-content { margin-left: 0; }
}

/* ================================================================
   LISTE CLIENTS
   ================================================================ */
.clients-list { display: flex; flex-direction: column; gap: .5rem; }
.client-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: .9rem 1.1rem;
  gap: 1rem;
}
.client-row .info { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.client-row .name { font-weight: 600; color: var(--gray-900); }
.client-row .sub { font-size: .8125rem; color: var(--gray-500); }
.client-row .actions { display: flex; gap: .5rem; align-items: center; flex-shrink: 0; }

.status-badge { font-size: .75rem; padding: .2rem .6rem; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.status-jamais_envoye { background: var(--gray-100); color: var(--gray-500); }
.status-en_attente    { background: var(--warning-light); color: var(--warning); }
.status-utilise       { background: var(--success-light); color: var(--success); }
.status-expire        { background: var(--danger-light);  color: var(--danger); }

.empty-state { text-align: center; color: var(--gray-400); padding: 2.5rem; }

/* ================================================================
   ÉDITEUR CREDENTIALS
   ================================================================ */
.cred-edit-row { display: flex; gap: .75rem; align-items: flex-start; margin-bottom: .75rem; }
.cred-edit-row .form-group { flex: 1; margin-bottom: 0; }
.cred-edit-row .btn-remove { margin-top: 1.6rem; }

.cred-list { display: flex; flex-direction: column; gap: .9rem; margin: 1.5rem 0; }
.cred-row label { display: block; font-size: .8125rem; font-weight: 600; color: var(--gray-700); margin-bottom: .35rem; }
.cred-value-wrap { display: flex; gap: .5rem; }
.cred-value-wrap input { font-family: ui-monospace, monospace; background: var(--gray-50); }
