/* === UltimateScraper — Soft Fawn Theme === */

:root {
  --primary: #d5b572;
  --primary-dark: #c4a35e;
  --primary-light: #e8d4a0;
  --dark: #201f14;
  --dark-soft: #3a3828;
  --bg: #f8f2e1;
  --bg-card: #ffffff;
  --bg-section: #faf7ef;
  --text: #201f14;
  --text-muted: #7a7560;
  --text-light: #a09b8a;
  --border: #e8e2d0;
  --border-focus: #d5b572;
  --success: #5a8a5e;
  --error: #c45a4a;
  --google-blue: #4285f4;
  --osm-green: #7ebc6f;
  --shadow-sm: 0 1px 3px rgba(32, 31, 20, 0.06);
  --shadow-md: 0 4px 16px rgba(32, 31, 20, 0.08);
  --shadow-lg: 0 8px 32px rgba(32, 31, 20, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

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

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === Header === */

.header {
  background: var(--dark);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--bg);
}

.logo-icon { color: var(--primary); }

.logo-img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.logo-text {
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.3px;
}

.header-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
  background: rgba(213, 181, 114, 0.12);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid rgba(213, 181, 114, 0.25);
}

/* === Main === */

.main { flex: 1; padding: 40px 24px 60px; }
.container { max-width: 800px; margin: 0 auto; }

/* === Hero === */

.hero { text-align: center; margin-bottom: 40px; }

.hero h1 {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.2;
  margin-bottom: 12px;
}

.highlight { color: var(--primary-dark); }

.hero-sub {
  font-size: 16px;
  color: var(--text-muted);
  max-width: 520px;
  margin: 0 auto;
  line-height: 1.6;
}

/* === Form Card === */

.form-card {
  background: var(--bg-card);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

/* === Sections === */

.section {
  padding: 28px 32px;
  border-bottom: 1px solid var(--border);
}

.section:last-child { border-bottom: none; }

.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-light);
  margin-bottom: 20px;
}

.section-viz {
  background: var(--bg-section);
}

.section-submit {
  background: var(--bg-section);
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
}

/* === Grid === */

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* === Fields === */

.field { margin-bottom: 20px; }
.field:last-child { margin-bottom: 0; }

.field label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 8px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input[type="text"]:focus,
input[type="password"]:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(213, 181, 114, 0.15);
}

input::placeholder { color: var(--text-light); }

.input-with-icon { position: relative; }

.input-with-icon svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

.input-with-icon input { padding-left: 42px; }

/* === Tooltips === */

.tooltip-trigger {
  color: var(--text-light);
  cursor: help;
  position: relative;
  display: inline-flex;
}

.tooltip-trigger:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--dark);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  width: 260px;
  z-index: 50;
  pointer-events: none;
  box-shadow: var(--shadow-md);
}

/* === Sliders === */

.slider-container {
  display: flex;
  align-items: center;
  gap: 16px;
}

.slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  background: linear-gradient(to right, var(--primary) 0%, var(--primary) var(--fill, 0%), var(--border) var(--fill, 0%), var(--border) 100%);
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid var(--bg-card);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: transform var(--transition);
}

.slider::-webkit-slider-thumb:hover { transform: scale(1.15); }

.slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid var(--bg-card);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.slider-value {
  min-width: 44px;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--primary-dark);
  background: rgba(213, 181, 114, 0.12);
  padding: 4px 10px;
  border-radius: 6px;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
  padding: 0 2px;
}

/* === Tag Lists === */

.tag-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.tag-group {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.tag-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: rgba(213, 181, 114, 0.06);
  border-bottom: 1px solid var(--border);
}

.tag-group-header svg { color: var(--primary-dark); }

.tag-count {
  margin-left: auto;
  background: var(--primary);
  color: var(--dark);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px;
  min-height: 48px;
  max-height: 180px;
  overflow-y: auto;
}

.tags-empty {
  color: var(--text-light);
  font-size: 13px;
  font-style: italic;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(213, 181, 114, 0.1);
  border: 1px solid rgba(213, 181, 114, 0.25);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text);
  cursor: default;
  transition: all var(--transition);
  max-width: 100%;
}

.tag:hover {
  border-color: var(--primary);
  background: rgba(213, 181, 114, 0.18);
}

.tag-original {
  background: rgba(213, 181, 114, 0.22);
  border-color: var(--primary);
  font-weight: 600;
  color: var(--primary-dark);
}

