/* 전역 변수 및 테마 설정 */
:root {
  --bg-color: #0b0f19;
  --card-bg: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f3f4f6;
  --text-secondary: #cbd5e1; /* 가독성을 위해 더 밝게 조정 */
  
  /* 화자별 세련된 Accent Colors */
  --s1-color: #3b82f6; /* 진행자 - 신뢰의 블루 */
  --s1-bg: rgba(59, 130, 246, 0.1);
  --s2-color: #10b981; /* 전문가 - 차분한 에메랄드 */
  --s2-bg: rgba(16, 185, 129, 0.1);
  --s3-color: #a855f7; /* 초보자 - 생기 있는 보라 */
  --s3-bg: rgba(168, 85, 247, 0.1);
  
  --primary-gradient: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
  --btn-hover-gradient: linear-gradient(135deg, #4f46e5, #9333ea, #db2777);
  --success-color: #10b981;
  --success-gradient: linear-gradient(135deg, #10b981, #059669);
  --font-main: 'Inter', sans-serif;
  --font-title: 'Outfit', sans-serif;
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* 움직이는 멋진 오로라 백그라운드 효과 */
.glass-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  background: radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 40%),
              radial-gradient(circle at 90% 80%, rgba(236, 72, 153, 0.15) 0%, transparent 40%);
  filter: blur(80px);
}

.container {
  width: 100%;
  max-width: 1280px;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

header {
  text-align: center;
  margin-bottom: 10px;
}

.glow-text {
  font-family: var(--font-title);
  font-size: 3rem;
  font-weight: 800;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 10px;
  letter-spacing: -0.03em;
  filter: drop-shadow(0 2px 10px rgba(99, 102, 241, 0.3));
}

.subtitle {
  color: #f1f5f9; /* 아주 선명하게 가독성 개선 */
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* 메인 대시보드 그리드 */
.grid {
  display: grid;
  grid-template-columns: 1.1fr 1.3fr;
  gap: 30px;
  align-items: stretch;
}

@media (max-width: 968px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

/* 카드 및 글래스모피즘 컴포넌트 */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 30px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
}

.section-title {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 25px;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 15px;
  letter-spacing: -0.01em;
}

/* 인풋 양식 스타일링 */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.input-group label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

textarea, input[type="text"], input[type="password"], input[type="number"], select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  color: var(--text-primary);
  padding: 12px 16px;
  font-family: var(--font-main);
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

textarea:focus, input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus, select:focus {
  outline: none;
  border-color: #6366f1;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.25);
}

input[type="number"] {
  text-align: center;
}

select option {
  background-color: #111827;
  color: var(--text-primary);
}

optgroup {
  background-color: #111827;
  color: #a5b4fc; /* 남성/여성 목소리 타이틀이 선명히 보이도록 색상 지정 */
  font-weight: 700;
}

/* 화자 설정 섹션 */
.speakers-header {
  font-size: 1.1rem;
  margin: 15px 0;
  color: var(--text-primary);
}

.speakers-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 25px;
}

.card-sub {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 14px;
  padding: 15px;
}

.speaker-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.speaker-badge.s1 { background: var(--s1-bg); color: var(--s1-color); }
.speaker-badge.s2 { background: var(--s2-bg); color: var(--s2-color); }
.speaker-badge.s3 { background: var(--s3-bg); color: var(--s3-color); }

.speaker-inputs {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 10px;
}

.speaker-inputs input, .speaker-inputs .select-wrapper {
  grid-column: span 1;
}

.speaker-inputs input.speaker-tone {
  grid-column: span 2;
  font-size: 0.85rem;
}

.select-wrapper {
  position: relative;
  width: 100%;
}

.select-wrapper select {
  width: 100%;
  appearance: none;
}

.select-wrapper::after {
  content: "▼";
  font-size: 0.8rem;
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-secondary);
}

/* 버튼 컴포넌트 */
.btn {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: var(--primary-gradient);
}

.btn-primary:hover {
  background: var(--btn-hover-gradient);
  transform: scale(1.02);
  box-shadow: 0 5px 15px rgba(168, 85, 247, 0.4);
}

.btn-success {
  background: var(--success-gradient);
}

.btn-success:hover {
  background: linear-gradient(135deg, #059669, #047857);
  transform: scale(1.02);
  box-shadow: 0 5px 15px rgba(16, 185, 129, 0.4);
}

/* 우측 결과 패널 상태 */
.status-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 350px;
  color: var(--text-secondary);
  text-align: center;
  gap: 15px;
}

.placeholder-icon {
  font-size: 3rem;
  opacity: 0.5;
}

.hidden {
  display: none !important;
}

/* 로딩 스피너 */
.loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 350px;
  gap: 20px;
  text-align: center;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-left-color: #6366f1;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* DOCX 보관 뱃지 */
.docx-badge {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: rgba(43, 87, 154, 0.15);
  border: 1px solid rgba(43, 87, 154, 0.3);
  padding: 12px 18px;
  border-radius: 12px;
  margin-bottom: 20px;
}

.docx-badge .icon {
  font-size: 1.5rem;
}

.docx-badge .info {
  flex: 1;
  min-width: 200px;
}

.docx-badge .info .label {
  font-size: 0.8rem;
  color: #a5b4fc;
  font-weight: 600;
}

.docx-badge .info .path {
  font-size: 0.85rem;
  color: var(--text-primary);
  word-break: break-all;
  font-family: monospace;
}

/* 대본 보기 */
.script-content {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.script-title {
  font-family: var(--font-title);
  font-size: 1.3rem;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.dialogue-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
  flex-grow: 1;
  min-height: 580px;
  max-height: 720px;
  overflow-y: auto;
  padding-right: 12px;
  margin-bottom: 25px;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 20px;
}

.dialogue-container::-webkit-scrollbar {
  width: 8px;
}

.dialogue-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
}

.dialogue-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  transition: background 0.2s ease;
}

