/* 색상 변수를 CSS 변수로 변환 */
:root {
  --color-bg-primary: #dff2fd;
  --color-bg-secondary: #f0f8ff;
  --color-bg-white: #ffffff;
  --color-bg-upload: #f4faff;
  --color-bg-option-inactive: #e4f3ff;
  --color-primary: #4195ef;
  --color-primary-dark: #337ff0;
  --color-primary-darker: #045fe6;
  --color-secondary: #499cf6;
  --color-text-primary: #516c89;
  --color-text-secondary: #555;
  --color-text-inactive: #8bafd6;
  --color-text-inactive2: #6693c4;
  --color-border-primary: #65a0df;
  --color-border-secondary: #97bce4;
  --color-border-light: #c1dfff;
}

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--color-bg-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

/* Container */
.container {
  max-width: 1024px;
  width: 100%;
  position: relative;
}

/* 헤더 */
.header {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 24px;
}

.header .logo-section {
  display: flex;
  align-items: center;
  gap: 15px;
}

.header .logo-section .logo-icon {
  width: 65px;
  height: 60px;
}

.header .logo-section .title {
  font-family: 'Mont', 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 76px;
  font-weight: 900;
  color: var(--color-primary-darker);
  line-height: 1;
}

/* 버튼 그룹 */
.button-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

/* 파일 추가하기 버튼 */
.btn-add-file {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  font-size: 18px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px;
  transition: opacity 0.3s;
}

.btn-add-file:hover {
  opacity: 0.7;
}

.btn-add-file svg {
  width: 22px;
  height: 17px;
}

/* 이전 결과 보기 버튼 */
.btn-previous-results {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--color-primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 31px;
  font-size: 18px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.3s;
}

.btn-previous-results:hover {
  background-color: #2d7fdb;
}

.btn-previous-results svg {
  width: 20px;
  height: 20px;
}

/* 메인 컨텐츠 */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 32px;
}

/* 섹션 공통 스타일 */
.section {
  background-color: var(--color-bg-white);
  border: 3px solid var(--color-border-primary);
  border-radius: 25px;
  padding: 36px 75px;
}

.section.section-processing {
  background-color: var(--color-bg-secondary);
  border-color: var(--color-border-light);
}

/* 파일 업로드 및 성별 선택 섹션 */
.section-upload {
  display: flex;
  gap: 48px;
  align-items: flex-start;
}

.section-upload .upload-area {
  flex: 1;
}

.section-upload .upload-box {
  background-color: var(--color-bg-upload);
  border: 1px solid var(--color-border-secondary);
  border-radius: 10px;
  padding: 36px;
  text-align: center;
  position: relative;
  min-height: 171px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

.section-upload .upload-text {
  font-size: 18px;
  color: var(--color-text-primary);
  line-height: 24px;
  margin: 0;
}

.section-upload .btn-file-select {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--color-primary);
  color: white;
  border: none;
  padding: 7px 15px;
  border-radius: 10px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s;
}

.section-upload .btn-file-select:hover {
  background-color: #2d7fdb;
}

.section-upload .btn-file-select .upload-icon {
  width: 17px;
  height: 17px;
}

.section-upload .gender-selection {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-upload .section-header {
  display: flex;
  align-items: center;
  gap: 9px;
}

.section-upload .section-header .section-icon {
  width: 25px;
  height: auto;
}

.section-upload .section-header .section-title {
  font-size: 23px;
  font-weight: 600;
  color: var(--color-primary-darker);
  line-height: 22px;
}

.section-upload .section-description {
  font-size: 18px;
  color: var(--color-text-primary);
  line-height: 22px;
  margin: 0;
}

.section-upload .gender-buttons {
  display: flex;
  gap: 12px;
}

.section-upload .btn-gender {
  flex: 1;
  background-color: var(--color-bg-upload);
  border: 1px solid var(--color-border-secondary);
  color: var(--color-text-inactive);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.section-upload .btn-gender.active {
  background-color: var(--color-secondary);
  border-color: var(--color-secondary);
  color: white;
}

.section-upload .btn-gender:hover:not(.active) {
  background-color: #f7fbff;
}

/* 처리 방식 선택 섹션 */
.section-processing .section-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-bottom: 24px;
}

.section-processing .section-header .section-icon {
  width: 24px;
  height: auto;
}

.section-processing .section-header .section-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--color-primary-darker);
  line-height: 22px;
}

.section-processing .processing-options {
  display: flex;
  gap: 16px;
}

.section-processing .option-card {
  flex: 1;
  border: 1px solid var(--color-border-secondary);
  background-color: var(--color-bg-white);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s;
}

