/* 실시간 STT 컨테이너 */
.realtime-container {
  margin: 1rem auto 2rem;
  padding: 0 1.5rem;
}

/* 컨트롤 패널 */
.control-panel {
  background: white;
  border-radius: 20px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.mic-controls {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.mic-button {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  padding: 0.875rem 1.5rem;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.3px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
}

.mic-button:hover {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  transform: translateY(-1px);
}

.mic-button.recording {
  background: #dc2626;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: #9ca3af;
}

.status-dot.recording {
  background: #dc2626;
  animation: pulse 1.5s infinite;
}

/* TTS 토글 버튼 스타일 */
.tts-toggle-container, .thinking-toggle-container {
  display: flex;
  align-items: center;
  margin-left: 15px;
}

.tts-toggle-label, .thinking-toggle-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.tts-toggle-label input, .thinking-toggle-label input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.tts-toggle-switch, .thinking-toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  background-color: #ccc;
  border-radius: 34px;
  transition: 0.4s;
  margin-right: 8px;
}

.tts-toggle-switch:before, .thinking-toggle-switch:before {
  position: absolute;
  content: '';
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  transition: 0.4s;
}

input:checked + .tts-toggle-switch {
  background: var(--primary-gradient);
}

input:checked + .thinking-toggle-switch {
  background: #10b981;
}

input:checked + .tts-toggle-switch:before,
input:checked + .thinking-toggle-switch:before {
  transform: translateX(18px);
}

.tts-toggle-text, .thinking-toggle-text {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-color);
}

/* 사고 모드 특별 스타일 */
.thinking-toggle-container {
  margin-left: auto;
}

/* 결과 패널 */
.result-panel {
  background: white;
  border-radius: 1rem;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.result-panel h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  color: var(--text-color);
  font-size: 1.25rem;
}

.result-content {
  background: var(--background-color);
  border-radius: 0.75rem;
  padding: 1.5rem;
  min-height: 100px;
  white-space: pre-wrap;
  line-height: 1.6;
}

@keyframes pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
  }
}

@media (max-width: 768px) {
  .realtime-container {
    margin-top: 1rem;
    padding: 0 1rem;
    width: 100%;
  }

  .mic-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .mic-button {
    justify-content: center;
  }

  /* 모바일에서 TTS 토글 버튼 스타일 조정 */
  .tts-toggle-container {
    margin-left: 0;
    margin-top: 0.5rem;
    justify-content: flex-start;
  }
}

/* 채팅 컨테이너 스타일 수정 */
.chat-container {
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  background: #fafafa;
  background-image:
    radial-gradient(
      circle at 0% 0%,
      rgba(99, 102, 241, 0.03) 0,
      transparent 40%
    ),
    radial-gradient(
      circle at 100% 100%,
      rgba(99, 102, 241, 0.03) 0,
      transparent 40%
    );
}

/* 스크롤바 스타일링 */
.chat-messages::-webkit-scrollbar {
  width: 5px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.2);
  border-radius: 20px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.3);
}

/* 메시지 스타일 수정 */
.message {
  max-width: 80%;
  padding: 1rem 1.25rem;
  border-radius: 18px;
  margin: 0.5rem 3rem;
  animation: fadeIn 0.3s ease-in-out;
  position: relative;
  font-size: 0.95rem;
  line-height: 1.6;
}

.user-message {
  align-self: flex-end;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.15);
}

.assistant-message {
  align-self: flex-start;
  background: white;
  color: #1f2937;
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

/* 메시지 시간 스타일 수정 */
.message-time {
  font-size: 0.75rem;
  margin-top: 0.5rem;
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* client_id 표시 스타일 추가 */
.client-id {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.6);
  margin-left: 4px;
}

.assistant-message .client-id {
  color: #999;
}

.user-message .message-time {
  color: rgba(255, 255, 255, 0.9);
  justify-content: flex-end;
}

.assistant-message .message-time {
  color: #666;
}

/* AI 답변 대기 중 스타일 수정 */
.ai-thinking {
  align-self: flex-start;
  background: white;
  color: #6b7280;
  border-radius: 18px 18px 18px 4px;
  padding: 0.875rem 1.25rem;
  margin: 0.5rem 3rem 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 12px;
  font-style: italic;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.05);
  animation: fadeIn 0.3s ease-in-out;
}

/* 타이핑 인디케이터 스타일 수정 */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
}

.typing-dot {
  width: 5px;
  height: 5px;
  background: #6366f1;
  border-radius: 50%;
  opacity: 0.6;
  animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-4px);
  }
}

/* 메시지 내용 스타일 */
.message-content {
  word-break: break-word;
}

/* 메시지 아바타 추가 */
.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  position: absolute;
  bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.user-message .message-avatar {
  right: -48px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
}

