/* ============================================================
   VERSAILLES ÉNERGIE — PORTAIL PARTENAIRES
   Stylesheet principal
============================================================ */

:root {
  --slate: #405058;
  --slate-dark: #2d3a40;
  --leaf: #70B040;
  --leaf-dark: #5a9233;
  --cream: #f8f4ec;
  --cream-dark: #f5f0e6;
  --white: #ffffff;
  --text: #2d3a40;
  --text-soft: #7d8a93;
  --border: #e5dfd0;
  --border-soft: #f0ebe0;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --success: #059669;
  --success-light: #d1fae5;
  --info: #2563eb;
  --info-light: #dbeafe;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--cream-dark);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .font-serif {
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  color: var(--slate);
  font-weight: 600;
}
h1 { font-size: 28px; margin-bottom: 14px; }
h2 { font-size: 22px; margin-bottom: 12px; }
h3 { font-size: 18px; margin-bottom: 8px; }

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

button {
  font-family: inherit; font-size: 15px;
  border: none; cursor: pointer;
  border-radius: var(--radius);
  padding: 12px 22px;
  font-weight: 600;
  transition: all 0.15s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--leaf); color: var(--slate-dark); }
.btn-primary:hover:not(:disabled) { background: var(--leaf-dark); color: var(--white); transform: translateY(-1px); }
.btn-secondary { background: var(--slate-dark); color: var(--white); }
.btn-secondary:hover:not(:disabled) { background: var(--slate); }
.btn-ghost { background: var(--white); color: var(--slate); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--cream); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-xs { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ============= TOPBAR ============= */
.topbar {
  background: var(--slate-dark);
  color: var(--white);
  padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  padding-top: calc(14px + env(safe-area-inset-top));
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-logo {
  width: 56px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.topbar-logo img { width: 100%; height: 100%; object-fit: contain; }
.topbar-title { font-family: 'Fraunces', Georgia, serif; font-style: italic; font-size: 19px; font-weight: 600; color: var(--white); }
.topbar-sub { font-size: 11px; opacity: 0.7; letter-spacing: 0.5px; text-transform: uppercase; }
.topbar-menu-btn {
  width: 38px; height: 38px;
  background: rgba(255,255,255,0.1); color: var(--cream);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: none;
}
.topbar-menu-btn:hover { background: rgba(255,255,255,0.18); }

/* ============= MAIN ============= */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 18px;
  padding-bottom: calc(100px + env(safe-area-inset-bottom));
}

/* ============= CARDS / SECTIONS ============= */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  border: 1px solid var(--border-soft);
}
.card-clickable { cursor: pointer; transition: all 0.15s; }
.card-clickable:hover { border-color: var(--leaf); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.section-title { font-family: 'Fraunces', Georgia, serif; font-style: italic; font-size: 17px; color: var(--slate); margin-bottom: 12px; }

/* ============= STATS ============= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}
.stat {
  background: var(--white);
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
}
.stat-label { font-size: 11px; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.stat-value { font-family: 'Fraunces', Georgia, serif; font-style: italic; font-size: 24px; font-weight: 600; color: var(--slate); }
.stat-value-sm { font-size: 18px; }

/* ============= FORMS ============= */
.form-group { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--slate); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  transition: all 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--leaf);
  box-shadow: 0 0 0 3px rgba(112, 176, 64, 0.15);
}
.form-input:disabled { background: var(--cream); cursor: not-allowed; opacity: 0.65; }
.form-textarea { min-height: 80px; resize: vertical; }
.form-hint { font-size: 11px; color: var(--text-soft); margin-top: 4px; }
.form-error { color: var(--danger); font-size: 12px; margin-top: 4px; }