.section-processing .option-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.section-processing .option-card .option-header {
  background-color: var(--color-secondary);
  border: 1px solid var(--color-secondary);
  padding: 10px 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.section-processing .option-card .option-header.inactive {
  background-color: var(--color-bg-option-inactive);
  border-color: var(--color-border-secondary);
}

.section-processing .option-card .option-header .check-icon {
  width: 18px;
  height: 18px;
}

.section-processing .option-card .option-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: white;
  margin: 0;
  line-height: normal;
}

.section-processing .option-card:not(.active) .option-header h3 {
  color: var(--color-text-inactive2);
}

.section-processing .option-card .option-body {
  padding: 15px 25px;
  text-align: center;
}

.section-processing .option-card .option-body p {
  font-size: 16px;
  color: var(--color-text-primary);
  line-height: 22px;
  margin: 0;
}

/* 분석 시작 버튼 */
.btn-start-analysis {
  display: block;
  margin: 0 auto;
  background-color: var(--color-primary-dark);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 10px;
  font-size: 28px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.3s;
  min-width: 200px;
  height: 58px;
}

.btn-start-analysis:hover {
  background-color: #2566c7;
}

.btn-start-analysis:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 파일 업로드 아이템 */
.file-upload-item {
  display: flex;
  gap: 48px;
  align-items: flex-start;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--color-border-light);
  position: relative;
}

.file-upload-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.file-upload-item .upload-box {
  flex: 1;
}

.file-upload-item .gender-selection {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 파일 삭제 버튼 */
.remove-file-btn {
  position: absolute;
  top: 0;
  right: 0;
  background: #ef4444;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s;
}

.remove-file-btn:hover {
  background: #dc2626;
  transform: scale(1.05);
}

/* 이메일 섹션 */
.email-section {
  margin-top: 24px;
  padding: 20px;
  background: var(--color-bg-white);
  border-radius: 12px;
  border: 2px dashed var(--color-border-secondary);
  transition: all 0.3s ease;
}

.email-section.hidden {
  display: none;
}

.email-section .field-label {
  display: block;
  font-size: 18px;
  font-weight: 600;
  color: var(--color-primary-darker);
  margin-bottom: 10px;
}

.email-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  border: 2px solid var(--color-border-secondary);
  border-radius: 8px;
  transition: all 0.3s ease;
}

.email-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(65, 149, 239, 0.1);
}

.email-note {
  margin-top: 10px;
  font-size: 14px;
  color: var(--color-text-primary);
  font-style: italic;
}

/* 프로그레스 섹션 */
.progress-section {
  background: var(--color-bg-white);
  border: 3px solid var(--color-border-primary);
  border-radius: 25px;
  padding: 36px 75px;
  margin-top: 32px;
}

.progress-section.hidden,
.results-section.hidden {
  display: none;
}

.progress-section h2 {
  text-align: center;
  margin-bottom: 30px;
  color: var(--color-primary-darker);
  font-size: 28px;
}

.progress-container {
  margin-bottom: 30px;
}

.progress-bar {
  width: 100%;
  height: 30px;
  background: #e4f3ff;
  border-radius: 15px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--color-border-secondary);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  border-radius: 15px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-text {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--color-primary-darker);
  margin-top: 10px;
}

.progress-steps {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.step-item {
  flex: 1;
  text-align: center;
  padding: 16px 8px;
  background: #f4faff;
  border-radius: 12px;
  opacity: 0.5;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.step-item.active {
  opacity: 1;
  background: #e4f3ff;
  border: 2px solid var(--color-primary);
  transform: scale(1.05);
}

.step-item.completed {
  opacity: 1;
  background: #d4f4dd;
  border: 2px solid #10b981;
}

.step-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.step-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
}

/* 결과 섹션 */
.results-section {
  background: var(--color-bg-white);
  border: 3px solid var(--color-border-primary);
  border-radius: 25px;
  padding: 36px 75px;
  margin-top: 32px;
}

.results-section h2 {
  margin-bottom: 24px;
  color: var(--color-primary-darker);
  font-size: 28px;
}

.result-item {
  background: #f4faff;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  border-left: 5px solid var(--color-primary);
}

.result-item.error {
  border-left-color: #ef4444;
  background: #fef2f2;
}

.result-item h3 {
  color: var(--color-primary-darker);
  margin-bottom: 16px;
  font-size: 22px;
}

.result-section {
  margin-bottom: 20px;
}

.result-section h4 {
  color: var(--color-primary);
  margin-bottom: 10px;
  font-size: 18px;
  font-weight: 600;
}

.result-section .script {
  background: white;
  padding: 16px;
  border-radius: 8px;
  line-height: 1.8;
  color: var(--color-text-primary);
  margin-bottom: 8px;
  border: 1px solid var(--color-border-secondary);
}

.result-section .metadata {
  color: var(--color-text-primary);
  font-size: 16px;
}

.error-message {
  color: #ef4444;
  font-weight: 500;
  padding: 16px;
  background: #fef2f2;
  border-radius: 8px;
  margin-top: 8px;
  border: 1px solid #fecaca;
}

.summary {
  background: #e4f3ff;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 24px;
  font-weight: 500;
}

.summary .success {
  color: #10b981;
}

.summary .error {
  color: #ef4444;
}

/* 그래프 관련 스타일 */
.chart-container {
  position: relative;
  width: 100%;
  background: white;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 16px;
  overflow-x: auto;
  border: 1px solid var(--color-border-secondary);
}

.chart-container canvas {
  max-width: 100%;
  height: auto !important;
  cursor: grab;
}

.chart-container canvas:active {
  cursor: grabbing;
}

.chart-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  background: #f4faff;
  border-radius: 8px;
  flex-wrap: wrap;
}

