/* ===========================================================================
 * mailbox_ai — onglets CRM (fiche client « Mail » + fiche projet « E-Mail »).
 *
 * Feuille DEDIEE aux deux onglets : elle est la SEULE chargee dans les fiches
 * Perfex (le CSS du webmail n'y est plus injecte -> zero risque de fuite sur le
 * theme). REGLE ABSOLUE du module : tout selecteur est prefixe .mbxct- et ancre
 * sous .mbxct-card / .mbxct-empty — aucun style ne peut toucher le coeur Perfex.
 *
 * Palette alignee sur le design system v2 du webmail (variables --mbx-* de
 * mailbox_ai.css), redeclaree localement car cette feuille vit seule.
 * ======================================================================== */

.mbxct-card {
  --mbxct-blue: #2f6fed;
  --mbxct-blue-soft: #eef4ff;
  --mbxct-dark: #2b3340;
  --mbxct-border: #e7ebf0;
  --mbxct-muted: #8a94a6;
  --mbxct-danger: #e74c3c;

  background: #fff;
  border: 1px solid var(--mbxct-border);
  border-radius: 10px;
  overflow: hidden;
}

/* --- En-tete : icone + titre + compteur + actions ------------------------ */
.mbxct-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid var(--mbxct-border);
}

.mbxct-head-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mbxct-head-ico {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--mbxct-blue-soft);
  color: var(--mbxct-blue);
  font-size: 16px;
}

.mbxct-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--mbxct-dark);
  line-height: 1.2;
}

.mbxct-count {
  display: inline-block;
  min-width: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--mbxct-blue-soft);
  color: var(--mbxct-blue);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.mbxct-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--mbxct-muted);
}

.mbxct-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* --- Liste --------------------------------------------------------------- */
.mbxct-rows {
  display: block;
}

.mbxct-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--mbxct-border);
}

.mbxct-row:last-child {
  border-bottom: 0;
}

.mbxct-row:hover {
  background: #f7f9fc;
}

/* Zone cliquable principale (VRAI lien -> webmail, nouvel onglet). */
.mbxct-link {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: inherit;
  text-decoration: none;
}

.mbxct-link:hover,
.mbxct-link:focus {
  color: inherit;
  text-decoration: none;
}

.mbxct-avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .5px;
}

.mbxct-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mbxct-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.mbxct-from {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--mbxct-dark, #2b3340);
}

/* Date SEPAREE, alignee a droite, jamais ecrasee. */
.mbxct-date {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--mbxct-muted, #8a94a6);
  white-space: nowrap;
}

.mbxct-attach-icon,
.mbxct-out-icon {
  font-size: 11px;
  color: var(--mbxct-muted, #8a94a6);
}

.mbxct-subject {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--mbxct-dark, #2b3340);
}

.mbxct-snippet {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--mbxct-muted, #8a94a6);
}

/* Non lu : graisse sur expediteur + sujet (meme langage que le webmail). */
.mbxct-unread .mbxct-from,
.mbxct-unread .mbxct-subject {
  font-weight: 600;
}

/* --- Action « delier » (discrete : grise, rouge au survol) ---------------- */
.mbxct-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding-right: 10px;
}

.mbxct-unlink {
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--mbxct-muted, #8a94a6);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.mbxct-unlink:hover,
.mbxct-unlink:focus {
  background: #fdeeec;
  color: var(--mbxct-danger, #e74c3c);
}

.mbxct-unlink[disabled] {
  opacity: .5;
  cursor: default;
}

/* --- Pied : charger plus ------------------------------------------------- */
.mbxct-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-top: 1px solid var(--mbxct-border);
}

.mbxct-more {
  border: 1px solid var(--mbxct-border);
  background: #fff;
  color: var(--mbxct-dark);
  border-radius: 8px;
  padding: 6px 16px;
  font-size: 13px;
  cursor: pointer;
}

.mbxct-more:hover {
  border-color: var(--mbxct-blue);
  color: var(--mbxct-blue);
}

.mbxct-more[disabled] {
  opacity: .6;
  cursor: default;
}

/* --- Etats (vide / chargement / erreur) ---------------------------------- */
.mbxct-empty {
  padding: 34px 20px;
  text-align: center;
  color: #8a94a6;
}

.mbxct-empty > i {
  font-size: 26px;
  color: #c3cbd8;
  margin-bottom: 10px;
  display: inline-block;
}

.mbxct-empty-title {
  font-size: 14px;
  font-weight: 600;
  color: #2b3340;
}

.mbxct-empty-help {
  margin-top: 4px;
  font-size: 12px;
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

.mbxct-empty--error .mbxct-empty-title {
  color: #e74c3c;
}

/* --- Responsive : la fiche projet se consulte sur mobile ------------------ */
@media (max-width: 576px) {
  .mbxct-head {
    padding: 12px;
  }

  /* Les actions d'en-tete passent sous le titre, pleine largeur. */
  .mbxct-head-actions {
    width: 100%;
  }

  .mbxct-link {
    gap: 10px;
    padding: 10px 12px;
  }

  .mbxct-avatar {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }
}
