/* === RESET & BASE === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #faf5ff;
  --bg-card: #ffffff;
  --violet: #7c3aed;
  --violet-light: #a78bfa;
  --violet-dark: #5b21b6;
  --pink: #ec4899;
  --pink-light: #f9a8d4;
  --text: #1e1b4b;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --border: #e5e7eb;
  --border-violet: #ddd6fe;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(124,58,237,0.08), 0 4px 10px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 40px rgba(124,58,237,0.12), 0 8px 16px rgba(0,0,0,0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* === HERO === */
.hero {
  text-align: center;
  padding: 80px 24px 48px;
  background: linear-gradient(135deg, #faf5ff 0%, #ede9fe 50%, #fce7f3 100%);
  border-bottom: 1px solid var(--border-violet);
}

.hero-badge {
  display: inline-block;
  background: var(--violet);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 6px 16px;
  border-radius: 100px;
  margin-bottom: 20px;
}

.hero h1 {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.hero h1 .accent {
  color: var(--violet);
}

.tagline {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto;
}

/* === ANALYSIS INPUT === */
.analysis-input {
  padding: 48px 0;
}

.input-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-violet);
  text-align: center;
}

.input-card h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.input-card > p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.input-row {
  display: flex;
  gap: 12px;
  max-width: 640px;
  margin: 0 auto 16px;
}

.input-row input {
  flex: 1;
  padding: 14px 20px;
  border: 2px solid var(--border-violet);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  transition: border-color 0.2s;
  outline: none;
  background: var(--bg);
}

.input-row input:focus {
  border-color: var(--violet);
}

.input-row button {
  padding: 14px 32px;
  background: var(--violet);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.input-row button:hover {
  background: var(--violet-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124,58,237,0.3);
}

.input-row button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.quick-picks {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.chip {
  background: var(--bg);
  border: 1px solid var(--border-violet);
  border-radius: 100px;
  padding: 6px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--violet);
  font-weight: 500;
}

.chip:hover {
  background: var(--violet);
  color: white;
  border-color: var(--violet);
}

.error-msg {
  color: var(--danger);
  margin-top: 12px;
  font-size: 0.9rem;
}

/* === SUMMARY BAR === */
.summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px 28px;
  margin-bottom: 32px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 16px;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}

.summary-value {
  font-size: 1.1rem;
  font-weight: 700;
}

.summary-value.accent {
  color: var(--pink);
}

.export-btn {
  background: var(--bg);
  border: 2px solid var(--violet);
  color: var(--violet);
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}

.export-btn:hover {
  background: var(--violet);
  color: white;
}

/* === CHARTS === */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 32px;
}

.chart-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.chart-card h3 {
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.chart-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.chart-container {
  position: relative;
  height: 320px;
}

.chart-container canvas {
  max-height: 320px;
}

/* === HEATMAP === */
.heatmap-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 32px;
}

.heatmap-card h3 {
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.heatmap-container {
  overflow-x: auto;
  margin-top: 12px;
}

.heatmap-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.heatmap-table th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.heatmap-table td {
  padding: 10px 14px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  border-radius: 4px;
}

.heatmap-table td.label-cell {
  text-align: left;
  font-weight: 500;
  color: var(--text);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* === PRODUCT CARDS === */
.section-title {
  font-size: 1.25rem;
  margin-bottom: 20px;
}

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

.product-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: all 0.2s;
  cursor: pointer;
}

.product-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

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

.product-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.product-brand {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.product-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 100px;
  white-space: nowrap;
}

.badge-leader {
  background: #dcfce7;
  color: #166534;
}

.badge-challenger {
  background: #dbeafe;
  color: #1e40af;
}

.badge-niche {
  background: #fef3c7;
  color: #92400e;
}

.badge-emerging {
  background: #fce7f3;
  color: #9d174d;
}

.product-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  font-size: 0.85rem;
}

.stat {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-icon {
  font-size: 0.9rem;
}

.rating-stars {
  color: var(--warning);
  font-weight: 700;
}

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

.price-range {
  color: var(--violet);
  font-weight: 600;
}

.opportunity-bar-mini {
  height: 6px;
  background: var(--border);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 8px;
}

.opportunity-fill-mini {
  height: 100%;
  border-radius: 100px;
  transition: width 0.6s ease;
}

.opportunity-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.product-details {
  display: none;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; max-height: 0; }
  to { opacity: 1; max-height: 500px; }
}

