/* ==============================
   Reset & Variables
================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:     #2563eb;
  --primary-h:   #1d4ed8;
  --danger:      #dc2626;
  --danger-h:    #b91c1c;
  --success-bg:  #f0fdf4;
  --success-cl:  #166534;
  --success-br:  #bbf7d0;
  --error-bg:    #fef2f2;
  --error-cl:    #991b1b;
  --error-br:    #fecaca;
  --info-bg:     #eff6ff;
  --info-cl:     #1e40af;
  --info-br:     #bfdbfe;
  --text:        #1e293b;
  --muted:       #64748b;
  --border:      #e2e8f0;
  --bg:          #f8fafc;
  --white:       #ffffff;
  --radius:      6px;
  --shadow:      0 1px 3px rgba(0,0,0,.08);
  --shadow-md:   0 4px 12px rgba(0,0,0,.1);
  --font:        'Segoe UI', system-ui, sans-serif;
  --max-w:       1100px;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ==============================
   Layout
================================ */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex: 1;
}

.page-header {
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; }

.mb-2 { margin-bottom: 1.5rem; }

/* ==============================
   Navbar
================================ */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 58px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand { font-weight: 700; font-size: 1.1rem; color: var(--primary); display:flex; align-items:center; gap:.5rem; }
.navbar-logo  { height: 28px; width: 28px; object-fit: contain; border-radius: 6px; }

.navbar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text);
  padding: .25rem .5rem;
}

.navbar-menu {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.navbar-menu a        { font-size: .9rem; color: var(--text); }
.navbar-menu a:hover  { color: var(--primary); text-decoration: none; }
.navbar-sep           { color: var(--border); }
.navbar-user          { font-size: .875rem; color: var(--muted); }
.nav-highlight        { font-weight: 600; color: var(--primary) !important; }

/* ==============================
   Buttons
================================ */
.btn {
  display: inline-block;
  padding: .5rem 1.125rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s;
  text-decoration: none;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; }

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

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

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

.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-full { width: 100%; text-align: center; }

/* ==============================
   Cards
================================ */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; }

.card-link {
  display: block;
  transition: box-shadow .2s, transform .15s;
  color: var(--text);
}
.card-link:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  text-decoration: none;
  color: var(--text);
}
.card-icon { font-size: 2rem; margin-bottom: .5rem; }
.card h3   { font-size: 1.05rem; font-weight: 600; margin-bottom: .3rem; }
.card p    { font-size: .9rem; color: var(--muted); }

/* ==============================
   Dashboard grid
================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
}

/* ==============================
   Auth
================================ */
.auth-box {
  max-width: 420px;
  margin: 3rem auto;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.25rem;
  box-shadow: var(--shadow-md);
}
.auth-box h1   { font-size: 1.4rem; font-weight: 700; margin-bottom: 1.5rem; }
.auth-note     { font-size: .875rem; color: var(--muted); margin-top: 1.25rem; text-align: center; }

/* ==============================
   Forms
================================ */
.form-group { margin-bottom: 1.1rem; }

.form-group label {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: .35rem;
}
.form-group small { color: var(--muted); }

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .55rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: var(--font);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-group textarea { resize: vertical; min-height: 100px; }