.dialogue-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.45);
}

/* 대화 턴 버블 */
.dialogue-card {
  padding: 14px 18px;
  border-radius: 12px;
  line-height: 1.6;
  border-left: 4px solid transparent;
  word-break: break-all;
  overflow-wrap: break-word;
}

.dialogue-card.sp-s1 {
  background: var(--s1-bg);
  border-left-color: var(--s1-color);
}
.dialogue-card.sp-s2 {
  background: var(--s2-bg);
  border-left-color: var(--s2-color);
}
.dialogue-card.sp-s3 {
  background: var(--s3-bg);
  border-left-color: var(--s3-color);
}

.dialogue-card .name {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.dialogue-card.sp-s1 .name { color: #93c5fd; }
.dialogue-card.sp-s2 .name { color: #6ee7b7; }
.dialogue-card.sp-s3 .name { color: #d8b4fe; }

.dialogue-card .text {
  font-size: 0.95rem;
  color: var(--text-primary);
  word-break: break-all;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

/* 승인 요청 섹션 */
.approval-section {
  background: rgba(245, 158, 11, 0.05);
  border: 1px dashed rgba(245, 158, 11, 0.3);
  padding: 20px;
  border-radius: 14px;
  margin-bottom: 20px;
}

.approval-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.approval-header h4 {
  color: #f59e0b;
  font-size: 1rem;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: #f59e0b;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 10px rgba(245, 158, 11, 0.8); }
  100% { transform: scale(0.9); opacity: 0.6; }
}

.approval-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 15px;
}

/* TTS 합성 로더 */
.tts-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  padding: 25px;
  background: rgba(99, 102, 241, 0.05);
  border: 1px solid rgba(99, 102, 241, 0.1);
  border-radius: 14px;
  text-align: center;
}

.wave-loader {
  display: flex;
  gap: 6px;
  height: 30px;
  align-items: center;
}

.wave-loader span {
  display: block;
  width: 4px;
  height: 10px;
  background: #818cf8;
  border-radius: 2px;
  animation: wave 1.2s infinite ease-in-out;
}

.wave-loader span:nth-child(2) { animation-delay: 0.2s; }
.wave-loader span:nth-child(3) { animation-delay: 0.4s; }
.wave-loader span:nth-child(4) { animation-delay: 0.6s; }
.wave-loader span:nth-child(5) { animation-delay: 0.8s; }

@keyframes wave {
  0%, 100% { height: 10px; }
  50% { height: 30px; background: #c084fc; }
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary-gradient);
  transition: width 0.3s ease;
}

/* 오디오 플레이어 섹션 */
.audio-player-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 25px;
  background: rgba(16, 185, 129, 0.05);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 16px;
}

.success-banner {
  color: var(--success-color);
  font-weight: 700;
  text-align: center;
  font-size: 1.1rem;
}

.player-wrapper {
  display: flex;
  justify-content: center;
}

audio {
  width: 100%;
  outline: none;
}

/* 오디오 컨트롤러 다크 커스터마이징 느낌 주입 */
audio::-webkit-media-controls-panel {
  background-color: rgba(255, 255, 255, 0.08);
}
audio::-webkit-media-controls-play-button,
audio::-webkit-media-controls-mute-button {
  filter: invert(1);
}

.btn-download {
  background: var(--success-gradient);
}

.btn-download:hover {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 5px 15px rgba(16, 185, 129, 0.3);
}

/* 대본 액션 컨트롤 바 */
.action-bar-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 25px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  padding: 10px;
  border-radius: 12px;
  flex-wrap: wrap;
}

.bar-btn {
  flex: 1 1 auto;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  min-width: 100px;
}

.bar-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

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

/* 녹음 시작 버튼 특수 강조 */
.btn-record-start {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.btn-record-start:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.25) !important;
  border-color: rgba(239, 68, 68, 0.6) !important;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}

