/* Confluence-inspired stylesheet */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --nav-height: 56px;
  --sidebar-width: 280px;
  --color-primary: #0052CC;
  --color-primary-dark: #003884;
  --color-bg: #F4F5F7;
  --color-surface: #FFFFFF;
  --color-border: #DFE1E6;
  --color-text: #172B4D;
  --color-text-subtle: #6B778C;
  --color-link: #0052CC;
  --color-active-bg: #DEEBFF;
  --color-active-text: #0052CC;
  --color-hover-bg: #EBECF0;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --radius: 3px;
  --shadow: 0 1px 3px rgba(9,30,66,0.13), 0 0 0 1px rgba(9,30,66,0.08);
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
}

/* TOP NAV */
.top-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--color-primary);
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.top-nav-inner {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 20px;
  gap: 20px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: white;
  text-decoration: none;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  flex-shrink: 0;
}
.logo span { color: white; }
.top-nav-title {
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  border-left: 1px solid rgba(255,255,255,0.3);
  padding-left: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* LAYOUT */
.app-wrapper { display: flex; flex-direction: column; min-height: 100vh; }
.main-layout {
  display: flex;
  margin-top: var(--nav-height);
  min-height: calc(100vh - var(--nav-height));
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  position: fixed;
  top: var(--nav-height);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 50;
}
.sidebar-inner { padding: 16px 0 40px; }
.sidebar-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-subtle);
  padding: 0 16px 8px;
}

/* TREE */
.tree-root, .tree-children {
  list-style: none;
}
.tree-root { padding: 0; }
.tree-children { padding-left: 0; }

.tree-item {
  position: relative;
}

.tree-item details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
}
.tree-item details > summary::-webkit-details-marker { display: none; }
.tree-item details > summary::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%236B778C' d='M6 4l4 4-4 4V4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  flex-shrink: 0;
  transition: transform 0.15s;
  margin-left: 4px;
}
.tree-item details[open] > summary::before {
  transform: rotate(90deg);
}

.tree-link {
  display: block;
  padding: 5px 16px 5px 4px;
  color: var(--color-text);
  text-decoration: none;
  font-size: 13.5px;
  line-height: 1.4;
  border-radius: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.tree-link:hover { background: var(--color-hover-bg); color: var(--color-text); }
.tree-link.active {
  background: var(--color-active-bg);
  color: var(--color-active-text);
  font-weight: 600;
}

/* Indent levels via nested ul */
.tree-root > .tree-item { }
.tree-root > .tree-item .tree-children > .tree-item .tree-link,
.tree-root > .tree-item .tree-children > .tree-item details > summary { padding-left: 20px; }
.tree-root > .tree-item .tree-children > .tree-item .tree-children > .tree-item .tree-link,
.tree-root > .tree-item .tree-children > .tree-item .tree-children > .tree-item details > summary { padding-left: 36px; }
.tree-root > .tree-item .tree-children > .tree-item .tree-children > .tree-item .tree-children > .tree-item .tree-link { padding-left: 52px; }
.tree-root > .tree-item .tree-children > .tree-item .tree-children > .tree-item .tree-children > .tree-item .tree-children > .tree-item .tree-link { padding-left: 68px; }
.tree-root > .tree-item .tree-children > .tree-item .tree-children > .tree-item .tree-children > .tree-item .tree-children > .tree-item .tree-children > .tree-item .tree-link { padding-left: 84px; }

.tree-root > .tree-item > .tree-link,
.tree-root > .tree-item > details > summary { padding-left: 16px; }

/* Fix summary link padding for deeper levels */
.tree-children .tree-link { padding-right: 8px; }

/* CONTENT */
.content-area {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
}
.content-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 40px 60px;
}

/* BREADCRUMB */
.breadcrumb {
  font-size: 12px;
  color: var(--color-text-subtle);
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.breadcrumb a { color: var(--color-link); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--color-text-subtle); }
.breadcrumb .current { color: var(--color-text); font-weight: 500; }

/* PAGE HEADER */
.page-header { margin-bottom: 28px; border-bottom: 1px solid var(--color-border); padding-bottom: 20px; }
.page-title { font-size: 28px; font-weight: 600; color: var(--color-text); line-height: 1.25; margin-bottom: 8px; }
.page-meta { font-size: 12px; color: var(--color-text-subtle); display: flex; gap: 6px; align-items: center; }
.page-meta .sep { color: var(--color-border); }

