* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 1800px;
  margin: 0 auto;
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
}

header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 24px 32px;
}

header h1 {
  font-size: 28px;
  margin-bottom: 16px;
}

.header-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.stat-card {
  background: rgba(255,255,255,0.2);
  padding: 12px 20px;
  border-radius: 8px;
  backdrop-filter: blur(10px);
  min-width: 120px;
}

.stat-value {
  font-size: 28px;
  font-weight: bold;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  opacity: 0.9;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Brand Filter Tabs */
.brand-filters {
  display: flex;
  gap: 8px;
  padding: 16px 32px;
  background: #f8f9fa;
  border-bottom: 2px solid #e9ecef;
  flex-wrap: wrap;
}

.brand-btn {
  padding: 8px 16px;
  border: 2px solid #dee2e6;
  background: white;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  transition: all 0.2s;
}

.brand-btn:hover {
  background: #f8f9fa;
  border-color: #667eea;
}

.brand-btn.active {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  padding: 0 32px;
  background: #f8f9fa;
  border-bottom: 2px solid #e9ecef;
}

.tab-btn {
  padding: 16px 24px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}

.tab-btn:hover {
  background: rgba(102,126,234,0.1);
}

.tab-btn.active {
  border-bottom-color: #667eea;
  color: #667eea;
}

.tab-content {
  display: none;
  padding: 24px 32px;
}

.tab-content.active {
  display: block;
}

/* Badge Summary Bar */
.badge-summary-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 24px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  border: 2px solid #dee2e6;
}

.badge-summary-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: #495057;
  cursor: help;
}

.badge-summary-icon {
  font-size: 18px;
}

.badge-summary-label {
  font-weight: 600;
}

.badge-summary-count {
  background: #667eea;
  color: white;
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 700;
  min-width: 24px;
  text-align: center;
}

.badge-summary-divider {
  color: #adb5bd;
  font-weight: 300;
  font-size: 16px;
}

/* Compact Product Grid */
.products-grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.product-card {
  border: 2px solid #e9ecef;
  border-radius: 12px;
  padding: 12px;
  background: white;
  transition: all 0.2s;
  position: relative;
  display: flex;
  flex-direction: column;
}

.product-card-clickable {
  cursor: pointer;
  flex: 1;
}

.product-card:hover {
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102,126,234,0.2);
  transform: translateY(-2px);
}

