/* ============================================================
   후후페이 — 실시간 거래 피드 위젯 스타일
   Ref: docs/02_DESIGN.md §10
   ============================================================ */

/* ── Feed Section Wrapper ── */
.feed-section {
  max-width: 1000px;
  margin: 0 auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* ── Feed Header ── */
.feed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-6) var(--space-8);
  border-bottom: 1px solid var(--border-subtle);
}

.feed-header-left h2 {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.feed-header-left p {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.feed-live-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  white-space: nowrap;
}

.feed-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3883FF;
  flex-shrink: 0;
  animation: feedPulse 1.6s infinite;
}

@keyframes feedPulse {
  0%   { box-shadow: 0 0 0 0 rgba(56, 131, 255, 0.6); }
  70%  { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ── Column Headers (Desktop) ── */
.feed-column-header {
  display: grid;
  grid-template-columns: 120px 1fr 140px 120px;
  padding: var(--space-3) var(--space-8);
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

@media (max-width: 767px) {
  .feed-column-header { display: none; }
}

/* ── Feed List ── */
.feed-list {
  max-height: 480px;
  overflow-y: auto;
  position: relative;
}

.feed-list::-webkit-scrollbar { width: 4px; }
.feed-list::-webkit-scrollbar-track { background: transparent; }
.feed-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* ── Feed Row (Desktop) ── */
.feed-row {
  display: grid;
  grid-template-columns: 120px 1fr 140px 120px;
  padding: var(--space-4) var(--space-8);
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  animation: feedSlideIn 0.5s ease-out;
  transition: background var(--transition);
}

.feed-row:hover { background: rgba(79, 70, 229, 0.04); }
.feed-row:last-child { border-bottom: none; }

/* FEAT-6: 클릭 가능한 피드 row */
.feed-row[data-clickable] {
  cursor: pointer;
}
.feed-row[data-clickable]:hover {
  background: rgba(255, 255, 255, 0.05);
}

@media (max-width: 767px) {
  .feed-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-6);
    min-height: 88px;
    grid-template-columns: unset;
  }
}

@keyframes feedSlideIn {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.98);
    background: rgba(124, 58, 237, 0.08);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    background: transparent;
  }
}

.feed-row.fade-out {
  animation: feedFadeOut 0.4s ease-in forwards;
}

@keyframes feedFadeOut {
  to {
    opacity: 0;
    transform: translateY(8px);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
  }
}

/* ── Feed Row: Name Cell ── */
.feed-name {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.feed-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9375rem;
  flex-shrink: 0;
}

.feed-name-text {
  color: var(--text-primary);
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-sm);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ── Feed Row: Service Cell ── */
.feed-service {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

@media (max-width: 767px) {
  .feed-service { font-size: var(--font-size-xs); }
}

/* ── Feed Row: Amount Cell ── */
.feed-amount {
  font-family: 'Inter', sans-serif;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text-primary);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
}

@media (max-width: 767px) {
  .feed-amount { text-align: left; font-size: var(--font-size-base); font-weight: var(--font-weight-bold); }
}

/* ── Feed Row: Status Badge ── */
.feed-status {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  justify-self: start;
}

.feed-status--completed {
  background: rgba(56, 131, 255, 0.15);
  color: #3883FF;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
}

.feed-status--rejected {
  background: rgba(239, 68, 68, 0.15);
  color: #EF4444;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
}

/* ── New Items Banner ── */
.feed-new-banner {
  position: sticky;
  top: 0;
  background: rgba(79, 70, 229, 0.9);
  color: #fff;
  text-align: center;
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: background var(--transition);
  z-index: 10;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: none;
}

.feed-new-banner.visible { display: block; }
.feed-new-banner:hover { background: rgba(79, 70, 229, 1); }

/* ── Feed Empty State ── */
.feed-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-12) var(--space-6);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.feed-empty-icon { font-size: 2.5rem; opacity: 0.5; }

/* ── Feed Loading State ── */
.feed-skeleton {
  display: grid;
  grid-template-columns: 120px 1fr 140px 120px;
  padding: var(--space-4) var(--space-8);
  align-items: center;
  gap: var(--space-4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.feed-skeleton-bar {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 0%,
    rgba(255, 255, 255, 0.13) 40%,
    rgba(255, 255, 255, 0.05) 80%
  );
  background-size: 300% 100%;
  animation: feedShimmer 1.6s ease-in-out infinite;
}

/* 각 bar의 shimmer 위상 엇갈리기 */
.feed-skeleton-bar:nth-child(1) { animation-delay: 0s; }
.feed-skeleton-bar:nth-child(2) { animation-delay: 0.15s; }
.feed-skeleton-bar:nth-child(3) { animation-delay: 0.3s; }
.feed-skeleton-bar:nth-child(4) { animation-delay: 0.45s; }

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

/* 모바일: 스켈레톤도 flex 전환 */
@media (max-width: 767px) {
  .feed-skeleton {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-6);
  }
  .feed-skeleton-bar:nth-child(1) { width: 60%; height: 12px; }
  .feed-skeleton-bar:nth-child(2) { width: 80%; height: 12px; }
  .feed-skeleton-bar:nth-child(3) { width: 40%; height: 12px; }
  .feed-skeleton-bar:nth-child(4) { display: none; }
}

/* ── 모바일 최적화 (481~767px) ── */
@media (min-width: 481px) and (max-width: 767px) {
  .feed-row {
    display: grid;
    grid-template-columns: 1fr 120px 80px;
    padding: var(--space-3) var(--space-6);
    gap: var(--space-2);
    min-height: auto;
    align-items: center;
  }
  .feed-name { display: none; }
  .feed-service { grid-column: 1; font-size: var(--font-size-sm); }
  .feed-amount  { grid-column: 2; text-align: right; font-size: var(--font-size-sm); }
  .feed-status  { grid-column: 3; font-size: var(--font-size-xs); }
}

/* ── 모바일 최적화 (≤480px) ── */
@media (max-width: 480px) {
  /* 헤더: 세로 정렬 */
  .feed-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
  }
  .feed-header-left h2 { font-size: var(--font-size-lg); margin-bottom: var(--space-1); }
  .feed-header-left p  { font-size: var(--font-size-xs); line-height: 1.4; }
  .feed-live-indicator { font-size: var(--font-size-xs); align-self: flex-start; }

  /* feed-row: 안 C — 3열×2행 grid */
  .feed-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    grid-template-rows: auto auto;
    grid-template-areas:
      "name    name    name"
      "service amount  status";
    row-gap: var(--space-1);
    column-gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    min-height: 48px;
    align-items: center;
    flex-direction: unset;
  }
  .feed-name    { grid-area: name; }
  .feed-service { grid-area: service; font-size: var(--font-size-xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .feed-amount  { grid-area: amount; font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold); white-space: nowrap; color: var(--color-primary); }
  .feed-status  { grid-area: status; padding: 2px 6px; font-size: 0.625rem; }

  /* 아이콘/이름 크기 축소 */
  .feed-icon      { width: 28px; height: 28px; font-size: 0.8125rem; }
  .feed-name-text { font-size: var(--font-size-xs); }

  /* 리스트 최대 높이 */
  .feed-list { max-height: 320px; }
}