.chart-btn {
  background: var(--color-primary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chart-btn:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

.chart-btn:active {
  transform: translateY(0);
}

.chart-info {
  flex: 1;
  font-size: 14px;
  color: var(--color-text-primary);
  text-align: right;
}

/* 단어별 강세 정보 테이블 */
.word-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--color-border-secondary);
}

.word-table thead {
  background: var(--color-primary);
  color: white;
}

.word-table th,
.word-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border-light);
}

.word-table th {
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.word-table td {
  font-size: 15px;
}

.word-table tbody tr:hover {
  background: #f8fafc;
}

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

/* 강세 표시 문장 */
.accent-sentence {
  background: white;
  padding: 20px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 2;
  color: var(--color-text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--color-border-secondary);
}

.accent-high {
  color: #ef4444;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: #ef4444;
  text-decoration-thickness: 2px;
}

.accent-low {
  color: var(--color-primary);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--color-primary);
  text-decoration-thickness: 2px;
}

.pause {
  color: #94a3b8;
  font-style: italic;
  margin: 0 4px;
}

/* 점수별 색상 구분 문장 */
.score-sentence {
  background: white;
  padding: 20px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 2;
  color: var(--color-text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--color-border-secondary);
}

.score-low {
  color: #dc2626;
  font-weight: 700;
}

.score-medium {
  color: #f59e0b;
  font-weight: 600;
}

.score-high {
  color: #10b981;
  font-weight: 600;
}

/* 점수 기준표 (범례) */
.score-legend {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-top: 20px;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 8px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.legend-dot.score-high {
  background-color: #10b981;
}

.legend-dot.score-medium {
  background-color: #f59e0b;
}

.legend-dot.score-low {
  background-color: #dc2626;
}

.legend-label {
  font-size: 14px;
  color: var(--color-text-primary);
  font-weight: 500;
}

/* 음소별 발음 점수 */
.phoneme-sentence {
  background: white;
  padding: 20px;
  border-radius: 8px;
  font-size: 20px;
  line-height: 2;
  letter-spacing: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--color-border-secondary);
}

.phoneme-error {
  color: #dc2626;
  font-weight: 900;
}

.phoneme-normal {
  color: var(--color-text-primary);
}

/* 반응형 */
@media (max-width: 768px) {
  .header {
    margin-bottom: 16px;
  }

  .header .logo-section {
    flex-direction: column;
    gap: 10px;
  }

  .header .logo-section .logo-icon {
    width: 45px;
    height: 40px;
  }

  .header .logo-section .title {
    font-size: 48px;
  }

  .button-group {
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
    align-items: stretch;
  }

  .btn-add-file,
  .btn-previous-results {
    justify-content: center;
  }

  .section {
    padding: 24px;
  }

  .section-upload {
    flex-direction: column;
    gap: 24px;
  }

  .file-upload-item {
    flex-direction: column;
    gap: 24px;
  }

  .processing-options {
    flex-direction: column;
  }

  .btn-start-analysis {
    width: 100%;
  }

  .progress-section,
  .results-section {
    padding: 24px;
  }

  .progress-steps {
    flex-wrap: wrap;
  }

  .step-item {
    min-width: calc(50% - 6px);
  }

  .chart-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .chart-info {
    text-align: center;
  }

  .chart-btn {
    width: 100%;
  }

  .word-table {
    font-size: 13px;
  }

  .word-table th,
  .word-table td {
    padding: 8px 12px;
  }

  .accent-sentence,
  .score-sentence,
  .phoneme-sentence {
    font-size: 16px;
    padding: 16px;
  }

  .phoneme-sentence {
    letter-spacing: 1px;
  }

  .score-legend {
    gap: 16px;
  }

  .legend-label {
    font-size: 13px;
  }
}
