/* ============================================
   LEAD VALIDATOR - UI STYLESHEET
   Claude/Anthropic-Inspired Design System
   ============================================ */

/* ============================================
   DESIGN TOKENS
   ============================================ */
:root {
  /* Backgrounds - warm, paper-like */
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-2: #f5f3f0;
  
  /* Borders - warm gray */
  --border: #e8e6e1;
  --border-hover: #ddd9d2;
  
  /* Text - warm blacks and grays */
  --text: #1a1816;
  --text-secondary: #625f5a;
  --text-muted: #78726d;
  
  /* Accent - warm terracotta (Anthropic-style) */
  --accent: #c96442;
  --accent-hover: #b45636;
  --accent-light: #faf0ec;
  
  /* Semantic colors - muted, not neon */
  --success: #4a7c59;
  --success-light: #eef5f0;
  --warn: #c97d42;
  --warn-light: #fdf4ed;
  --danger: #c55044;
  --danger-light: #fcefed;
  --info: #5082a6;
  --info-light: #eef4f8;
  
  /* Shape & Motion */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(26, 24, 22, 0.04);
  --shadow-md: 0 4px 12px rgba(26, 24, 22, 0.06);
  --shadow-lg: 0 8px 24px rgba(26, 24, 22, 0.1);
  --transition: 180ms ease;
  
  /* Layout */
  --max-width: 1140px;
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
}

/* ============================================
   BASE STYLES
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   APP SHELL - Header & Layout
   ============================================ */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: var(--spacing-xl) var(--spacing-lg);
  text-align: center;
}

.header-content {
  max-width: var(--max-width);
  margin: 0 auto;
}

.header-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 var(--spacing-xs) 0;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.header-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin: 0;
  font-weight: 400;
}

.app-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px var(--spacing-lg);
}

.app-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-xl);
  align-items: start;
}

.app-section {
  min-width: 0;
}

.section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 var(--spacing-md) 0;
}

/* Legacy h1 hidden - using header instead */
body > h1 {
  display: none;
}

/* ============================================
   UPLOAD DROP ZONE
   ============================================ */
.upload-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 28px;
}

#drop-zone {
  border: 2px dashed var(--border);
  padding: 48px var(--spacing-xl);
  background: var(--surface-2);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition);
  text-align: center;
}

#drop-zone:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

#drop-zone:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

#drop-zone.hover {
  border-color: var(--success);
  background: var(--success-light);
}

.drop-zone-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto var(--spacing-md);
  color: var(--text-muted);
  transition: color var(--transition);
}

#drop-zone:hover .drop-zone-icon {
  color: var(--accent);
}

.drop-zone-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 var(--spacing-sm) 0;
}

.drop-zone-hint {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}

/* ============================================
   JOB CARDS (Active Jobs)
   ============================================ */
.job-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  background: var(--surface);
  text-align: left;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.job-block:hover {
  box-shadow: var(--shadow-md);
}

