/* Layout CSS - 3 Panel Layout */
/* Folders Panel (220px) | Articles List (360px) | Content (Expanded) */

.m3-body {
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* Main App Container - 3 Column Layout */
.app-container {
  display: grid;
  grid-template-columns: 220px 360px 1fr;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ==================== Folders Panel (220px) ==================== */
.folders-panel {
  width: 220px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--md-sys-color-outline-variant);
  overflow: hidden;
}

.folders-panel .panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  flex-shrink: 0;
}

.folders-panel .site-title {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
}

.folders-panel .site-title .material-symbols-outlined {
  color: var(--md-sys-color-primary);
  font-size: 28px;
}

.folders-panel .panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

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

.folder-item {
  margin: 0;
}

.folder-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--md-sys-color-on-surface-variant);
  text-decoration: none;
  border-radius: var(--md-sys-shape-corner-full);
  margin: 2px 8px;
  transition: background-color 200ms ease, color 200ms ease;
  position: relative;
}

.folder-link:hover {
  background-color: rgba(var(--md-sys-color-hover-rgb), var(--md-sys-state-hover-opacity));
  text-decoration: none;
}

.folder-item.active .folder-link {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.folder-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.folder-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-count {
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
  padding: 2px 8px;
  border-radius: var(--md-sys-shape-corner-full);
  flex-shrink: 0;
}

.folder-item.active .folder-count {
  background-color: var(--md-sys-color-on-secondary-container);
  color: var(--md-sys-color-secondary-container);
}

/* ==================== Articles Panel (360px) ==================== */
.articles-panel {
  width: 360px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--md-sys-color-outline-variant);
  overflow: hidden;
}

.articles-panel .panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  flex-shrink: 0;
}

.articles-panel .panel-title {
  margin: 0;
  color: var(--md-sys-color-on-surface);
}

.articles-panel .panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

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

.article-item {
  margin: 0;
}

.article-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
  border-radius: var(--md-sys-shape-corner-medium);
  margin: 4px 8px;
  transition: background-color 200ms ease;
}

.article-link:hover {
  background-color: rgba(var(--md-sys-color-hover-rgb), var(--md-sys-state-hover-opacity));
  text-decoration: none;
}

