/* byRhinoGen 매뉴얼 테마 (WordToHelp DOM에 현재 사이트 디자인을 입힘)
 *
 * 업로드 시 manual_bundle 서비스가 번들 동봉 assets/style.css를 버리고 이 파일로
 * 교체한다. WordToHelp가 만든 고정 클래스 구조(.sidebar/.toc/.content 등)를 타깃으로
 * frontend/src/app/globals.css 의 디자인 토큰을 미러링한다.
 *
 * 주의: globals.css 토큰과 수동 동기화 대상이다. 디자인 토큰이 바뀌면 이 파일도 갱신할 것.
 * iframe 은 독립 문서라 Pretendard 를 CDN 으로 직접 로드한다.
 */
@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css");

:root {
  color-scheme: light;
  --primary-color: #0092ff;
  --primary-strong: #006ef4;
  --bg-color: #ffffff;
  --sidebar-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --hover-bg: #f8fafc;
  --divider-color: #cecece;
  --header-height: 60px;
  --font-sans: "Pretendard Variable", "Pretendard", -apple-system,
    BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* 콘텐츠를 와이드 화면에서 중앙 컨테이너로 묶는다(Figma 6-w-메뉴얼: 1277px,
 * 사이트 Navbar 의 max-w-7xl 정렬과 맞춤). 사이드바 영역 + 56px 간격 + 본문. */
.layout {
  display: flex;
  gap: 56px;
  max-width: 1277px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 282px;
  flex-shrink: 0;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--divider-color);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  z-index: 40;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 1.75rem 1.5rem 1.25rem;
}

.sidebar-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-main);
  margin: 0;
  line-height: 1.3;
}

.toc {
  padding: 0.5rem 0 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc > ul {
  padding: 0 1rem;
}

.toc li {
  position: relative;
}

.toc-item {
  display: flex;
  align-items: flex-start;
  margin-bottom: 2px;
}

.toc-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  transition: all 0.2s;
  margin-top: 3px;
  margin-right: 4px;
}

.toc-toggle:hover {
  background-color: var(--hover-bg);
  color: var(--text-main);
}

.toc-toggle svg {
  transition: transform 0.3s ease;
}

.toc-toggle.expanded svg {
  transform: rotate(90deg);
}

.toc a {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.45rem 0.6rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.9375rem;
  transition: all 0.2s;
  word-break: break-word;
  line-height: 1.45;
}

.toc a:hover {
  background-color: var(--hover-bg);
  color: var(--text-main);
}

.toc a.active {
  background-color: rgba(0, 146, 255, 0.1);
  color: var(--primary-color);
  font-weight: 600;
}

.toc-children {
  display: none;
  padding-left: 24px !important;
  border-left: 1px solid var(--border-color);
  margin-left: 12px !important;
  margin-top: 2px;
  margin-bottom: 8px;
}

.toc-children.expanded {
  display: block;
  animation: slideDown 0.2s ease-out forwards;
}

.toc-children a {
  font-size: 0.875rem;
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
}

.toc-folder-item {
  font-weight: 600 !important;
  color: var(--text-main) !important;
}

.toc-children .toc-children {
  margin-left: 12px !important;
  border-left: 1px dashed var(--border-color);
}

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

/* Main Content */
.content-wrapper {
  flex: 1;
  min-width: 0;
  padding: 3rem 0 6rem;
}

.content {
  width: 100%;
  max-width: 926px;
}

.content h1,
.content h2,
.content h3,
.content h4 {
  color: var(--text-main);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.content h1 {
  font-size: 1.75rem;
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--divider-color);
}

.content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

.content h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 1.75rem;
  margin-bottom: 0.75rem;
}

.content h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

/* Banner style for Steps, Note, See Also (H3, H4) */
.content .section-banner {
  background-color: var(--hover-bg);
  padding: 0.4rem 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  display: block;
}

.content .has-bg-color {
  background-color: var(--para-bg);
}

.content p {
  margin-bottom: 1rem;
  color: var(--text-main);
  font-size: 1rem;
  line-height: 1.6;
}

.content a {
  color: var(--primary-color);
  text-decoration: underline;
  transition: color 0.2s;
}

.content a:hover {
  color: var(--primary-strong);
}

.content ul,
.content ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
  color: var(--text-main);
  font-size: 1rem;
}

.content li {
  margin-bottom: 0.4rem;
  line-height: 1.6;
}

.content li > ul,
.content li > ol {
  margin-top: 0.4rem;
  margin-bottom: 0;
}

/* Base image */
.content img {
  max-width: 100%;
  height: auto;
}

.content img.content-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.5rem 0;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

body.images-inline .content img.content-image {
  display: inline-block !important;
  vertical-align: top;
  margin: 4px !important;
  max-width: none !important;
  border: 1px solid var(--border-color);
}

.content .inline-icon {
  width: 32px !important;
  height: 32px !important;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 8px;
  display: inline-block !important;
  border: none;
  border-radius: 0;
}

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.75rem 0;
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.content th,
.content td {
  padding: 0.75rem 1rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border-color);
}

.content th {
  font-weight: 600;
  color: var(--text-main);
  background-color: var(--hover-bg);
}

.content tr:last-child td {
  border-bottom: none;
}

/* Mobile menu button + overlay */
#mobile-menu-btn {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 50;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-main);
  cursor: pointer;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.4);
  z-index: 39;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .layout {
    gap: 0;
    padding: 0;
  }

  /* 모바일은 사이드바를 화면 밖 고정 drawer 로 되돌린다(데스크톱 sticky 무효화). */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    height: auto;
    transform: translateX(-100%);
    width: 280px;
    box-shadow: var(--shadow-dropdown, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .content-wrapper {
    padding: 4.5rem 1.5rem 4rem;
  }

  #mobile-menu-btn {
    display: flex;
  }

  .overlay.show {
    display: block;
    opacity: 1;
  }

  .content h1 {
    font-size: 1.5rem;
  }

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