.progress-bar {
  height: 6px;
  background: linear-gradient(90deg, var(--accent), #d98a6a);
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 3px;
}

.progress-container {
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
  margin: var(--spacing-md) 0;
}

.status {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: var(--spacing-sm);
  font-weight: 500;
}

.log-line {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: var(--spacing-xs);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}

.actions {
  font-size: 13px;
  margin-top: var(--spacing-md);
}

.actions a,
.actions .cancel-btn {
  display: inline-block;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--surface-2);
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.actions a:hover,
.actions .cancel-btn:hover {
  background: var(--danger-light);
  color: var(--danger);
  border-color: rgba(197, 80, 68, 0.3);
}

.actions a:focus,
.actions .cancel-btn:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.close-job {
  position: absolute;
  top: var(--spacing-md);
  right: var(--spacing-md);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.close-job:hover {
  background: var(--danger-light);
  color: var(--danger);
}

.close-job:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.error-message {
  color: var(--danger);
  background: var(--danger-light);
  padding: var(--spacing-md);
  border-radius: var(--radius-sm);
  margin-top: var(--spacing-md);
  font-size: 13px;
  display: none;
  border: 1px solid rgba(197, 80, 68, 0.15);
}

.global-error {
  color: var(--danger);
  background: var(--danger-light);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-lg);
  display: none;
  border: 1px solid rgba(197, 80, 68, 0.15);
  font-size: 14px;
  text-align: left;
}

footer {
  text-align: center;
  padding: var(--spacing-xl) var(--spacing-lg);
  font-size: 13px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 48px;
}

.file-name {
  word-break: break-all;
  font-size: 16px;
  padding-right: 44px;
}

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

/* ============================================
   JOB SUMMARY STATS
   ============================================ */
.job-summary {
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  margin-top: var(--spacing-md);
  display: none;
}

.summary-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.stat {
  background: var(--surface);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid var(--border);
  font-weight: 500;
}

.stat strong {
  font-weight: 700;
}

.stat.valid {
  border-left: 3px solid var(--success);
  color: var(--success);
}

.stat.risky {
  border-left: 3px solid var(--warn);
  color: var(--warn);
}

.stat.invalid {
  border-left: 3px solid var(--danger);
  color: var(--danger);
}

.stat.score {
  border-left: 3px solid var(--info);
  color: var(--info);
}

.top-risks {
  font-size: 13px;
  color: var(--text-secondary);
}

.risk-tag {
  display: inline-block;
  background: var(--warn-light);
  color: var(--warn);
  padding: 3px var(--spacing-sm);
  border-radius: var(--radius-sm);
  font-size: 11px;
  margin: 2px;
  font-weight: 500;
}

/* ============================================
   MODAL (Column Picker)
   ============================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(26, 24, 22, 0.3);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--spacing-lg);
}

.modal-content {
  background: var(--surface);
  padding: var(--spacing-xl);
  border-radius: var(--radius-lg);
  max-width: 450px;
  max-height: 85vh;
  overflow-y: auto;
  width: 100%;
  text-align: left;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: modalIn 180ms ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-content h3 {
  margin: 0 0 var(--spacing-sm) 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.modal-content p {
  color: var(--text-secondary);
  margin: 0 0 var(--spacing-lg) 0;
  font-size: 14px;
  line-height: 1.5;
}

.column-option {
  display: flex;
  align-items: center;
  padding: 14px var(--spacing-md);
  margin: var(--spacing-sm) 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  background: var(--surface);
}

.column-option:hover {
  background: var(--surface-2);
  border-color: var(--border-hover);
}

.column-option.selected {
  background: var(--accent-light);
  border-color: var(--accent);
}

.column-option input {
  margin-right: var(--spacing-md);
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
}

.column-option:focus-within {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.modal-buttons {
  margin-top: var(--spacing-lg);
  display: flex;
  gap: var(--spacing-md);
  justify-content: flex-end;
}

.modal-buttons button {
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.modal-buttons button:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: var(--shadow-sm);
}

.btn-primary:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--border-hover);
  border-color: var(--border-hover);
}

.remember-choice {
  margin-top: var(--spacing-md);
  font-size: 13px;
  color: var(--text-secondary);
}

.remember-choice label {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.remember-choice input {
  margin-right: var(--spacing-sm);
  accent-color: var(--accent);
}

/* ============================================
   DOWNLOAD BUTTONS GRID
   ============================================ */
.download-section {
  margin-top: var(--spacing-md);
}

.download-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-sm);
}

.download-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-sm);
}

.download-grid a {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.download-grid a:hover {
  background: var(--info-light);
  color: var(--info);
  box-shadow: var(--shadow-sm);
}

.download-grid a:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.download-grid a.scores {
  grid-column: 1 / -1;
  background: var(--info-light);
  color: var(--info);
  border-color: rgba(80, 130, 166, 0.2);
  font-weight: 600;
}

.download-grid a.scores:hover {
  background: #d8e7f0;
  box-shadow: var(--shadow-sm);
}

.download-grid a.bundle {
  grid-column: 1 / -1;
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-weight: 600;
}

.download-grid a.bundle:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-md);
}

/* ============================================
   JOB HISTORY PANEL
   ============================================ */
.job-history-panel {
  text-align: left;
}

.job-history-panel h2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 20px 0;
  letter-spacing: -0.01em;
}

.history-buttons {
  display: flex;
  gap: var(--spacing-sm);
}

