@tailwind base;
@tailwind components;
@tailwind utilities;

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

code {
  font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
    monospace;
}

/* 스크롤바 스타일링 */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* 채팅 메시지 애니메이션 */
.message-enter {
  opacity: 0;
  transform: translateY(20px);
}

.message-enter-active {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 300ms, transform 300ms;
}

/* 로딩 애니메이션 */
.typing-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #9ca3af;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-indicator:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typing {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* 그라데이션 텍스트 */
.gradient-text {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* 카드 호버 효과 */
.card-hover {
  transition: all 0.3s ease;
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* 버튼 애니메이션 */
.btn-animate {
  transition: all 0.2s ease;
}

.btn-animate:hover {
  transform: translateY(-1px);
}

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

/* PDF 뷰어 스타일 */
.react-pdf__Page {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.react-pdf__Page__canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.react-pdf__Page__textContent {
  position: absolute;
  top: 0;
  left: 0;
  transform: scale(1);
  transform-origin: 0 0;
  white-space: pre;
  cursor: text;
  color: transparent;
  font-family: sans-serif;
  overflow: hidden;
  user-select: text;
}

.react-pdf__Page__textContent span {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
}

.react-pdf__Page__annotations {
  position: absolute;
  top: 0;
  left: 0;
  transform: scale(1);
  transform-origin: 0 0;
}

.react-pdf__Page__annotation {
  position: absolute;
  transform: scale(1);
  transform-origin: 0% 0%;
}

/* 마크다운 콘텐츠 스타일 */
.markdown-content {
  max-width: 100%;
  line-height: 1.6;
  color: #374151;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: #1f2937;
}

.markdown-content h1 {
  font-size: 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.5rem;
}

.markdown-content h2 {
  font-size: 1.25rem;
}

.markdown-content h3 {
  font-size: 1.125rem;
}

.markdown-content h4 {
  font-size: 1rem;
}

.markdown-content p {
  margin-bottom: 1rem;
  color: #374151;
}

.markdown-content ul,
.markdown-content ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.markdown-content li {
  margin-bottom: 0.25rem;
  color: #374151;
}

.markdown-content strong {
  font-weight: 600;
  color: #1f2937;
}

.markdown-content em {
  font-style: italic;
  color: #4b5563;
}

.markdown-content code {
  background-color: #f3f4f6;
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  font-family: 'Courier New', monospace;
}

.markdown-content pre {
  background-color: #1f2937;
  color: #f9fafb;
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin-bottom: 1rem;
}

.markdown-content pre code {
  background-color: transparent;
  padding: 0;
  color: inherit;
}

.markdown-content blockquote {
  border-left: 4px solid #3b82f6;
  padding-left: 1rem;
  margin: 1rem 0;
  font-style: italic;
  color: #4b5563;
  background-color: #eff6ff;
  padding: 0.5rem 1rem;
  border-radius: 0 0.25rem 0.25rem 0;
}

.markdown-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  border: 1px solid #d1d5db;
}

.markdown-content th,
.markdown-content td {
  border: 1px solid #d1d5db;
  padding: 0.5rem;
  text-align: left;
}

.markdown-content th {
  background-color: #f9fafb;
  font-weight: 600;
  color: #1f2937;
}

.markdown-content tr:hover {
  background-color: #f9fafb;
}

.markdown-content hr {
  border: none !important;
  border-top: none !important;
  margin: 2rem 0;
  display: none !important; /* hr 요소 완전 숨김 */
  height: 0 !important;
  visibility: hidden !important;
}

/* 모든 가능한 선 제거 */
.markdown-content * {
  border-top: none !important;
}

.markdown-content > *:first-child {
  border-top: none !important;
}

/* 참조 문서 섹션의 모든 선 제거 */
.mt-3.pt-3 {
  border-top: none !important;
  border: none !important;
}

/* 특정 클래스의 테두리 제거 (입력 영역 제외) */
.border-t:not(input):not(.input-area) {
  border-top: none !important;
}

/* 메시지 버블의 모든 테두리 제거 */
.rounded-2xl {
  border: none !important;
  border-top: none !important;
  border-bottom: none !important;
  border-left: none !important;
  border-right: none !important;
}

/* 마크다운 콘텐츠 스타일 */
.markdown-content {
  border: none !important;
  background: transparent !important;
  color: #374151 !important;
  font-family: inherit !important;
  line-height: 1.6 !important;
  white-space: pre-wrap !important;
  word-wrap: break-word !important;
}

/* 마크다운 요소들 기본 스타일 */
.markdown-content h1 {
  font-size: 1.5rem !important;
  font-weight: bold !important;
  color: #374151 !important;
  margin: 1rem 0 0.5rem 0 !important;
  border-bottom: 2px solid #E5E7EB !important;
  padding-bottom: 0.5rem !important;
}

.markdown-content h2 {
  font-size: 1.25rem !important;
  font-weight: bold !important;
  color: #374151 !important;
  margin: 1.5rem 0 0.5rem 0 !important;
}

.markdown-content h3 {
  font-size: 1.125rem !important;
  font-weight: bold !important;
  color: #374151 !important;
  margin: 1.25rem 0 0.5rem 0 !important;
}

.markdown-content h4 {
  font-size: 1rem !important;
  font-weight: bold !important;
  color: #374151 !important;
  margin: 1rem 0 0.5rem 0 !important;
}

.markdown-content p {
  margin: 0.5rem 0 !important;
  line-height: 1.6 !important;
  color: #4B5563 !important;
}

.markdown-content ul {
  margin: 0.5rem 0 !important;
  padding-left: 1.5rem !important;
  list-style-type: disc !important;
}

.markdown-content ol {
  margin: 0.5rem 0 !important;
  padding-left: 1.5rem !important;
  list-style-type: decimal !important;
}

.markdown-content li {
  margin: 0.25rem 0 !important;
  color: #4B5563 !important;
}

.markdown-content strong {
  font-weight: bold !important;
  color: #374151 !important;
}

.markdown-content em {
  font-style: italic !important;
  color: #4B5563 !important;
}

.markdown-content code {
  background-color: #F3F4F6 !important;
  padding: 0.125rem 0.25rem !important;
  border-radius: 0.25rem !important;
  font-family: 'Courier New', monospace !important;
  font-size: 0.875rem !important;
  color: #374151 !important;
}

/* 마크다운 내용이 pre 태그로 감싸지지 않도록 설정 */
.markdown-content {
  white-space: normal !important;
  word-wrap: break-word !important;
}

/* 전체 마크다운을 감싸는 pre 태그의 스타일을 일반 div처럼 변경 */
.markdown-content > pre {
  white-space: normal !important;
  word-wrap: break-word !important;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  font-family: inherit !important;
  font-size: inherit !important;
  line-height: inherit !important;
}

/* 마크다운 pre 래퍼 스타일 */
.markdown-pre-wrapper {
  white-space: normal !important;
  word-wrap: break-word !important;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  font-family: inherit !important;
  font-size: inherit !important;
  line-height: inherit !important;
  display: block !important;
  overflow: visible !important;
}

/* react-markdown이 생성하는 모든 pre 태그에 대한 강력한 리셋 */
.markdown-content pre,
.markdown-content > pre,
.markdown-content pre[class*="language-"],
.markdown-content pre:not([class]),
.markdown-content pre code,
.markdown-content > pre code {
  white-space: normal !important;
  word-wrap: break-word !important;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  font-family: inherit !important;
  font-size: inherit !important;
  line-height: inherit !important;
  display: block !important;
  overflow: visible !important;
  color: inherit !important;
}

/* 실제 코드 블록에만 적용되는 pre 태그 스타일 */
.markdown-content pre {
  background-color: #F3F4F6 !important;
  color: #374151 !important;
  padding: 1rem !important;
  border-radius: 0.5rem !important;
  overflow-x: auto !important;
  margin: 1rem 0 !important;
  white-space: pre-wrap !important;
  word-wrap: break-word !important;
}

/* pre 태그 내부의 코드 블록만 스타일 적용 */
.markdown-content pre code {
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
  font-size: inherit !important;
}

.markdown-content blockquote {
  border-left: 4px solid #3B82F6 !important;
  padding-left: 1rem !important;
  margin: 1rem 0 !important;
  font-style: italic !important;
  color: #6B7280 !important;
  background-color: #EFF6FF !important;
  padding: 0.5rem 1rem !important;
  border-radius: 0 0.25rem 0.25rem 0 !important;
}

.markdown-content table {
  width: 100% !important;
  border-collapse: collapse !important;
  margin: 1rem 0 !important;
}

.markdown-content th {
  border: 1px solid #D1D5DB !important;
  padding: 0.5rem !important;
  text-align: left !important;
  background-color: #F9FAFB !important;
  font-weight: bold !important;
  color: #374151 !important;
}

.markdown-content td {
  border: 1px solid #D1D5DB !important;
  padding: 0.5rem !important;
  text-align: left !important;
  color: #4B5563 !important;
}

.markdown-content hr {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  border-top: none !important;
  border-bottom: none !important;
  border-left: none !important;
  border-right: none !important;
  outline: none !important;
  box-shadow: none !important;
}

/* 모든 hr 요소 강제 숨김 */
hr {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

/* 모든 가능한 가로줄 요소 강제 숨김 */
hr,
.hr,
.horizontal-line,
.border-t,
.border-top,
[class*="border-t"],
[class*="border-top"] {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  border-top: none !important;
  outline: none !important;
  box-shadow: none !important;
}

/* 참조 문서 섹션의 모든 선과 배경 제거 */
.mt-3.pt-3 {
  border: none !important;
  border-top: none !important;
  border-bottom: none !important;
  border-left: none !important;
  border-right: none !important;
  background: transparent !important;
  background-color: transparent !important;
  outline: none !important;
  box-shadow: none !important;
}

/* 모든 hr 태그 완전 제거 */
hr {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  background: none !important;
}

/* 참조 문서 위의 모든 선 제거 */
.mt-3.pt-3::before,
.mt-3.pt-3::after {
  display: none !important;
  content: none !important;
}

/* 입력 영역 스타일 보호 */
.input-area {
  border-top: none !important;
  background: white !important;
  position: relative !important;
  z-index: 10 !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  height: auto !important;
  min-height: 80px !important;
}

.input-area input {
  border: 1px solid #d1d5db !important;
  background: white !important;
  color: #374151 !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  width: 100% !important;
  height: auto !important;
  min-height: 48px !important;
  padding-left: 20px !important;
  padding-right: 16px !important;
}

.input-area input:focus {
  border: 1px solid #3b82f6 !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
}

/* 입력 영역 버튼 스타일 */
.input-area button {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  background: linear-gradient(to right, #2563eb, #9333ea) !important;
  color: white !important;
}
