/**
 * AI Link Product Compare CSS v2.0
 * UI/UX 전면 개선 - 조달 특화
 */

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --primary-bg: #eef2ff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --success: #10b981;
  --success-light: #34d399;
  --success-bg: #d1fae5;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --error: #ef4444;
  --error-bg: #fee2e2;
  --info: #0ea5e9;
  --info-bg: #e0f2fe;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --header-height: 64px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Noto Sans KR', sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.6;
  padding-top: var(--header-height);
}

.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* ============================================
   페이지 헤더
   ============================================ */
.page-header {
  text-align: center;
  margin-bottom: 32px;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.page-subtitle {
  font-size: 1rem;
  color: var(--gray-500);
}

/* ============================================
   제품 헤더 카드
   ============================================ */
.products-header {
  display: grid;
  grid-template-columns: 160px repeat(var(--product-count, 2), 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.header-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-500);
}

.product-header-card {
  background: white;
  border-radius: var(--radius-xl);
  padding: 24px 16px;
  text-align: center;
  box-shadow: var(--shadow-md);
  border: 2px solid transparent;
  transition: all 0.3s;
  position: relative;
}

.product-header-card.recommended {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-bg), var(--shadow-lg);
}

.product-header-card.recommended::before {
  content: '🏆 AI 추천';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 16px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 20px;
  white-space: nowrap;
}

.product-thumb {
  width: 72px;
  height: 72px;
  background: var(--gray-100);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 12px;
  overflow: hidden;
}

.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 4px;
  line-height: 1.4;
  min-height: 2.8em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-company {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-bottom: 10px;
}

.product-badges {
  display: flex;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  min-height: 28px;
}

.badge {
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-proc {
  background: var(--success-bg);
  color: #059669;
}

.badge-pending {
  background: var(--warning-bg);
  color: #d97706;
}

.badge-innovation {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #b45309;
}

.badge-excellent {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #1d4ed8;
}

.badge-venture {
  background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
  color: #6d28d9;
}

/* 완성도 바 */
.completeness-mini {
  margin-top: 8px;
}

.completeness-bar {
  height: 4px;
  background: var(--gray-200);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 4px;
}

.completeness-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s;
}

.completeness-fill.low {
  background: var(--gray-400);
}

.completeness-fill.medium {
  background: var(--warning);
}

.completeness-fill.high {
  background: var(--success);
}

.completeness-fill.perfect {
  background: linear-gradient(90deg, var(--success) 0%, var(--info) 100%);
}

.completeness-text {
  font-size: 0.7rem;
  color: var(--gray-500);
}

/* 제품 액션 버튼 */
.product-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 12px;
}

.product-action-btn {
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.product-action-btn.primary {
  background: var(--primary);
  color: white;
}

.product-action-btn.primary:hover {
  background: var(--primary-dark);
}

.product-action-btn.secondary {
  background: var(--gray-100);
  color: var(--gray-700);
}

.product-action-btn.secondary:hover {
  background: var(--gray-200);
}

/* ============================================
   핵심 비교 섹션
   ============================================ */
.key-compare-section {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: 24px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.compare-grid {
  display: grid;
  grid-template-columns: 160px repeat(var(--product-count, 2), 1fr);
}

.compare-row {
  display: contents;
}

.compare-row:hover .compare-cell {
  background: var(--gray-50);
}

.compare-cell {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  transition: background 0.2s;
}

.compare-cell.label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-600);
  background: var(--gray-50);
}

.compare-cell.value {
  font-size: 0.9rem;
  color: var(--gray-800);
  justify-content: center;
  text-align: center;
}

/* 하이라이트 (승자 표시) */
.compare-cell.winner {
  background: var(--success-bg) !important;
  position: relative;
}

.compare-cell.winner::after {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 18px;
  height: 18px;
  background: var(--success);
  color: white;
  border-radius: 50%;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.value-good {
  color: var(--success);
  font-weight: 600;
}

.value-warning {
  color: var(--warning);
}

.value-empty {
  color: var(--gray-400);
  font-style: italic;
  font-size: 0.85rem;
}

/* ============================================
   상세 비교 섹션 (접기/펼치기)
   ============================================ */
.detail-section {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: 16px;
}

.detail-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--gray-100);
  cursor: pointer;
  transition: background 0.2s;
}

