/* ============================================================
   步态报告分析系统 — 主样式表
   ============================================================ */

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

:root {
  --primary:       #4361ee;
  --primary-light: #eef0fd;
  --primary-dark:  #3352d0;
  --success:       #2ecc71;
  --success-dark:  #27ae60;
  --danger:        #e74c3c;
  --warning:       #f39c12;
  --left-color:    #4361ee;
  --right-color:   #e84393;
  --diff-pos:      #e74c3c;
  --diff-neg:      #2ecc71;
  --bg:            #f0f2f8;
  --surface:       #ffffff;
  --border:        #e2e6f0;
  --text:          #1a1d2e;
  --text-muted:    #6b7280;
  --radius:        12px;
  --shadow:        0 2px 16px rgba(67,97,238,.08);
  --shadow-hover:  0 6px 24px rgba(67,97,238,.16);
  --transition:    .22s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
#app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  font-size: 2rem;
  color: var(--primary);
  background: var(--primary-light);
  border-radius: 12px;
  padding: 10px 14px;
}

.header-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.header-subtitle {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Main ── */
#app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
  flex: 1;
  width: 100%;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 20px;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover:not(:disabled) {
  background: var(--success-dark);
  border-color: var(--success-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(46,204,113,.3);
}

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-upload {
  margin-top: 20px;
  font-size: 1rem;
  padding: 12px 28px;
}

.btn-sm {
  padding: 5px 14px;
  font-size: .82rem;
}

/* ── Drop Zone ── */
#upload-section {
  display: flex;
  justify-content: center;
  padding: 40px 0;
}

.drop-zone {
  background: var(--surface);
  border: 2.5px dashed var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 640px;
  padding: 60px 40px;
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.drop-zone-icon {
  font-size: 4rem;
  color: var(--primary);
  margin-bottom: 20px;
  opacity: .8;
}

.drop-zone-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text);
}

.drop-zone-desc {
  color: var(--text-muted);
  font-size: .95rem;
  margin-bottom: 6px;
}

.drop-zone-hint {
  font-size: .78rem;
  color: #adb5bd;
  margin-bottom: 4px;
}

/* ── Progress ── */
#progress-section {
  display: flex;
  justify-content: center;
  padding: 40px 0;
}

.progress-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 48px 48px;
  text-align: center;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 480px;
}

.progress-icon {
  font-size: 3rem;
  color: var(--primary);
  margin-bottom: 20px;
}

.progress-icon.spin i { animation: spin 1s linear infinite; }

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

.progress-text {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.progress-bar-wrap {
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #8b5cf6);
  border-radius: 99px;
  width: 0%;
  transition: width .4s ease;
}

/* ── Section Cards ── */
.section-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  overflow: hidden;
  border: 1px solid var(--border);
  animation: fadeInUp .4s ease;
}

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

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #f8f9ff 0%, #ffffff 100%);
}

.card-header i {
  color: var(--primary);
  font-size: 1.1rem;
}

.card-header h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.card-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Info Grid ── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0;
  padding: 0;
}

.info-item {
  padding: 18px 24px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.info-item:nth-child(n) {
  border-right: 1px solid var(--border);
}

.info-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.info-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

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

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  padding: 20px 24px;
}

.stat-card {
  background: var(--bg);
  border-radius: 10px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.stat-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.stat-label {
  font-size: .76rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.stat-values {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 6px;
}

.stat-left {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--left-color);
}

.stat-right {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--right-color);
}

.stat-unit {
  font-size: .72rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.stat-diff {
  font-size: .78rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  display: inline-block;
}

.stat-diff.positive { background: #fdecea; color: var(--diff-pos); }
.stat-diff.negative { background: #e8f8ef; color: var(--diff-neg); }
.stat-diff.neutral  { background: #f0f2f8; color: var(--text-muted); }

/* ── Data Table ── */
.table-wrap {
  overflow-x: auto;
  padding: 0 0 4px;
}

.search-input {
  padding: 7px 14px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: .88rem;
  outline: none;
  transition: border-color var(--transition);
  min-width: 180px;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(67,97,238,.12);
}

.select-input {
  padding: 7px 12px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: .88rem;
  outline: none;
  cursor: pointer;
  background: #fff;
  transition: border-color var(--transition);
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.data-table th {
  background: #f8f9ff;
  color: var(--text-muted);
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 12px 20px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr:hover td {
  background: var(--primary-light);
}

.data-table .left-col  { color: var(--left-color);  font-weight: 600; }
.data-table .right-col { color: var(--right-color); font-weight: 600; }
.data-table .diff-col  { font-weight: 600; }

.param-name { font-weight: 500; }
.param-unit {
  font-size: .78rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
}

.side-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: .76rem;
  font-weight: 600;
}

.side-badge.left  { background: #eef0fd; color: var(--left-color); }
.side-badge.right { background: #fce4f0; color: var(--right-color); }
.side-badge.even  { background: #f0f2f8; color: var(--text-muted); }

.diff-positive { color: var(--diff-pos); }
.diff-negative { color: var(--diff-neg); }
.diff-zero     { color: var(--text-muted); }

/* ── Charts ── */
.chart-container {
  padding: 24px;
  position: relative;
}

/* ── Raw Text ── */
.raw-text {
  background: #1e2033;
  color: #a8b3cf;
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: .8rem;
  line-height: 1.7;
  padding: 20px 24px;
  overflow-x: auto;
  max-height: 400px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Error ── */
#error-section {
  display: flex;
  justify-content: center;
  padding: 40px 0;
}

.error-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 48px 40px;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 480px;
  width: 100%;
  border-top: 4px solid var(--danger);
}

.error-icon {
  font-size: 3rem;
  color: var(--danger);
  margin-bottom: 16px;
}

.error-card h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--danger);
}

.error-card p {
  color: var(--text-muted);
  font-size: .9rem;
  margin-bottom: 24px;
  line-height: 1.6;
}

/* ── Footer ── */
#app-footer {
  text-align: center;
  padding: 20px;
  font-size: .8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ── Utilities ── */
.hidden { display: none !important; }

/* ── Legend ── */
.chart-legend {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .85rem;
  color: var(--text-muted);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.legend-dot.left  { background: var(--left-color); }
.legend-dot.right { background: var(--right-color); }

/* ── Responsive ── */
@media (max-width: 768px) {
  #app-main { padding: 20px 16px; }
  .header-inner { padding: 12px 16px; }
  .header-title { font-size: 1rem; }
  .drop-zone { padding: 40px 20px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .info-grid  { grid-template-columns: repeat(2, 1fr); }
  .data-table th, .data-table td { padding: 10px 14px; }
  .btn { padding: 8px 14px; font-size: .84rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .info-grid  { grid-template-columns: 1fr 1fr; }
  .header-actions { width: 100%; justify-content: flex-end; }
}

/* ── Parse Info Banner ── */
.parse-banner {
  background: linear-gradient(135deg, #eef0fd, #f0f8ff);
  border: 1px solid #c5cae0;
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 12px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .88rem;
  color: var(--primary);
  animation: fadeInUp .3s ease;
}

.parse-banner i { font-size: 1rem; }

/* ── No-data row ── */
.no-data-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
  font-size: .9rem;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #c5cae0; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }
