/* ===== Embedded Code Viewer ===== */

/* Explorer layout: sidebar left, code viewer right */
.github-explorer {
  display: flex;
  flex-direction: column;
}

.github-explorer__layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--space-xl);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.github-explorer__sidebar {
  align-self: stretch;
  overflow-y: auto;
  min-height: 0;
}

.github-explorer__main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.github-explorer__main > * {
  flex: 1;
  min-height: 0;
}

/* Repo list (vertical sidebar) */
.repo-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Repo selector grid (legacy, kept for compatibility) */
.repo-grid-select {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.repo-select-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 2px solid transparent;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all var(--duration-fast);
}
.repo-select-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.03);
}
.repo-select-card--active {
  border-color: var(--border);
  border-left-color: var(--red);
  background: rgba(208, 30, 30, 0.08);
}
.repo-select-card__info { min-width: 0; }
.repo-select-card__name {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--white);
}
.repo-select-card__desc {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.repo-select-card__lang {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}
.repo-select-card__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* Header bar */
.repo-explorer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
}
.repo-explorer__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--white);
  min-width: 0;
}
.repo-explorer__title svg { width: 16px; height: 16px; color: var(--grey); flex-shrink: 0; }
.repo-explorer__actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.repo-explorer__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--white);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--duration-fast);
  text-decoration: none;
}
.repo-explorer__btn:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.2); }
.repo-explorer__btn svg { width: 14px; height: 14px; }

/* Explorer container */
.repo-explorer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Body: tree + code */
.repo-explorer__body {
  display: grid;
  grid-template-columns: 260px 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* File tree */
.file-tree {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.15);
  padding: 8px 0;
  min-height: 0;
}
.file-tree__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 13px;
  font-family: var(--font-mono);
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: all var(--duration-fast);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-tree__item:hover { background: rgba(255, 255, 255, 0.04); color: var(--white); }
.file-tree__item--active { background: rgba(208, 30, 30, 0.12); color: var(--white); border-right: 2px solid var(--red); }
.file-tree__item--dir { font-weight: 600; color: rgba(255, 255, 255, 0.5); }
.file-tree__icon { width: 14px; height: 14px; flex-shrink: 0; opacity: 0.5; }
.file-tree__item--active .file-tree__icon { opacity: 1; color: var(--red); }

.file-tree__item[data-depth="1"] { padding-left: 32px; }
.file-tree__item[data-depth="2"] { padding-left: 48px; }
.file-tree__item[data-depth="3"] { padding-left: 64px; }
.file-tree__item[data-depth="4"] { padding-left: 80px; }

/* Code pane */
.code-pane { overflow: auto; position: relative; min-height: 0; }
.code-pane__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}
.code-pane__filename {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 8px;
}
.code-pane__lang {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.5);
}
.code-pane__dl {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  transition: all var(--duration-fast);
}
.code-pane__dl:hover { color: var(--white); border-color: rgba(255, 255, 255, 0.3); }
.code-pane__dl svg { width: 12px; height: 12px; }

.code-pane__content pre {
  margin: 0;
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.85);
  tab-size: 2;
  white-space: pre;
  overflow-x: auto;
}
.code-pane__content .ln {
  display: inline-block;
  width: 40px;
  text-align: right;
  padding-right: 16px;
  color: rgba(255, 255, 255, 0.15);
  user-select: none;
  font-size: 12px;
}

.code-pane__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  gap: 12px;
  color: rgba(255, 255, 255, 0.3);
  font-size: 14px;
}
.code-pane__empty svg { width: 48px; height: 48px; opacity: 0.3; }
.code-pane__loading { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--grey); font-size: 14px; }

/* Syntax highlighting */
.tok-kw { color: #ff7b72; }
.tok-str { color: #a5d6ff; }
.tok-cmt { color: #8b949e; font-style: italic; }
.tok-num { color: #79c0ff; }

/* Responsive */
@media (max-width: 1023px) {
  .github-explorer__layout {
    grid-template-columns: 200px 1fr;
    gap: var(--space-md);
  }
  .repo-explorer__body {
    grid-template-columns: 200px 1fr;
  }
}

@media (max-width: 768px) {
  .github-explorer__layout {
    grid-template-columns: 1fr;
  }
  .github-explorer__sidebar {
    position: static;
    max-height: none;
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-lg);
  }
  .github-explorer__sidebar .label { display: none; }
  .repo-list { flex-direction: row; gap: 8px; }
  .repo-select-card { flex-direction: row; white-space: nowrap; border-left: none; border-bottom: 2px solid transparent; }
  .repo-select-card--active { border-left-color: transparent; border-bottom-color: var(--red); }
  .repo-explorer__body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .file-tree { border-right: none; border-bottom: 1px solid var(--border); max-height: 200px; }
  .repo-explorer__header { flex-wrap: wrap; }
  .repo-explorer__body { max-height: 60vh; }
}
