/* ─────────────────────────────────────────────────────────────────────────────
   _research.css — 연구 분석 대시보드 전용 스타일
───────────────────────────────────────────────────────────────────────────── */

/* 페이지 레이아웃 */
.research-dashboard {
  padding: 2rem 0 4rem;
}

.research-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.research-page-title h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-gray-900, #111827);
  margin: 0 0 0.25rem;
}

.research-page-subtitle {
  font-size: 0.9rem;
  color: var(--color-gray-500, #6b7280);
  margin: 0;
}

.research-header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.research-last-updated {
  font-size: 0.8rem;
  color: var(--color-gray-400, #9ca3af);
}

/* 탭 */
.research-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid #e5e7eb;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.research-tab {
  padding: 0.625rem 1.125rem;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.research-tab:hover { color: #374151; }

.research-tab.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
}

/* 탭 컨텐츠 */
.research-tab-content { display: none; }
.research-tab-content.active { display: block; }

/* KPI 카드 그리드 */
.research-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 900px) {
  .research-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .research-kpi-grid { grid-template-columns: 1fr; }
}

.research-kpi-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.kpi-icon {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-icon-blue { background: #dbeafe; color: #2563eb; }
.kpi-icon-green { background: #d1fae5; color: #059669; }
.kpi-icon-purple { background: #ede9fe; color: #7c3aed; }
.kpi-icon-orange { background: #ffedd5; color: #ea580c; }

.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: #111827;
  line-height: 1;
  margin-bottom: 0.2rem;
}

.kpi-label {
  font-size: 0.78rem;
  color: #6b7280;
}

/* 연구 카드 */
.research-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.research-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid #f3f4f6;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.research-card-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #111827;
  margin: 0;
}

.research-card-hint {
  font-size: 0.78rem;
  color: #9ca3af;
}

.research-card-body {
  padding: 1.25rem;
}

/* 2열 그리드 */
.research-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 768px) {
  .research-grid-2 { grid-template-columns: 1fr; }
}

/* 테이블 */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.research-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.research-table th {
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-weight: 600;
  color: #374151;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
}

.research-table td {
  padding: 0.55rem 0.75rem;
  color: #374151;
  border-bottom: 1px solid #f3f4f6;
}

.research-table tbody tr:hover { background: #f9fafb; }
.research-table tbody tr:last-child td { border-bottom: none; }

.research-table-sm .research-table th,
.research-table-sm .research-table td {
  padding: 0.45rem 0.6rem;
  font-size: 0.82rem;
}

.table-loading {
  text-align: center;
  color: #9ca3af;
  padding: 2rem !important;
  font-style: italic;
}

.table-footnote {
  font-size: 0.78rem;
  color: #9ca3af;
  margin: 0.75rem 0 0;
}

/* 필터 바 */
.research-filter-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.research-filter-bar label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #374151;
  font-weight: 500;
}

.research-select {
  padding: 0.4rem 0.7rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #374151;
  background: #fff;
  cursor: pointer;
  min-width: 130px;
}

.research-input {
  padding: 0.4rem 0.7rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #374151;
}

.btn-sm {
  padding: 0.4rem 0.875rem;
  font-size: 0.85rem;
}

/* 규범 데이터 */
.normative-item-selector {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

/* 공식 카드 */
.formula-card .research-card-body {
  padding: 1.5rem;
}

.formula-display {
  background: #f8fafc;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid #e2e8f0;
}

.formula-line {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.formula-line:last-child { margin-bottom: 0; }

.formula-label {
  font-weight: 600;
  color: #374151;
  font-size: 0.9rem;
  white-space: nowrap;
  padding-top: 0.1em;
}

.formula-eq {
  font-family: 'Courier New', monospace;
  font-size: 0.88rem;
  color: #1e293b;
  line-height: 1.6;
}

.formula-term {
  display: inline-block;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-weight: 600;
  margin: 0 0.15rem;
}

.formula-term.positive { background: #d1fae5; color: #065f46; }
.formula-term.negative { background: #fee2e2; color: #991b1b; }

.formula-secondary { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid #e2e8f0; }

.formula-var-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
}

@media (max-width: 900px) {
  .formula-var-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 480px) {
  .formula-var-grid { grid-template-columns: repeat(2, 1fr); }
}

.formula-var-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.875rem 0.75rem;
  text-align: center;
  background: #f9fafb;
}

.formula-var-card.negative { background: #fff5f5; border-color: #fecaca; }

.fv-coef {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  color: #2563eb;
  margin-bottom: 0.2rem;
}

.formula-var-card.negative .fv-coef { color: #dc2626; }

.fv-name {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.15rem;
}

.fv-unit {
  display: block;
  font-size: 0.72rem;
  color: #9ca3af;
  margin-bottom: 0.5rem;
}

.fv-dist-mini {
  height: 32px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 1px;
}

.fv-dist-mini .bar {
  width: 4px;
  background: #93c5fd;
  border-radius: 1px;
  transition: height 0.3s;
}

.formula-var-card.negative .fv-dist-mini .bar { background: #fca5a5; }

/* 종단 분석 요약 */
.longitudinal-summary {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.lng-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.lng-value {
  font-size: 2rem;
  font-weight: 700;
  color: #374151;
}

.lng-value.improved { color: #059669; }
.lng-value.stable { color: #d97706; }
.lng-value.declined { color: #dc2626; }

.lng-label {
  font-size: 0.8rem;
  color: #6b7280;
}

/* 내보내기 */
.export-filter-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: end;
}

@media (max-width: 700px) {
  .export-filter-grid { grid-template-columns: 1fr; }
}

.export-filter-group { display: flex; flex-direction: column; gap: 0.4rem; }

.export-filter-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: #374151;
}

.export-date-range {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.export-date-range span { color: #9ca3af; font-size: 0.85rem; }

.export-columns-info {
  background: #f8fafc;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  border: 1px solid #e2e8f0;
}

.export-columns-info h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  margin: 0 0 0.75rem;
}

.export-columns-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.export-col-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: 'Courier New', monospace;
  font-weight: 500;
}

.export-col-badge.id { background: #e0e7ff; color: #3730a3; }
.export-col-badge.demog { background: #d1fae5; color: #065f46; }
.export-col-badge.body { background: #fef3c7; color: #92400e; }
.export-col-badge.fitness { background: #dbeafe; color: #1e40af; }
.export-col-badge.score { background: #fce7f3; color: #9d174d; }

.export-actions {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.export-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.export-disclaimer {
  font-size: 0.78rem;
  color: #9ca3af;
  line-height: 1.5;
  max-width: 520px;
  margin: 0;
}

/* 로딩 오버레이 */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid #e5e7eb;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-message {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: #374151;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* 개선/악화 배지 */
.badge-improved { color: #059669; font-weight: 600; }
.badge-stable { color: #d97706; font-weight: 600; }
.badge-declined { color: #dc2626; font-weight: 600; }

/* active 내비게이션 링크 */
.nav-menu a.active {
  color: #2563eb;
  font-weight: 600;
}
