/* TAM-Q 프로젝트 페이지 스타일 */
/* 하이브리드 구조: 섹션별 주석으로 관리 */

/* ===== 공통 스타일 ===== */
/* CSS 변수 */
:root {
  --primary-blue: #3b82f6;
  --light-blue: #60a5fa;
  --lighter-blue: #93c5fd;
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --font-base: "Noto Sans KR", "Heebo", sans-serif;
  --font-heading: "Noto Sans KR", "Heebo", sans-serif;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* 기본 스타일 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-base);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: var(--gray-800);
  line-height: 1.6;
}

/* ===== 레이아웃 스타일 ===== */
/* 헤더 스타일 */
.header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--gray-900);
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.logo:hover {
  opacity: 0.8;
}

.logo-icon {
  font-size: 1.75rem;
}

.logo-text {
  font-family: var(--font-heading);
  font-weight: 700;
}

.header-nav {
  display: flex;
  gap: 2rem;
  align-items: center;
}

/* 컨테이너 */
.container {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  min-height: calc(100vh - 80px);
  padding: 2rem;
  gap: 2rem;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

/* 사이드바 */
.sidebar {
  width: 280px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  height: fit-content;
}

.sidebar-content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.5rem;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.sidebar-logo:hover {
  opacity: 0.8;
}

.sidebar-logo .logo-icon.blue {
  color: var(--primary-blue);
}

.sidebar-logo .logo-text.blue {
  color: var(--primary-blue);
  font-family: var(--font-heading);
  font-weight: 700;
}

/* 프로젝트 메뉴 */
.project-menu {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.menu-item {
  background: transparent;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-base);
  width: 100%;
  text-align: left;
}

.menu-item:hover {
  background: rgba(59, 130, 246, 0.05);
  border-color: var(--light-blue);
  transform: translateY(-1px);
}

.menu-item.active {
  background: linear-gradient(
    135deg,
    var(--primary-blue) 0%,
    var(--light-blue) 100%
  );
  border-color: var(--primary-blue);
  color: var(--white);
  box-shadow: var(--shadow-md);
}

.menu-item.active:hover {
  background: linear-gradient(
    135deg,
    var(--light-blue) 0%,
    var(--lighter-blue) 100%
  );
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.menu-icon {
  font-size: 1.25rem;
  width: 1.5rem;
  text-align: center;
}

.menu-text {
  font-weight: 600;
  font-size: 1rem;
}

/* 메인 콘텐츠 */
.main-content {
  flex: 1;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* 콘텐츠 헤더 */
.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--gray-200);
}

.page-title {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-blue);
  margin: 0;
}

/* 저장 버튼 */
.save-btn {
  background: var(--white);
  color: #10b981;
  border: 2px solid #10b981;
  border-radius: 12px;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-base);
}

.save-btn:hover {
  background: #ecfdf5; /* green-50 */
  color: #059669;
  border-color: #059669;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.save-btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-md);
}

.save-icon {
  font-size: 1rem;
}

.save-text {
  font-weight: 600;
}

/* 콘텐츠 섹션 */
.content-section {
  flex: 1;
}

.section-content {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.section-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: linear-gradient(
    135deg,
    rgba(59, 130, 246, 0.1) 0%,
    rgba(147, 197, 253, 0.1) 100%
  );
  border-radius: 12px;
  border-left: 4px solid var(--primary-blue);
}

/* 텍스트 영역 */
.content-textarea {
  flex: 1;
  width: 100%;
  min-height: 400px;
  padding: 1.5rem;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  font-family: var(--font-base);
  font-size: 1rem;
  line-height: 1.6;
  resize: vertical;
  transition: all 0.3s ease;
  background: var(--white);
}

.content-textarea:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.content-textarea::placeholder {
  color: var(--gray-400);
  font-style: italic;
}

/* 로딩 상태 */
.save-btn.loading {
  pointer-events: none;
  opacity: 0.8;
}

.save-btn.loading .save-text {
  opacity: 0;
}

