/* ═══════════════════════════════════════════════════════════════════════════
   SociétéConnect — main.css
   Design system : DM Sans · palette bleue nuit + accent jaune · accessible
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
  --sidebar-bg:  #0a1628;
  --sidebar-w:   224px;
  --topbar-h:    56px;

  --brand:       #F5C518;
  --brand-dark:  #d4a800;
  --brand-rgb:   245, 197, 24;

  --bg:          #f4f5f7;
  --surface:     #ffffff;
  --surface-2:   #f0f2f5;
  --border:      #e2e5ea;
  --border-2:    #c8cdd6;

  --text:        #0d1117;
  --text-muted:  #64748b;
  --text-light:  #94a3b8;

  --blue:        #185FA5;
  --green:       #3B6D11;
  --amber:       #BA7517;
  --red:         #A32D2D;
  --purple:      #533AB7;

  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   20px;

  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,.1);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.15);

  --font-sans:   'DM Sans', system-ui, sans-serif;
  --font-mono:   'DM Mono', 'Courier New', monospace;

  --transition:  0.18s ease;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body { font-family: var(--font-sans); background: var(--bg); color: var(--text);
       font-size: 14px; line-height: 1.6; height: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
.font-mono { font-family: var(--font-mono); }

/* ── Layout principal ────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  overflow: hidden;
}
.brand-logos {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.logo-company {
  height: 28px;
  max-width: 80px;        /* jamais plus large que 80px */
  width: auto;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}
