/* ==========================================================================
   MEDIN+ — Charte graphique minimaliste
   Mono-couleur (cyan), beaucoup de blanc, typographie Inter
   ========================================================================== */

/* --- Reset & base --- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
input, textarea, select { -webkit-appearance: none; appearance: none; }

/* --- Design tokens --- */
:root {
  /* Couleur primaire unique */
  --primary: #0E9DAA;
  --primary-hover: #0B8590;
  --primary-soft: #E6F7F8;
  --primary-text: #075963;

  /* Neutres */
  --text: #18181B;
  --text-muted: #71717A;
  --text-subtle: #A1A1AA;
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --border: #E4E4E7;
  --border-strong: #D4D4D8;
  --hover: #F4F4F5;

  /* Sémantique */
  --success: #10B981;
  --success-soft: #ECFDF5;
  --warning: #F59E0B;
  --warning-soft: #FEF3C7;
  --danger: #EF4444;
  --danger-soft: #FEE2E2;

  /* Layout */
  --radius: 8px;
  --radius-lg: 12px;
  --radius-pill: 9999px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --max-w: 560px;
}

/* --- Typography helpers --- */
.h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.h2 { font-size: 18px; font-weight: 600; margin: 0; }
.h3 { font-size: 14px; font-weight: 600; margin: 0; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-center { text-align: center; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }

/* --- Layout --- */
.app { min-height: 100vh; padding-bottom: 80px; }
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 16px; }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 20px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* --- Header / app bar --- */
.appbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.appbar-inner {
  max-width: var(--max-w); margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; min-height: 56px;
}
.appbar-title { font-weight: 600; font-size: 16px; flex: 1; }
.appbar .icon-btn { color: var(--text); }

.icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }

/* --- Card --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.card-flat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.card-tight { padding: 12px; }
.card-section { padding: 14px 16px; }
.card-section + .card-section { border-top: 1px solid var(--border); }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  height: 44px; padding: 0 18px;
  border-radius: var(--radius);
  font-weight: 500; font-size: 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  transition: all 0.15s;
  text-decoration: none;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-ghost { border-color: transparent; }
.btn-ghost:hover { background: var(--hover); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #DC2626; color: #fff; }
.btn-block { width: 100%; }
.btn-sm { height: 36px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 52px; padding: 0 24px; font-size: 15px; }
.btn svg { width: 16px; height: 16px; }

/* --- Form --- */
.field { display: block; }
.field + .field { margin-top: 12px; }
.field-label {
  display: block;
  font-size: 11px; font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.input, .select, .textarea {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.textarea { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14, 157, 170, 0.15);
}
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.input.filled { background: var(--primary-soft); border-color: var(--primary-soft); }
.select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371717A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 36px;
}

/* Field row variant — span 2 cols */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }

/* --- Chip selector --- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center;
  height: 36px; padding: 0 14px;
  font-size: 13px; font-weight: 500;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.chip:hover { border-color: var(--primary); }
.chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* --- Checkbox --- */
.checkbox {
  appearance: none; -webkit-appearance: none;
  width: 22px; height: 22px;
  border: 2px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: all 0.15s;
}
.checkbox:hover { border-color: var(--primary); }
.checkbox:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.checkbox:checked::after {
  content: '';
  position: absolute;
  left: 5px; top: 1px;
  width: 7px; height: 12px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}
.checkbox:focus { box-shadow: 0 0 0 3px rgba(14, 157, 170, 0.15); outline: none; }

.checkbox-row { user-select: none; }
.checkbox-row:hover .checkbox { border-color: var(--primary); }

