/* TWYN Theme Variables */
:root {
  --twyn-primary: #667eea;
  --twyn-primary-dark: #5a6fd8;
  --twyn-gradient-start: #667eea;
  --twyn-gradient-end: #764ba2;
  --twyn-text: #1e293b;
  --twyn-text-muted: #64748b;
  --twyn-border: #e2e8f0;
  --twyn-bg: #ffffff;
  --twyn-bg-light: #f8fafc;
  --twyn-success: #22c55e;
  --twyn-warning: #f59e0b;
  --twyn-error: #ef4444;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'SF Pro Display', Roboto, system-ui, sans-serif;
  background: linear-gradient(135deg, #f0f4ff 0%, #ffffff 50%, #f8fafc 100%);
  color: var(--twyn-text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
  background: white;
  border-bottom: 1px solid var(--twyn-border);
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--twyn-text);
  font-weight: 700;
  font-size: 18px;
}

.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--twyn-gradient-start) 0%, var(--twyn-gradient-end) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 20px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge {
  font-size: 12px;
  color: var(--twyn-text-muted);
  border: 1px solid var(--twyn-border);
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--twyn-bg-light);
}

.header-link {
  font-size: 14px;
  color: var(--twyn-primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.header-link:hover {
  color: var(--twyn-primary-dark);
}

.install-cta-button {
  font-size: 15px;
  color: white;
  background: linear-gradient(135deg, var(--twyn-primary) 0%, var(--twyn-primary-dark) 100%);
  text-decoration: none;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 10px;
  transition: all 0.3s;
  display: none; /* Hidden by default, shown via JS if extension not detected */
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  border: none;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
}

.install-cta-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.install-cta-button:hover::before {
  left: 100%;
}

.install-cta-button:hover {
  background: linear-gradient(135deg, var(--twyn-primary-dark) 0%, var(--twyn-primary) 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* Context Section */
.context-section {
  background: white;
  border: 1px solid var(--twyn-border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

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

.context-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--twyn-text);
}

.context-toggle {
  background: none;
  border: none;
  color: var(--twyn-primary);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.context-toggle:hover {
  background: var(--twyn-bg-light);
}

.context-items {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.context-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--twyn-bg-light);
  border: 1px solid var(--twyn-border);
  border-radius: 8px;
  font-size: 13px;
  flex-wrap: wrap;
}

.context-item img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.context-item-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-item {
  color: var(--twyn-text-muted);
}

.context-item img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
}

.context-item-title {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Product Feed */
.feed-section {
  margin-bottom: 32px;
}

.feed-header {
  margin-bottom: 20px;
}

.feed-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--twyn-text);
  margin-bottom: 8px;
}

.feed-subtitle {
  font-size: 14px;
  color: var(--twyn-text-muted);
}

/* Product Grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

@media (max-width: 768px) {
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
  }
}

@media (max-width: 480px) {
  .product-grid {
    grid-template-columns: 1fr;
  }
}

/* Product Card */
.product-card {
  background: white;
  border: 1px solid var(--twyn-border);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.2s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
  transform: translateY(-2px);
  border-color: var(--twyn-primary);
}

/* Ensure card is fully clickable - don't block pointer events */
.product-card > * {
  pointer-events: auto;
}

.product-image-container {
  position: relative;
  width: 100%;
  padding-top: 100%; /* 1:1 aspect ratio */
  background: var(--twyn-bg-light);
  overflow: hidden;
}

.product-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-image-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--twyn-gradient-start) 0%, var(--twyn-gradient-end) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
}

.merchant-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.95);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--twyn-text);
  text-transform: capitalize;
}

.product-info {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.product-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--twyn-text);
  margin-bottom: 8px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 40px;
}

.product-rating {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
}

.stars {
  color: #fbbf24;
  font-size: 12px;
}

.rating-value {
  font-weight: 600;
  color: var(--twyn-text);
}

.review-count {
  color: var(--twyn-text-muted);
}

.product-price {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 12px;
  font-size: 18px;
  font-weight: 700;
  color: var(--twyn-success);
}

.currency {
  font-size: 14px;
}

.view-button {
  margin-top: auto;
  padding: 10px 16px;
  background: var(--twyn-primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: block;
  transition: all 0.2s;
}

.view-button:hover {
  background: var(--twyn-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* Loading States */
.loading-skeleton {
  background: var(--twyn-bg-light);
  border-radius: 12px;
  overflow: hidden;
}

.skeleton-image {
  width: 100%;
  padding-top: 100%;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
}

.skeleton-text {
  height: 16px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
  border-radius: 4px;
  margin-bottom: 8px;
}

.skeleton-text.short {
  width: 60%;
}

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

/* Loading Spinner */
.loading-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--twyn-bg-light);
  border-top: 4px solid var(--twyn-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Load More Button */
.load-more-container {
  display: flex;
  justify-content: center;
  margin-top: 32px;
}

.load-more-button {
  padding: 12px 24px;
  background: white;
  border: 2px solid var(--twyn-primary);
  color: var(--twyn-primary);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.load-more-button:hover:not(:disabled) {
  background: var(--twyn-primary);
  color: white;
}

.load-more-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: white;
  border: 1px solid var(--twyn-border);
  border-radius: 12px;
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.empty-state-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--twyn-text);
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 16px;
  color: var(--twyn-text-muted);
  margin-bottom: 24px;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.empty-state-button {
  display: inline-block;
  padding: 12px 24px;
  background: var(--twyn-primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
}

.empty-state-button:hover {
  background: var(--twyn-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Error State */
.error-state {
  text-align: center;
  padding: 40px 20px;
  background: white;
  border: 1px solid var(--twyn-border);
  border-radius: 12px;
  color: var(--twyn-error);
}

.error-message {
  font-size: 16px;
  margin-bottom: 16px;
}

.retry-button {
  padding: 10px 20px;
  background: var(--twyn-primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.retry-button:hover {
  background: var(--twyn-primary-dark);
}

/* Footer */
.footer {
  background: white;
  border-top: 1px solid var(--twyn-border);
  padding: 24px 20px;
  margin-top: 60px;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 14px;
  color: var(--twyn-text-muted);
}

.footer-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-link {
  color: var(--twyn-primary);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-link:hover {
  color: var(--twyn-primary-dark);
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .container {
    padding: 16px;
  }

  .feed-title {
    font-size: 20px;
  }

  .footer-content {
    flex-direction: column;
    text-align: center;
  }
}