.job-history-panel h2 button {
  font-size: 12px;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.job-history-panel h2 button:hover {
  background: var(--surface-2);
  border-color: var(--border-hover);
}

.job-history-panel h2 button:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.btn-clear-local {
  color: var(--danger) !important;
  border-color: rgba(197, 80, 68, 0.2) !important;
}

.btn-clear-local:hover {
  background: var(--danger-light) !important;
}

.stalled-badge {
  font-weight: 600;
  color: var(--danger);
}

.history-job {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition);
}

.history-job:hover {
  box-shadow: var(--shadow-md);
}

.history-job.expanded {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.history-job-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  cursor: pointer;
  gap: var(--spacing-md);
}

.history-job-header::after {
  content: '';
  width: 20px;
  height: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%238a8783'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-size: contain;
  flex-shrink: 0;
  transition: transform var(--transition);
}

.history-job.expanded .history-job-header::after {
  transform: rotate(180deg);
}

.history-job-info {
  flex: 1;
  min-width: 0;
}

.history-job-filename {
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
  font-size: 14px;
}

.history-job-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: var(--spacing-xs);
}

.history-job-status {
  font-size: 11px;
  padding: var(--spacing-xs) 10px;
  border-radius: 20px;
  white-space: nowrap;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.history-job-status.completed {
  background: var(--success-light);
  color: var(--success);
}

.history-job-status.cancelled {
  background: var(--warn-light);
  color: var(--warn);
}

.history-job-status.failed {
  background: var(--danger-light);
  color: var(--danger);
}

.history-job-status.running {
  background: var(--info-light);
  color: var(--info);
}

.history-job-details {
  display: none;
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border);
}

.history-job.expanded .history-job-details {
  display: block;
}

.history-job-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border);
}

.history-job-actions span {
  font-size: 11px;
  color: var(--text-muted);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}

.history-job-actions button {
  padding: var(--spacing-sm) 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(197, 80, 68, 0.2);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all var(--transition);
}

.history-job-actions button:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.btn-delete {
  background: var(--danger-light);
  color: var(--danger);
}

.btn-delete:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.load-more-btn {
  display: block;
  width: 100%;
  padding: var(--spacing-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.load-more-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-hover);
}

.load-more-btn:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.no-history {
  text-align: center;
  color: var(--text-muted);
  padding: var(--spacing-xl) var(--spacing-lg);
  font-size: 14px;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
}

.empty-jobs {
  text-align: center;
  color: var(--text-muted);
  padding: 48px var(--spacing-lg);
  font-size: 14px;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
  margin-top: 20px;
}

.empty-jobs-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-sm);
}

.history-job-error-text {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 0 0 var(--spacing-sm) 0;
}

.history-job-error-detail {
  color: var(--danger);
  font-size: 12px;
  padding: var(--spacing-md);
  background: var(--danger-light);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(197, 80, 68, 0.15);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 900px) {
  .app-main {
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
  }
}

@media (max-width: 600px) {
  .app-header {
    padding: var(--spacing-lg) var(--spacing-md);
  }
  
  .header-title {
    font-size: 22px;
  }
  
  .app-container {
    padding: var(--spacing-lg) var(--spacing-md);
  }
  
  #drop-zone {
    padding: var(--spacing-xl) var(--spacing-lg);
  }
  
  .job-block,
  .history-job {
    padding: var(--spacing-md);
  }
  
  .modal-content {
    padding: var(--spacing-lg);
  }
  
  .download-grid {
    grid-template-columns: 1fr;
  }
  
  .download-grid a.scores,
  .download-grid a.bundle {
    grid-column: 1;
  }
  
  .modal-buttons {
    flex-direction: column;
  }
  
  .modal-buttons button {
    width: 100%;
  }
}

@media (max-width: 375px) {
  .app-header {
    padding: var(--spacing-md);
  }
  
  .header-title {
    font-size: 20px;
  }
  
  .app-container {
    padding: var(--spacing-md);
  }
  
  .upload-card {
    padding: var(--spacing-md);
  }
  
  #drop-zone {
    padding: var(--spacing-lg) var(--spacing-md);
  }
  
  .job-block,
  .history-job {
    padding: 14px;
  }
  
  .file-name {
    font-size: 14px;
  }
  
  .history-buttons {
    flex-direction: column;
    width: 100%;
  }
  
  .history-buttons button {
    width: 100%;
  }
}
