/**
 * Social Inbox LIST modernization — Phase 3A.1
 * Scoped under #inboxView.social-inbox-list-modern .social-inbox-list-panel
 * Do NOT style chat detail, composer, bubbles, or CRM context from this file.
 * No !important.
 */

/* ——— List panel shell ——— */
#inboxView.social-inbox-list-modern .social-inbox-list-panel {
  background: var(--ds-color-surface, var(--surface, #fff));
  border-color: var(--ds-color-line, var(--line, #e8ecef));
  box-shadow: none;
  padding: 12px 12px 8px;
  gap: 0;
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel.panel {
  border-radius: var(--ds-radius-md, 10px);
}

/* ——— Header ——— */
#inboxView.social-inbox-list-modern .social-inbox-list-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ds-color-line, var(--line, #e8ecef));
}

#inboxView.social-inbox-list-modern .social-inbox-list-heading__main {
  min-width: 0;
  flex: 1;
}

#inboxView.social-inbox-list-modern .social-inbox-list-heading h2 {
  margin: 0;
  font-size: var(--ds-type-lg, 16px);
  line-height: var(--ds-type-lh-lg, 24px);
  font-weight: var(--ds-type-semibold, 600);
  color: var(--ds-color-ink, var(--ink, #24262d));
  letter-spacing: -0.01em;
}

#inboxView.social-inbox-list-modern .social-inbox-list-sub {
  margin: 2px 0 0;
  font-size: var(--ds-type-xs, 12px);
  line-height: var(--ds-type-lh-xs, 16px);
  color: var(--ds-color-muted, var(--muted, #6b7280));
}

#inboxView.social-inbox-list-modern .social-inbox-list-heading__stat,
#inboxView.social-inbox-list-modern #socialInboxUnreadBadge {
  display: inline-flex;
  align-items: center;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--ds-color-accent-soft, var(--accent-soft, #e4f4f1));
  color: var(--ds-color-accent-strong, var(--accent-strong, #0b5f59));
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
}

#inboxView.social-inbox-list-modern .social-inbox-list-heading__stat[hidden],
#inboxView.social-inbox-list-modern #socialInboxUnreadBadge[hidden] {
  display: none;
}

#inboxView.social-inbox-list-modern .social-inbox-refresh-btn {
  flex-shrink: 0;
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--ds-color-line, var(--line, #e8ecef));
  background: var(--ds-color-surface, #fff);
  color: var(--ds-color-muted, #6b7280);
  font-size: 14px;
  line-height: 1;
}

#inboxView.social-inbox-list-modern .social-inbox-refresh-btn:hover {
  color: var(--ds-color-ink, #24262d);
  border-color: color-mix(in srgb, var(--ds-color-accent, #0f766e) 35%, var(--ds-color-line, #e8ecef));
  background: var(--ds-color-accent-soft, #e4f4f1);
}

/* ——— Filters ——— */
#inboxView.social-inbox-list-modern .social-inbox-filters,
#inboxView.social-inbox-list-modern #socialInboxFilters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
  padding: 0;
}

#inboxView.social-inbox-list-modern .social-filter-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--ds-color-line, var(--line, #e8ecef));
  background: var(--ds-color-surface, #fff);
  color: var(--ds-color-muted, #6b7280);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: none;
}

#inboxView.social-inbox-list-modern .social-filter-chip:hover {
  color: var(--ds-color-ink, #24262d);
  border-color: color-mix(in srgb, var(--ds-color-accent, #0f766e) 30%, var(--ds-color-line, #e8ecef));
}

#inboxView.social-inbox-list-modern .social-filter-chip.is-active {
  color: var(--ds-color-accent-strong, #0b5f59);
  background: var(--ds-color-accent-soft, #e4f4f1);
  border-color: color-mix(in srgb, var(--ds-color-accent, #0f766e) 40%, var(--ds-color-line, #e8ecef));
  font-weight: 600;
}

/* ——— Alerts ——— */
#inboxView.social-inbox-list-modern .social-inbox-alerts,
#inboxView.social-inbox-list-modern #socialInboxAlerts {
  margin-bottom: 8px;
  gap: 6px;
}

#inboxView.social-inbox-list-modern .social-inbox-alert {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--ds-color-warning, #b45309) 28%, var(--ds-color-line, #e8ecef));
  background: var(--ds-color-warning-soft, #fff5df);
  color: var(--ds-color-warning, #b45309);
  font-size: 12px;
  line-height: 1.35;
}

#inboxView.social-inbox-list-modern .social-inbox-alert strong {
  margin-bottom: 2px;
  font-size: 12px;
}

#inboxView.social-inbox-list-modern .social-inbox-alert p {
  margin: 0 0 6px;
}

/* ——— List scroll ——— */
#inboxView.social-inbox-list-modern .social-inbox-list,
#inboxView.social-inbox-list-modern #socialInboxList {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 2px;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
}

#inboxView.social-inbox-list-modern .social-inbox-empty {
  margin: 28px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--ds-color-muted, #6b7280);
  line-height: 1.4;
}

/* ——— Conversation cards ——— */
#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card.social-inbox-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "main aside"
    "badges badges";
  gap: 4px 8px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--ds-color-line, var(--line, #e8ecef));
  border-radius: 8px;
  background: var(--ds-color-surface, #fff);
  box-shadow: none;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  align-items: start;
  /* Compatibility: cards are flex children of #socialInboxList; prevent shrink when many rows */
  flex: 0 0 auto;
  flex-shrink: 0;
  transition: border-color 120ms ease, background 120ms ease;
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card.social-inbox-card .inbox-card-main {
  grid-area: main;
  min-width: 0;
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card.social-inbox-card .inbox-card-meta,
#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card.social-inbox-card .social-crm-card__aside {
  grid-area: aside;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card.social-inbox-card .inbox-card-badges,
#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card.social-inbox-card .social-crm-card__badges {
  grid-area: badges;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-top: 2px;
  /* ui-v2 overflow:hidden zeroes grid auto min-size and collapses this row (~2px). */
  min-height: 18px;
  overflow: visible;
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card.social-inbox-card:hover {
  border-color: color-mix(in srgb, var(--ds-color-accent, #0f766e) 28%, var(--ds-color-line, #e8ecef));
  background: color-mix(in srgb, var(--ds-color-accent-soft, #e4f4f1) 35%, #fff);
  box-shadow: none;
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card.social-inbox-card.is-active {
  border-color: color-mix(in srgb, var(--ds-color-accent, #0f766e) 45%, var(--ds-color-line, #e8ecef));
  background: color-mix(in srgb, var(--ds-color-accent-soft, #e4f4f1) 55%, #fff);
  box-shadow: inset 2px 0 0 var(--ds-color-accent, #0f766e);
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card.social-inbox-card.is-unread {
  border-left: 3px solid var(--ds-color-accent, #0f766e);
  background: color-mix(in srgb, var(--ds-color-accent-soft, #e4f4f1) 22%, #fff);
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card.social-inbox-card.is-unread.is-active {
  background: color-mix(in srgb, var(--ds-color-accent-soft, #e4f4f1) 60%, #fff);
  box-shadow: inset 2px 0 0 var(--ds-color-accent-strong, #0b5f59);
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card__identity {
  gap: 8px;
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card__name-row strong,
#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card__name-row .social-username,
#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card__name-row h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--ds-color-ink, #24262d);
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card.is-unread .social-crm-card__name-row strong,
#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card.is-unread .social-crm-card__name-row .social-username {
  font-weight: 700;
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ds-color-accent, #0f766e);
  flex-shrink: 0;
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card__preview {
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--ds-color-muted, #6b7280);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card__time,
#inboxView.social-inbox-list-modern .social-inbox-list-panel .inbox-card-time {
  font-size: 11px;
  line-height: 1.2;
  color: var(--ds-color-muted, #6b7280);
  white-space: nowrap;
}

/* Badges — quieter */
#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card__badges .badge {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  box-shadow: none;
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .badge--whatsapp {
  color: #0f6b3c;
  background: color-mix(in srgb, #eaf8ef 90%, #fff);
  border-color: color-mix(in srgb, #15803d 18%, transparent);
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .badge--instagram {
  color: #7a3e6b;
  background: color-mix(in srgb, #f7eef5 90%, #fff);
  border-color: color-mix(in srgb, #a8558a 18%, transparent);
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .badge--messenger {
  color: #0b5cab;
  background: color-mix(in srgb, #e8f3ff 90%, #fff);
  border-color: color-mix(in srgb, #0084ff 18%, transparent);
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-account-badge,
#inboxView.social-inbox-list-modern .social-inbox-list-panel .badge--muted {
  color: var(--ds-color-muted, #6b7280);
  background: var(--ds-color-bg, #f6f8fa);
  border-color: var(--ds-color-line, #e8ecef);
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card__status--new {
  color: var(--ds-color-accent-strong, #0b5f59);
  background: var(--ds-color-accent-soft, #e4f4f1);
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card__status--pending {
  color: var(--ds-color-warning, #b45309);
  background: var(--ds-color-warning-soft, #fff5df);
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card__status--quote {
  color: var(--ds-color-info, #2563eb);
  background: var(--ds-color-info-soft, #eaf1ff);
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card__status--rep {
  color: #5b4b8a;
  background: #f3f0fa;
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card__status--muted,
#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card__status--success {
  color: var(--ds-color-muted, #6b7280);
  background: var(--ds-color-bg, #f6f8fa);
}

/* ——— Card menu ——— */
#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-menu__trigger {
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ds-color-muted, #6b7280);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-menu__trigger:hover,
#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-menu.is-open .social-crm-menu__trigger {
  border-color: var(--ds-color-line, #e8ecef);
  background: var(--ds-color-bg, #f6f8fa);
  color: var(--ds-color-ink, #24262d);
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-menu__panel {
  min-width: 180px;
  max-width: 200px;
  padding: 4px;
  border: 1px solid var(--ds-color-line, #e8ecef);
  border-radius: 8px;
  background: var(--ds-color-surface, #fff);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  z-index: 40;
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-menu__panel button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ds-color-ink, #24262d);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-menu__panel button:hover {
  background: var(--ds-color-bg, #f6f8fa);
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-menu__panel button.is-danger {
  margin-top: 4px;
  border-top: 1px solid var(--ds-color-line, #e8ecef);
  border-radius: 0 0 6px 6px;
  color: var(--ds-color-danger, #b42318);
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-menu__panel button.is-danger:hover {
  background: var(--ds-color-danger-soft, #fdecea);
}

#inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-menu__icon {
  width: 1.1em;
  text-align: center;
  opacity: 0.85;
}

/* ——— Mobile / tablet list ——— */
@media (max-width: 1024px) {
  #inboxView.social-inbox-list-modern .social-inbox-list-panel {
    padding: 10px;
  }
}

@media (max-width: 767px) {
  #inboxView.social-inbox-list-modern .social-inbox-list-panel {
    min-width: 0;
    max-width: none;
    width: 100%;
    border-radius: 0;
    padding: 10px 10px 12px;
  }

  #inboxView.social-inbox-list-modern .social-inbox-filters,
  #inboxView.social-inbox-list-modern #socialInboxFilters,
  #inboxView.social-inbox-list-modern #socialInboxFilters.mobile-social-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    gap: 6px;
    padding-bottom: 4px;
    margin-bottom: 8px;
  }

  #inboxView.social-inbox-list-modern .social-filter-chip {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 8px 12px;
  }

  #inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-card.social-inbox-card {
    padding: 10px;
    min-height: 44px;
  }

  #inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-menu__trigger {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }

  #inboxView.social-inbox-list-modern .social-inbox-refresh-btn {
    width: 44px;
    min-width: 44px;
    height: 44px;
  }

  #inboxView.social-inbox-list-modern .social-inbox-list-panel .social-crm-menu__panel button {
    min-height: 44px;
  }
}

/* Conversation ⋯ menu — body-level popup (escapes header overflow:hidden) */
#inboxView .social-inbox-action-sheet[hidden] {
  display: none;
}

#inboxView .social-inbox-action-sheet:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: block;
}

#inboxView .social-inbox-action-sheet__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(15, 23, 42, 0.42);
  cursor: pointer;
}

#inboxView .social-inbox-action-sheet__panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, calc(100vw - 40px));
  max-height: min(80vh, 520px);
  overflow: auto;
  padding: 16px 16px 14px;
  border-radius: 14px;
  background: var(--ds-color-surface, #fff);
  border: 1px solid var(--ds-color-line, #e8ecef);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.22);
}

#inboxView .social-inbox-action-sheet__title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 650;
  color: var(--ds-color-ink, #24262d);
}

#inboxView .social-inbox-action-sheet__actions {
  display: grid;
  gap: 6px;
}

#inboxView .social-inbox-action-sheet__item,
#inboxView .social-inbox-action-sheet__cancel {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--ds-color-line, #e8ecef);
  border-radius: 10px;
  background: var(--ds-color-surface, #fff);
  color: var(--ds-color-ink, #24262d);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

#inboxView .social-inbox-action-sheet__item:hover,
#inboxView .social-inbox-action-sheet__item:focus-visible {
  background: var(--ds-color-bg, #f6f8fa);
  outline: none;
}

#inboxView .social-inbox-action-sheet__item.is-danger {
  color: #b91c1c;
}

#inboxView .social-inbox-action-sheet__cancel {
  margin-top: 8px;
  justify-content: center;
  font-weight: 500;
  color: var(--ds-color-muted, #6b7280);
}

@media (max-width: 767px) {
  #inboxView .social-inbox-action-sheet__panel {
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    transform: none;
    width: 100%;
    max-width: none;
    border-radius: 16px 16px 0 0;
    padding: 12px 14px calc(14px + env(safe-area-inset-bottom, 0px));
  }
}
