/* ============================================================
   ZEYDS FAVORIS — Styles (mobile-first)
   Bibliotheque personnelle : Services + Emplois + Zeyds Cash.

   Ecrit mobile d'abord (base = smartphone 320-430px), enrichi
   progressivement via des media queries min-width, meme
   architecture que zeyds-cash.css. Reutilise les tokens definis
   dans styles.css (:root) plutot que d'en creer de nouveaux.
   ============================================================ */

#view-favorites,
#view-favorites *,
.fav-toast {
  box-sizing: border-box;
}

.fav-shell {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: grid;
  gap: 14px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

/* ---- Header --------------------------------------------------- */
.fav-header h2 {
  margin: 0 0 2px;
  font-size: clamp(20px, 6vw, 28px);
  font-weight: 900;
  letter-spacing: -.02em;
  color: var(--ink);
}

.fav-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

/* ---- Recherche -------------------------------------------------- */
.fav-search-row {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.fav-search-icon {
  position: absolute;
  left: 14px;
  color: var(--muted);
  font-size: 15px;
  pointer-events: none;
}

#favSearchInput {
  width: 100%;
  min-height: 46px;
  padding: 0 14px 0 38px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
}

#favSearchInput:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(8, 36, 92, .1);
}

/* ---- Toolbar (filtres + tri) ------------------------------------- */
.fav-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.fav-filter-bar {
  display: flex;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  white-space: nowrap;
  padding-bottom: 2px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.fav-filter-bar::-webkit-scrollbar { display: none; }

.fav-chip {
  flex-shrink: 0;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}

.fav-chip span[data-fav-count] {
  margin-left: 3px;
  font-weight: 800;
  opacity: .7;
}

.fav-chip[aria-pressed="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.fav-sort-select {
  align-self: flex-end;
  min-height: 40px;
  max-width: 180px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 700;
}

/* ---- Grille de cartes --------------------------------------------- */
.fav-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.fav-card {
  display: flex;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
  touch-action: manipulation;
}

.fav-card-media {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 11px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--sand);
  font-size: 22px;
}

.fav-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fav-card-body {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 3px;
  align-content: start;
}

.fav-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.fav-card-top strong {
  min-width: 0;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.fav-card-subtitle {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fav-card-meta {
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fav-status-chip {
  justify-self: start;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(8, 36, 92, .07);
  color: var(--brand);
  font-size: 10.5px;
  font-weight: 800;
}

.fav-status-chip.fav-status-warn {
  background: rgba(214, 59, 52, .1);
  color: var(--danger);
}

.fav-secured-chip {
  justify-self: start;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(20, 138, 97, .12);
  color: var(--success);
  font-size: 10.5px;
  font-weight: 800;
}

.fav-card-cta {
  justify-self: end;
  margin-top: 2px;
  border: 0;
  background: none;
  padding: 4px 0;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---- Coeur (favori) — zone tactile >= 44px ------------------------ */
.fav-heart {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  margin: -10px -6px 0 0;
  border: 0;
  background: none;
  color: rgba(15, 27, 50, .28);
  font-size: 22px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .16s ease, color .16s ease;
}

.fav-heart:active { transform: scale(1.18); }

.fav-heart.is-favorite {
  color: var(--accent);
  animation: favPop .22s ease;
}

@keyframes favPop {
  0% { transform: scale(.7); }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.cash-fav-heart {
  margin: -4px -4px 0 auto;
}

/* ---- Etat vide ------------------------------------------------------ */
.fav-empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 34px 18px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
}

.fav-empty-icon { font-size: 32px; }

.fav-empty h3 {
  margin: 0;
  font-size: 15px;
  color: var(--ink);
}

.fav-empty p {
  margin: 0;
  max-width: 46ch;
  font-size: 13px;
}

.fav-empty-cta {
  min-height: 46px;
  padding: 0 20px;
  border: 0;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff;
  font-weight: 800;
  font-size: 13.5px;
  cursor: pointer;
  touch-action: manipulation;
}

.fav-empty-shortcuts {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}

.fav-empty-shortcuts button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.fav-empty-shortcuts span { font-size: 20px; flex-shrink: 0; }
.fav-empty-shortcuts strong { display: block; font-size: 13px; color: var(--ink); }
.fav-empty-shortcuts small { display: block; font-size: 11.5px; color: var(--muted); }

/* ---- Skeletons -------------------------------------------------------- */
.fav-skeleton { pointer-events: none; }

.fav-skel-line {
  display: block;
  height: 10px;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(8, 36, 92, .06) 25%, rgba(8, 36, 92, .12) 37%, rgba(8, 36, 92, .06) 63%);
  background-size: 400% 100%;
  animation: favShimmer 1.4s ease infinite;
}

.fav-skel-title { width: 70%; height: 12px; }
.fav-skel-sub { width: 45%; }
.fav-skel-meta { width: 55%; }

@keyframes favShimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ---- Toast ------------------------------------------------------------- */
.fav-toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 12px);
  z-index: 200;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  text-align: center;
  box-shadow: var(--shadow-hover);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.fav-toast.visible { opacity: 1; transform: translate(-50%, 0); }
.fav-toast.fav-toast-error { background: var(--danger); }

/* ---- Tablette (>=768px) ------------------------------------------------ */
@media (min-width: 768px) {
  .fav-toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .fav-sort-select { align-self: center; }

  .fav-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .fav-empty-shortcuts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---- Desktop (>=1024px) ------------------------------------------------ */
@media (min-width: 1024px) {
  .fav-shell { gap: 18px; }

  .fav-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .fav-card { padding: 12px; }
}

/* ---- Grand desktop (>=1280px) ------------------------------------------ */
@media (min-width: 1280px) {
  .fav-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .fav-heart, .fav-heart.is-favorite, .fav-skel-line { animation: none; }
  .fav-toast { transition: none; }
}

/* ---- Integration du coeur dans les cartes des 3 modules d'origine ----- */
.provider-card-title { flex-wrap: wrap; }
.provider-card-title h3 { min-width: 0; flex: 1 1 auto; }
.provider-card-title .fav-heart {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  margin: -6px -4px 0 auto;
  font-size: 18px;
}

.cash-card-tags { position: relative; }
.cash-card-tags .cash-fav-heart {
  width: 30px;
  height: 30px;
  font-size: 17px;
}

/* ---- Messages (journal de contacts) — reutilise les classes .fav-* ---- */
.fav-loading {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

.msg-card { cursor: default; }

.msg-card .fav-card-media,
.msg-card .fav-card-top {
  cursor: pointer;
}

.msg-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.msg-card-actions .fav-card-cta { margin-top: 0; }

.msg-recontact-btn {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--brand);
  border-radius: 999px;
  background: none;
  color: var(--brand);
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}