/* 비활성화 링크 스타일 */
.disabled-link {
  opacity: 0.4;
  pointer-events: none;
  cursor: not-allowed;
}

/* 이미지 갤러리 카드 스타일 */
.image-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.image-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  border-color: rgba(99, 102, 241, 0.3);
}

.image-wrapper {
  position: relative;
  width: 100%;
  padding-top: 100%; /* 1:1 Aspect Ratio */
  background: #111827;
  overflow: hidden;
}

.image-wrapper img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.image-card:hover .image-wrapper img {
  transform: scale(1.05);
}

.image-info {
  padding: 12px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.image-caption {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
  height: 48px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.image-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: auto;
}

.image-actions .btn {
  padding: 6px 10px;
  font-size: 0.75rem;
  border-radius: 6px;
}

.btn-view-img {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-view-img:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* 이미지 모달 레이어 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: zoom-out;
}

.modal-content-img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.1);
}

/* 대본 맞춤형 AI 사진 생성 카드 내 정렬 및 편집기 스타일 */
.image-generator-section {
  display: flex;
  flex-direction: column;
}

.guide-textarea {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) rgba(0, 0, 0, 0.1);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.guide-textarea:focus {
  outline: none;
  border-color: rgba(99, 102, 241, 0.5) !important;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.15);
}

.guide-textarea::-webkit-scrollbar {
  width: 6px;
}

.guide-textarea::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

.guide-textarea::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.guide-textarea::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.35);
}

.image-generator-section #btnGenerateImages {
  margin-top: auto;
}

/* 대본 히스토리 아이템 스타일 */
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(99, 102, 241, 0.3);
}

.history-item-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.history-item-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-actions {
  display: flex;
  gap: 6px;
  margin-left: 10px;
}

.btn-history-load {
  padding: 4px 8px;
  font-size: 0.75rem;
  height: 26px;
  width: auto;
  border-radius: 4px;
}

.history-item-placeholder {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: center;
  padding: 15px;
}