.product-card.winning {
  border-color: #28a745;
  background: linear-gradient(to bottom, #f0fff4 0%, white 100%);
}

.product-card.losing {
  border-color: #dc3545;
  background: linear-gradient(to bottom, #fff5f5 0%, white 100%);
}

.product-card.tied {
  border-color: #ffc107;
  background: linear-gradient(to bottom, #fffbf0 0%, white 100%);
}

/* Product Header (Image + Name) */
.product-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.product-image {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.product-info {
  flex: 1;
  min-width: 0;
}

.product-info h3 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asin {
  font-size: 11px;
  color: #6c757d;
  font-family: monospace;
}

/* Win Badge */
.win-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 8px;
}

.win-badge.winning {
  background: #d4edda;
  color: #155724;
}

.win-badge.losing {
  background: #f8d7da;
  color: #721c24;
}

.win-badge.tied {
  background: #fff3cd;
  color: #856404;
}

/* Product Badges (earned achievements) */
.product-badges {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-left: auto;
}

.product-badge {
  font-size: 16px;
  cursor: help;
  transition: transform 0.2s;
  display: inline-block;
}

.product-badge:hover {
  transform: scale(1.2);
}

/* Compact Metrics */
.compact-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}

.metric-compact {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
}

.metric-compact .label {
  color: #6c757d;
  font-weight: 500;
}

.metric-compact .value {
  font-weight: 600;
}

.metric-compact.win .value {
  color: #28a745;
}

.metric-compact.lose .value {
  color: #dc3545;
}

/* Keywords */
.keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.keyword-tag {
  display: inline-block;
  padding: 3px 8px;
  background: #e9ecef;
  border-radius: 10px;
  font-size: 10px;
  color: #495057;
}

/* Product Card Actions (Delete Button) */
.product-card-actions {
  display: flex;
  justify-content: center;
  padding-top: 8px;
  margin-top: 8px;
  border-top: 1px solid #e9ecef;
}

.delete-btn {
  background: transparent;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
  opacity: 0.5;
}

.delete-btn:hover {
  background: #fff5f5;
  opacity: 1;
  transform: scale(1.1);
}

/* VS Comparison View (Modal/Expanded) */
.comparison-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.comparison-modal.active {
  display: flex;
}

.comparison-detail {
  background: white;
  border-radius: 16px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
  position: relative;
}

.close-modal {
  position: absolute;
  top: 16px;
  right: 16px;
  background: #e9ecef;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.close-modal:hover {
  background: #dc3545;
  color: white;
}

.products-comparison {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 24px;
  align-items: start;
  margin-top: 24px;
}

.product-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.product-column .product-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 12px;
}

.product-column .product-image {
  width: 120px;
  height: 120px;
}

.product-column .product-info {
  text-align: center;
  width: 100%;
}

.product-column .product-info h3 {
  font-size: 16px;
  white-space: normal;
}

.vs-divider {
  font-size: 24px;
  font-weight: bold;
  color: #667eea;
  padding: 8px 16px;
  background: #f8f9fa;
  border-radius: 12px;
  align-self: center;
}

.metrics {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #f8f9fa;
  border-radius: 8px;
}

.metric-label {
  font-size: 13px;
  color: #6c757d;
  font-weight: 500;
}

.metric-value {
  font-size: 15px;
  font-weight: 600;
}

.metric-value.winning {
  color: #28a745;
}

.metric-value.losing {
  color: #dc3545;
}

/* Recommendations */
.recommendation-card {
  border-left: 4px solid #667eea;
  background: white;
  padding: 16px;
  margin-bottom: 16px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.recommendation-card.high {
  border-left-color: #dc3545;
}

.recommendation-card.medium {
  border-left-color: #ffc107;
}

.recommendation-card.low {
  border-left-color: #28a745;
}

.recommendation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.priority-badge {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.priority-badge.high {
  background: #f8d7da;
  color: #721c24;
}

.priority-badge.medium {
  background: #fff3cd;
  color: #856404;
}

.priority-badge.low {
  background: #d4edda;
  color: #155724;
}

.recommendation-issue {
  font-weight: 500;
  margin-bottom: 12px;
  color: #495057;
}

.suggestion-list {
  list-style: none;
  padding: 0;
}

.suggestion-list li {
  padding: 6px 0 6px 20px;
  position: relative;
  color: #6c757d;
  font-size: 14px;
}

.suggestion-list li:before {
  content: "→";
  position: absolute;
  left: 0;
  color: #667eea;
  font-weight: bold;
}

/* Comments */
.comment-form {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 24px;
}

.comment-form h3 {
  margin-bottom: 16px;
  color: #495057;
}

.comment-form select,
.comment-form input,
.comment-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  margin-bottom: 12px;
  font-family: inherit;
  font-size: 14px;
}

.comment-form textarea {
  min-height: 80px;
  resize: vertical;
}

.comment-form button {
  background: #667eea;
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.comment-form button:hover {
  background: #5568d3;
}

.comment-card {
  background: white;
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 12px;
  border: 2px solid #e9ecef;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.comment-author {
  font-weight: 600;
  color: #495057;
}

.comment-type {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.comment-type.win {
  background: #d4edda;
  color: #155724;
}

.comment-type.loss {
  background: #f8d7da;
  color: #721c24;
}

.comment-type.general {
  background: #e9ecef;
  color: #495057;
}

.comment-text {
  margin-bottom: 8px;
  color: #495057;
  line-height: 1.5;
}

.comment-time {
  font-size: 12px;
  color: #6c757d;
}

/* Badges */
.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.badge-card {
  background: white;
  padding: 20px;
  border-radius: 12px;
  text-align: center;
  border: 2px solid #e9ecef;
  transition: all 0.2s;
}

.badge-card:hover {
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102,126,234,0.2);
}

.badge-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.badge-name {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 8px;
  color: #495057;
}

.badge-description {
  font-size: 13px;
  color: #6c757d;
  line-height: 1.4;
}

/* Add Product Form */
.add-product-form {
  background: #f8f9fa;
  padding: 24px;
  border-radius: 12px;
  max-width: 800px;
  margin: 0 auto;
}

.add-product-form h3 {
  margin-bottom: 8px;
  color: #495057;
  font-size: 20px;
}

.add-product-form .form-description {
  color: #6c757d;
  font-size: 14px;
  margin-bottom: 24px;
}

.add-product-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.add-product-form .form-row:last-of-type {
  grid-template-columns: 1fr;
}

.add-product-form .form-group {
  display: flex;
  flex-direction: column;
}

.add-product-form label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #495057;
}

.add-product-form input,
.add-product-form select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.2s;
}

.add-product-form input:focus,
.add-product-form select:focus {
  outline: none;
  border-color: #667eea;
}

.add-product-form small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #6c757d;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.btn-primary {
  background: #667eea;
  color: white;
  border: none;
  padding: 12px 32px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 15px;
}

