/* styles.css */

:root {
  --primary-color: #4a90e2;
  --primary-dark: #357abd;
  --secondary-color: #f8f9fa;
  --text-color: #2c3e50;
  --border-color: #e9ecef;
  --success-color: #2ecc71;
  --warning-color: #e67e22;
  --card-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  --transition-smooth: all 0.3s ease;
}

body {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  font-family: 'Noto Sans KR', sans-serif;
  background-color: var(--secondary-color);
  color: var(--text-color);
  line-height: 1.6;
}

.container {
  background: white;
  padding: 40px;
  border-radius: 24px;
  box-shadow: var(--card-shadow);
  margin: 20px auto;
}

h1 {
  color: var(--text-color);
  margin-bottom: 40px;
  font-size: 2.5em;
  text-align: center;
  font-weight: 700;
}

.video-section {
  position: relative;
  width: 100%;
  max-width: 720px;
  margin: 0 auto clamp(10px, 2vw, 20px);
  border-radius: clamp(16px, 3vw, 24px);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  background: var(--secondary-color);
  transition: var(--transition-smooth);
}

.video-section:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

video {
  border: 2px solid var(--border-color);
  border-radius: 10px;
}

button {
  display: inline-block;
  padding: 12px 25px;
  min-width: 120px;
  font-size: 1rem;
  text-align: center;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.3s ease;
}

button:hover {
  background: #357abd;
}

button:disabled {
  background: var(--border-color);
  cursor: not-allowed;
}

#previewContainer {
  position: relative;
  width: 100%;
  max-width: 300px;
  margin: clamp(20px, 4vw, 30px) auto;
  border-radius: clamp(16px, 3vw, 24px);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition: var(--transition-smooth);
}

#previewContainer:hover {
  transform: scale(1.02);
}

#previewImage {
  width: 100%;
  height: auto;
  display: none;
  border-radius: clamp(16px, 3vw, 24px);
}

#loadingIndicator {
  margin-top: 15px;
  font-size: 1.2em;
  font-weight: bold;
  display: none;
}

.result-section {
  max-width: 800px;
  margin: 40px auto;
  padding: 20px;
  background: white;
}