.article-item.active .article-link {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.article-link-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.article-title {
  margin: 0;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-excerpt {
  margin: 0;
  color: var(--md-sys-color-on-surface-variant);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-item.active .article-excerpt {
  color: var(--md-sys-color-on-primary-container);
  opacity: 0.8;
}

.article-reading-time {
  color: var(--md-sys-color-on-surface-variant);
  align-self: flex-start;
  margin-top: 4px;
}

.article-item.active .article-reading-time {
  color: var(--md-sys-color-on-primary-container);
  opacity: 0.7;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--md-sys-color-on-surface-variant);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* ==================== Content Panel (Expanded) ==================== */
.content-panel {
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  background-color: var(--md-sys-color-surface);
}

.content-article {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 48px;
}

.content-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.content-header h1 {
  margin: 0 0 16px 0;
  color: var(--md-sys-color-on-surface);
}

.content-description {
  color: var(--md-sys-color-on-surface-variant);
  margin: 0;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
  color: var(--md-sys-color-on-surface-variant);
}

.breadcrumb-link {
  color: var(--md-sys-color-primary);
}

.breadcrumb-separator {
  font-size: 18px;
  opacity: 0.5;
}

.breadcrumb-current {
  color: var(--md-sys-color-on-surface-variant);
}

/* Article meta */
.article-meta {
  display: flex;
  gap: 24px;
  margin-top: 16px;
  color: var(--md-sys-color-on-surface-variant);
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.meta-item .material-symbols-outlined {
  font-size: 18px;
}

/* Content body */
.content-body {
  color: var(--md-sys-color-on-surface);
}

.content-body h1 {
  font-family: var(--md-sys-typescale-display-small-font);
  font-size: var(--md-sys-typescale-display-small-size);
  line-height: 1.3;
  font-weight: var(--md-sys-typescale-display-small-weight);
  margin: 0 0 24px 0;
  color: var(--md-sys-color-on-surface);
}

.content-body h2 {
  font-family: var(--md-sys-typescale-headline-medium-font);
  font-size: var(--md-sys-typescale-headline-medium-size);
  line-height: var(--md-sys-typescale-headline-medium-line-height);
  font-weight: var(--md-sys-typescale-headline-medium-weight);
  margin: 32px 0 16px 0;
  color: var(--md-sys-color-on-surface);
}

.content-body h3 {
  font-family: var(--md-sys-typescale-headline-small-font);
  font-size: var(--md-sys-typescale-headline-small-size);
  line-height: var(--md-sys-typescale-headline-small-line-height);
  font-weight: var(--md-sys-typescale-headline-small-weight);
  margin: 24px 0 12px 0;
  color: var(--md-sys-color-on-surface);
}

.content-body h4 {
  font-family: var(--md-sys-typescale-title-large-font);
  font-size: var(--md-sys-typescale-title-large-size);
  line-height: var(--md-sys-typescale-title-large-line-height);
  font-weight: 500;
  margin: 20px 0 10px 0;
  color: var(--md-sys-color-on-surface);
}

.content-body p {
  margin: 0 0 16px 0;
}

.content-body ul,
.content-body ol {
  margin: 0 0 16px 0;
  padding-left: 24px;
}

.content-body li {
  margin-bottom: 8px;
}

.content-body code {
  font-family: var(--md-sys-font-family-mono);
  font-size: 14px;
  background-color: var(--md-sys-color-surface-container-high);
  padding: 2px 6px;
  border-radius: var(--md-sys-shape-corner-extra-small);
}

.content-body pre {
  background-color: var(--md-sys-color-surface-container-highest);
  padding: 16px;
  border-radius: var(--md-sys-shape-corner-medium);
  overflow-x: auto;
  margin: 0 0 16px 0;
}

.content-body pre code {
  background: none;
  padding: 0;
}

.content-body blockquote {
  border-left: 4px solid var(--md-sys-color-primary);
  margin: 24px 0 16px 0;
  padding: 12px 20px;
  background-color: var(--md-sys-color-surface-container-low);
  border-radius: 0 var(--md-sys-shape-corner-small) var(--md-sys-shape-corner-small) 0;
  color: var(--md-sys-color-on-surface-variant);
}

.content-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--md-sys-shape-corner-medium);
  margin: 16px 0;
}

.content-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

.content-body th,
.content-body td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.content-body th {
  background-color: var(--md-sys-color-surface-container);
  font-weight: 500;
}

.content-body hr {
  border: none;
  height: 1px;
  background-color: var(--md-sys-color-outline-variant);
  margin: 32px 0;
}

/* Article navigation */
.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-radius: var(--md-sys-shape-corner-large);
  text-decoration: none;
  color: var(--md-sys-color-on-surface);
  transition: background-color 200ms ease;
  max-width: 45%;
}

.nav-link:hover {
  background-color: var(--md-sys-color-surface-container-highest);
  text-decoration: none;
}

.nav-link .material-symbols-outlined {
  color: var(--md-sys-color-primary);
}

.nav-link-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.nav-link-text .m3-label-small {
  color: var(--md-sys-color-on-surface-variant);
}

.nav-link-text .m3-title-small {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.nav-prev {
  margin-right: auto;
}

.nav-next {
  margin-left: auto;
  text-align: right;
}

/* Home page sections */
.home-sections {
  margin-top: 32px;
}

.home-sections h2 {
  margin-bottom: 16px;
}

/* Section articles in list view */
.section-articles {
  margin-top: 32px;
}

.article-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.article-card {
  border-radius: var(--md-sys-shape-corner-large);
  overflow: hidden;
  transition: box-shadow 200ms ease;
}

.article-card:hover {
  box-shadow: var(--md-sys-elevation-level2);
}

.article-card-link {
  display: block;
  padding: 20px;
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
}

.article-card-link:hover {
  text-decoration: none;
}

.article-card h3 {
  margin: 0 0 8px 0;
}

.article-card p {
  margin: 0;
  color: var(--md-sys-color-on-surface-variant);
}

/* ==================== Responsive Design ==================== */
@media (max-width: 1200px) {
  .app-container {
    grid-template-columns: 200px 300px 1fr;
  }
  
  .folders-panel {
    width: 200px;
  }
  
  .articles-panel {
    width: 300px;
  }
}

@media (max-width: 900px) {
  .app-container {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  
  .folders-panel {
    width: 100%;
    height: auto;
    max-height: 50vh;
    min-height: 50vh;
    border-right: none;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    display: none;
  }
  
  .folders-panel.open {
    display: flex;
  }
  
  .articles-panel {
    width: 100%;
    height: auto;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    display: none;
  }
  
  .articles-panel.open {
    display: flex;
  }
  
  .content-panel {
    height: auto;
    min-height: 60vh;
  }
  
  .content-article {
    padding: 24px 16px;
  }
}

/* Mobile navigation toggle (for responsive) */
.mobile-nav-toggle {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: var(--md-sys-shape-corner-large);
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border: none;
  cursor: pointer;
  box-shadow: var(--md-sys-elevation-level3);
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.mobile-nav-toggle .material-symbols-outlined {
  font-size: 24px;
}

@media (max-width: 900px) {
  .mobile-nav-toggle {
    display: flex;
  }
}