/* WIKI CONTENT */
.wiki-content { line-height: 1.7; }
.wiki-content h1 { font-size: 24px; font-weight: 600; margin: 28px 0 12px; color: var(--color-text); }
.wiki-content h2 { font-size: 20px; font-weight: 600; margin: 24px 0 10px; color: var(--color-text); border-bottom: 1px solid var(--color-border); padding-bottom: 6px; }
.wiki-content h3 { font-size: 16px; font-weight: 600; margin: 20px 0 8px; color: var(--color-text); }
.wiki-content h4, .wiki-content h5, .wiki-content h6 { font-size: 14px; font-weight: 600; margin: 16px 0 6px; }
.wiki-content p { margin: 0 0 12px; }
.wiki-content ul, .wiki-content ol { margin: 8px 0 12px 24px; }
.wiki-content li { margin-bottom: 4px; }
.wiki-content a { color: var(--color-link); text-decoration: none; }
.wiki-content a:hover { text-decoration: underline; }
.wiki-content img { max-width: 100%; height: auto; border-radius: var(--radius); box-shadow: var(--shadow); margin: 8px 0; }
.wiki-content table { border-collapse: collapse; width: 100%; margin: 16px 0; font-size: 13.5px; }
.wiki-content th { background: #F4F5F7; font-weight: 600; text-align: left; padding: 8px 12px; border: 1px solid var(--color-border); }
.wiki-content td { padding: 8px 12px; border: 1px solid var(--color-border); vertical-align: top; }
.wiki-content tr:nth-child(even) td { background: #FAFBFC; }
.wiki-content pre, .wiki-content code { font-family: var(--font-mono); font-size: 13px; background: #F4F5F7; border-radius: var(--radius); }
.wiki-content pre { padding: 12px 16px; overflow-x: auto; margin: 12px 0; border: 1px solid var(--color-border); }
.wiki-content code { padding: 1px 5px; }
.wiki-content pre code { padding: 0; background: none; }
.wiki-content blockquote { border-left: 3px solid var(--color-primary); margin: 12px 0; padding: 8px 16px; color: var(--color-text-subtle); background: #F4F5F7; border-radius: 0 var(--radius) var(--radius) 0; }
.wiki-content hr { border: none; border-top: 1px solid var(--color-border); margin: 24px 0; }
.wiki-content .confluence-information-macro { border-radius: var(--radius); padding: 12px 16px; margin: 12px 0; border-left: 4px solid; }
.wiki-content .confluence-information-macro-note { background: #FFFAE6; border-color: #FF991F; }
.wiki-content .confluence-information-macro-warning { background: #FFEBE6; border-color: #DE350B; }
.wiki-content .confluence-information-macro-tip { background: #E3FCEF; border-color: #00875A; }
.wiki-content .confluence-information-macro-information { background: #DEEBFF; border-color: #0052CC; }
.wiki-content .confluence-information-macro-body { margin-top: 4px; }
.wiki-content .confluence-information-macro-icon { display: none; }

/* Confluence panels */
.wiki-content .panel { border: 1px solid var(--color-border); border-radius: var(--radius); margin: 12px 0; }
.wiki-content .panelHeader { background: #F4F5F7; padding: 8px 12px; font-weight: 600; border-bottom: 1px solid var(--color-border); border-radius: var(--radius) var(--radius) 0 0; }
.wiki-content .panelContent { padding: 12px; }

/* Confluence expand macro */
.wiki-content .expand-container { border: 1px solid var(--color-border); border-radius: var(--radius); margin: 8px 0; }
.wiki-content .expand-control { padding: 8px 12px; cursor: pointer; background: #F4F5F7; font-weight: 500; }
.wiki-content .expand-content { padding: 12px; }

/* Status macros */
.wiki-content .status-macro { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }

/* CHILD PAGES */
.child-pages { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--color-border); }
.child-pages h3 { font-size: 14px; font-weight: 600; color: var(--color-text-subtle); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; }
.child-pages ul { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.child-pages li a {
  display: block;
  padding: 10px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-link);
  text-decoration: none;
  font-size: 13.5px;
  transition: box-shadow 0.1s, border-color 0.1s;
}
.child-pages li a:hover { box-shadow: var(--shadow); border-color: #b3c4e0; }

/* DRAWIO FIGURE */
.wiki-content .drawio-figure { margin: 16px 0; }
.wiki-content .drawio-figure figcaption { font-size: 12px; color: var(--color-text-subtle); margin-top: 6px; }

/* LIGHTBOX TRIGGER */
.wiki-content a.lightbox-trigger { display: inline-block; cursor: zoom-in; }
.wiki-content a.lightbox-trigger img { transition: opacity 0.15s, box-shadow 0.15s; }
.wiki-content a.lightbox-trigger:hover img { opacity: 0.88; box-shadow: 0 4px 16px rgba(0,0,0,0.22); }

/* LIGHTBOX OVERLAY */
.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(9, 30, 66, 0.82);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.lightbox-overlay.active { display: flex; }
.lightbox-content {
  position: relative;
  max-width: 92vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
#lightbox-img {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  cursor: default;
}
.lightbox-close {
  position: fixed;
  top: 16px;
  right: 20px;
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  font-size: 28px;
  line-height: 1;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  z-index: 1001;
}
.lightbox-close:hover { background: rgba(255,255,255,0.3); }

/* SCROLLBAR */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }

/* RESPONSIVE */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: translateX(0); }
  .content-area { margin-left: 0; }
  .content-inner { padding: 20px 16px 40px; }
}
