/* ============================================================
   CSS Variables & Reset
   ============================================================ */
:root {
  --color-bg: #f5f6fa;
  --color-surface: #ffffff;
  --color-primary: #4f6ef7;
  --color-primary-hover: #3b5de7;
  --color-accent: #8b5cf6;
  --color-text: #2c3e50;
  --color-text-secondary: #7f8c9b;
  --color-border: #e2e6ed;
  --color-success: #27ae60;
  --color-error: #e74c3c;
  --color-warning: #f39c12;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============================================================
   Layout
   ============================================================ */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 20px;
}

/* ============================================================
   Header
   ============================================================ */
.header {
  text-align: center;
  margin-bottom: 36px;
}

.header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 4px;
}

.subtitle {
  color: var(--color-text-secondary);
  font-size: 0.92rem;
}

/* ============================================================
   Input Section
   ============================================================ */
.input-section {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.input-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.input-row {
  display: flex;
  gap: 10px;
}

.input-row input {
  flex: 1;
  padding: 11px 16px;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.95rem;
  transition: border-color 0.2s;
  outline: none;
}

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

.hint {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--color-text-secondary);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  padding: 11px 24px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn-debug {
  background: #f5f0ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.btn-debug:hover:not(:disabled) {
  background: #ede9fe;
}

/* ============================================================
   Status
   ============================================================ */
.status-area {
  margin-top: 18px;
}

.status-area.hidden,
.result-section.hidden,
.analysis-section.hidden,
.error-section.hidden {
  display: none;
}

.status-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: #f0f4ff;
  border-radius: 8px;
  border: 1px solid #d6e0ff;
  font-size: 0.9rem;
}

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

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

/* ============================================================
   Result Section
   ============================================================ */
.result-section h2,
.analysis-section h2,
.recent-section h2 {
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.result-card,
.analysis-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.analysis-section {
  margin-top: 20px;
}

.analysis-card {
  border-left: 4px solid var(--color-accent);
}

.field-list {
  list-style: none;
}

.field-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

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

.field-label {
  font-weight: 600;
  min-width: 80px;
  color: var(--color-text-secondary);
  flex-shrink: 0;
  font-size: 0.88rem;
}

.field-value {
  word-break: break-word;
  font-size: 0.92rem;
}

.field-value.html-content {
  line-height: 1.8;
}

.field-value.html-content p {
  margin-bottom: 6px;
}

/* ============================================================
   Analysis Card
   ============================================================ */
.analysis-summary {
  background: #f0f4ff;
  padding: 14px 18px;
  border-radius: 8px;
  font-size: 0.92rem;
  line-height: 1.7;
  margin-bottom: 16px;
}

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

.analysis-item {
  padding: 12px 16px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

.analysis-item.full-width {
  grid-column: 1 / -1;
}

.analysis-item .alabel {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.analysis-item .avalue {
  font-size: 0.9rem;
}

.keyword-tag {
  display: inline-block;
  background: #e0e7ff;
  color: #3730a3;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.82rem;
  margin: 2px 4px 2px 0;
}

.salary-highlight {
  color: var(--color-primary);
  font-weight: 700;
  font-size: 1.05rem;
}

/* ============================================================
   Error Section
   ============================================================ */
.error-section {
  margin-bottom: 24px;
}

.error-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
  background: #fef2f2;
  border-radius: 8px;
  border: 1px solid #fecaca;
}

.error-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.error-card strong {
  display: block;
  margin-bottom: 4px;
}

.error-card p {
  font-size: 0.88rem;
  color: #991b1b;
}

/* ============================================================
   Recent Tasks
   ============================================================ */
.recent-section {
  margin-top: 24px;
}

.recent-list {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.empty-hint {
  padding: 24px;
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.88rem;
}

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

.task-url {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 12px;
}

.task-badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
  flex-shrink: 0;
}

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

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

.badge-completed {
  background: #d1fae5;
  color: #065f46;
}

.badge-failed {
  background: #fee2e2;
  color: #991b1b;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 640px) {
  .container {
    padding: 16px 12px;
  }

  .header h1 {
    font-size: 1.5rem;
  }

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

  .btn {
    width: 100%;
  }

  .field-item {
    flex-direction: column;
    gap: 2px;
  }

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