.assistant-message .message-avatar {
  left: -48px;
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

/* 상태 표시줄 스타일 수정 */
.chat-status-bar {
  padding: 1rem 1.5rem;
  background: #ffffff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 20px 20px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.status-indicator-wrapper {
  position: relative;
  overflow: hidden;
}

@keyframes progress {
  0% {
    width: 0;
  }
  50% {
    width: 100%;
  }
  100% {
    width: 0;
  }
}

/* 상태별 스타일 */
.status-ready {
  background-color: #ecfdf5;
  color: #047857;
}

.status-recording {
  background-color: #fef2f2;
  color: #dc2626;
}

.status-processing {
  background-color: #eff6ff;
  color: #1d4ed8;
}

.status-thinking {
  background-color: #fffbeb;
  color: #b45309;
}

/* 상태 아이콘 스타일 */
.status-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
}

/* 스피너 애니메이션 수정 */
.status-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.status-spinner.active {
  opacity: 1;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 메시지 입력 중 표시 애니메이션 */
.typing-indicator {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: #007aff;
  border-radius: 50%;
  opacity: 0.3;
  animation: typingAnimation 1s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingAnimation {
  0%,
  100% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* 반응형 디자인 개선 */
@media (max-width: 768px) {
  .message {
    max-width: 85%;
    margin: 0.5rem 2rem;
  }

  .message-avatar {
    width: 32px;
    height: 32px;
  }

  .user-message .message-avatar {
    right: -34px;
  }

  .assistant-message .message-avatar {
    left: -34px;
  }
}

@media (max-width: 480px) {
  .message {
    max-width: 90%;
    margin: 0.5rem 1.5rem;
  }

  .chat-messages {
    padding: 1rem;
  }
}

/* 실시간 인식 텍스트를 위한 스타일 */
.partial-transcript {
  background: rgba(99, 102, 241, 0.1) !important;
  border: 1px dashed var(--primary-color) !important;
  animation: pulse 1.5s infinite;
}

.streaming-text {
  opacity: 0.85;
  transition: all 0.2s ease;
}

.streaming-text .message-content {
  background-color: rgba(99, 102, 241, 0.05);
  animation: pulse 2s infinite;
}

.final-text {
  opacity: 1;
}

.final-text .message-content {
  background-color: rgba(99, 102, 241, 0.1);
}

.streaming-text {
  opacity: 0.85;
  transition: all 0.2s ease;
}

.streaming-text .message-content {
  background-color: rgba(99, 102, 241, 0.05);
  animation: pulse 2s infinite;
}

.final-text {
  opacity: 1;
}

.final-text .message-content {
  background-color: rgba(99, 102, 241, 0.1);
}

@keyframes pulse {
  0% {
    border-color: rgba(99, 102, 241, 0.4);
  }
  50% {
    border-color: rgba(99, 102, 241, 0.8);
  }
  100% {
    border-color: rgba(95, 97, 231, 0.4);
  }
}

/* 사고 모드를 위한 <think> 태그 스타일 */
think {
  display: block;
  background-color: transparent;
  border-left: 2px solid rgba(16, 185, 129, 0.2);
  padding: 1px 1px;
  margin: 1px 0;
  color: rgba(107, 114, 128, 0.65);
  opacity: 0.45 !important;
  font-style: italic;
  font-size: 0.95em;
  max-width: 98%;
  margin-left: auto;
  margin-right: auto;
  transition: opacity 0.3s ease;
  text-indent: 5px;
}

/* think 태그에 호버 시 약간 더 선명하게 처리 */
think:hover {
  opacity: 0.7 !important;
}

/* think 태그에 "AI의 생각 과정" 레이블 추가 */
think::before {
  content: "🤔 AI 사고 과정";
  display: inline-block;
  background-color: rgba(16, 185, 129, 0.1);
  color: rgba(16, 185, 129, 0.6);
  font-size: 0.8em;
  font-weight: 400;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
  font-style: normal;
  text-indent: 0;
}

/* think 내부의 모든 텍스트 스타일 */
think p, think ul, think ol, think pre, think blockquote {
  margin-left: 4px;
  border-left: 1px solid rgba(16, 185, 129, 0.1);
  padding-left: 8px;
  color: rgba(107, 114, 128, 0.65);
}

/* think 태그 내부의 코드 블록 스타일 */
think pre, think code {
  background-color: rgba(209, 250, 229, 0.1);
  padding: 4px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
  border: 1px solid rgba(167, 243, 208, 0.15);
  color: rgba(4, 120, 87, 0.5);
}

/* think 태그 내부 목록 스타일 */
think ul, think ol {
  padding-left: 18px;
  margin: 6px 0;
}

think li {
  margin-bottom: 4px;
}

/* think 태그 안의 강조 텍스트 */
think strong, think b {
  color: rgba(4, 120, 87, 0.8);
  font-weight: 500;
}

/* 사고 영역에 대한 애니메이션 효과 간소화 */
@keyframes thinkingFade {
  from { 
    opacity: 0.7;
  }
  to { 
    opacity: 0.8;
  }
}

think {
  animation: thinkingFade 0.5s ease-in-out;
}

/* 사고 영역과 일반 답변 사이 구분자 간소화 */
think + p, think + div {
  position: relative;
  margin-top: 12px;
}

/* 일반 답변 레이블 삭제하고 보이지 않게 설정 */
think + p::before, think + div::before {
  content: "";
  display: none;
}
