/**
 * modules/satisfaction-analyzer.css
 * 만족도 분석 & 보고서 생성기 스타일시트
 */

/* 1. 기본 레이아웃 & 컨테이너 */
.analyzer-card-wrapper {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  margin-bottom: 32px;
  transition: all 0.3s ease;
}

body.rpa-light-theme .analyzer-card-wrapper {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(241, 245, 249, 0.8);
}

/* 테마 분기 컬러 대응 */
:root {
  --color-score-5: #3b82f6; /* 5점: 파란색 (긍정 우수) */
  --color-score-4: #60a5fa; /* 4점: 연한 파란색 (긍정) */
  --color-score-3: #f59e0b; /* 3점: 노란색 (보통/중립) */
  --color-score-2: #fca5a5; /* 2점: 연한 빨간색 (부정) */
  --color-score-1: #ef4444; /* 1점: 빨간색 (부정 심각) */
  --color-accent-bar: var(--primary-gold, #d97706);
}

body.theme-teal {
  --color-accent-bar: var(--primary-teal, #00a896);
}

/* 2. 입력 영역 & 탭 스타일 */
.analyzer-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 8px;
}

.tab-btn {
  background: none;
  border: none;
  padding: 10px 20px;
  font-size: 1rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  background: rgba(0, 0, 0, 0.03);
  color: #1e293b;
}

.tab-btn.active {
  background: var(--color-accent-bar);
  color: #ffffff;
}
body.theme-teal .tab-btn.active {
  color: #ffffff;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

/* CSV 업로드 드롭존 */
.file-upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 40px 20px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.5);
  transition: all 0.2s ease;
}

.file-upload-label:hover, .file-upload-label.dragover {
  border-color: var(--color-accent-bar);
  background: rgba(255, 255, 255, 0.9);
}

.file-upload-label i {
  font-size: 3rem;
  color: #94a3b8;
  margin-bottom: 12px;
  transition: transform 0.2s ease;
}

.file-upload-label:hover i {
  transform: translateY(-4px);
  color: var(--color-accent-bar);
}

.file-upload-label span {
  font-size: 0.95rem;
  color: #64748b;
  text-align: center;
}

.file-upload-label .file-hint {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-top: 6px;
}

/* 텍스트 입력창 */
.textarea-control {
  width: 100%;
  padding: 16px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.5);
  resize: vertical;
  min-height: 180px;
  transition: border-color 0.2s ease;
}

.textarea-control:focus {
  outline: none;
  border-color: var(--color-accent-bar);
  background: #ffffff;
}

.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  gap: 12px;
}

/* 3. 컬럼 리뷰 테이블 */
.review-table-wrapper {
  overflow-x: auto;
  margin-top: 16px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.review-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.review-table th, .review-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
}

.review-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
}

.review-table tbody tr:hover {
  background: rgba(248, 250, 252, 0.5);
}

.column-type-select {
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background-color: #ffffff;
  font-family: inherit;
  font-size: 0.85rem;
  color: #334155;
  cursor: pointer;
  width: 100%;
  max-width: 200px;
  transition: all 0.2s ease;
}

.column-type-select:focus {
  border-color: var(--color-accent-bar);
  outline: none;
}

.col-sample-data code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  color: #475569;
  margin-right: 4px;
  display: inline-block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

/* 4. 요약 통계 카드 그리드 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-title {
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 600;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.2;
}

.stat-desc {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 6px;
}

/* 5. 문항별 리포트 카드 */
.questions-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.question-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.q-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
  gap: 16px;
}

.q-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
  line-height: 1.4;
}

.badge-warning {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  color: #b45309;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.q-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  background: #f8fafc;
  padding: 14px;
  border-radius: 10px;
  margin-bottom: 20px;
}

.q-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.q-stat-label {
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 4px;
}

.q-stat-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: #334155;
}

.distribution-area h5 {
  font-size: 0.85rem;
  color: #475569;
  margin: 0 0 12px 0;
}

/* CSS 막대 그래프 스타일 */
.distribution-bar-item {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.8rem;
  gap: 12px;
}

.bar-label {
  width: 75px;
  color: #64748b;
  font-weight: 600;
}