.result-header {
  background: linear-gradient(135deg, #4a90e2, #357abd);
  padding: 30px;
  color: white;
  border-bottom: 1px solid var(--border-color);
}

.result-header h2 {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.result-timestamp {
  display: block;
  margin-top: 0.5rem;
  color: #6c757d;
  font-size: 0.9rem;
}

.result-content {
  padding: 30px;
}

.result-card {
  background: white;
  border-radius: 12px;
  padding: 30px;
  margin-bottom: 35px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid #edf2f7;
  transition: all 0.2s ease;
}

.result-card.basic-info-card {
  border-top: 5px solid #4a90e2;
}

.result-card.comprehensive-card {
  border-top: 5px solid #2ecc71;
}

.result-card.facial-elements-card {
  border-top: 5px solid #e74c3c;
}

.result-card.lifetime-card {
  border-top: 5px solid #f39c12;
}

.result-card.love-card {
  border-top: 5px solid #e84393;
}

.info-item {
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 12px;
  background: #f8fafc;
  transition: all 0.2s ease;
}

.basic-info-card .info-item {
  border-left-color: #4a90e2;
}

.comprehensive-card .info-item {
  border-left-color: #2ecc71;
}

.facial-elements-card .facial-element {
  padding: 20px;
  margin: 15px 0;
  border-radius: 8px;
  background: #f8fafc;
}

.lifetime-card .info-item {
  border-left-color: #f39c12;
}

.love-card .info-item {
  border-left-color: #e84393;
}

.result-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.info-item:hover {
  background: #f1f5f9;
}

.result-card h3 {
  font-size: 1.4rem;
  color: #1a202c;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 1px solid #edf2f7;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.section-icon {
  font-size: 1.4rem;
  opacity: 0.8;
}

.result-item {
  display: flex;
  align-items: center;
  margin-bottom: 0.8rem;
  padding: 0.8rem;
  background: #f8f9fa;
  border-radius: 0.5rem;
}

.result-item-icon {
  margin-right: 1rem;
  font-size: 1.2rem;
}

.result-item-content {
  flex: 1;
}

.result-item-label {
  font-weight: 500;
  color: #495057;
}

.result-item-value {
  color: #6c757d;
  margin-left: 0.5rem;
}

.element-detail {
  color: #4a5568;
}

.element-detail p {
  margin: 12px 0;
  line-height: 1.6;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.element-detail strong {
  min-width: 80px;
  color: #2d3748;
  font-weight: 600;
}

.facial-element {
  background: #f8f9fa;
  padding: 20px;
  margin: 15px 0;
  border-radius: 12px;
  border-left: 4px solid #4a90e2;
}

.facial-element h4 {
  color: #2c3e50;
  margin: 0 0 15px 0;
  font-size: 1.2rem;
  font-weight: 600;
}

#input_video {
    border-radius: 8px;
    display: none; /* 비디오 입력은 숨기고 캔버스만 표시 */
}

#output_canvas {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 24px;
}

/* 메시지 래퍼 스타일 수정 */
.messages-wrapper {
    position: fixed;
    bottom: 40px;  /* 하단에서의 여백 */
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 800px;  /* 더 넓게 조정 */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    z-index: 1000;
    padding: 0 20px;
    box-sizing: border-box;
}

/* 메시지 기본 스타일 (공통) */
.warning-message,
.status-indicator {
    width: 100%;
    padding: 20px 32px;
    border-radius: 16px;
    font-size: 24px;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
    display: none;
    letter-spacing: 0.5px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-sizing: border-box;
    color: white;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* 경고 메시지 색상 */
.warning-message {
    background-color: rgba(231, 76, 60, 0.95);
}

/* 상태 표시기 색상 */
.status-indicator {
    background-color: rgba(46, 204, 113, 0.95);
}

/* 활성화 상태 */
.warning-message.active,
.status-indicator.active {
    display: block;
}

/* 퇴장 애니메이션 */
.warning-message.exit,
.status-indicator.exit {
    opacity: 0;
    transform: translateY(40px);  /* 아래로 사라지기 */
}

/* 반응형 디자인 개선 */
@media (max-width: 768px) {
    .messages-wrapper {
        bottom: 30px;
        padding: 0 15px;
    }
    
    .warning-message,
    .status-indicator {
        font-size: 18px;
        padding: 16px 24px;
    }
}

/* 더 작은 화면에 대한 대응 */
@media (max-width: 480px) {
    .messages-wrapper {
        bottom: 20px;
    }
    
    .warning-message,
    .status-indicator {
        font-size: 16px;
        padding: 14px 20px;
        border-radius: 12px;
    }
}

/* 캡처 버튼 컨테이너 */
.capture-container {
    margin-bottom: 20px;
}

/* 캡처 버튼 스타일 */
.capture-button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.capture-button:hover {
    background-color: #2980b9;
}

.capture-button:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

/* 로딩 인디케이터 스타일 */
.loading-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.98);
  padding: 30px;  /* 패딩 축소 */
  border-radius: 20px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  text-align: center;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  width: auto;  /* 고정 너비 제거 */
  min-width: 200px;  /* 최소 너비 설정 */
  max-width: 300px;  /* 최대 너비 축소 */
  animation: fadeIn 0.3s ease-out;
}

.loading-indicator i {
  font-size: 2.5rem;  /* 아이콘 크기 축소 */
  background: linear-gradient(45deg, var(--primary-color), var(--success-color));
  -webkit-text-fill-color: transparent;
  margin-bottom: 16px;  /* 마진 축소 */
}

.loading-indicator p {
  margin: 0;  /* 마진 제거 */
  color: var(--text-color);
  font-size: 1.1rem;  /* 폰트 크기 축소 */
  font-weight: 500;
  line-height: 1.4;
  word-break: keep-all;  /* 한글 단어 분리 방지 */
}

/* 새로운 로딩 애니메이션 */
.loading-animation {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto;
}

.loading-animation div {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary-color);
  animation: loading-animation 1.2s linear infinite;
}

.loading-animation div:nth-child(1) {
  top: 8px;
  left: 8px;
  animation-delay: 0s;
}

.loading-animation div:nth-child(2) {
  top: 8px;
  left: 32px;
  animation-delay: -0.4s;
}

.loading-animation div:nth-child(3) {
  top: 8px;
  left: 56px;
  animation-delay: -0.8s;
}

.loading-animation div:nth-child(4) {
  top: 32px;
  left: 8px;
  animation-delay: -0.4s;
}

.loading-animation div:nth-child(5) {
  top: 32px;
  left: 32px;
  animation-delay: -0.8s;
}

.loading-animation div:nth-child(6) {
  top: 32px;
  left: 56px;
  animation-delay: -1.2s;
}

.loading-animation div:nth-child(7) {
  top: 56px;
  left: 8px;
  animation-delay: -0.8s;
}

.loading-animation div:nth-child(8) {
  top: 56px;
  left: 32px;
  animation-delay: -1.2s;
}

.loading-animation div:nth-child(9) {
  top: 56px;
  left: 56px;
  animation-delay: -1.6s;
}

@keyframes loading-animation {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.7);
  }
}