.product-details.expanded {
  display: block;
}

.detail-section {
  margin-bottom: 12px;
}

.detail-section h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.praise-tag {
  display: inline-block;
  background: #dcfce7;
  color: #166534;
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 100px;
  margin: 2px 4px 2px 0;
}

.complaint-tag {
  display: inline-block;
  background: #fee2e2;
  color: #991b1b;
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 100px;
  margin: 2px 4px 2px 0;
}

.expand-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 8px;
}

/* === GAPS === */
.gaps-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 32px;
}

.gaps-card h3 {
  margin-bottom: 16px;
}

.gap-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.gap-item:last-child {
  border-bottom: none;
}

.gap-severity {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 100px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}

.severity-high {
  background: #fee2e2;
  color: #991b1b;
}

.severity-medium {
  background: #fef3c7;
  color: #92400e;
}

.severity-low {
  background: #dbeafe;
  color: #1e40af;
}

.gap-content h4 {
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.gap-content p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* === RECOMMENDATION === */
.recommendation-card {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  background: linear-gradient(135deg, #ede9fe, #fce7f3);
  border-radius: var(--radius);
  padding: 28px;
  border: 1px solid var(--border-violet);
  margin-bottom: 32px;
}

.rec-icon {
  font-size: 2rem;
  color: var(--violet);
  flex-shrink: 0;
}

.rec-content h3 {
  margin-bottom: 8px;
  color: var(--violet-dark);
}

.rec-content p {
  color: var(--text);
  line-height: 1.7;
}

/* === HISTORY === */
.history-section {
  padding: 48px 0;
}

.history-section h2 {
  font-size: 1.5rem;
  margin-bottom: 20px;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.history-empty {
  color: var(--text-muted);
  grid-column: 1 / -1;
  text-align: center;
  padding: 32px;
}

.history-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
}

.history-card:hover {
  border-color: var(--violet-light);
  box-shadow: var(--shadow-lg);
}

.history-card h4 {
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.history-card .history-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.history-card .history-score {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--border-violet);
  color: var(--violet);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 100px;
  margin-top: 6px;
}

/* === SIGNUP === */
.signup-section {
  padding: 48px 0 80px;
}

.signup-card {
  background: linear-gradient(135deg, var(--violet-dark), var(--violet));
  color: white;
  border-radius: var(--radius);
  padding: 48px;
  text-align: center;
  box-shadow: var(--shadow-xl);
}

.signup-card h2 {
  font-size: 1.75rem;
  margin-bottom: 8px;
}

.signup-card > p {
  opacity: 0.85;
  margin-bottom: 24px;
}

.signup-row {
  display: flex;
  gap: 12px;
  max-width: 480px;
  margin: 0 auto;
}

.signup-row input {
  flex: 1;
  padding: 14px 20px;
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  background: rgba(255,255,255,0.1);
  color: white;
  outline: none;
  transition: border-color 0.2s;
}

.signup-row input::placeholder {
  color: rgba(255,255,255,0.5);
}

.signup-row input:focus {
  border-color: rgba(255,255,255,0.5);
}

.signup-row button {
  padding: 14px 28px;
  background: var(--pink);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.signup-row button:hover {
  background: #db2777;
  transform: translateY(-1px);
}

.subscribe-msg {
  margin-top: 12px;
  font-size: 0.9rem;
}

.subscribe-msg.success {
  color: #a7f3d0;
}

.subscribe-msg.error {
  color: #fca5a5;
}

/* === FOOTER === */
footer {
  text-align: center;
  padding: 32px 24px;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

footer a {
  color: var(--violet);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .hero h1 {
    font-size: 2.5rem;
  }

  .input-row {
    flex-direction: column;
  }

  .charts-row {
    grid-template-columns: 1fr;
  }

  .summary-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .product-grid {
    grid-template-columns: 1fr;
  }

  .signup-row {
    flex-direction: column;
  }

  .recommendation-card {
    flex-direction: column;
  }

  .input-card {
    padding: 24px;
  }

  .signup-card {
    padding: 32px 24px;
  }
}
