/* ==========================================================================
   FEED PAGE — Production-grade cluster cards & modal
   Добавить в custom.css ИЛИ как отдельный файл feed.css
   ========================================================================== */

/* --- Feed Layout --- */
.feed-container { 
  max-width: 780px; 
  margin: 0 auto; 
  padding: 32px 24px 80px;
}
@media (max-width: 768px) { 
  .feed-container { padding: 16px 12px 60px; } 
}

.feed-container .page-head { margin-bottom: 20px; }
.feed-container .page-head .title h1 { 
  font-size: 24px; 
  font-weight: 700; 
  letter-spacing: -0.03em; 
}
.feed-container .page-head .title .sub { 
  font-size: 13px; 
  color: var(--muted); 
  margin-top: 2px; 
}

/* --- Search Bar (compact) --- */
.feed-container .card { margin-bottom: 20px; }
.feed-container .card-body { padding: 12px 16px; }
.feed-container .card-body .row-center { gap: 12px; }
.feed-container .card-body .field > label { display: none; }
.feed-container .card-body .input { 
  padding: 8px 12px; 
  font-size: 13px; 
  border-radius: 8px; 
}
.feed-container .switch-label { font-size: 12px; white-space: nowrap; }

/* --- Cluster Cards (Feed) --- */
#clusters-list { 
  display: flex; 
  flex-direction: column; 
  gap: 12px; 
}

.cl-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}
.cl-card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}
.cl-card:active { transform: translateY(0); }

/* New indicator */
.cl-card.is-new { border-left: 3px solid var(--brand); }

/* Header */
.cl-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}
.cl-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0;
}

.cl-time {
  flex-shrink: 0;
  text-align: right;
}
.cl-date {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

/* Meta row */
.cl-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.cl-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.cl-badge--score {
  background: linear-gradient(135deg, rgba(239,68,68,0.08), rgba(249,115,22,0.08));
  color: #dc2626;
}
.cl-badge--score.high {
  background: linear-gradient(135deg, rgba(239,68,68,0.12), rgba(249,115,22,0.12));
  color: #b91c1c;
}
.cl-badge--msgs {
  background: var(--surface-hover);
  color: var(--text-sec);
}
.cl-badge--views {
  background: rgba(59,130,246,0.08);
  color: #2563eb;
}
.cl-badge--reach {
  background: rgba(16,185,129,0.08);
  color: #059669;
}
.cl-badge--theme {
  background: var(--brand-light);
  color: var(--brand);
}
.cl-badge--ad {
  background: #FEF3C7;
  color: #b45309;
}

.cl-sep {
  color: var(--line-strong);
  font-size: 10px;
  user-select: none;
}

/* Preview text */
.cl-preview {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-sec);
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Sources row */
.cl-sources {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.cl-source-avatar {
  position: relative;
  display: inline-flex;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.cl-source-avatar:hover { 
  transform: scale(1.12); 
  z-index: 2; 
}
.cl-source-avatar__img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  border: 1.5px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line);
}
.cl-source-avatar__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cl-source-avatar__placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  border-radius: 50%;
}

.cl-source-avatar__badge {
  position: absolute;
  bottom: -2px;
  right: -3px;
  background: var(--surface);
  border-radius: 50%;
  padding: 1.5px;
  display: flex;
  box-shadow: 0 0 0 1px var(--line);
  z-index: 2;
}

.cl-more-sources {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 4px;
  white-space: nowrap;
}

.cl-publish-badge {
  font-size: 12px;
  font-weight: 500;
  margin-top: 8px;
  padding: 4px 0;
}
.cl-publish-badge--scheduled { color: #f59e0b; }
.cl-publish-badge--published { color: #10b981; }

/* Empty state */
.cl-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 14px;
}

/* Loading skeleton */
.cl-skeleton {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  animation: cl-pulse 1.5s ease infinite;
}
.cl-skeleton__bar {
  height: 14px;
  background: var(--surface-hover);
  border-radius: 6px;
  margin-bottom: 10px;
}
.cl-skeleton__bar--title { width: 70%; height: 18px; }
.cl-skeleton__bar--meta { width: 40%; height: 12px; }
.cl-skeleton__bar--text { width: 90%; }
.cl-skeleton__bar--sources { width: 50%; height: 26px; margin-top: 4px; }

@keyframes cl-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* --- Modal (Redesign) --- */
#posts-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
  overflow-y: auto;
  background: rgba(0,0,0,0);
  backdrop-filter: blur(0px);
  transition: background 0.25s, backdrop-filter 0.25s;
}
#posts-modal.open {
  display: flex;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
}

#posts-modal .modal-content {
  background: var(--surface);
  width: 100%;
  max-width: 720px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  /* max-height: 85vh; */
  transform: translateY(8px);
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s;
}
#posts-modal.open .modal-content {
  transform: translateY(0);
  opacity: 1;
}

/* Modal header */
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.modal-header h2 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--surface-hover);
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: 18px;
  transition: all 0.15s;
  flex-shrink: 0;
  margin-left: 12px;
}
.modal-close:hover { 
  background: var(--line); 
  color: var(--text); 
}

/* Modal body */
.modal-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

/* Message card inside modal */
.msg-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: border-color 0.15s;
}
.msg-card:hover { border-color: var(--line-strong); }
.msg-card:last-child { margin-bottom: 0; }

.msg-card__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.msg-card__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}
.msg-card__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.msg-card__source {
  flex: 1;
  min-width: 0;
}
.msg-card__source-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-card__source-name a { 
  color: inherit; 
  text-decoration: none; 
}
.msg-card__source-name a:hover { color: var(--brand); }
.msg-card__date {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.msg-card__text {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-sec);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow-y: auto;
}

.msg-card__media {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.msg-card__media img {
  max-width: 200px;
  max-height: 140px;
  border-radius: 8px;
  object-fit: cover;
}
.msg-card__media-video {
  position: relative;
}
.msg-card__media-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  color: #fff;
  font-size: 28px;
}

.msg-card__medoid {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(245,158,11,0.12);
  border: 1px solid rgba(245,158,11,0.25);
  font-size: 11px;
  font-weight: 500;
  color: #92400e;
}

/* Compose button */
.modal-compose-trigger {
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.modal-compose-trigger .btn { width: 100%; }

/* Scroll sentinel */
#clusters-sentinel {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* New clusters button */
#new-clusters-btn {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  padding: 8px 20px;
  border-radius: 99px;
  background: var(--brand);
  color: #fff;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(79,70,229,0.3);
  transition: all 0.2s;
}
#new-clusters-btn:hover {
  box-shadow: 0 6px 20px rgba(79,70,229,0.4);
  transform: translateX(-50%) translateY(-1px);
}
#new-clusters-btn.hidden { display: none; }

/* Responsive */
@media (max-width: 640px) {
  .cl-card { padding: 14px 16px; }
  .cl-title { font-size: 15px; }
  .cl-preview { font-size: 13px; -webkit-line-clamp: 2; }
  .cl-meta { gap: 4px; }
  .cl-badge { font-size: 10px; padding: 2px 6px; }
  
  #posts-modal { padding: 20px 12px; }
  #posts-modal .modal-content { border-radius: 12px; }
  .modal-header { padding: 14px 16px; }
  .modal-messages { padding: 14px 16px; }
}