/* Radio cards */
.radio-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.radio-card {
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.radio-card.selected { border-color: var(--leaf); background: var(--success-light); }
.radio-card input { display: none; }

/* ============= AUTH SCREEN ============= */
.auth-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}
/* Sur les écrans courts (mobiles en paysage, signup long), aligner en haut pour permettre le scroll */
@media (max-height: 700px) {
  .auth-screen { align-items: flex-start; }
}
.auth-card {
  background: var(--white);
  border-radius: 20px;
  padding: 36px 28px;
  width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-soft);
  margin: auto;
}
.auth-logo {
  width: auto; height: 80px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
}
.auth-logo img { height: 100%; width: auto; max-width: 280px; object-fit: contain; }
.auth-title { text-align: center; margin-bottom: 8px; color: var(--slate); }
.auth-subtitle { text-align: center; color: var(--text-soft); margin-bottom: 26px; font-size: 14px; }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 22px; padding: 4px; background: var(--cream); border-radius: 10px; }
.auth-tab {
  flex: 1; padding: 10px; text-align: center; font-weight: 600;
  border-radius: 7px; color: var(--text-soft); font-size: 13px;
  cursor: pointer; transition: all 0.2s;
  background: transparent; border: none;
}
.auth-tab.active { background: var(--white); color: var(--slate); box-shadow: var(--shadow); }
.auth-footer { text-align: center; margin-top: 18px; font-size: 13px; color: var(--text-soft); }

/* ============= BOTTOM NAV ============= */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-top: 1px solid var(--border-soft);
  display: flex;
  padding: 6px 0;
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
  z-index: 50;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px; background: transparent; border: none; cursor: pointer;
  color: var(--text-soft); font-size: 11px; font-weight: 600;
}
.nav-btn.active { color: var(--leaf); }
.nav-btn svg { width: 24px; height: 24px; }

/* ============= SEARCH BAR ============= */
.search-bar {
  position: relative;
  margin-bottom: 14px;
}
.search-bar input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  transition: all 0.15s;
}
.search-bar input:focus {
  outline: none; border-color: var(--leaf);
  box-shadow: 0 0 0 3px rgba(112, 176, 64, 0.15);
}
.search-bar svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-soft);
  pointer-events: none;
}
.search-bar .search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 16px;
  line-height: 1;
}
.search-bar .search-clear:hover { color: var(--danger); }
.search-results-count {
  font-size: 12px;
  color: var(--text-soft);
  margin-bottom: 10px;
}

/* ============= FILTER CHIPS ============= */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.filter-chips-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.filter-chips-label {
  font-size: 11px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 4px;
  font-weight: 600;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 11px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-soft);
  cursor: pointer;
  transition: all 0.12s;
  font-family: inherit;
  white-space: nowrap;
}
.filter-chip:hover { border-color: var(--leaf); color: var(--slate); }
.filter-chip.active {
  background: var(--leaf);
  color: var(--slate-dark);
  border-color: var(--leaf);
  font-weight: 600;
}
.filter-chips-reset {
  background: transparent;
  border: none;
  color: var(--text-soft);
  font-size: 11px;
  padding: 5px 8px;
  cursor: pointer;
  text-decoration: underline;
}
.filter-chips-reset:hover { color: var(--danger); }