.save-btn.loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top: 2px solid var(--white);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* 반응형 디자인 */
@media (max-width: 768px) {
  .container {
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
  }

  .sidebar {
    width: 100%;
    order: 2;
  }

  .main-content {
    order: 1;
    padding: 1.5rem;
  }

  .content-header {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  .page-title {
    font-size: 1.5rem;
  }

  .project-menu {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .menu-item {
    padding: 0.75rem;
    font-size: 0.875rem;
  }

  .menu-icon {
    font-size: 1rem;
  }

  .content-textarea {
    min-height: 300px;
    padding: 1rem;
  }

  .selected-reference-item {
    flex-direction: column;
    align-items: stretch;
  }

  .remove-reference-btn {
    align-self: flex-end;
  }
}

@media (max-width: 480px) {
  .header-content {
    padding: 0 1rem;
  }

  .logo {
    font-size: 1.25rem;
  }

  .project-menu {
    grid-template-columns: 1fr;
  }

  .menu-item {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
    padding: 1rem 0.75rem;
  }

  .menu-icon {
    font-size: 1.25rem;
  }

  .menu-text {
    font-size: 0.875rem;
  }
}

/* ===== 주제 섹션 스타일 ===== */
.topic-section {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.input-group {
  background: rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid rgba(59, 130, 246, 0.1);
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-field label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.875rem;
}

.form-input {
  padding: 0.75rem 1rem;
  border: 2px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.9);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input:read-only {
  background: rgba(243, 244, 246, 0.9);
  cursor: not-allowed;
  color: var(--gray-600);
}

.input-with-button {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.input-with-button .form-input,
.input-with-button .form-textarea {
  flex: 1;
}

.lock-input-btn {
  padding: 0.75rem 1.25rem;
  background: var(--primary-blue);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  min-width: 80px;
}

.lock-input-btn:hover:not(:disabled) {
  background: var(--light-blue);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.lock-input-btn:disabled {
  background: var(--gray-400);
  cursor: not-allowed;
  opacity: 0.7;
}

.lock-textarea-btn {
  align-self: flex-start;
  margin-top: 0;
}

.form-textarea {
  padding: 1rem;
  border: 2px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  font-size: 1rem;
  min-height: 120px;
  resize: vertical;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.9);
  font-family: inherit;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-textarea:read-only {
  background: rgba(243, 244, 246, 0.9);
  cursor: not-allowed;
  color: var(--gray-600);
  resize: none;
}

/* ===== 참고자료 섹션 스타일 ===== */
.ai-recommendation-section,
.ai-references-section,
.selected-topic-section,
.selected-references-section,
.research-section {
  background: rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid rgba(59, 130, 246, 0.1);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.subsection-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.recommend-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.875rem;
}

.recommend-btn {
  background: var(--white);
  color: #10b981;
  border: 2px solid #10b981;
}

.recommend-btn:hover {
  background: #ecfdf5; /* green-50 */
  color: #059669;
  border-color: #059669;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

.reference-actions {
  display: flex;
  gap: 0.75rem;
}

.get-references-btn,
.refresh-references-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.875rem;
}

.get-references-btn {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
}

.refresh-references-btn {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
  color: white;
}

.get-references-btn:hover,
.refresh-references-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.get-references-btn:disabled,
.refresh-references-btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  opacity: 0.6;
}

.references-area {
  min-height: 200px;
  border: 2px dashed rgba(59, 130, 246, 0.3);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.references-area.has-references {
  display: block;
  border: none;
  padding: 0;
}

.references-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.reference-card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  transition: all 0.3s ease;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.reference-card:hover {
  border-color: var(--primary-blue);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
  transform: translateY(-1px);
}

.reference-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
  overflow: hidden;
}

.reference-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary-blue);
  margin: 0;
  word-break: break-word;
  overflow-wrap: break-word;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.reference-description {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin: 0;
  word-break: break-word;
  overflow-wrap: break-word;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.reference-reason,
.selected-reference-reason {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin: 0.25rem 0 0;
  line-height: 1.5;
}

.reference-reason .reason-label,
.selected-reference-reason .reason-label {
  font-weight: 600;
  color: var(--primary-blue);
  margin-right: 0.35rem;
}

.reference-link {
  font-size: 0.85rem;
  color: var(--primary-blue);
  font-weight: 600;
  text-decoration: none;
  word-break: break-all;
  overflow-wrap: break-word;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  display: inline-block;
}

.reference-link:hover {
  text-decoration: underline;
}

.selected-references-section {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.selected-references-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.selected-references-guide {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.selected-references-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.selected-references-empty {
  padding: 1rem;
  border-radius: 10px;
  border: 1px dashed rgba(59, 130, 246, 0.25);
  background: rgba(59, 130, 246, 0.04);
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-align: center;
}

.selected-reference-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: #fff;
  box-shadow: 0 6px 12px rgba(148, 163, 184, 0.04);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.selected-reference-text {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.selected-reference-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
  word-break: break-word;
  overflow-wrap: break-word;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.selected-reference-description {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: break-word;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.selected-reference-link {
  font-size: 0.85rem;
  color: var(--primary-blue);
  font-weight: 600;
  text-decoration: none;
  width: fit-content;
  word-break: break-all;
  overflow-wrap: break-word;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  display: inline-block;
}

.selected-reference-link:hover {
  text-decoration: underline;
}

.remove-reference-btn {
  align-self: center;
  border: 1px solid rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  border-radius: 6px;
  padding: 0.45rem 0.85rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.remove-reference-btn:hover {
  background: rgba(239, 68, 68, 0.16);
}

.remove-reference-btn:focus {
  outline: 2px solid rgba(239, 68, 68, 0.35);
  outline-offset: 2px;
}

.reference-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary-blue);
  background: rgba(59, 130, 246, 0.12);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  width: fit-content;
}

.reference-type-badge::before {
  content: "📑";
  font-size: 0.75rem;
}

.reference-type-badge[data-type="book"]::before {
  content: "📚";
}

.reference-type-badge[data-type="online"]::before {
  content: "🌐";
}

.select-reference-btn {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  align-self: center;
}

.select-reference-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.select-reference-btn .btn-icon {
  display: inline-flex;
  align-items: center;
  margin-right: 0.35rem;
  font-size: 0.85rem;
}

.select-reference-btn.is-selected {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary-blue);
  border: 1px solid rgba(59, 130, 246, 0.4);
  box-shadow: none;
}

.select-reference-btn.is-selected:hover {
  transform: none;
  box-shadow: none;
  background: rgba(59, 130, 246, 0.18);
}

.pdf-section .section-description {
  margin-bottom: 1.25rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.pdf-empty {
  text-align: center;
  padding: 2.5rem 1.5rem;
  border: 1px dashed rgba(59, 130, 246, 0.25);
  border-radius: 12px;
  color: var(--text-secondary);
  background: rgba(59, 130, 246, 0.04);
}

.pdf-empty-tip {
  margin-top: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.pdf-grid .reference-card {
  align-items: stretch;
}

.pdf-grid .reference-content {
  gap: 0.4rem;
}

.pdf-grid .reference-description {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.open-pdf-btn {
  min-width: 80px;
}

.pdf-card-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.delete-pdf-btn {
  min-width: 80px;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
}

.delete-pdf-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.delete-pdf-btn:focus {
  outline: 2px solid rgba(239, 68, 68, 0.4);
  outline-offset: 2px;
}

/* ===== 보고서 섹션 스타일 ===== */
.report-section {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.report-form {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  padding: 2rem;
  border: 1px solid rgba(59, 130, 246, 0.1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.report-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid rgba(59, 130, 246, 0.2);
}

.report-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-blue);
  margin: 0;
  font-family: var(--font-heading);
}

.report-fields {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.report-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.report-field label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.report-input {
  padding: 0.75rem 1rem;
  border: 2px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.9);
  font-family: inherit;
}

.report-input:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.report-textarea {
  padding: 1rem;
  border: 2px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  font-size: 1rem;
  resize: vertical;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.9);
  font-family: inherit;
  line-height: 1.6;
}

.report-textarea:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.report-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
}

.report-actions {
  display: flex;
  justify-content: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(59, 130, 246, 0.1);
}

.save-report-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 2rem;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1rem;
}

.save-report-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
}

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

.auto-fill-notice {
  color: #10b981;
  font-size: 0.75rem;
  margin-top: 0.25rem;
  font-style: italic;
}

.field-with-button {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.generate-content-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.875rem;
  align-self: flex-start;
}

.generate-content-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.generate-content-btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.add-example-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.875rem;
  align-self: flex-start;
}

.add-example-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.add-example-btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* 보고서 선택 모달 */
.record-insert-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(17, 24, 39, 0.55);
  backdrop-filter: blur(6px);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
}

.record-insert-modal.active {
  display: flex;
}

.record-insert-content {
  background: var(--white);
  border-radius: 16px;
  width: 100%;
  max-width: 720px;
  box-shadow: 0 25px 70px rgba(15, 23, 42, 0.35);
  animation: modalSlideUp 0.35s ease-out;
}

.record-insert-content .modal-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid rgba(59, 130, 246, 0.15);
}

.record-insert-content .modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-800);
}

