/* SoumiQ Pro — feuille de style PWA */
:root {
  --blue-dark: #0A2540;
  --blue: #1556C7;
  --blue-light: #E8F0FE;
  --green: #10B981;
  --green-dark: #065F46;
  --green-light: #D1FAE5;
  --orange: #F59E0B;
  --red: #DC2626;
  --gray-900: #1A202C;
  --gray-700: #2D3748;
  --gray-500: #718096;
  --gray-300: #CBD5E0;
  --gray-200: #E2E8F0;
  --gray-100: #EDF2F7;
  --gray-50: #F7FAFC;
  --white: #fff;
  --shadow-sm: 0 1px 3px rgba(10,37,64,.08);
  --shadow-md: 0 4px 14px rgba(10,37,64,.12);
  --shadow-lg: 0 12px 32px rgba(10,37,64,.18);
  --radius: 14px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; line-height: 1.5;
  color: var(--gray-900);
  background: var(--gray-50);
  padding-top: calc(60px + env(safe-area-inset-top)); padding-bottom: env(safe-area-inset-bottom);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select { font: inherit; }
a { color: var(--blue); text-decoration: none; }

/* HEADER */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: var(--blue-dark);
  color: var(--white);
  padding-top: env(safe-area-inset-top);
  box-shadow: var(--shadow-md);
}
.app-header-inner {
  max-width: 800px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  height: 60px;
}
.app-logo {
  display: flex; align-items: center; gap: 10px;
  color: var(--white); font-size: 1.05rem;
}
.app-logo strong { color: var(--green); font-weight: 700; }
.app-logo img { filter: brightness(0) invert(1); }
.app-menu-btn { color: var(--white); padding: 6px; }

/* MENU */
.app-menu {
  position: fixed; top: calc(60px + env(safe-area-inset-top)); right: 0; width: 260px;
  background: var(--white);
  box-shadow: var(--shadow-lg);
  z-index: 49;
  padding: 8px 0;
  border-bottom-left-radius: var(--radius);
}
.app-menu a {
  display: block; padding: 14px 20px;
  color: var(--gray-900);
  border-bottom: 1px solid var(--gray-100);
}
.app-menu a:hover, .app-menu a.active { background: var(--blue-light); color: var(--blue); }
.app-menu a.external { color: var(--gray-500); font-size: 0.92rem; }
.app-menu-foot { padding: 14px 20px; font-size: 0.78rem; color: var(--gray-500); }

/* MAIN */
.app-main {
  max-width: 800px; margin: 0 auto;
  padding: 16px;
}

/* SEARCH */
.search-bar {
  display: flex; gap: 8px;
  position: sticky; top: calc(60px + env(safe-area-inset-top)); z-index: 40;
  background: var(--gray-50); padding: 10px 0;
  margin: -16px -16px 0; padding-left: 16px; padding-right: 16px;
}
.search-input-wrap {
  flex: 1;
  position: relative;
  display: flex; align-items: center; gap: 8px;
  background: var(--white);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 0 12px;
  transition: border-color 0.15s;
}
.search-input-wrap:focus-within { border-color: var(--blue); }
.search-input-wrap svg { color: var(--gray-500); flex-shrink: 0; }
#searchInput {
  flex: 1; min-width: 0;
  height: 50px;
  border: 0; outline: 0; background: transparent;
  font-size: 16px;
}
.search-clear {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--gray-700);
  font-size: 1.4rem; line-height: 1;
}
.filter-toggle {
  position: relative;
  width: 50px; height: 50px;
  background: var(--white);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  color: var(--gray-700);
  display: flex; align-items: center; justify-content: center;
}
.filter-toggle.active { background: var(--blue); border-color: var(--blue); color: var(--white); }
.filter-count {
  position: absolute; top: -6px; right: -6px;
  background: var(--green); color: var(--white);
  border-radius: 50%; width: 22px; height: 22px;
  font-size: 0.72rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* FILTRES */
.filter-panel {
  background: var(--white);
  padding: 16px;
  border-radius: var(--radius);
  margin-top: 12px;
  box-shadow: var(--shadow-sm);
  display: grid; gap: 14px;
}
.filter-row { display: flex; flex-direction: column; gap: 6px; }
.filter-row label { font-size: 0.85rem; color: var(--gray-700); font-weight: 600; }
.filter-row select {
  padding: 12px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--white);
}
.filter-reset {
  background: var(--gray-100);
  color: var(--gray-700);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* STATUT / LOADER */
.status { padding: 60px 20px; text-align: center; }
.status-loader { color: var(--gray-700); }
.status-loader p { margin-top: 14px; }
.status-sub { font-size: 0.86rem; color: var(--gray-500); margin-top: 4px !important; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  margin: 0 auto;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  text-align: center; padding: 60px 20px;
  color: var(--gray-500);
}
.empty .empty-emoji { font-size: 3rem; margin-bottom: 12px; }
.empty h3 { color: var(--gray-700); margin-bottom: 8px; }

/* RÉSULTATS */
.results-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 4px 6px;
  font-size: 0.92rem;
  color: var(--gray-700);
}
.results-bar select {
  background: transparent; border: 0;
  font-weight: 600; color: var(--blue);
  padding: 4px;
}