.detail-section-header:hover {
  background: var(--gray-200);
}

.detail-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-section-toggle {
  color: var(--gray-500);
  transition: transform 0.3s;
}

.detail-section.open .detail-section-toggle {
  transform: rotate(180deg);
}

.detail-section-body {
  display: none;
}

.detail-section.open .detail-section-body {
  display: block;
}

/* ============================================
   데이터 부족 안내 배너
   ============================================ */
.data-request-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-radius: var(--radius-lg);
  margin: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.data-request-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.data-request-icon {
  font-size: 1.25rem;
}

.data-request-text {
  font-size: 0.85rem;
  color: var(--gray-800);
}

.data-request-text strong {
  color: #b45309;
}

.data-request-btn {
  padding: 8px 14px;
  background: white;
  border: 1px solid #d97706;
  color: #b45309;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.data-request-btn:hover {
  background: #fffbeb;
}

/* ============================================
   AI 추천 섹션
   ============================================ */
.ai-recommendation {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: 24px;
}

.ai-rec-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border-bottom: 1px solid var(--gray-200);
}

.ai-rec-icon {
  font-size: 1.75rem;
}

.ai-rec-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-800);
}

.ai-rec-body {
  padding: 20px;
}

.ai-rec-winner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--primary-bg);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
}

.ai-rec-winner-icon {
  font-size: 2rem;
}

.ai-rec-winner-info h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 2px;
}

.ai-rec-winner-info p {
  font-size: 0.85rem;
  color: var(--gray-600);
}

.ai-rec-reasons {
  margin-bottom: 16px;
}

.ai-rec-reasons h5,
.ai-rec-cautions h5 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 10px;
}

.reason-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reason-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--success-bg);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: #065f46;
}

.reason-item i {
  color: var(--success);
  margin-top: 2px;
}

.ai-rec-cautions {
  margin-bottom: 16px;
}

.caution-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--warning-bg);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: #92400e;
  margin-bottom: 8px;
}

.caution-item i {
  color: var(--warning);
  margin-top: 2px;
}

.ai-rec-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ai-rec-btn {
  padding: 10px 20px;
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  border: none;
}

.ai-rec-btn.primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.ai-rec-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.ai-rec-btn.secondary {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.ai-rec-btn.secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

/* ============================================
   하단 액션 바
   ============================================ */
.bottom-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 20px 0;
}

.action-btn {
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.action-btn.primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.action-btn.primary:hover {
  transform: translateY(-2px);
}

.action-btn.secondary {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.action-btn.secondary:hover {
  background: var(--gray-50);
}

/* ============================================
   빈 상태
   ============================================ */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}

.empty-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
}

.empty-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 8px;
}

.empty-desc {
  font-size: 0.9rem;
  color: var(--gray-500);
  margin-bottom: 20px;
  line-height: 1.6;
}

/* ============================================
   레퍼런스 태그
   ============================================ */
.ref-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.ref-tag {
  padding: 4px 10px;
  background: var(--info-bg);
  color: #0369a1;
  border-radius: 20px;
  font-size: 0.8rem;
}

/* 주의사항 텍스트 */
.caution-text {
  padding: 10px 12px;
  background: var(--error-bg);
  border-left: 3px solid var(--error);
  border-radius: 0 6px 6px 0;
  font-size: 0.85rem;
  color: #991b1b;
  text-align: left;
}

/* 한줄평 텍스트 */
.summary-text {
  font-style: italic;
  color: var(--gray-700);
  padding: 10px 12px;
  background: var(--gray-50);
  border-radius: 6px;
  text-align: left;
}

/* ============================================
   모바일 카드 뷰
   ============================================ */
.mobile-compare {
  display: none;
}

.mobile-product-card {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  margin-bottom: 16px;
  overflow: hidden;
}

.mobile-product-card.recommended {
  border: 2px solid var(--primary);
}

.mobile-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--gray-50);
}

.mobile-card-thumb {
  width: 50px;
  height: 50px;
  background: white;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.mobile-card-info {
  flex: 1;
}

.mobile-card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 2px;
}