.record-insert-content .modal-body {
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.record-insert-content .modal-description {
  margin: 0;
  color: var(--gray-600);
  line-height: 1.6;
}

.record-insert-content .modal-footer {
  padding: 1.25rem 2rem;
  border-top: 1px solid rgba(59, 130, 246, 0.15);
  display: flex;
  justify-content: flex-end;
}

.report-select-area {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.report-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.report-list-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 1rem 1.25rem;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
}

.report-list-item:hover {
  transform: translateY(-2px);
  background: rgba(59, 130, 246, 0.12);
  box-shadow: 0 10px 25px rgba(59, 130, 246, 0.18);
}

.report-list-item-title {
  font-weight: 700;
  color: var(--gray-800);
}

.report-list-item-meta {
  font-size: 0.8rem;
  color: var(--gray-500);
}

.report-list-empty,
.report-list-loading {
  padding: 2rem 1.5rem;
  text-align: center;
  background: rgba(107, 114, 128, 0.08);
  border-radius: 12px;
  color: var(--gray-600);
}

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

@media (max-width: 640px) {
  .record-insert-content {
    max-width: 100%;
  }

  .record-insert-content .modal-header,
  .record-insert-content .modal-body,
  .record-insert-content .modal-footer {
    padding: 1.25rem;
  }

  .report-list {
    max-height: 260px;
  }
}

/* ===== 생기부500자 섹션 스타일 ===== */
.record-section {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.record-form {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  padding: 2rem;
  border: 1px solid rgba(59, 130, 246, 0.1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.record-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid rgba(59, 130, 246, 0.2);
}

.record-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-blue);
  margin: 0 0 0.5rem 0;
  font-family: var(--font-heading);
}

.record-description {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin: 0;
}

.record-fields {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.byte-counter {
  background: rgba(59, 130, 246, 0.05);
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid rgba(59, 130, 246, 0.1);
}

.counter-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.current-bytes {
  font-weight: 700;
  font-size: 1.25rem;
  color: #10b981;
}

.max-bytes {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(59, 130, 246, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #10b981;
  border-radius: 4px;
  transition: all 0.3s ease;
  width: 0%;
}

.record-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.record-field label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.record-textarea {
  padding: 1rem;
  border: 2px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  font-size: 1rem;
  resize: vertical;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.9);
  font-family: inherit;
  line-height: 1.6;
  min-height: 200px;
}

.record-textarea:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.record-guidelines {
  background: rgba(139, 92, 246, 0.05);
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid rgba(139, 92, 246, 0.1);
  margin-top: 0.5rem;
}

.record-guidelines h4 {
  margin: 0 0 0.75rem 0;
  color: #8b5cf6;
  font-size: 0.875rem;
  font-weight: 600;
}

.record-guidelines ul {
  margin: 0;
  padding-left: 1.25rem;
  list-style: none;
}

.record-guidelines li {
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.record-guidelines li:before {
  content: "•";
  color: #8b5cf6;
  font-weight: bold;
  display: inline-block;
  width: 1em;
  margin-left: -1em;
}

.record-guidelines strong {
  color: var(--text-primary);
  font-weight: 600;
}

.record-actions {
  display: flex;
  justify-content: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(59, 130, 246, 0.1);
}

.save-record-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 2rem;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1rem;
}

.save-record-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
}

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

/* ===== 탐구과정 섹션 스타일 (챗봇) ===== */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 600px;
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 12px;
  overflow: hidden;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: linear-gradient(
    135deg,
    var(--primary-blue) 0%,
    var(--light-blue) 100%
  );
  color: white;
}