.logo-text-badge {
  width: 28px; height: 28px;
  background: var(--brand);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #0a1628;
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.brand-name { font-size: 13px; font-weight: 600; color: #fff; line-height: 1.2;
              white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-connect { color: var(--brand); }
.brand-sub { font-size: 10px; color: rgba(255,255,255,.4);
             white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Navigation */
.sidebar-nav {
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  color: rgba(255,255,255,.5);
  font-size: 13px;
  font-weight: 400;
  position: relative;
  transition: all var(--transition);
}
.nav-item:hover { background: rgba(255,255,255,.06); color: rgba(255,255,255,.85); }
.nav-item.active {
  background: rgba(245,197,24,.12);
  color: var(--brand);
  font-weight: 500;
}
.nav-icon { width: 18px; text-align: center; font-size: 14px; flex-shrink: 0; }
.nav-label { flex: 1; }
.nav-badge {
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 20px;
  display: inline-flex; align-items: center;
}
.msg-badge   { background: var(--brand); color: #0a1628; }
.notif-badge { background: #e24b4a; color: #fff; }

.sidebar-spacer { flex: 1; min-height: 16px; }

/* Langue */
.lang-switcher {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 8px 10px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.lang-btn {
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 10px; font-weight: 600;
  color: rgba(255,255,255,.4);
  transition: all var(--transition);
}
.lang-btn:hover { color: rgba(255,255,255,.8); background: rgba(255,255,255,.06); }
.lang-btn.active { background: rgba(245,197,24,.15); color: var(--brand); }

/* User */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.avatar-circle {
  width: 32px; height: 32px;
  background: var(--brand);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #0a1628;
  flex-shrink: 0;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { display: block; font-size: 12px; font-weight: 500; color: #fff; }
.visual-badge {
  display: inline-block;
  font-size: 9px; color: var(--brand);
  background: rgba(245,197,24,.12);
  border-radius: 4px;
  padding: 1px 5px;
  margin-top: 2px;
}
.logout-btn {
  color: rgba(255,255,255,.35);
  font-size: 15px;
  padding: 4px;
  transition: color var(--transition);
}
.logout-btn:hover { color: #e24b4a; }

/* Footer sidebar */
.sidebar-footer {
  padding: 10px 14px 14px;
  border-top: 1px solid rgba(255,255,255,.05);
}
.footer-legal { font-size: 10px; color: rgba(255,255,255,.3); display: block; margin-bottom: 8px; }
.footer-legal:hover { color: rgba(255,255,255,.6); }
.powered-by {
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; color: rgba(255,255,255,.25);
}
.logo-opsline {
  height: 16px; width: auto; opacity: .55;
  filter: brightness(2) grayscale(1);
}
.opsline-text { color: rgba(255,255,255,.4); font-size: 10px; }

/* ── Main content ────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 50;
}
.sidebar-toggle {
  display: none;
  background: none; border: none;
  font-size: 20px; color: var(--text-muted);
  padding: 4px;
}
.topbar-title { flex: 1; font-size: 15px; font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.notif-bell {
  width: 34px; height: 34px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  position: relative;
  transition: background var(--transition);
}
.notif-bell:hover { background: var(--surface-2); }
.bell-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: #e24b4a;
  border-radius: 50%;
  border: 2px solid var(--surface);
  animation: pulse 1.5s infinite;
}

/* Bandeau flash notification */
.notif-flash {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: #1a3a1a;
  border-bottom: 2px solid #3B6D11;
  z-index: 80;
  animation: slideDown .35s ease;
}
.notif-flash.flash-message   { background: #1a2f1a; border-color: #3B6D11; }
.notif-flash.flash-appointment{ background: #162035; border-color: #185FA5; }
.flash-icon { font-size: 18px; }
.flash-body { flex: 1; font-size: 13px; color: #c0dd97; }
.flash-body strong { display: block; color: #eaf3de; font-size: 14px; }
.notif-flash > button {
  background: none; border: none;
  color: rgba(255,255,255,.5); font-size: 15px;
  padding: 4px;
}

/* Flash écran (malentendant) */
@keyframes screenFlash {
  0%   { box-shadow: inset 0 0 0 4px rgba(var(--brand-rgb),.0); }
  25%  { box-shadow: inset 0 0 0 6px rgba(var(--brand-rgb),.7); }
  50%  { box-shadow: inset 0 0 0 4px rgba(var(--brand-rgb),.3); }
  75%  { box-shadow: inset 0 0 0 6px rgba(var(--brand-rgb),.5); }
  100% { box-shadow: inset 0 0 0 0 rgba(var(--brand-rgb),.0); }
}
body.screen-flash { animation: screenFlash .6s ease; }

/* Page content */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── Panneau notifications ───────────────────────────────────────────────── */
.notif-panel {
  position: fixed; top: 0; right: 0;
  width: 340px; height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 200;
  transform: translateX(100%);
  transition: transform .25s ease;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.notif-panel.open { transform: none; }
.notif-panel-header {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px; font-weight: 500;
}
.notif-panel-header button {
  background: none; border: none;
  color: var(--text-muted); font-size: 12px; padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.notif-panel-header button:last-child { margin-left: auto; }
.notif-panel-list { flex: 1; overflow-y: auto; }
.notif-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: #f0f7ff; }
.ni-icon { font-size: 16px; flex-shrink: 0; margin-top: 2px; }
.ni-body { flex: 1; }
.ni-body strong { display: block; font-size: 13px; }
.ni-body span { font-size: 12px; color: var(--text-muted); }
.ni-time { font-size: 11px; color: var(--text-light); flex-shrink: 0; }
.empty-notif { padding: 20px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* Overlay */
.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.25);
  z-index: 190;
}
.overlay.open { display: block; }

/* ── Boutons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
}
.btn-primary {
  background: var(--brand); color: #0a1628;
  border-color: var(--brand);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-ghost {
  background: transparent;
  border-color: var(--border-2);
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger {
  background: #fef2f2; color: var(--red);
  border-color: #fecaca;
}
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Formulaires ─────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type=text], input[type=email], input[type=password],
input[type=datetime-local], select, textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb),.15);
}
textarea { resize: vertical; min-height: 72px; }
.search-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

/* Autocomplete */
.input-with-suggest { position: relative; }
.suggest-dropdown {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 9999;
  max-height: 200px; overflow-y: auto;
  display: none;
}
.suggest-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.suggest-item:hover { background: var(--surface-2); }
.suggest-item span { font-size: 11px; color: var(--text-muted); }

/* ── Modales ─────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 560px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 15px; font-weight: 600; }
.modal-head > button {
  background: none; border: none;
  color: var(--text-muted); font-size: 16px;
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.modal-head > button:hover { background: var(--surface-2); }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  overflow-x: visible;
  display: flex; flex-direction: column; gap: 14px;
  position: relative;
}

/* Quand une suggestion est ouverte, désactiver overflow-y temporairement */
.modal-body.suggest-open {
  overflow-y: visible;
}
.modal-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  gap: 10px;
}
.modal-foot-right { display: flex; gap: 8px; margin-left: auto; }

/* Mentions légales */
.legal-modal { max-width: 640px; }
.legal-body { font-size: 13px; line-height: 1.8; }
.legal-body h3 {
  font-size: 13px; font-weight: 600;
  color: var(--blue);
  margin: 16px 0 4px;
}
.legal-body ul { margin: 6px 0 6px 18px; }
.legal-body a { color: var(--blue); text-decoration: underline; }
.legal-intro, .legal-footer {
  font-size: 11px; color: var(--text-muted);
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.legal-footer { border-top: 1px solid var(--border); border-bottom: none; margin-top: 12px; }

/* ── Stats ───────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.stat-label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 26px; font-weight: 600; line-height: 1.1; }
.stat-sub   { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.stat-warning .stat-value { color: var(--amber); }
.stat-success .stat-value { color: var(--green); }

/* ── Section heading ─────────────────────────────────────────────────────── */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.section-head h2 { font-size: 15px; font-weight: 600; }

/* ── Liste RDV dashboard ─────────────────────────────────────────────────── */
.appt-list { display: flex; flex-direction: column; gap: 8px; }
.appt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 14px;
  transition: box-shadow var(--transition);
}
.appt-card:hover { box-shadow: var(--shadow-sm); }
.appt-time { width: 72px; flex-shrink: 0; }
.time-h { display: block; font-size: 16px; font-weight: 600; }
.time-end { font-size: 11px; color: var(--text-muted); }
.appt-bar { width: 4px; height: 40px; border-radius: 4px; flex-shrink: 0; }
.appt-info { flex: 1; min-width: 0; }
.appt-name { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.appt-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.appt-msg-btn { flex-shrink: 0; }

/* Tags */
.tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px; font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.tag-type    { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.tag-service { background: #f0fdf4; color: var(--green); border-color: #bbf7d0; }

/* Status pills */
.status-pill {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.status-pill.status-confirmed   { background: #dbeafe; color: #1d4ed8; }
.status-pill.status-pending     { background: #fef3c7; color: #92400e; }
.status-pill.status-cancelled   { background: #fee2e2; color: #991b1b; }
.status-pill.status-done        { background: #dcfce7; color: #166534; }
.status-pill.status-rescheduled { background: #ede9fe; color: #5b21b6; }

/* ── Formulaire RDV progressif ───────────────────────────────────────────── */
.appt-step {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: opacity var(--transition);
}
.appt-step + .appt-step { margin-top: 8px; }
.appt-step.step-locked {
  opacity: .45;
  pointer-events: none;
}
.step-label {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 500;
  flex-wrap: nowrap; min-width: 0;
}
.step-client-info {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 4px; min-width: 0; overflow: hidden;
  font-weight: 400;
}
.step-num {
  width: 20px; height: 20px;
  background: var(--blue); color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}
.appt-step.step-locked .step-num { background: var(--text-light); }
.step-edit {
  margin-left: auto;
  font-size: 11px; color: var(--blue);
  cursor: pointer; font-weight: 400;
}
.step-edit:hover { text-decoration: underline; }
.step-content { padding: 10px 12px; }
.step-summary { padding: 8px 12px; }
.step-summary-card {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
}
.step-summary-card span { color: var(--text-muted); font-size: 12px; }

/* Choix véhicule */
.vehicle-choice-list { display: flex; flex-direction: column; gap: 6px; }
.vehicle-choice-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  gap: 10px;
  transition: background var(--transition);
}
.vehicle-choice-row:has(.vc-checkbox:checked) {
  background: #f0f7ff; border-color: #185FA5;
}
.vehicle-choice-row:has(.vc-checkbox:disabled) { opacity: .5; }
.vc-check-label {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; flex: 1;
}
.vc-check-label input[type=checkbox] {
  width: 16px; height: 16px; flex-shrink: 0; cursor: pointer;
}
.vc-info { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 13px; }

/* Badges origine */
.origin-badge {
  font-size: 9px; font-weight: 600;
  padding: 0 5px; line-height: 16px;
  border-radius: 3px;
}
.origin-reseau  { background: #dbeafe; color: #1d4ed8; }
.origin-externe { background: #fef3c7; color: #92400e; }

/* Sélecteurs date + heure côte à côte */
.dt-picker-row { display: flex; gap: 8px; }
.dt-picker-row input[type=date] { flex: 1.4; }
.dt-picker-row select { flex: 1; }

.cal-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.fc-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  overflow: hidden;
}
/* FullCalendar overrides */
.fc .fc-button-primary {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
  font-size: 12px !important;
  font-family: var(--font-sans) !important;
}
.fc .fc-button-primary:hover { background: var(--surface-2) !important; }
.fc .fc-button-primary.fc-button-active {
  background: var(--brand) !important;
  border-color: var(--brand) !important;
  color: #0a1628 !important;
}
.fc .fc-toolbar-title { font-size: 15px !important; font-weight: 600 !important; }
.fc-event { border-radius: 6px !important; border-width: 0 0 0 3px !important; font-size: 11px !important; }
.fc-timegrid-slot { height: 32px !important; }
.fc-day-today { background: rgba(var(--brand-rgb), .04) !important; }
.fc-scrollgrid { border-radius: var(--radius-md) !important; overflow: hidden; }

/* ── Messagerie ─────────────────────────────────────────────────────────── */
.msg-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - var(--topbar-h) - 48px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.threads-col {
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.threads-header { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.threads-list { flex: 1; overflow-y: auto; }
.thread-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
}
.thread-item:hover { background: var(--surface-2); }
.thread-item.active { background: #f0f7ff; }
.thread-item.unread { background: #fffbeb; }
.thread-avatar {
  width: 36px; height: 36px;
  background: var(--surface-2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px; color: var(--text-muted);
  flex-shrink: 0;
}
.thread-body { flex: 1; min-width: 0; }
.thread-top { display: flex; justify-content: space-between; align-items: center; }
.thread-name { font-size: 13px; font-weight: 500; }
.thread-time { font-size: 10px; color: var(--text-light); }
.thread-preview { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-unread {
  position: absolute; right: 10px; bottom: 10px;
  background: var(--brand); color: #0a1628;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 20px;
}

.chat-col {
  display: flex; flex-direction: column;
  overflow: hidden; position: relative;
}
.chat-placeholder {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text-muted); gap: 8px;
}
.placeholder-icon { font-size: 36px; opacity: .3; }
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-client-info { display: flex; align-items: center; gap: 10px; }
.avatar-md {
  width: 36px; height: 36px;
  background: var(--brand);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #0a1628;
}
.chat-client-name { font-size: 14px; font-weight: 500; }
.chat-client-meta { font-size: 11px; color: var(--text-muted); }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.msg-bubble { display: flex; flex-direction: column; max-width: 72%; }
.msg-in  { align-self: flex-start; }
.msg-out { align-self: flex-end; }
.bubble-content {
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 13px; line-height: 1.5;
}
.msg-in  .bubble-content { background: var(--surface-2); border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px; }
.msg-out .bubble-content { background: var(--blue); color: #fff; border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg); }
.bubble-time { font-size: 10px; color: var(--text-light); margin-top: 3px; padding: 0 4px; }
.msg-out .bubble-time { text-align: right; }

.link-box {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: #f0f7ff;
  border-top: 1px solid var(--border);
}
.link-box input { flex: 1; background: var(--surface); }
.chat-input-area {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input-area textarea { flex: 1; min-height: 44px; max-height: 120px; }
.btn-send { flex-shrink: 0; align-self: flex-end; }

/* ── Clients grid ────────────────────────────────────────────────────────── */
.clients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
/* Card : colonne avatar | colonne infos (3 lignes) */
.client-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  display: flex; align-items: flex-start; gap: 12px;
  transition: box-shadow var(--transition);
}
.client-card:hover { box-shadow: var(--shadow-sm); }
.cc-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--blue), #0a3d7a);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex-shrink: 0;
  margin-top: 1px;
}
/* Colonne infos — prend tout l'espace, débordement géré */
.cc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }

/* Ligne 1 : nom + badge langue sur la même ligne */
.cc-name-row {
  display: flex; align-items: center; gap: 6px;
}
.cc-name {
  font-size: 14px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}

/* Ligne 2 : email + téléphone sur UNE seule ligne, tronqué si besoin */
.cc-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden;
}
.cc-email {
  overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}
.cc-phone { flex-shrink: 0; font-family: var(--font-mono); letter-spacing: .02em; }
.cc-meta-empty { font-style: italic; color: var(--text-light); font-size: 11px; }

/* Ligne 3 : boutons actions */
.cc-actions {
  display: flex; gap: 3px;
  margin-top: 2px;
}
.cc-actions .btn-sm {
  padding: 3px 8px;
  font-size: 12px;
}

/* Badge langue — à droite du nom */
.lang-tag {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 5px;
  font-size: 9px; font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  line-height: 16px;
}

/* Lien display */
.link-display { display: flex; gap: 8px; }
.link-display input { flex: 1; font-size: 11px; font-family: var(--font-mono); }

/* ── Véhicules pills sur card client ─────────────────────────────────────── */
.cc-vehicles {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin: 2px 0;
  min-height: 4px;
}
.veh-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px 2px 4px;
  border-radius: 20px;
  font-size: 11px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  max-width: 100%;          /* ne dépasse pas la card */
  overflow: hidden;
}
.veh-pill.veh-actif    { background: #f0fdf4; border-color: #bbf7d0; }
.veh-pill.veh-restitue { background: #f8fafc; border-color: var(--border); opacity: .65; }
.veh-pill.veh-archive  { background: #f8fafc; border-color: var(--border); opacity: .4; }
.veh-type-badge {
  font-size: 9px; font-weight: 700;
  background: var(--blue); color: #fff;
  border-radius: 3px; padding: 0 4px; line-height: 14px;
  flex-shrink: 0;
  white-space: nowrap;
}
.veh-pill.veh-restitue .veh-type-badge,
.veh-pill.veh-archive  .veh-type-badge { background: var(--text-muted); }
.veh-model {
  font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.veh-reg {
  font-family: var(--font-mono); font-size: 10px; color: var(--text-muted);
  white-space: nowrap; flex-shrink: 0;
}
.veh-status-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.veh-actif    .veh-status-dot { background: var(--green); }
.veh-restitue .veh-status-dot { background: var(--text-muted); }
.veh-archive  .veh-status-dot { background: var(--border-2); }

/* Bouton Inviter */
.btn-invite {
  background: #1a3a1a; color: #c0dd97;
  border: 1px solid #3B6D11;
  font-weight: 600;
}
.btn-invite:hover { background: #27500A; color: #eaf3de; }

/* Modale véhicules — liste */
.mv-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 6px;
  gap: 10px;
}
.mv-row-info {
  display: flex; align-items: center; gap: 8px;
  flex: 1; min-width: 0; flex-wrap: wrap;
  font-size: 13px;
}
.mv-row-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.veh-status-label {
  font-size: 10px; font-weight: 600;
  padding: 1px 7px; border-radius: 20px;
}
.veh-status-label.veh-actif    { background: #dcfce7; color: #166534; }
.veh-status-label.veh-restitue { background: #f1f5f9; color: var(--text-muted); }
.veh-status-label.veh-archive  { background: #f1f5f9; color: var(--text-light); }

/* Formulaire ajout véhicule */
.veh-add-form {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

/* Boîte lien invitation */
.invite-link-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  padding: 12px;
  margin-top: 4px;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  gap: 12px;
}
.empty-icon { font-size: 40px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ── Alert ───────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
}
.alert-danger { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; }

/* ── Auth pages ──────────────────────────────────────────────────────────── */
.auth-body {
  min-height: 100vh;
  background: linear-gradient(135deg, #0a1628 0%, #162040 50%, #0a1628 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-container { width: 100%; max-width: 400px; }
.auth-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo h1 { font-size: 22px; font-weight: 600; margin: 10px 0 4px; }
.auth-logo p  { font-size: 13px; color: var(--text-muted); }
.auth-badge {
  width: 52px; height: 52px;
  background: var(--brand);
  border-radius: var(--radius-lg);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; color: #0a1628;
  margin-bottom: 8px;
}
.auth-company-logo { height: 48px; width: auto; border-radius: var(--radius-md); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-divider {
  text-align: center;
  font-size: 12px; color: var(--text-muted);
  margin: 14px 0 8px;
  position: relative;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  position: absolute; top: 50%;
  width: 35%; height: 1px;
  background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after  { right: 0; }
.auth-footer {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: 16px;
  font-size: 11px; color: rgba(255,255,255,.35);
}
.auth-footer a { color: rgba(255,255,255,.5); }
.auth-footer a:hover { color: #fff; }
.logo-opsline-auth { height: 14px; width: auto; opacity: .5; filter: brightness(10); }

/* ── Portail client ──────────────────────────────────────────────────────── */
.client-body { background: var(--bg); }
.client-header {
  background: var(--sidebar-bg);
  padding: 0 24px;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.client-brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 600; color: #fff;
}
.logo-company-sm { height: 28px; border-radius: 4px; }
.client-header-right { display: flex; align-items: center; gap: 8px; }
.client-main { max-width: 960px; margin: 0 auto; padding: 28px 20px; }
.client-greeting {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 28px;
}
.greeting-avatar {
  width: 52px; height: 52px;
  background: var(--brand);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: #0a1628;
  flex-shrink: 0;
}
.client-greeting h1 { font-size: 20px; font-weight: 600; }
.text-muted { color: var(--text-muted); font-size: 13px; }
.client-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.client-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.client-section h2 { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.client-appts { display: flex; flex-direction: column; gap: 10px; }
.client-appt-card {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  border-left-width: 4px;
}
.client-appt-card.status-confirmed   { border-left-color: var(--blue); }
.client-appt-card.status-pending     { border-left-color: var(--amber); }
.client-appt-card.status-cancelled   { border-left-color: var(--red); }
.client-appt-card.status-done        { border-left-color: var(--green); }
.client-appt-card.status-rescheduled { border-left-color: var(--purple); }
.ca-date {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-width: 40px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 6px;
}
.ca-day   { font-size: 18px; font-weight: 700; line-height: 1; }
.ca-month { font-size: 10px; color: var(--text-muted); font-weight: 600; }
.ca-body  { flex: 1; }
.ca-time  { font-size: 11px; color: var(--text-muted); }
.ca-title { font-size: 13px; font-weight: 500; margin: 2px 0; }
.ca-vehicle, .ca-reg { font-size: 11px; color: var(--text-muted); }

.client-chat { display: flex; flex-direction: column; height: 360px; }
.client-messages {
  flex: 1; overflow-y: auto;
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.client-input-area { display: flex; align-items: flex-end; gap: 8px; }
.client-input-area textarea { flex: 1; }
.chat-hint { font-size: 11px; color: var(--text-muted); margin-top: 8px; }

.client-footer {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 16px;
  font-size: 11px; color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 32px;
}
.client-footer a { color: var(--text-muted); }
.client-footer a:hover { color: var(--text); }

/* ── Animations ──────────────────────────────────────────────────────────── */
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.4); opacity: .7; }
}
@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); z-index: 200; }
  .sidebar.open { transform: none; }
  .sidebar-toggle { display: flex; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .client-layout { grid-template-columns: 1fr; }
  .msg-layout { grid-template-columns: 1fr; }
  .threads-col { max-height: 200px; border-right: none; border-bottom: 1px solid var(--border); }
}
@media (max-width: 600px) {
  .page-content { padding: 14px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .clients-grid { grid-template-columns: 1fr; }
  .modal-box { border-radius: var(--radius-lg); }
}