.bar-track {
  flex: 1;
  height: 10px;
  background: #e2e8f0;
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  width: 0%; /* JS에서 스무스하게 늘어남 */
  border-radius: 5px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 5점 척도 컬러셋 */
.score-color-5 { background-color: var(--color-score-5); }
.score-color-4 { background-color: var(--color-score-4); }
.score-color-3 { background-color: var(--color-score-3); }
.score-color-2 { background-color: var(--color-score-2); }
.score-color-1 { background-color: var(--color-score-1); }

/* 10점 척도 3그룹 전용 라벨 컬러 */
.rating-good { color: var(--color-score-5); }
.rating-mid { color: var(--color-score-3); }
.rating-bad { color: var(--color-score-1); }

.bar-percent {
  width: 100px;
  text-align: right;
  color: #475569;
  font-weight: 600;
}

/* 6. 주관식 피드백 아코디언 */
.accordion-item {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
  background: #ffffff;
}

.accordion-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: #f8fafc;
  border: none;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  transition: background 0.2s ease;
}

.accordion-header:hover {
  background: #f1f5f9;
}

.accordion-header i {
  transition: transform 0.2s ease;
}

.accordion-body {
  max-height: 0;
  overflow-y: auto;
  padding: 0 20px;
  transition: all 0.3s ease;
}

.comment-list-ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.comment-item {
  display: flex;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.88rem;
  line-height: 1.5;
  align-items: flex-start;
}

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

.comment-bullet {
  color: var(--color-accent-bar);
  margin-right: 12px;
  font-size: 0.75rem;
  margin-top: 4px;
}

.comment-text {
  color: #475569;
}

/* 7. 로딩 오버레이 */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.loading-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(0,0,0,0.06);
  border-top-color: var(--color-accent-bar);
  border-radius: 50%;
  animation: spin 1s infinite linear;
  margin-bottom: 16px;
}

.loading-text {
  font-size: 1rem;
  font-weight: 600;
  color: #475569;
}

/* 8. 상태에 따른 구획 노출 분기 */
.analyzer-section {
  display: none;
}

.analyzer-section.show {
  display: block;
  animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 9. 애니메이션 키프레임 */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* 10. 반응형 미디어 쿼리 */
@media (max-width: 768px) {
  .analyzer-card-wrapper {
    padding: 20px;
  }
  .q-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .action-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .action-bar button, .action-bar a {
    width: 100%;
    text-align: center;
  }
  .review-table th:nth-child(3),
  .review-table td:nth-child(3) {
    display: none; /* 모바일에서는 가로폭 확보를 위해 데이터 샘플 생략 */
  }
}

/* 11. 누적 막대그래프(Stacked Bar Chart) 및 범례 스타일 */
.cumulative-visual-box {
  margin-top: 12px;
}

.cumulative-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #475569;
  margin-bottom: 8px;
  align-items: center;
}

.rating-legend-item {
  display: inline-flex;
  align-items: center;
}

.legend-separator {
  color: #cbd5e1;
  font-size: 0.7rem;
  user-select: none;
}

.rating-color-5 { color: var(--color-score-5); }
.rating-color-4 { color: var(--color-score-4); }
.rating-color-3 { color: var(--color-score-3); }
.rating-color-2 { color: var(--color-score-2); }
.rating-color-1 { color: var(--color-score-1); }

.cumulative-track {
  display: flex;
  height: 12px;
  border-radius: 6px;
  background: #f1f5f9;
  overflow: hidden;
}

.bar-segment {
  height: 100%;
  width: 0%;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 12. 라이트 테마(rpa-light-theme) 전용 폼 및 텍스트 영역 가독성 보완 */
body.rpa-light-theme .textarea-control {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: var(--color-ink-800, #1e293b) !important;
}

body.rpa-light-theme .textarea-control:focus {
  background: #ffffff !important;
  border-color: var(--color-teal, #00a896) !important;
  box-shadow: var(--focus-ring, 0 0 0 3px rgba(0, 168, 150, 0.18)) !important;
  color: var(--color-ink-900, #0f172a) !important;
}