.chat-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.chat-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-icon {
  font-size: 1.25rem;
}

.chat-name {
  font-weight: 600;
  font-size: 1rem;
}

.start-chat-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.875rem;
}

.start-chat-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.start-chat-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.delete-chat-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(239, 68, 68, 0.8);
  color: white;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.875rem;
}

.delete-chat-btn:hover {
  background: rgba(239, 68, 68, 1);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

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

.chat-messages {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.welcome-message {
  text-align: center;
  padding: 2rem;
  color: var(--text-primary);
}

.welcome-message .message-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.welcome-message h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary-blue);
  margin: 0 0 0.5rem 0;
}

.welcome-message p {
  color: #6b7280;
  margin: 0;
  line-height: 1.5;
}

.message {
  display: flex;
  gap: 0.75rem;
  max-width: 80%;
}

.user-message {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ai-message {
  align-self: flex-start;
}

.message-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: linear-gradient(
    135deg,
    var(--primary-blue) 0%,
    var(--light-blue) 100%
  );
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.avatar-icon {
  font-size: 1.25rem;
  color: white;
}

.message-content {
  flex: 1;
  min-width: 0;
}

.message-sender {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary-blue);
  margin-bottom: 0.25rem;
}

.message-text {
  background: rgba(255, 255, 255, 0.9);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(59, 130, 246, 0.1);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-primary);
  word-wrap: break-word;
}