/* --- Toggle switch --- */
.toggle {
  position: relative; display: inline-block;
  width: 44px; height: 26px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer;
  inset: 0;
  background: var(--border-strong);
  border-radius: 26px;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 22px; height: 22px;
  left: 2px; top: 2px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* --- Badges --- */
.badge {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 8px;
  font-size: 11px; font-weight: 500;
  border-radius: var(--radius-pill);
  background: var(--hover); color: var(--text-muted);
}
.badge-primary { background: var(--primary-soft); color: var(--primary-text); }
.badge-success { background: var(--success-soft); color: #047857; }
.badge-warning { background: var(--warning-soft); color: #92400E; }
.badge-danger { background: var(--danger-soft); color: #991B1B; }

/* --- Avatar --- */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft);
  color: var(--primary-text);
  font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}
.avatar-lg { width: 44px; height: 44px; font-size: 14px; }
.avatar-sm { width: 28px; height: 28px; font-size: 10px; }

/* --- Swipe-to-delete --- */
.swipe-row {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  margin-bottom: 8px;
}
.swipe-row .swipe-bg {
  position: absolute;
  inset: 0;
  background: var(--danger);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 24px;
  color: white;
  font-weight: 500;
  font-size: 13px;
  gap: 8px;
}
.swipe-row .swipe-bg svg { width: 20px; height: 20px; }
.swipe-row .swipe-foreground {
  position: relative;
  z-index: 1;
  background: var(--surface);
  transition: transform 0.25s cubic-bezier(.2, .9, .3, 1);
  /* Permet le scroll vertical mais on capture l'horizontal */
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}
.swipe-row.is-dragging .swipe-foreground { transition: none; }
.swipe-row.is-revealed .swipe-foreground { transform: translateX(-100px); }

/* --- List item (visitor card) --- */
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  text-decoration: none;
  color: inherit;
}
.list-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}
.list-item-body { flex: 1; min-width: 0; }
.list-item-title { font-weight: 500; font-size: 14px; color: var(--text); word-break: break-word; }
.list-item-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; word-break: break-word; }

/* --- Bottom navigation --- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-inner {
  max-width: var(--max-w); margin: 0 auto;
  display: flex; justify-content: space-around;
  padding: 6px 4px;
}
.nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px;
  color: var(--text-subtle);
  font-size: 11px;
  text-decoration: none;
  transition: color 0.15s;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item:hover { color: var(--text-muted); text-decoration: none; }
.nav-item.active { color: var(--primary); }

/* --- FAB (floating action button) --- */
.fab {
  position: fixed;
  bottom: calc(76px + env(safe-area-inset-bottom));
  right: 16px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(14, 157, 170, 0.35);
  z-index: 40;
  transition: transform 0.15s;
}
.fab:hover { background: var(--primary-hover); color: #fff; text-decoration: none; }
.fab:active { transform: scale(0.95); }
.fab svg { width: 24px; height: 24px; }

/* --- KPI cards --- */
.kpi { padding: 16px; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.kpi-value { font-size: 28px; font-weight: 600; color: var(--text); letter-spacing: -0.02em; }
.kpi-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* --- Empty state --- */
.empty {
  text-align: center; padding: 48px 16px;
  color: var(--text-muted);
}
.empty-icon {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  background: var(--hover);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-subtle);
}
.empty-icon svg { width: 28px; height: 28px; }
.empty-title { color: var(--text); font-weight: 500; margin-bottom: 4px; }

/* --- Toast --- */
.toast {
  position: fixed;
  top: 16px; left: 16px; right: 16px;
  max-width: var(--max-w);
  margin: 0 auto;
  background: var(--text);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius);
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  transform: translateY(-150%);
  opacity: 0;
  transition: all 0.25s ease-out;
  z-index: 100;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* --- Tabs --- */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  flex: 1;
  padding: 12px 8px;
  text-align: center;
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: all 0.15s;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-count { display: inline-block; margin-left: 4px; padding: 1px 6px; font-size: 11px; background: var(--hover); border-radius: var(--radius-pill); }
.tab.active .tab-count { background: var(--primary-soft); color: var(--primary-text); }

/* --- Logo --- */
.logo { font-weight: 700; font-size: 18px; color: var(--primary); letter-spacing: -0.01em; }
.logo-mark { display: inline-flex; align-items: center; gap: 8px; }

/* --- Section divider --- */
.section-title {
  display: flex; align-items: center; gap: 8px;
  margin: 20px 4px 8px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted);
}
.section-title-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--primary);
}

/* --- Bar chart --- */
.bar-row { margin-bottom: 12px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.bar-label { font-size: 13px; color: var(--text); }
.bar-value { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.bar-track { width: 100%; height: 6px; background: var(--hover); border-radius: var(--radius-pill); overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: var(--radius-pill); transition: width 0.6s ease-out; }

/* --- Skeleton loader --- */
.skel { background: linear-gradient(90deg, var(--hover) 25%, #FAFAFA 50%, var(--hover) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: var(--radius); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* --- Utilities --- */
.hidden { display: none !important; }
.flex-1 { flex: 1; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }
.px-4 { padding-left: 16px; padding-right: 16px; }

/* --- Auth screen --- */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
}
.auth-logo { text-align: center; margin-bottom: 32px; }

/* --- Responsive --- */
@media (min-width: 640px) {
  .container { padding: 0 24px; }
}