.tag-text {
  cursor: text;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-remove {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  transition: color var(--transition);
  flex-shrink: 0;
}

.tag-remove:hover { color: var(--error); }

.tag-add {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-light);
  cursor: pointer;
  transition: all var(--transition);
}

.tag-add:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: rgba(213, 181, 114, 0.06);
}

.tag-input-wrapper {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.tag-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.tag-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(213, 181, 114, 0.15);
}

.tag-input::placeholder { color: var(--text-light); }

.tag-slider {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: rgba(213, 181, 114, 0.04);
}

.tag-slider label {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}

.tag-slider-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.tag-slider .slider-container { gap: 10px; }

.tag-slider .slider-value {
  font-size: 13px;
  padding: 2px 8px;
  min-width: 36px;
}

.tag-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-light);
  margin-bottom: 20px;
}

/* === Matrix Visualization === */

.matrix-container {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.matrix-axis {
  flex-shrink: 0;
  width: 130px;
  border-right: 2px solid var(--primary-light);
}

.axis-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: rgba(213, 181, 114, 0.08);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.axis-header svg { color: var(--primary-dark); }

.axis-items { padding: 4px 0; }

.axis-item {
  padding: 5px 12px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}

.axis-item-original {
  font-weight: 600;
  color: var(--primary-dark);
  border-left-color: var(--primary);
  background: rgba(213, 181, 114, 0.06);
}

.matrix-grid-wrapper {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

.matrix-x-header {
  border-bottom: 1px solid var(--border);
  background: rgba(213, 181, 114, 0.08);
}

.matrix-x-header .axis-header {
  border-bottom: none;
}

.axis-items-h {
  display: flex;
  padding: 0 4px 6px;
  gap: 2px;
  overflow: hidden;
}

.axis-item-h {
  padding: 3px 8px;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.axis-item-h.axis-item-original {
  font-weight: 600;
  color: var(--primary-dark);
}

.matrix-grid {
  display: grid;
  padding: 4px;
  gap: 2px;
}

.matrix-cell {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 3px;
  transition: all 0.3s ease;
  position: relative;
  cursor: pointer;
  min-width: 6px;
  min-height: 6px;
}

.matrix-cell-active {
  background: var(--primary);
  opacity: 0.6;
}

.matrix-cell-active:hover {
  opacity: 1;
  transform: scale(1.5);
  z-index: 2;
  box-shadow: 0 2px 12px rgba(213, 181, 114, 0.6);
  border-radius: 4px;
}

.matrix-cell-original {
  background: var(--primary-dark);
  opacity: 0.9;
}

.matrix-cell-original:hover {
  opacity: 1;
  transform: scale(1.5);
  z-index: 2;
  box-shadow: 0 2px 12px rgba(196, 163, 94, 0.7);
}

.matrix-cell-overflow {
  background: var(--border);
  opacity: 0.4;
  display: flex;
  align-items: center;
  justify-content: center;
}

.matrix-fade-right {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 40px;
  background: linear-gradient(to right, transparent, var(--bg-card));
  pointer-events: none;
  z-index: 1;
}

.matrix-fade-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 30px;
  background: linear-gradient(to bottom, transparent, var(--bg-card));
  pointer-events: none;
  z-index: 1;
}

/* === Stats Dashboard === */

.stats-dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: all var(--transition);
}

.stat-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-searches .stat-icon { background: rgba(213, 181, 114, 0.15); color: var(--primary-dark); }
.stat-results .stat-icon { background: rgba(66, 133, 244, 0.1); color: var(--google-blue); }
.stat-unique .stat-icon { background: rgba(90, 138, 94, 0.1); color: var(--success); }
.stat-emails .stat-icon { background: rgba(196, 90, 74, 0.1); color: var(--error); }

.stat-content { min-width: 0; }

.stat-number {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 2px;
}

.stat-detail {
  font-size: 10px;
  color: var(--text-light);
  margin-top: 2px;
}

/* === Pipeline === */

.pipeline {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  flex-wrap: nowrap;
}

.pipeline-step {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pipe-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.pipe-input { background: rgba(213, 181, 114, 0.15); color: var(--primary-dark); }
.pipe-google { background: rgba(66, 133, 244, 0.12); color: var(--google-blue); }
.pipe-osm { background: rgba(126, 188, 111, 0.12); color: var(--osm-green); }
.pipe-dedup { background: rgba(90, 138, 94, 0.12); color: var(--success); }
.pipe-email { background: rgba(196, 90, 74, 0.12); color: var(--error); }
.pipe-output { background: rgba(32, 31, 20, 0.08); color: var(--dark-soft); }

.pipe-text {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.pipe-text strong {
  color: var(--text);
  font-weight: 600;
}

.pipe-arrow {
  color: var(--text-light);
  flex-shrink: 0;
  display: flex;
}

.pipe-plus {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-light);
  flex-shrink: 0;
}

/* === Checkboxes === */

.checkbox-group { display: flex; gap: 16px; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}

.checkbox-label input[type="checkbox"] { display: none; }

.checkmark {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.checkbox-label input:checked + .checkmark {
  background: var(--primary);
  border-color: var(--primary);
}

.checkbox-label input:checked + .checkmark::after {
  content: '';
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

.checkbox-text {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}

.checkbox-text svg { color: var(--text-light); }

/* === Radio Buttons === */

.radio-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.radio-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.radio-label:hover {
  border-color: var(--primary-light);
  background: rgba(213, 181, 114, 0.04);
}

.radio-label input { display: none; }

.radio-mark {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all var(--transition);
}

.radio-label input:checked ~ .radio-mark { border-color: var(--primary); }

.radio-label input:checked ~ .radio-mark::after {
  content: '';
  width: 10px;
  height: 10px;
  background: var(--primary);
  border-radius: 50%;
}

.radio-label input:checked ~ .radio-content .radio-title { color: var(--primary-dark); }

.radio-label:has(input:checked) {
  border-color: var(--primary);
  background: rgba(213, 181, 114, 0.06);
}

.radio-content { display: flex; flex-direction: column; gap: 2px; }
.radio-title { font-size: 14px; font-weight: 600; }
.radio-desc { font-size: 12px; color: var(--text-muted); }

/* === Expandable === */

.expand-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  user-select: none;
  transition: color var(--transition);
}

.expand-toggle:hover { color: var(--text); }
.expand-toggle svg { transition: transform var(--transition); }
.expand-toggle.open svg { transform: rotate(90deg); }
.expand-content { margin-top: 12px; }

/* === Submit Button === */

.btn-submit {
  width: 100%;
  max-width: 400px;
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: var(--dark);
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all var(--transition);
}

.btn-submit:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(213, 181, 114, 0.4);
}

.btn-submit:active:not(:disabled) { transform: translateY(0); }
.btn-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-loader { display: flex; align-items: center; gap: 8px; }
.spinner { animation: spin 1s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* === Status === */

.status-message {
  margin-top: 24px;
  padding: 20px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
}

.status-message.success {
  background: rgba(90, 138, 94, 0.08);
  border: 1px solid rgba(90, 138, 94, 0.2);
  color: var(--success);
}

.status-message.error {
  background: rgba(196, 90, 74, 0.08);
  border: 1px solid rgba(196, 90, 74, 0.2);
  color: var(--error);
}

/* === Footer === */

.footer { text-align: center; padding: 24px; font-size: 13px; color: var(--text-light); }
.footer a { color: var(--primary-dark); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* === Responsive === */

@media (max-width: 768px) {
  .stats-dashboard {
    grid-template-columns: repeat(2, 1fr);
  }

  .pipeline {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .matrix-axis { width: 100px; }
}

@media (max-width: 640px) {
  .hero h1 { font-size: 28px; }
  .hero-sub { font-size: 14px; }
  .section { padding: 24px 20px; }
  .row-2 { grid-template-columns: 1fr; gap: 16px; }
  .radio-group { grid-template-columns: 1fr; }
  .tag-section { grid-template-columns: 1fr; }
  .checkbox-group { flex-direction: column; gap: 12px; }

  .stats-dashboard { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; flex-direction: column; gap: 8px; }
  .stat-icon { width: 32px; height: 32px; }
  .stat-number { font-size: 18px; }

  .matrix-container { flex-direction: column; }
  .matrix-axis {
    width: 100%;
    border-right: none;
    border-bottom: 2px solid var(--primary-light);
  }
  .axis-items { display: flex; overflow-x: auto; padding: 4px 8px; gap: 4px; }
  .axis-item { padding: 3px 8px; font-size: 11px; border-left: none; border-bottom: 2px solid transparent; }
  .axis-item-original { border-left-color: transparent; border-bottom-color: var(--primary); }

  .tooltip-trigger:hover::after {
    left: 0;
    transform: none;
    width: 220px;
  }
}