.mobile-card-company {
  font-size: 0.8rem;
  color: var(--gray-500);
}

.mobile-card-badge {
  padding: 3px 8px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border-radius: 12px;
  font-size: 0.65rem;
  font-weight: 600;
}

.mobile-card-body {
  padding: 12px 16px;
}

.mobile-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
}

.mobile-card-row:last-child {
  border-bottom: none;
}

.mobile-card-label {
  font-size: 0.8rem;
  color: var(--gray-600);
}

.mobile-card-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-800);
}

.mobile-card-value.good {
  color: var(--success);
}

.mobile-card-value.empty {
  color: var(--gray-400);
  font-weight: 400;
}

.mobile-card-footer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--gray-50);
}

.mobile-card-btn {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  border: none;
}

.mobile-card-btn.primary {
  background: var(--primary);
  color: white;
}

.mobile-card-btn.primary:hover {
  background: var(--primary-dark);
}

.mobile-card-btn.secondary {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.mobile-card-btn.secondary:hover {
  background: var(--gray-50);
}

/* ============================================
   반응형
   ============================================ */
@media (max-width: 768px) {
  .main-content {
    padding: 16px;
  }
  
  .page-title {
    font-size: 1.5rem;
  }
  
  /* 데스크톱 뷰 숨기기 */
  .products-header,
  .key-compare-section,
  .detail-section {
    display: none;
  }
  
  /* 모바일 뷰 보이기 */
  .mobile-compare {
    display: block;
  }
  
  .ai-rec-winner {
    flex-direction: column;
    text-align: center;
  }
  
  .ai-rec-actions {
    flex-direction: column;
  }
  
  .ai-rec-btn {
    justify-content: center;
  }
  
  .bottom-actions {
    flex-direction: column;
  }
  
  .action-btn {
    justify-content: center;
  }
}

/* Footer */
.footer {
  background: var(--gray-900);
  color: var(--gray-400);
  padding: 24px;
  text-align: center;
  font-size: 0.85rem;
  margin-top: 40px;
}
/* ============================================
   카테고리 기반 비교함 추가 스타일
   ============================================ */

/* 페이지 헤더 카테고리 배지 */
.page-category-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 24px;
  margin-bottom: 12px;
}

.page-category-icon {
  font-size: 1.2rem;
}

.page-category-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: white;
}

.page-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

.page-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  color: white;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.page-action-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.page-action-btn.primary {
  background: white;
  color: var(--primary);
  border-color: white;
}

.page-action-btn.primary:hover {
  background: #f3f4f6;
}

/* 제품 헤더 카드 제거 버튼 */
.product-remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  background: var(--gray-100);
  border: none;
  border-radius: 50%;
  color: var(--gray-500);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  transition: all 0.2s;
  z-index: 10;
}

.product-remove-btn:hover {
  background: #ef4444;
  color: white;
}

.product-header-card {
  position: relative;
}

/* 빈 상태 팁 */
.empty-tip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: #e0f2fe;
  color: #0369a1;
  border-radius: 8px;
  font-size: 0.9rem;
  margin: 16px 0 24px;
}

.empty-tip i {
  color: #f59e0b;
}

/* 반응형: 모바일 페이지 액션 */
@media (max-width: 768px) {
  .page-actions {
    flex-direction: column;
    align-items: stretch;
  }
  
  .page-action-btn {
    justify-content: center;
  }
}
/* 토스트 및 버튼 애니메이션 */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes pulse {
  0%, 100% { 
    transform: scale(1);
    background: var(--gray-100);
  }
  50% { 
    transform: scale(1.2);
    background: #ef4444;
    color: white;
  }
}

/* 비활성화된 버튼 스타일 */
.action-btn.disabled,
.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* 버튼 호버 시 툴팁 */
.action-btn[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background: #333;
  color: white;
  font-size: 0.75rem;
  border-radius: 4px;
  white-space: nowrap;
  margin-bottom: 8px;
}

/* 페이지 헤더 상태 배지 */
.page-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
}

.page-status-badge.full {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.page-status-badge.full i {
  color: #10b981;
}

/* 제품 수 카운터 표시 */
.page-action-btn .count {
  opacity: 0.8;
  font-weight: 400;
}