@import url("../../variables.css");
@import url("../../common/css/main.css");
@import url("../../common/css/markdown.css");

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

body {
  font-family: var(--font-primary);
  font-weight: var(--font-weight-regular);
  background: var(--light-gray);
  color: var(--primary-black);
  line-height: 1.4;
  font-size: 14px;
  min-height: 100vh;
}

:lang(ko) {
  font-family: var(--font-korean);
}

:lang(en) {
  font-family: var(--font-english);
}

.main-header {
  background: var(--primary-white);
  border-bottom: var(--border-width) solid var(--border-color);
  padding: var(--spacing-md) var(--spacing-xl);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.logo-section {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.logo-icon {
  font-size: 20px;
}

.logo-text {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary-black);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: var(--font-english);
}

.header-actions {
  display: flex;
  gap: 20px;
}

.header-actions button {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

.header-actions button:hover {
  background: #f0f0f0;
}

.main-content {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  min-height: 100vh;
}

.sidebar {
  width: 400px;
  background: #e5e5e5;
  padding: 40px;
  overflow-y: auto;
  min-height: 100vh;
  transition: all 0.3s ease;
}

.filter-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-black);
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: var(--font-english);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.filter-title::after {
  content: "▼";
  font-size: 14px;
  transition: transform 0.3s ease;
}

.filter-title.collapsed::after {
  transform: rotate(-90deg);
}

.filter-content {
  transition: max-height 0.3s ease, padding 0.3s ease;
  overflow: hidden;
  max-height: 1000px;
}

.filter-content.collapsed {
  max-height: 0;
  padding: 0;
}

.filter-content.expanded {
  max-height: 1000px;
}

.filter-dropdown {
  margin-bottom: 20px;
}

.chapter-list {
  margin: 0;
}

.filter-dropdown select {
  width: 100%;
  padding: 12px;
  border: none;
  border: 1px solid var(--primary-black);
  background: #ffffff;
  font-size: 14px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  outline: none;
  font-family: var(--font-korean);
  box-shadow: none;
  appearance: none;
}

.chapter-item {
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.chapter-item:not(:last-child) {
  border-bottom: 1px solid var(--primary-black);
}

.chapter-item:hover,
.chapter-item.active {
  background: var(--dark-gray);
}

.chapter-item.active {
  font-weight: 600;
}

.chapter-question {
  padding: 20px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-black);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-english);
}

.chapter-text {
  text-align: left;
  flex: 1;
}

.chapter-icon {
  font-size: 16px;
  font-weight: 700;
}

.content-area {
  flex: 1;
  background: #ffffff;
  position: sticky;
  top: 0;
  z-index: 60;
  overflow: hidden;
}

.content-header {
  padding: 40px 40px 20px 40px;
  border-bottom: 1px solid var(--primary-black);
  background: #ffffff;
  position: sticky;
  top: 0;
  z-index: 50;
}

.content-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary-black);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: var(--font-english);
}

.post-list {
  display: grid;
  gap: 1px;
  background: var(--primary-black);
  padding: 0;
  margin: 0;
}

.post-item {
  background: #ffffff;
  padding: 30px 40px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  position: relative;
}

.post-item:hover {
  background: #f8f8f8;
  transform: translateX(5px);
}

.post-item.practice {
  background: #ffffff;
  position: relative;
}

.post-item.practice::after {
  content: "실습";
  position: absolute;
  top: 15px;
  right: 20px;
  background: var(--primary-black);
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.post-item.practice:hover {
  background: #f8f8f8;
  transform: translateX(8px);
}

.post-item.practice .post-title {
  color: var(--primary-black);
  font-weight: 700;
}

.post-item.practice .post-meta {
  color: #666666;
}

.post-meta {
  font-size: 12px;
  color: #666666;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  font-family: var(--font-english);
}

.post-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary-black);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.3;
  font-family: var(--font-english);
}

.viewer-header {
  display: none;
}

@media (max-width: 1024px) {
  .main-content {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-height: none;
    padding: 20px 20px 0 20px;
    min-height: auto;
    transition: padding 0.3s ease;
  }

  .sidebar.expanded-state {
    padding-bottom: 20px;
  }

  .filter-content {
    max-height: 0;
    padding: 0;
  }

  .filter-content.collapsed {
    max-height: 0;
    padding: 0;
  }

  .filter-content.expanded {
    max-height: 1000px;
    padding: 0;
    padding-bottom: 20px;
  }

  .filter-content.expanded .filter-dropdown {
    margin-bottom: 20px;
  }

  .filter-content.expanded .chapter-list {
    max-height: 60vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    background: var(--primary-white);
  }

  .filter-content.expanded .chapter-list::-webkit-scrollbar {
    width: 6px;
  }

  .filter-content.expanded .chapter-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
  }

  .filter-content.expanded .chapter-list::-webkit-scrollbar-thumb {
    background: var(--primary-black);
    border-radius: 3px;
  }

  .filter-content.expanded .chapter-list::-webkit-scrollbar-thumb:hover {
    background: #666666;
  }

  .content-header,
  .viewer-header {
    padding: 20px;
  }

  .post-item,
  .markdown-content {
    padding: 20px;
  }

  .header-content {
    padding: 0 20px;
  }
}

@media (max-width: 768px) {
  .main-header {
    padding: 15px 20px;
  }

  .logo-text {
    font-size: 18px;
  }

  .header-actions {
    gap: 15px;
  }

  .sidebar,
  .content-header,
  .viewer-header,
  .post-item,
  .markdown-content {
    padding: 15px;
  }

  .chapter-question {
    font-size: 12px;
    padding: 12px;
  }

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

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

  .filter-content.expanded .chapter-list {
    max-height: 50vh;
  }
}

.filter-title.collapsed {
  margin-bottom: 0;
}

.loading-container {
  display: flex;
  justify-content: center;
  align-items: center;

  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;

  background-color: var(--primary-white);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 5px solid var(--medium-gray);
  border-top: 5px solid var(--primary-black);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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