/* 애니메이션 효과 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -48%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

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

/* 반응형 디자인 개선 */
@media (max-width: 768px) {
  .container {
    padding: 20px;
  }
  
  h1 {
    font-size: 2em;
    margin-bottom: 30px;
  }
  
  .loading-indicator {
    padding: 25px;
    min-width: 180px;
    max-width: 280px;
  }
  
  .loading-indicator i {
    font-size: 2.2rem;
    margin-bottom: 14px;
  }
  
  .loading-indicator p {
    font-size: 1rem;
  }
  
  .result-header {
    padding: 25px;
  }
  
  .result-header h2 {
    font-size: 1.8rem;
  }
  
  .result-content {
    padding: 20px;
  }
  
  .result-card {
    padding: 20px;
    margin-bottom: 25px;
  }
  
  .result-card h3 {
    font-size: 1.2rem;
  }
  
  .facial-element {
    padding: 15px;
  }
  
  .element-detail strong {
    min-width: 70px;
  }
}

@media (max-width: 480px) {
  .loading-indicator {
    padding: 20px;
    min-width: 160px;
    max-width: 260px;
    border-radius: 16px;
  }
  
  .loading-indicator i {
    font-size: 2rem;
    margin-bottom: 12px;
  }
  
  .loading-indicator p {
    font-size: 0.95rem;
  }
}

/* 접근성 개선 */
@media (prefers-reduced-motion: reduce) {
  .loading-indicator i {
    animation: none;
  }
  
  .result-card:hover {
    transform: none;
  }
}

/* 공통 컨테이너 스타일 */
.title-section,
.video-container,
.result-container {
  background: white;
  border-radius: clamp(16px, 3vw, 24px);
  box-shadow: var(--card-shadow);
  margin: clamp(15px, 3vw, 30px) auto;
  width: 90%;
  max-width: 1000px;
}

/* 타이틀 섹션 */
.title-section {
  text-align: center;
  padding: clamp(20px, 4vw, 40px);
}

.title-section h1 {
  margin: 0;
  color: var(--text-color);
  font-size: clamp(1.5rem, 3vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.3;
  word-break: keep-all;
}

/* 비디오 컨테이너 */
.video-container {
  padding: clamp(20px, 4vw, 40px);
}

/* 미디어 쿼리 개선 */
@media (max-width: 768px) {
  .title-section,
  .video-container,
  .result-container {
    width: 88%;
    margin: clamp(10px, 2vw, 20px) auto;
  }
  
  .title-section h1 {
    font-size: clamp(1.4rem, 2.5vw, 2rem);
  }
}

@media (max-width: 480px) {
  .title-section,
  .video-container,
  .result-container {
    width: 85%;
    padding: 15px;
    border-radius: 16px;
    margin: 15px auto;
  }
  
  .title-section h1 {
    font-size: clamp(1.3rem, 2vw, 1.8rem);
  }
}

/* 비디오 섹션 */
.video-section {
  position: relative;
  width: 100%;
  max-width: 720px;
  margin: 0 auto clamp(20px, 4vw, 40px);
  border-radius: clamp(16px, 3vw, 24px);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  background: var(--secondary-color);
  transition: var(--transition-smooth);
}

/* 결과 섹션 */
.result-container {
  display: none; /* 초기에는 숨김 */
}

.result-section {
  max-width: 800px;
  margin: 0 auto;
}

/* 미디어 쿼리 */
@media (max-width: 768px) {
  #previewContainer {
    max-width: 300px;  /* 태블릿 크기에서 더 작게 */
    margin: clamp(15px, 3vw, 25px) auto;
  }
}

@media (max-width: 480px) {
  #previewContainer {
    max-width: 250px;  /* 모바일에서 더 작게 */
    margin: 15px auto;
  }
}

/* 기본 정보 및 종합 분석 스타일 */
.basic-info,
.comprehensive-analysis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 15px;
}

.info-item {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 10px;
  border-left: 4px solid #4a90e2;
}

.info-item strong {
  display: block;
  margin-bottom: 8px;
  color: #2d3748;
}

/* 애니메이션 효과 */
.result-card {
  animation: fadeInUp 0.4s ease-out forwards;
  opacity: 0;
}

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

/* 각 카드별 순차적 애니메이션 (딜레이 시간 단축) */
.result-card:nth-child(1) { animation-delay: 0.1s; }
.result-card:nth-child(2) { animation-delay: 0.15s; }
.result-card:nth-child(3) { animation-delay: 0.2s; }
.result-card:nth-child(4) { animation-delay: 0.25s; }
.result-card:nth-child(5) { animation-delay: 0.3s; }
  