.form-inline { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.form-inline .form-group { margin-bottom: 0; flex: 1; min-width: 220px; }

/* ==============================
   Alerts
================================ */
.alert {
  padding: .8rem 1rem;
  border-radius: var(--radius);
  font-size: .9rem;
  margin-bottom: 1.25rem;
  border: 1px solid;
}
.alert-error   { background: var(--error-bg);   color: var(--error-cl);   border-color: var(--error-br); }
.alert-success { background: var(--success-bg); color: var(--success-cl); border-color: var(--success-br); }
.alert-info    { background: var(--info-bg);    color: var(--info-cl);    border-color: var(--info-br); }

/* ==============================
   Tables
================================ */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.table th, .table td {
  padding: .65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table th { font-weight: 600; background: var(--bg); color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.table tbody tr:hover { background: #f1f5f9; }
.th-sort { color: var(--text); font-weight: 600; text-decoration: none; white-space: nowrap; }
.th-sort:hover { color: var(--primary); }

/* ==============================
   Badges
================================ */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-admin  { background: #ede9fe; color: #5b21b6; }
.badge-user   { background: #e0f2fe; color: #0369a1; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-unsub  { background: #fef9c3; color: #854d0e; }
.badge-optout { background: #fee2e2; color: #991b1b; }

.row-unsub td { opacity: .75; }
.row-muted td { opacity: .5; }

/* ==============================
   Error page
================================ */
.error-page { text-align: center; padding: 5rem 1rem; }
.error-page h1 { font-size: 5rem; font-weight: 800; color: var(--border); line-height: 1; }
.error-page p  { color: var(--muted); margin: 1rem 0 2rem; }

/* ==============================
   Footer
================================ */
.footer {
  text-align: center;
  padding: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: .8rem;
  color: var(--muted);
}

/* ==============================
   Page header
================================ */
.page-header { margin-bottom: 1.75rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: .5rem; }

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: .5rem;
}
.page-header-actions { display: flex; gap: .5rem; }

/* ==============================
   Filter bar
================================ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  margin-bottom: 1.25rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .875rem 1rem;
}
.filter-bar input,
.filter-bar select {
  padding: .45rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  font-family: var(--font);
  background: var(--white);
  outline: none;
  min-width: 160px;
}
.filter-bar input:focus,
.filter-bar select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* ==============================
   Table actions
================================ */
.table-actions { display: flex; gap: .4rem; justify-content: flex-end; }

/* ==============================
   Contact badges
================================ */
.badge-count {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  padding: .1rem .55rem;
  color: var(--muted);
  vertical-align: middle;
}

.badge-famille_amis      { background: #fdf4ff; color: #7e22ce; }
.badge-prospect_locaux   { background: #ecfdf5; color: #065f46; }
.badge-prospect_distants { background: #eff6ff; color: #1e40af; }
.badge-doterra           { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }

.contact-name { font-weight: 500; color: var(--text); }
.contact-name:hover { color: var(--primary); text-decoration: none; }

.contact-cell { display: flex; flex-direction: column; gap: .1rem; }
.contact-cell-name { display: flex; align-items: center; gap: .3rem; }
.contact-cell-sub { font-size: .78rem; color: var(--muted); line-height: 1.3; }

.contact-dates-cell { font-size: .8rem; }
.contact-dates-cell div { margin-bottom: .1rem; }
.date-label { display: inline-block; width: 4rem; color: var(--muted); font-size: .72rem; }

.btn-wa    { display: inline-flex; align-items: center; opacity: .8; }
.btn-wa:hover { opacity: 1; }
.btn-wa-sm { display: inline-flex; align-items: center; margin-left: .3rem; opacity: .6; vertical-align: middle; }
.btn-wa-sm:hover { opacity: 1; }

/* ==============================
   Contact form
================================ */
.form-card { max-width: 820px; }

.form-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem 0.25rem;
  margin: 1.25rem 0;
  legend {
    font-size: .8rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 0 .4rem;
  }
}

.form-group-wide { grid-column: 1 / -1; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1.5rem;
}

.form-actions {
  display: flex;
  gap: .75rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.required { color: var(--danger); }

/* ==============================
   Contact show
================================ */
.show-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.detail-list { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1.25rem; }
.detail-list dt { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; align-self: center; }
.detail-list dd { font-size: .95rem; }

.mt-1 { margin-top: 1.25rem; }
.mt-2 { margin-top: 1.5rem; }
.notes-text { font-size: .9rem; color: var(--text); white-space: pre-line; margin-top: .5rem; }
.card-placeholder { opacity: .6; }

/* ==============================
   Mailing lists
================================ */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: .4rem;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .9rem;
  cursor: pointer;
  padding: .35rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  transition: border-color .15s, background .15s;
}
.checkbox-label:hover { border-color: var(--primary); }
.checkbox-label input[type=checkbox]:checked + * { color: var(--primary); font-weight: 600; }
.checkbox-label input[type=checkbox] { accent-color: var(--primary); }

.field-hint { font-size: .8rem; color: var(--muted); margin-bottom: .5rem; }
.var-tag {
  display: inline-block;
  background: #fef9c3;
  color: #854d0e;
  border: 1px solid #fde68a;
  border-radius: 4px;
  padding: 0 .35rem;
  font-size: .8rem;
  font-family: monospace;
}

/* Attachment badges (show page + form) */
.att-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .15rem .55rem;
  font-size: .8rem;
  margin: .15rem .2rem .15rem 0;
}
.att-badge::before { content: '📎'; font-size: .75rem; }

.att-list { display: flex; flex-direction: column; gap: .35rem; }
.att-item { display: flex; align-items: center; gap: .5rem; font-size: .875rem; }
.att-item input[type=checkbox] { accent-color: var(--primary); }

.send-total {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: .5rem .75rem;
  font-size: .9rem;
  font-weight: 500;
  margin-top: .5rem;
}

/* Listes dans fiche contact */
.list-simple { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.list-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .5rem .75rem;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: .9rem;
}
.list-item-row > div { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.subscribe-form {
  display: flex;
  gap: .5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  align-items: center;
}
.subscribe-form select {
  flex: 1;
  padding: .45rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  font-family: var(--font);
  background: var(--white);
  outline: none;
}
.subscribe-form select:focus { border-color: var(--primary); }

/* ==============================
   Empty state
================================ */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
}
.empty-state p { margin-bottom: 1.25rem; }

/* ==============================
   Utilities
================================ */
.text-muted { color: var(--muted); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  font-size: .875rem;
}
.btn-ghost:hover { color: var(--text); text-decoration: none; background: var(--bg); }

/* ==============================
   Responsive
================================ */
@media (max-width: 768px) {
  .form-grid  { grid-template-columns: 1fr; }
  .show-grid  { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  /* Navbar hamburger */
  .navbar { padding: 0 1rem; }
  .navbar-toggle { display: block; }
  .navbar-menu {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    position: absolute;
    top: 58px;
    left: 0; right: 0;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    z-index: 99;
    padding: .5rem 0;
  }
  .navbar-menu.open { display: flex; }
  .navbar-menu li   { width: 100%; }
  .navbar-menu a,
  .navbar-menu .btn { display: block; padding: .75rem 1.25rem; font-size: 1rem; }
  .navbar-sep       { display: none; }

  /* Layout général */
  .container { padding: 1rem .75rem; }
  .auth-box  { margin: 1rem; padding: 1.5rem; }
  .form-inline { flex-direction: column; }
  .page-header-row { flex-direction: column; align-items: flex-start; gap: .5rem; }
  .page-header-row > div { width: 100%; }
  .page-header-row > div .btn { flex: 1; text-align: center; }

  /* Tableau contacts : masquer colonnes secondaires */
  .table th:nth-child(3),
  .table td:nth-child(3) { display: none; }

  /* Boutons d'action empilés */
  .table-actions { flex-direction: column; gap: .3rem; }
  .table-actions .btn  { font-size: .75rem; padding: .25rem .5rem; }
  .table-actions form  { width: 100%; }
  .table-actions form .btn { width: 100%; }

  /* Formulaires */
  .form-card { margin: 0; border-radius: 0; box-shadow: none; }
  .filter-bar { flex-direction: column; }
  .filter-bar input,
  .filter-bar select,
  .filter-bar .btn { width: 100%; }
}
