/* Dashboard — Lead Scanner UI
   Extends theme.css. All colors reference CSS variables from theme.css.
*/

/* ===== NAV ===== */
.dash-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 60px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.dash-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.dash-brand-logo {
  font-size: 22px;
  color: var(--accent);
  line-height: 1;
}

.dash-brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--fg);
  letter-spacing: -0.02em;
}

.dash-nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.dash-nav-tag {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-transform: uppercase;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--bg-card);
}

/* ===== MAIN LAYOUT ===== */
.dash-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 28px 80px;
}

/* ===== STATS BAR ===== */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.dash-stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.dash-stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 6px;
}

.dash-stat-label {
  font-size: 13px;
  color: var(--fg-dim);
  font-family: var(--font-display);
  font-weight: 500;
}

/* ===== SCAN PANEL ===== */
.scan-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 28px;
}

.scan-panel-header {
  margin-bottom: 24px;
}

.scan-panel-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.scan-panel-sub {
  font-size: 0.9rem;
  color: var(--fg-muted);
}

/* Scan form */
.scan-form-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 140px;
}

.form-group--wide {
  flex: 2;
  min-width: 220px;
}

.form-group--action {
  flex: 0 0 auto;
  min-width: auto;
}

.form-label {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  text-transform: uppercase;
}

.form-optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg-dim);
}

.form-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2355556a' d='M0 0l6 8 6-8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.btn-scan {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #0a0a0f;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  padding: 11px 24px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
  height: 44px;
}

.btn-scan:hover { opacity: 0.88; }
.btn-scan:active { transform: scale(0.98); }
.btn-scan:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-scan-icon { font-size: 1.1rem; }

/* Scan status */
.scan-status {
  margin-top: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
}

.scan-status-inner {
  display: flex;
  align-items: center;
  gap: 14px;
}

.scan-pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.scan-status-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent);
}

.scan-status-sub {
  font-size: 0.82rem;
  color: var(--fg-muted);
  margin-top: 2px;
}

/* ===== BODY (SIDEBAR + TABLE) ===== */
.dash-body {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: start;
}

/* ===== SCANS SIDEBAR ===== */
.scans-sidebar {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--fg-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidebar-refresh {
  background: none;
  border: none;
  color: var(--fg-dim);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s;
}
.sidebar-refresh:hover { color: var(--accent); }

.scans-empty {
  padding: 24px 18px;
  font-size: 0.85rem;
  color: var(--fg-dim);
  text-align: center;
  line-height: 1.5;
}

.scans-list {
  max-height: 480px;
  overflow-y: auto;
}

.scan-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.scan-item:last-child { border-bottom: none; }
.scan-item:hover { background: var(--bg-card); }
.scan-item--active { background: var(--bg-card); border-left: 2px solid var(--accent); }

.scan-item-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.scan-item-sub {
  font-size: 0.78rem;
  color: var(--fg-muted);
}

.scan-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.scan-badge {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 100px;
}

.scan-badge--running { background: rgba(74, 240, 176, 0.12); color: var(--accent); }
.scan-badge--completed { background: rgba(61, 212, 230, 0.12); color: var(--accent-secondary); }
.scan-badge--failed { background: rgba(255, 95, 87, 0.12); color: #ff5f57; }

.scan-item-count {
  font-size: 0.75rem;
  color: var(--fg-dim);
}

/* ===== LEADS PANEL ===== */
.leads-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.leads-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.leads-panel-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--fg);
}

.leads-panel-count {
  font-size: 0.82rem;
  color: var(--fg-dim);
  font-family: var(--font-display);
}

.leads-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 64px 24px;
  color: var(--fg-dim);
}

.leads-empty-icon {
  font-size: 2.5rem;
  opacity: 0.3;
}

.leads-empty-text {
  font-size: 0.9rem;
  text-align: center;
}

.leads-table-wrap {
  overflow-x: auto;
}

.leads-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.leads-table th {
  background: var(--bg-card);
  padding: 10px 14px;
  text-align: left;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-dim);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.lead-row {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.lead-row:last-child { border-bottom: none; }
.lead-row:hover { background: var(--bg-card); }

.leads-table td {
  padding: 12px 14px;
  vertical-align: top;
}

.lead-name {
  font-weight: 600;
  color: var(--fg);
  line-height: 1.3;
}

.lead-type-badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  white-space: nowrap;
}

.lead-location { color: var(--fg); font-size: 0.88rem; }
.lead-zip { color: var(--fg-dim); font-size: 0.78rem; margin-top: 2px; }
.lead-contact-item { color: var(--fg-muted); font-size: 0.82rem; margin-bottom: 2px; white-space: nowrap; }
.lead-na { color: var(--fg-dim); }

/* Gap score */
.gap-score {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1;
  white-space: nowrap;
}

.gap-score-max {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--fg-dim);
  margin-left: 1px;
}

.gap-score--high { color: #ff6b6b; }
.gap-score--med  { color: #ffd166; }
.gap-score--low  { color: var(--accent); }
.gap-score--none { color: var(--fg-dim); }

.lead-gap-reason {
  color: var(--fg-muted);
  font-size: 0.82rem;
  line-height: 1.45;
  max-width: 260px;
}

.lead-recommended {
  color: var(--accent-secondary);
  font-size: 0.82rem;
  line-height: 1.45;
  max-width: 180px;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.75);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6);
}

.modal-close {
  position: sticky;
  top: 0;
  float: right;
  margin: 16px 16px 0 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: 1rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--fg); }

.modal-body {
  padding: 28px 32px 32px;
}

.modal-lead-header {
  margin-bottom: 28px;
}

.modal-lead-name {
  font-size: 1.4rem;
  margin-bottom: 6px;
}

.modal-lead-type {
  font-size: 0.85rem;
  color: var(--fg-muted);
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

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

.modal-section { padding: 16px; background: var(--bg-card); border-radius: 8px; }
.modal-section--full { grid-column: 1 / -1; }

.modal-section--highlight {
  border-left: 3px solid #ff6b6b;
  background: rgba(255, 107, 107, 0.06);
}

.modal-section--tip {
  border-left: 3px solid var(--accent);
  background: var(--accent-glow);
}

.modal-section--gap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-section-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 8px;
}

.modal-gap-score { font-size: 2rem; }
.modal-link { color: var(--accent); text-decoration: none; }
.modal-link:hover { text-decoration: underline; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 0.9rem;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--fg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
  z-index: 300;
  max-width: 360px;
}

.toast--show { opacity: 1; transform: translateY(0); }
.toast--success { border-color: var(--accent); color: var(--accent); }
.toast--error { border-color: #ff5f57; color: #ff5f57; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .dash-body { grid-template-columns: 1fr; }
  .scans-sidebar { max-height: 300px; }
  .scans-list { max-height: 240px; }
}

@media (max-width: 768px) {
  .dash-main { padding: 20px 16px 60px; }
  .dash-stats { grid-template-columns: repeat(2, 1fr); }
  .scan-form-row { flex-direction: column; }
  .form-group--action { width: 100%; }
  .btn-scan { width: 100%; justify-content: center; }
  .modal-grid { grid-template-columns: 1fr; }
  .modal-body { padding: 20px; }
}