.user-message .message-text {
  background: linear-gradient(
    135deg,
    var(--primary-blue) 0%,
    var(--light-blue) 100%
  );
  color: white;
  border: none;
}

.message-time {
  font-size: 0.625rem;
  color: #9ca3af;
  margin-top: 0.25rem;
  text-align: right;
}

.ai-message .message-time {
  text-align: left;
}

.chat-input-container {
  padding: 1rem;
  background: rgba(255, 255, 255, 0.95);
  border-top: 1px solid rgba(59, 130, 246, 0.1);
}

.chat-input-wrapper {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  font-size: 0.875rem;
  resize: vertical;
  min-height: 2.5rem;
  max-height: 6rem;
  font-family: inherit;
  transition: all 0.3s ease;
}

.chat-input:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.send-message-btn {
  width: 2.5rem;
  height: 2.5rem;
  background: linear-gradient(
    135deg,
    var(--primary-blue) 0%,
    var(--light-blue) 100%
  );
  color: white;
  border: none;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.send-message-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.send-message-btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.recommendation-area {
  min-height: 200px;
  border: 2px dashed rgba(59, 130, 246, 0.3);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.placeholder-text {
  color: #6b7280;
  text-align: center;
  font-style: italic;
}

.loading-spinner {
  color: var(--primary-blue);
  font-weight: 600;
  text-align: center;
}

.recommendations-grid {
  display: grid;
  gap: 1rem;
}

.recommendation-card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s ease;
}

.recommendation-card:hover {
  border-color: var(--primary-blue);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
  transform: translateY(-1px);
}

.recommendation-content {
  flex: 1;
}

.recommendation-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary-blue);
  margin: 0 0 0.25rem 0;
}

