/* ==================== RESET & BASE ==================== */

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

:root {
  --primary: #ff5725;
  --primary-dark: #e64614;
  --bg: #ffffff;
  --bg-secondary: #f9fafb;
  --text: #111827;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --radius: 8px;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg-secondary);
  line-height: 1.6;
}

/* ==================== HOMEPAGE ==================== */

.container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0.25rem 0;
  text-align: center;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
}

.logo-container {
  margin: 0;
  padding: 0;
  line-height: 0;
}

.logo-image {
  height: 100px;
  width: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

.main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.search-bar {
  position: relative;
  margin-bottom: 2rem;
}

.search-input {
  width: 100%;
  padding: 1rem 3rem 1rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: all 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 87, 37, 0.1);
}

.search-icon {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2rem;
}

.stats {
  display: flex;
  gap: 2rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.document-list {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.folder-group {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.folder-title {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--text);
}

.folder-docs {
  display: grid;
  grid-template-columns: repeat(
    auto-fill,
    minmax(300px, 1fr)
  );
  gap: 1rem;
}

.doc-card {
  display: block;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
  background: var(--bg);
}

.doc-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.doc-card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 0.75rem;
}

.doc-card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.doc-card-badge {
  background: var(--primary);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.doc-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
  background: var(--bg);
  border-radius: var(--radius);
}

.error-state {
  text-align: center;
  padding: 3rem;
  color: #dc2626;
  background: #fef2f2;
  border-radius: var(--radius);
}

.footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.footer kbd {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font-family: monospace;
  font-size: 0.75rem;
}

/* ==================== VIEWER ==================== */

.viewer-container {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

.viewer-sidebar {
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 1.5rem;
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-header {
  margin-bottom: 2rem;
}

.sidebar-logo-container {
  text-align: center;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  height: 60px;
  width: auto;
  object-fit: contain;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

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

.toc-title {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.toc-list {
  list-style: none;
}

.toc-item {
  margin-bottom: 0.5rem;
}

.toc-link {
  color: var(--text);
  text-decoration: none;
  font-size: 0.875rem;
  display: block;
  padding: 0.25rem 0;
  border-left: 2px solid transparent;
  padding-left: 0.75rem;
  transition: all 0.2s;
}

.toc-link:hover {
  color: var(--primary);
  border-left-color: var(--primary);
}

.toc-empty {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-style: italic;
}

.viewer-main {
  background: var(--bg-secondary);
  overflow-y: auto;
}

.viewer-toolbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.doc-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.btn {
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

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

.viewer-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem 2rem;
  background: var(--bg);
  min-height: calc(100vh - 80px);
  box-shadow: var(--shadow);
}

/* ==================== MARKDOWN CONTENT ==================== */

.viewer-content h1,
.viewer-content h2,
.viewer-content h3,
.viewer-content h4 {
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-weight: 700;
  line-height: 1.3;
}

.viewer-content h1 {
  font-size: 2.25rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.5rem;
}

.viewer-content h2 {
  font-size: 1.875rem;
}

.viewer-content h3 {
  font-size: 1.5rem;
}

.viewer-content h4 {
  font-size: 1.25rem;
}

.viewer-content p {
  margin-bottom: 1rem;
}

.viewer-content ul,
.viewer-content ol {
  margin-bottom: 1rem;
  padding-left: 2rem;
}

.viewer-content li {
  margin-bottom: 0.5rem;
}

.viewer-content code {
  background: var(--bg-secondary);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: "Courier New", monospace;
  font-size: 0.875em;
}

.viewer-content pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 1.5rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 1rem;
}

.viewer-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.viewer-content blockquote {
  border-left: 4px solid var(--primary);
  padding-left: 1rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

.viewer-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

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

.viewer-content th {
  background: var(--bg-secondary);
  font-weight: 600;
}

.viewer-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 1.5rem 0;
}

.viewer-content a {
  color: var(--primary);
  text-decoration: none;
}

.viewer-content a:hover {
  text-decoration: underline;
}

.viewer-content .mermaid {
  text-align: center;
  margin: 2rem 0;
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 768px) {
  .viewer-container {
    grid-template-columns: 1fr;
  }

  .viewer-sidebar {
    display: none;
  }

  .folder-docs {
    grid-template-columns: 1fr;
  }

  .viewer-toolbar {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }

  .viewer-content {
    padding: 2rem 1rem;
  }
}
