
/* SSR Page Styles */
:root {
  --primary-color: #2563eb;
  --text-color: #1f2937;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;
  --bg-color: #ffffff;
  --bg-muted: #f9fafb;
  --sidebar-bg: #f9fafb;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  --header-height: 48px;
  --sidebar-width: 280px;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

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

/* SSR Site Shell */
body.ssr-page {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Top Bar / Header */
.ssr-top-bar {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  flex-shrink: 0;
}

.ssr-logo-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.ssr-logo {
  height: 28px;
  width: auto;
  object-fit: contain;
}

.ssr-logo-text {
  font-size: 1rem;
  font-weight: 500;
  white-space: nowrap;
  letter-spacing: 0.05em;
}

/* Layout Container */
.ssr-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar Navigation */
.ssr-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  padding: 1rem 0;
}

.ssr-nav-section {
  margin-bottom: 1.5rem;
}

.ssr-nav-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 1rem;
  margin: 0 0 0.5rem 0;
}

.ssr-nav-dir {
  margin-bottom: 0.5rem;
}

.ssr-nav-dir-name {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-color);
  padding: 0.375rem 1rem;
}

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

.ssr-nav-list li {
  margin: 0;
}

.ssr-nav-list li a {
  display: block;
  padding: 0.375rem 1rem 0.375rem 1.5rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  transition: background-color 0.15s, color 0.15s;
}

.ssr-nav-list li a:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-color);
}

.ssr-nav-list li.active a {
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary-color);
  font-weight: 500;
}

/* Nested directories */
.ssr-nav-dir .ssr-nav-dir {
  margin-left: 0.75rem;
}

.ssr-nav-dir .ssr-nav-dir .ssr-nav-dir-name {
  font-size: 0.8125rem;
}

.ssr-nav-dir .ssr-nav-list li a {
  padding-left: 2.25rem;
}

/* Main Content Area */
.ssr-main-content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-color);
}

.ssr-content-wrapper {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem;
}

/* Article Styles */
article {
  background: var(--bg-color);
}

article header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

article header h1 {
  margin: 0 0 0.5rem 0;
  font-size: 2rem;
  font-weight: 600;
}

article header .summary {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin: 0.5rem 0;
}

article header .summary p {
  margin: 0;
}

article header .authors {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0.5rem 0;
}

article header time {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Content Blocks */
.content-block {
  margin: 1.5rem 0;
}

.rte-content {
  line-height: 1.8;
}

.rte-content p {
  margin: 1rem 0;
}

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

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

/* Image Container */
.image-container {
  margin: 2rem 0;
}

.image-container img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.image-container figcaption {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  margin-top: 0.5rem;
}

/* Link Container */
.link-container {
  padding: 1rem;
  background: var(--bg-muted);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.link-container a {
  color: var(--primary-color);
  font-weight: 500;
  text-decoration: none;
}

.link-container a:hover {
  text-decoration: underline;
}

.link-container p {
  margin: 0.5rem 0 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Code Block */
.code-block {
  background: #1e293b;
  border-radius: 8px;
  overflow: hidden;
}

.code-block pre {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
}

.code-block code {
  color: #e2e8f0;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9rem;
}

/* Diagram Placeholder */
.diagram-placeholder {
  padding: 2rem;
  background: var(--bg-muted);
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  text-align: center;
  color: var(--text-muted);
}

/* Interactive Diagram Container */
.diagram-container {
  position: relative;
  min-height: 400px;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.diagram-container.diagram-loaded {
  border-style: solid;
}

.diagram-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 400px;
  color: var(--text-muted);
  background: var(--bg-muted);
}

.diagram-loading p {
  margin: 0;
  font-size: 0.9rem;
}

/* Noscript fallback for diagrams - shown when Lit app hasn't loaded yet */
.diagram-noscript {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 400px;
  color: var(--text-muted);
  background: var(--bg-muted);
  text-align: center;
  padding: 2rem;
}

.diagram-noscript p {
  margin: 0;
  font-size: 0.9rem;
}

.diagram-error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  color: var(--error-color);
  background: #fef2f2;
}

.diagram-error p {
  margin: 0;
  font-size: 0.9rem;
}

.diagram-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  z-index: 10;
}

.diagram-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-color);
  transition: background-color 0.15s, border-color 0.15s;
}