.results { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  display: flex; gap: 12px;
  align-items: stretch;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
  border-left: 4px solid var(--gray-300);
}
.card:active { transform: scale(0.98); }
.card.tier-1 { border-left-color: var(--green); }
.card.tier-2 { border-left-color: var(--orange); }
.card.tier-0 { border-left-color: var(--red); opacity: 0.78; }

.card-main { flex: 1; min-width: 0; }
.card-brand {
  font-size: 0.78rem; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: 0.04em;
  font-weight: 700;
  margin-bottom: 2px;
}
.card-model {
  font-size: 1.05rem; color: var(--gray-900);
  font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-meta {
  font-size: 0.84rem; color: var(--gray-700);
  margin-top: 4px;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.tag {
  display: inline-block;
  background: var(--gray-100);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.76rem;
  color: var(--gray-700);
}
.tag-cc { background: var(--green-light); color: var(--green-dark); }
.tag-type { background: var(--blue-light); color: var(--blue); }

.card-sub {
  flex-shrink: 0;
  text-align: right;
  display: flex; flex-direction: column; align-items: flex-end; justify-content: center;
  min-width: 86px;
}
.card-sub-amount {
  font-size: 1.4rem; font-weight: 800;
  color: var(--green-dark);
  line-height: 1;
}
.card-sub-amount.tier-2 { color: var(--orange); }
.card-sub-amount.tier-0 {
  font-size: 1rem;
  color: var(--red);
}
.card-sub-label {
  font-size: 0.7rem; color: var(--gray-500);
  margin-top: 2px;
  text-transform: uppercase; letter-spacing: 0.04em;
  font-weight: 600;
}

.pagination { padding: 20px 0; text-align: center; }
.pagination button {
  background: var(--white);
  color: var(--blue);
  border: 2px solid var(--blue);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* MODAL */
.modal {
  position: fixed; inset: 0;
  background: rgba(10,37,64,0.6);
  z-index: 100;
  display: flex; align-items: flex-end;
  animation: fadeIn 0.15s;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal-card {
  width: 100%;
  max-height: 92vh;
  background: var(--white);
  border-radius: 22px 22px 0 0;
  padding: 24px 20px env(safe-area-inset-bottom) 20px;
  overflow-y: auto;
  position: relative;
  animation: slideUp 0.25s cubic-bezier(0.16,1,0.3,1);
}
@keyframes slideUp { from { transform: translateY(100%); } }
.modal-close {
  position: absolute; top: 12px; right: 16px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--gray-100);
  font-size: 1.6rem; line-height: 1;
  color: var(--gray-700);
}

.modal-content h2 { font-size: 1.05rem; color: var(--gray-500); font-weight: 600; }
.modal-content h1 { font-size: 1.4rem; margin-bottom: 16px; }

.detail-sub {
  background: var(--green-light);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  margin: 16px 0;
}
.detail-sub.tier-2 { background: #FEF3C7; }
.detail-sub.tier-0 { background: #FEE2E2; }

.detail-sub-amount {
  font-size: 2.4rem; font-weight: 800;
  color: var(--green-dark);
  line-height: 1;
}
.detail-sub.tier-2 .detail-sub-amount { color: #92400E; }
.detail-sub.tier-0 .detail-sub-amount { color: var(--red); font-size: 1.4rem; }
.detail-sub-label {
  font-size: 0.86rem;
  margin-top: 6px;
  color: var(--green-dark);
}
.detail-sub.tier-2 .detail-sub-label { color: #92400E; }
.detail-sub.tier-0 .detail-sub-label { color: var(--red); }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 14px 0;
}
.detail-item {
  background: var(--gray-50);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}
.detail-item-label {
  font-size: 0.74rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.detail-item-value {
  font-size: 1rem;
  color: var(--gray-900);
  font-weight: 600;
  margin-top: 2px;
}

.detail-section { margin: 18px 0; }
.detail-section h3 {
  font-size: 0.94rem;
  color: var(--gray-700);
  margin-bottom: 8px;
}
.detail-formula {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--gray-100);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
}

.detail-reasons {
  background: #FEE2E2;
  padding: 14px;
  border-radius: var(--radius-sm);
  color: #7F1D1D;
}
.detail-reasons ul { margin-left: 20px; list-style: disc; }

/* FOOT */
.app-foot {
  text-align: center;
  padding: 30px 20px 24px;
  font-size: 0.78rem;
  color: var(--gray-500);
}

/* Hauteur pleine du body si peu de résultats */
.app-main { min-height: calc(100vh - 60px - 80px); }

/* Responsive */
@media (min-width: 700px) {
  .results { display: grid; grid-template-columns: repeat(2, 1fr); }
  .modal-card { max-width: 600px; margin: 0 auto; border-radius: var(--radius); margin-top: 5vh; max-height: 90vh; }
  .modal { align-items: center; padding: 16px; }
}

/* ============ WELCOME SCREEN ============ */
.welcome-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 40px 24px;
  text-align: center;
  margin: 16px 0;
}
.welcome-icon { font-size: 3.4rem; color: var(--blue); margin-bottom: 14px; line-height: 1; }
.welcome-card h2 { font-size: 1.5rem; color: var(--blue-dark); margin-bottom: 12px; }
.welcome-lead { color: var(--gray-700); font-size: 1.02rem; margin-bottom: 24px; line-height: 1.6; }
.welcome-stats {
  display: flex; gap: 12px; justify-content: center;
  margin: 24px 0;
}
.welcome-stat {
  background: var(--blue-light); padding: 14px 16px; border-radius: var(--radius-sm);
  flex: 1; max-width: 130px;
}
.welcome-stat strong {
  display: block; font-size: 1.4rem; font-weight: 800; color: var(--blue-dark);
}
.welcome-stat span {
  font-size: 0.78rem; color: var(--gray-700); text-transform: uppercase; letter-spacing: 0.04em;
}
.welcome-favs {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #78350f;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  margin: 16px auto;
  display: inline-flex; align-items: center; gap: 10px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.welcome-favs:hover { transform: translateY(-1px); }
.welcome-quickstart { margin-top: 30px; padding-top: 24px; border-top: 1px solid var(--gray-100); }
.welcome-quickstart-title {
  font-size: 0.86rem; color: var(--gray-500); margin-bottom: 12px;
  text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600;
}
.welcome-brands {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.welcome-brand {
  background: var(--gray-50); border: 1px solid var(--gray-200);
  padding: 12px 14px; border-radius: var(--radius-sm);
  display: flex; flex-direction: column; align-items: flex-start;
  font-weight: 600; color: var(--gray-900);
  cursor: pointer; transition: all 0.15s;
}
.welcome-brand:hover { background: var(--blue-light); border-color: var(--blue); color: var(--blue); }
.welcome-brand span {
  font-size: 0.76rem; color: var(--gray-500); margin-top: 2px; font-weight: 500;
}
.welcome-foot {
  font-size: 0.82rem; color: var(--gray-500); margin-top: 24px;
}

/* ============ FAVORI BUTTON ============ */
.card { position: relative; }
.card-fav {
  background: transparent; border: 0; padding: 6px;
  font-size: 1.5rem; line-height: 1; color: var(--gray-300);
  cursor: pointer; transition: color 0.15s, transform 0.1s;
  margin-top: 6px;
}
.card-fav.is-fav { color: #f59e0b; }
.card-fav:hover { transform: scale(1.15); }
.modal-fav {
  background: var(--gray-50); color: var(--gray-700);
  border: 1px solid var(--gray-200); padding: 10px 14px;
  border-radius: var(--radius-sm); font-weight: 600;
  width: 100%; margin-top: 8px; cursor: pointer;
}
.modal-fav.is-fav { background: #fef3c7; color: #78350f; border-color: #fde68a; }

/* ============ FILTRE FAVORIS TOGGLE ============ */
.filter-favs-row {
  display: flex; align-items: center; gap: 10px;
  background: #fef3c7; padding: 12px 14px; border-radius: var(--radius-sm);
  cursor: pointer;
}
.filter-favs-row input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.filter-favs-row label { color: #78350f; font-weight: 600; cursor: pointer; }

/* ============ PAYWALL MODAL ============ */
.paywall {
  position: fixed; inset: 0;
  background: rgba(10,37,64,0.7);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s;
}
.paywall-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 32px 24px;
  max-width: 460px; width: 100%;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.2s;
}
@keyframes scaleIn { from { transform: scale(0.92); opacity: 0; } }
.paywall-close {
  position: absolute; top: 12px; right: 16px;
  width: 32px; height: 32px;
  border-radius: 50%; background: var(--gray-100);
  font-size: 1.4rem; line-height: 1; cursor: pointer;
  color: var(--gray-700);
}
.paywall-icon {
  width: 56px; height: 56px;
  background: var(--blue);
  color: white; font-size: 1.8rem; font-weight: 800;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.paywall-card h2 {
  text-align: center; color: var(--blue-dark);
  margin-bottom: 12px; font-size: 1.3rem;
}
.paywall-card > p {
  text-align: center; color: var(--gray-700); line-height: 1.5;
  margin-bottom: 20px;
}
.paywall-features {
  background: var(--green-light); border-radius: var(--radius-sm);
  padding: 16px; margin: 16px 0;
}
.paywall-feature {
  color: var(--green-dark); font-size: 0.94rem;
  padding: 4px 0; font-weight: 500;
}
.paywall-cta {
  display: block; text-align: center;
  background: var(--blue); color: white;
  padding: 14px; border-radius: var(--radius-sm);
  font-weight: 700; font-size: 1rem;
  margin-top: 16px;
}
.paywall-cta:hover { background: var(--blue-dark); }
.paywall-note {
  text-align: center; font-size: 0.86rem; color: var(--gray-500);
  margin-top: 14px;
}
.paywall-note a { font-weight: 600; }

/* ============ MENU FAVS COUNTER ============ */
.app-menu .menu-counter {
  font-size: 0.76rem; color: var(--gray-500);
  font-weight: 600; margin-left: 4px;
}
