/* Base Variables & Reset */
:root {
  --hue: 226;
  
  /* Light Mode */
  --bg-color: hsl(var(--hue), 20%, 98%);
  --bg-card: hsl(0, 0%, 100%);
  --bg-card-hover: hsl(var(--hue), 10%, 96%);
  --text-main: hsl(var(--hue), 30%, 15%);
  --text-muted: hsl(var(--hue), 10%, 45%);
  --border-color: hsl(var(--hue), 20%, 90%);
  --border-focus: hsl(var(--hue), 80%, 60%);
  --primary: hsl(var(--hue), 80%, 55%);
  --primary-hover: hsl(var(--hue), 80%, 45%);
  --primary-fg: #fff;
  --danger: hsl(0, 80%, 60%);
  --success: hsl(150, 80%, 40%);
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 24px rgba(0,0,0,0.12);
  
  --radius: 8px;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg-color: hsl(var(--hue), 30%, 8%);
  --bg-card: hsl(var(--hue), 25%, 12%);
  --bg-card-hover: hsl(var(--hue), 25%, 16%);
  --text-main: hsl(var(--hue), 20%, 95%);
  --text-muted: hsl(var(--hue), 10%, 65%);
  --border-color: hsl(var(--hue), 20%, 20%);
  --border-focus: hsl(var(--hue), 80%, 60%);
  --primary: hsl(var(--hue), 80%, 60%);
  --primary-hover: hsl(var(--hue), 80%, 70%);
  --primary-fg: #fff;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 24px rgba(0,0,0,0.5);
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  transition: background-color var(--transition), color var(--transition);
}

a {
  color: inherit;
}

/* Layout */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--primary);
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.icon-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-bottom: 48px;
}

.stage {
  display: none;
  animation: fadeIn 0.4s ease forwards;
}
.stage.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Stage 1: Search */
.hero {
  text-align: center;
  padding: 64px 0 48px;
}
.hero h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}
.hero p {
  font-size: 1.125rem;
  color: var(--text-muted);
  max-width: 500px;
  margin: 0 auto;
}

.search-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: calc(var(--radius) * 1.5);
  padding: 32px;
  max-width: 600px;
  margin: 0 auto;
  box-shadow: var(--shadow-md);
}

.form-row {
  display: flex;
  gap: 16px;
}
.form-row .form-group {
  flex: 1;
}

.form-group {
  margin-bottom: 24px;
}
.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 8px;
}
.form-group label .req { color: var(--danger); }
.form-group label .opt { color: var(--text-muted); font-weight: 400; font-size: 0.75rem; }

input, select {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-main);
  font-family: inherit;
  font-size: 1rem;
  transition: all var(--transition);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px hsla(var(--hue), 80%, 60%, 0.15);
}
select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: var(--primary-fg);
  border: none;
  padding: 14px 24px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--transition), transform var(--transition);
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
}

/* Stage 2: Loading */
.loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  text-align: center;
}
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 24px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Stage 3: Results */
.results-header {
  margin-bottom: 32px;
}
.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  font-size: 0.875rem;
  transition: color var(--transition);
}
.btn-ghost:hover {
  color: var(--text-main);
}
.mb-4 { margin-bottom: 16px; }

.grid-layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 32px;
  align-items: start;
}

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

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

.biz-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  animation: cardIn 0.45s ease both;
}
.biz-card:hover {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-sm);
}
.biz-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.biz-card h4 {
  font-size: 1.125rem;
  margin-bottom: 4px;
}
.biz-card p.url {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.category-chip,
.website-badge {
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.category-chip {
  color: var(--primary);
  background: hsla(var(--hue), 80%, 60%, 0.11);
}

.website-badge.available {
  color: hsl(154, 80%, 30%);
  background: hsla(154, 75%, 48%, 0.13);
}

.website-badge.missing {
  color: hsl(35, 90%, 38%);
  background: hsla(35, 95%, 52%, 0.14);
}

.location {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.card-actions {
  display: flex;
  gap: 8px;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.875rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-color);
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  transition: all var(--transition);
}
.btn-sm:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}
.btn-sm.primary {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
}
.btn-sm.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.analysis-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: calc(var(--radius) * 1.5);
  padding: 32px;
  box-shadow: var(--shadow-md);
  min-height: 500px;
  position: sticky;
  top: 24px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  min-height: 400px;
}
.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.5;
}

.analysis-content h3 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.analysis-kicker {
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.personalized-message {
  color: var(--text-muted);
  margin-bottom: 14px;
}

.analysis-content .meta {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
@media (max-width: 600px) {
  .metrics-grid { grid-template-columns: 1fr; }
}

.metric-item {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: var(--radius);
}
.metric-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}
.progress-bg {
  height: 6px;
  background: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 1s cubic-bezier(0.1, 0.7, 0.1, 1);
}

.report-section h4 {
  font-size: 1rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.typing-container {
  background: var(--bg-color);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  font-family: var(--font-mono, monospace);
  font-size: 0.875rem;
  line-height: 1.6;
  white-space: pre-wrap;
  min-height: 150px;
  color: var(--text-main);
  position: relative;
}
.typing-container::after {
  content: '|';
  animation: blink 1s step-end infinite;
}
.typing-container.done::after {
  display: none;
}
@keyframes blink {
  50% { opacity: 0; }
}

.actions-row {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.modal.open {
  opacity: 1;
  pointer-events: auto;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
}
.modal-content {
  position: relative;
  background: var(--bg-card);
  width: 100%;
  max-width: 800px;
  border-radius: calc(var(--radius) * 1.5);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.1, 0.7, 0.1, 1);
}
.modal.open .modal-content {
  transform: translateY(0);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
}
.modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.modal-body {
  padding: 24px;
  background: var(--bg-color);
}

/* Browser Mockup */
.browser-chrome {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.browser-dots {
  display: flex;
  gap: 6px;
}
.browser-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-color);
}
.browser-dots span:nth-child(1) { background: #ff5f56; }
.browser-dots span:nth-child(2) { background: #ffbd2e; }
.browser-dots span:nth-child(3) { background: #27c93f; }

.browser-url {
  background: var(--bg-color);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex: 1;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-decoration: none;
}

.browser-url.disabled-link {
  pointer-events: none;
  opacity: 0.7;
}
.browser-viewport {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 0 0 var(--radius) var(--radius);
  height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a1a1a;
  text-align: center;
  padding: 32px;
}
[data-theme="dark"] .browser-viewport {
  background: #0a0a0a;
  color: #f0f0f0;
}
.preview-hero h1 {
  font-size: 2.5rem;
  margin-bottom: 16px;
}
.preview-hero p {
  color: #666;
  margin-bottom: 32px;
  font-size: 1.125rem;
}
[data-theme="dark"] .preview-hero p { color: #aaa; }
.social-links {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.social-badge {
  padding: 6px 12px;
  background: #f0f0f0;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  transition: transform var(--transition), background var(--transition);
}
[data-theme="dark"] .social-badge {
  background: #222;
}

.social-badge:hover {
  transform: translateY(-2px);
  background: hsla(var(--hue), 80%, 60%, 0.18);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 9999;
}
.toast {
  background: var(--text-main);
  color: var(--bg-color);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease forwards;
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