.recommendation-text {
  font-size: 0.875rem;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.4;
}

.select-recommendation-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.select-recommendation-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.error-message {
  color: #ef4444;
  text-align: center;
  padding: 1rem;
}

.error-message p {
  margin: 0.25rem 0;
}

.input-required-message {
  text-align: center;
  padding: 2rem;
  color: var(--text-primary);
}

.message-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.input-required-message h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary-blue);
  margin: 0 0 0.5rem 0;
}

.input-required-message p {
  color: #6b7280;
  margin: 0 0 1.5rem 0;
  line-height: 1.5;
}

.input-guide {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 300px;
  margin: 0 auto;
}

.guide-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: rgba(59, 130, 246, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(59, 130, 246, 0.1);
}

.guide-icon {
  font-size: 1.25rem;
  width: 1.5rem;
  text-align: center;
}

.guide-text {
  font-size: 0.875rem;
  color: var(--text-primary);
  font-weight: 500;
}

/* ===== 반응형 디자인 ===== */
@media (max-width: 768px) {
  .input-row {
    grid-template-columns: 1fr;
  }

  .report-row {
    grid-template-columns: 1fr;
  }

  .report-form {
    padding: 1.5rem;
  }

  .report-title {
    font-size: 1.25rem;
  }

  .section-header {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  .recommendation-card {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  .select-recommendation-btn {
    width: 100%;
  }

  .reference-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .get-references-btn,
  .refresh-references-btn {
    width: 100%;
    justify-content: center;
  }

  .reference-card {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  .select-reference-btn {
    width: 100%;
  }

  .chat-container {
    height: 500px;
  }

  .chat-header {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  .start-chat-btn {
    width: 100%;
    justify-content: center;
  }

  .chat-actions {
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
  }

  .delete-chat-btn {
    width: 100%;
    justify-content: center;
  }

  .message {
    max-width: 95%;
  }

  .chat-input-wrapper {
    flex-direction: column;
    gap: 0.5rem;
  }

  .send-message-btn {
    width: 100%;
    height: 2.75rem;
  }

  .record-form {
    padding: 1.5rem;
  }

  .record-title {
    font-size: 1.25rem;
  }

  .record-guidelines {
    padding: 0.75rem;
  }

  .record-guidelines li {
    font-size: 0.75rem;
  }
}

/* ===== 모달 팝업 스타일 ===== */
.modal-overlay {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-container {
  background: var(--white);
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease;
  overflow: hidden;
}

.modal-container.modal-warning {
  border-top: 4px solid #f59e0b;
}

.modal-container.modal-error {
  border-top: 4px solid #ef4444;
}

.modal-container.modal-info {
  border-top: 4px solid var(--primary-blue);
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem;
  border-bottom: 1px solid var(--gray-200);
}

.modal-icon {
  font-size: 1.5rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-900);
  margin: 0;
}

.modal-body {
  padding: 1.5rem;
}

.modal-message {
  color: var(--gray-700);
  font-size: 1rem;
  line-height: 1.6;
  margin: 0;
  white-space: pre-line;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.5rem;
  border-top: 1px solid var(--gray-200);
}

.modal-btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: var(--font-base);
}

.modal-btn-primary {
  background: linear-gradient(
    135deg,
    var(--primary-blue) 0%,
    var(--light-blue) 100%
  );
  color: var(--white);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.modal-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

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

/* 반응형 모달 */
@media (max-width: 768px) {
  .modal-container {
    max-width: 90%;
  }

  .modal-title {
    font-size: 1.125rem;
  }

  .modal-body {
    padding: 1.25rem 1rem;
  }

  .modal-footer {
    flex-direction: column-reverse;
  }

  .modal-btn {
    width: 100%;
  }
}