.btn-primary:hover {
  background: #5568d3;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102,126,234,0.3);
}

.btn-secondary {
  background: white;
  color: #495057;
  border: 2px solid #dee2e6;
  padding: 12px 32px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 15px;
}

.btn-secondary:hover {
  background: #f8f9fa;
  border-color: #adb5bd;
}

.add-product-result {
  margin-top: 20px;
  padding: 16px;
  border-radius: 8px;
  font-size: 14px;
  display: none;
}

.add-product-result.success {
  background: #d4edda;
  color: #155724;
  border: 2px solid #c3e6cb;
  display: block;
}

.add-product-result.error {
  background: #f8d7da;
  color: #721c24;
  border: 2px solid #f5c6cb;
  display: block;
}

.add-product-result.loading {
  background: #d1ecf1;
  color: #0c5460;
  border: 2px solid #bee5eb;
  display: block;
}

.add-product-result h4 {
  margin-bottom: 12px;
  font-size: 16px;
}

.add-product-result p {
  margin: 8px 0;
}

.add-product-result .warning {
  color: #856404;
  background: #fff3cd;
  padding: 8px 12px;
  border-radius: 6px;
  margin-top: 12px;
  border: 1px solid #ffeeba;
}

.success-message {
  line-height: 1.6;
}

/* Image Scraper Form */
.scraper-form {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 24px;
}

.scraper-form h3 {
  margin-bottom: 16px;
  color: #495057;
}

.scraper-form .form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 12px;
}

.scraper-form .form-group {
  flex: 1;
}

.scraper-form label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #495057;
}

.scraper-form input,
.scraper-form select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
}

.scraper-form button {
  background: #667eea;
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.scraper-form button:hover {
  background: #5568d3;
}

.scraper-form button:disabled {
  background: #adb5bd;
  cursor: not-allowed;
}

.scraper-result {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
}

.scraper-result.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.scraper-result.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.scraper-result.loading {
  background: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

/* Loading Spinner */
.loading {
  text-align: center;
  padding: 40px;
  color: #6c757d;
}

.spinner {
  border: 3px solid #f3f4f6;
  border-top: 3px solid #667eea;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
  
  .products-comparison {
    grid-template-columns: 1fr;
  }
  
  .vs-divider {
    order: 2;
  }
  
  .product-column.competitor {
    order: 3;
  }
}