/* ============= STATUS BADGES ============= */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.badge-nouveau { background: #dbeafe; color: #1e40af; }
.badge-contacte { background: #fef3c7; color: #92400e; }
.badge-rdv { background: #e9d5ff; color: #6b21a8; }
.badge-visite { background: #fed7aa; color: #9a3412; }
.badge-devis { background: #cffafe; color: #155e75; }
.badge-signe { background: var(--success-light); color: var(--success); }
.badge-a_payer { background: var(--slate-dark); color: var(--white); }
.badge-termine { background: var(--slate-dark); color: var(--white); }
.badge-perdu { background: var(--danger-light); color: var(--danger); }
.badge-mpr-bleu { background: #dbeafe; color: #1e40af; }
.badge-mpr-jaune { background: #fef3c7; color: #92400e; }
.badge-mpr-violet { background: #e9d5ff; color: #6b21a8; }
.badge-mpr-rose { background: #fce7f3; color: #9f1239; }
.badge-role { background: var(--leaf); color: var(--slate-dark); font-size: 10px; padding: 2px 6px; }

/* ============= MODAL ============= */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 1000;
  padding: 18px;
  padding-top: max(18px, env(safe-area-inset-top));
  padding-bottom: max(18px, env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 480px; width: 100%;
  margin: auto;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-title { font-family: 'Fraunces', Georgia, serif; font-style: italic; font-size: 22px; color: var(--slate); margin-bottom: 14px; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; justify-content: flex-end; flex-wrap: wrap; }

/* ============= TOAST ============= */
.toast {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: 600; font-size: 14px;
  z-index: 2000;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
}
.toast-success { background: var(--success); color: var(--white); }
.toast-error { background: var(--danger); color: var(--white); }
.toast-info { background: var(--slate); color: var(--white); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============= UTILITIES ============= */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.text-center { text-align: center; }
.text-soft { color: var(--text-soft); }
.text-leaf { color: var(--leaf); }
.text-slate { color: var(--slate); }
.fs-12 { font-size: 12px; }
.fs-14 { font-size: 14px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-18 { margin-top: 18px; } .mt-22 { margin-top: 22px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-22 { margin-bottom: 22px; }

/* Empty state */
.empty { text-align: center; padding: 40px 18px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-title { font-family: 'Fraunces', Georgia, serif; font-style: italic; font-size: 18px; color: var(--slate); margin-bottom: 6px; }
.empty-sub { color: var(--text-soft); font-size: 14px; }

/* iOS install banner */
.ios-install-banner {
  position: fixed; bottom: calc(70px + env(safe-area-inset-bottom)); left: 12px; right: 12px;
  background: var(--white); border: 1px solid var(--leaf);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  z-index: 200; animation: slideUp 0.4s ease;
}
.ios-install-content { display: flex; align-items: center; gap: 12px; padding: 14px; }
.ios-install-icon { font-size: 24px; }
@keyframes slideUp { from { transform: translateY(120px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* PWA Install button (cross-platform) */
.pwa-install-btn {
  position: fixed;
  top: 70px;
  right: 14px;
  background: var(--leaf);
  color: var(--slate-dark);
  padding: 8px 14px;
  border-radius: 24px;
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(64, 80, 88, 0.15);
  z-index: 90;
  animation: pwaFadeIn 0.4s ease;
  transition: all 0.15s;
}
.pwa-install-btn:hover {
  background: var(--leaf-dark);
  color: var(--white);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(64, 80, 88, 0.2);
}
.pwa-install-btn svg { flex-shrink: 0; }
@keyframes pwaFadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* Sur mobile, le bouton va en bas pour ne pas chevaucher la topbar */
@media (max-width: 480px) {
  .pwa-install-btn {
    top: auto;
    bottom: calc(80px + env(safe-area-inset-bottom));
    right: 12px;
    padding: 10px 16px;
    font-size: 14px;
  }
}

/* Loading spinner */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--border); border-top-color: var(--leaf);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 480px) {
  .form-row { grid-template-columns: 1fr; }
  main { padding: 14px; padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
  h1 { font-size: 24px; }
  h2 { font-size: 20px; }
  .auth-card { padding: 28px 22px; border-radius: 14px; }
  .auth-screen { padding: 16px; }
  .stats-grid { gap: 8px; }
  .stat { padding: 12px; }
  .stat-value { font-size: 20px; }
  .stat-value-sm { font-size: 16px; }
  .modal { padding: 20px; }
  .modal-title { font-size: 19px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions button { width: 100%; }
  .radio-cards { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 12px 14px; padding-top: calc(12px + env(safe-area-inset-top)); }
  .topbar-title { font-size: 17px; }
  .topbar-logo { width: 44px; height: 32px; }
  .ios-install-banner { left: 8px; right: 8px; bottom: calc(80px + env(safe-area-inset-bottom)); }
}

/* Très petits écrans (iPhone SE etc.) */
@media (max-width: 360px) {
  main { padding: 12px; }
  .auth-card { padding: 24px 18px; }
  .form-input, .form-select, .form-textarea { padding: 10px 12px; font-size: 14px; }
  button { padding: 11px 18px; font-size: 14px; }
  .nav-btn { font-size: 10px; }
  .nav-btn svg { width: 22px; height: 22px; }
}