.diagram-btn:hover {
  background: var(--bg-muted);
  border-color: var(--text-muted);
}

.svg-viewer-wrapper {
  width: 100%;
  height: 100%;
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.svg-viewer-wrapper svg {
  max-width: 100%;
  max-height: 100%;
}

/* API and Schema Links */
.api-link,
.schema-link {
  padding: 1rem;
  background: var(--bg-muted);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.api-link a,
.schema-link a {
  color: var(--primary-color);
  font-weight: 500;
  text-decoration: none;
}

.api-link a:hover,
.schema-link a:hover {
  text-decoration: underline;
}

.api-link p,
.schema-link p {
  width: 100%;
  margin: 0.5rem 0 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.api-link p p,
.schema-link p p {
  margin: 0;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.api-badge {
  background: #dbeafe;
  color: #1e40af;
}

.schema-badge {
  background: #fef3c7;
  color: #92400e;
}

/* Endpoint Styles */
.ssr-endpoint-content .endpoint-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.method-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
}

.method-get { background: #d1fae5; color: #065f46; }
.method-post { background: #dbeafe; color: #1e40af; }
.method-put { background: #fef3c7; color: #92400e; }
.method-patch { background: #e0e7ff; color: #3730a3; }
.method-delete { background: #fee2e2; color: #991b1b; }

.endpoint-path {
  font-family: 'Monaco', 'Menlo', monospace;
  background: var(--bg-muted);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-size: 0.9rem;
}

.deprecated-warning {
  color: var(--warning-color);
  font-weight: 500;
}

.description {
  color: var(--text-muted);
}

.tags {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Sections */
section {
  margin: 2rem 0;
}

section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

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

th {
  background: var(--bg-muted);
  font-weight: 600;
}

td code {
  background: var(--bg-muted);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-2xx { background: #d1fae5; color: #065f46; }
.status-3xx { background: #dbeafe; color: #1e40af; }
.status-4xx { background: #fef3c7; color: #92400e; }
.status-5xx { background: #fee2e2; color: #991b1b; }
.status-default { background: var(--bg-muted); color: var(--text-muted); }

/* Schema Styles */
.schema-type,
.schema-version {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0.25rem 0;
}

/* Enum Values */
.enum-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.enum-section li {
  background: var(--bg-muted);
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
}

.enum-section code {
  font-size: 0.85rem;
}

/* Top Menu (SSR) */
.ssr-top-menu {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}

.ssr-top-menu-item {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #e5e7eb;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease;
}

.ssr-top-menu-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Footer (SSR) */
.ssr-footer {
  flex-shrink: 0;
  padding: 2.5rem 2rem 1.5rem;
  margin-top: auto;
}

.ssr-footer-groups {
  display: grid;
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  justify-content: center;
}

@media (min-width: 640px) {
  .ssr-footer-groups {
    grid-template-columns: repeat(auto-fit, minmax(180px, max-content));
  }
}

.ssr-footer-group {
  min-width: 0;
}

.ssr-footer-group-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
}

.ssr-footer-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ssr-footer-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.ssr-footer-link:hover {
  opacity: 0.8;
}

.ssr-footer-copyright {
  text-align: center;
  font-size: 0.8rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0.7;
}

/* Responsive */
@media (max-width: 768px) {
  .ssr-layout {
    flex-direction: column;
  }

  .ssr-sidebar {
    width: 100%;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .ssr-content-wrapper {
    padding: 1rem;
  }

  article header h1 {
    font-size: 1.5rem;
  }

  .ssr-endpoint-content .endpoint-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  table {
    display: block;
    overflow-x: auto;
  }

  .ssr-top-menu {
    display: none;
  }

  .ssr-footer {
    padding: 1.5rem 1rem 1rem;
  }
}
