
/* === Sidebar layout order ===
   .sidebar is a flex column. By assigning explicit `order` values we control
   the visual position of every child independently of when each plugin inserts
   its element into the DOM — no JS timing hacks required.
   Known direct children and their desired visual order:
     0  .app-name      — site logo / title
     1  .search        — search input (inserted by docsify-search plugin)
     2  .sidebar-tabs  — Navigation / Page TOC toggle buttons (ours)
     3  .sidebar-toc-panel — page TOC list (ours)
     4  .sidebar-nav   — the main navigation tree
*/
.sidebar {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}
.sidebar > .app-name {
    order: 0;
    flex-shrink: 0;
}
.sidebar > .search {
    order: 1;
    flex: 0 0 auto;   /* never shrink/grow based on flex; size is driven by content */
    overflow: hidden; /* clip results to the constrained height */
    max-height: 50%;  /* at most half the sidebar; prevents pushing nav/toc off-screen */
}
/* Restore internal scroll on the results panel — our overflow:hidden on .search
   clips it to max-height, so the panel itself must scroll rather than the sidebar */
.sidebar .results-panel {
    overflow-y: auto;
    max-height: calc(50vh - 3rem); /* subtract ~input height */
}
.sidebar > .sidebar-tabs {
    order: 2;
    flex-shrink: 0;
}
.sidebar > .sidebar-toc-panel {
    order: 3;
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
}
.sidebar > .sidebar-nav {
    order: 4;
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
}

:root {
    --base-font-size: 20px;
    --base-line-height: 1.5; /* 1.7 */
    --bodyFontSize: 16px;
    --code-block-line-height: 1.2;
    --code-block-padding: 1em .5em 1em .5em;
    --heading-h1-margin: 0 0 0;
    --heading-h3-border-color: var(--mono-tint2);
    --heading-h4-border-color: var(--mono-tint3);
    --search-margin: .5rem 0 0;
    --search-result-item-padding: .5em 0;
    --sidebar-nav-indent: 0;
    --sidebar-nav-margin: .5rem 0 0;
    --sidebar-nav-pagelink-background: ;
    --sidebar-padding: 0 0.2rem 0 0.5rem;
    --sidebar-width: 18.5em;
    --siteFont: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; 
    --uib-blue: hsl(204 89% 55% / 70%);
    --uib-red: hsl(0 100% 45% / 70%);
}

/* #main.markdown-section > ul > li {
    padding-bottom: 0.5rem;
} */

.sidebar-nav>ul>li {
    font-style: italic;
    font-weight: bolder;
}
.sidebar-nav>ul>li:has(ul) {
    border-top: 1px solid var(--heading-h2-border-color);
    margin-top: .3rem;
    padding-top: .1rem;
}
.sidebar-nav>ul>li:not(:has(ul))>a {
    padding:0 !important;
}
.sidebar-nav>ul>li li {
    font-style: normal;
}
.sidebar-nav>ul>li>a {
    font-style: normal;
}
.sidebar .search {
    padding: 0 1rem;
    width: 99%;
}
.sidebar .search .input-wrap {
    align-items:center;
}
.results-panel.show > div > a p {
    font-size: smaller;
}

.sidebar-nav details {
    margin: 0;
}
.sidebar-nav details > summary {
    cursor: pointer;
    /* list-style: none; */
}

.dhide {
    display: none;
}

.app-name-link img {
    width: 2rem;
    float: left;
}

.app-name-link {
    font-size: 80%;
}

.app-name-link::after {
    content: "UIBUILDER v7 docs";
    float: right;
}

img[src*="#cool"] {
    display: none;
}

img[alt$=">"] {
    /* use as ![image alt >](/image-right.jpg) */
    float: right;
    max-width: 30%;
    position: relative;
    z-index: 1;
}

img[alt$="<"] {
    float: left;
}

img[alt$="><"] {
    display: block;
    max-width: 100%;
    height: auto;
    margin: auto;
    float: none !important;
}

figcaption {
  font-style: italic;
}
figcaption::before {
  content: "Figure: ";
}

.markdown-section h1,
.markdown-section h2 {
    color: var(--sidebar-nav-link-color--active, var(--sidebar-nav-link-color));
    line-height: 1.1;
}

.markdown-section h3,
.markdown-section h4,
.markdown-section h5 {
    color: hsl(204 89% 70%);
    line-height: 1.2;
}

.markdown-section h2 {
    border-bottom-width: thick;
}

.markdown-section h3 {
    border-bottom-width: thin;
}

.pagination-item {
    margin-top: 1em !important;
}

#main>hr {
    margin: 1em 0;
}

.flex-container {
    display: flex;
    flex-direction: row;
}

.flex-left {
    width: 69%;
    margin-right: 1%;
}

.flex-right {
    width: 29%;
    margin-left: 1%;
}

.cover-head {
    display: flex;
    font-size: xx-large;
}

.cover-head p {
    flex: 1;
    order: 2;
    margin-top: 0;
    margin-bottom: 0;
}

.ch-title {
    flex: 3;
    order: 1;
}

.ch-title p {
    margin-top: .1rem;
}

.cover blockquote p {
    margin-top: 0.1rem;
}

.uib-name {
    display: inline !important;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--uib-blue) !important;
}

.uib-red {
    color: var(--uib-red) !important;
    font-weight: 800;
}

#docsify-darklight-theme {
    top: 1rem;
    right: 5rem;
    position: absolute;
    z-index: 999;
}

/* === Sidebar Resize Handle === */
.sidebar-resize-handle {
    position: fixed;
    top: 0;
    bottom: 0;
    left: var(--sidebar-width, 18.5em);
    width: 6px;
    cursor: col-resize;
    z-index: 101;
    user-select: none;
    -webkit-user-select: none;
}
.sidebar-resize-handle::after {
    content: '';
    display: block;
    position: absolute;
    inset: 0;
    left: 50%;
    width: 2px;
    transform: translateX(-50%);
    background: transparent;
    transition: background-color 0.2s;
}
.sidebar-resize-handle:hover::after,
.sidebar-resize-handle.is-dragging::after,
.sidebar-resize-handle:focus-visible::after {
    background: var(--uib-blue, hsl(204 89% 55% / 70%));
}
.sidebar-resize-handle:focus-visible {
    outline: 2px solid var(--uib-blue, hsl(204 89% 55%));
    outline-offset: 2px;
}

/* === Sidebar Tabs === */
.sidebar-tabs {
    display: flex;
    gap: 0.3rem;
    padding: 0.3rem 0.5rem 0.4rem;
    border-bottom: 1px solid var(--heading-h2-border-color, hsl(0 0% 50% / 30%));
    flex-shrink: 0;
}
.sidebar-tab-btn {
    flex: 1;
    padding: 0.2rem 0.4rem;
    border: 1px solid currentColor;
    background: transparent;
    color: var(--sidebar-nav-link-color, inherit);
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.8em;
    line-height: 1.4;
    transition: background-color 0.2s, color 0.2s;
}
.sidebar-tab-btn:hover:not(.active) {
    background: hsl(204 89% 55% / 15%);
}
.sidebar-tab-btn.active {
    background: var(--sidebar-nav-link-color--active, hsl(204 89% 55%));
    color: var(--body-bg, #000);
    border-color: var(--sidebar-nav-link-color--active, hsl(204 89% 55%));
    font-weight: 600;
}

/* === Sidebar TOC Panel === */
.sidebar .sidebar-nav[aria-hidden='true'],
.sidebar-toc-panel[aria-hidden='true'] {
    display: none;
}
.sidebar-toc-panel {
    overflow-y: auto;
    padding: 0.3rem 0.5rem;
    font-size: 0.9em;
}
.sidebar-toc-panel ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.sidebar-toc-panel ul ul {
    padding-left: 1rem;
}
.sidebar-toc-panel li {
    margin: 0.2rem 0;
    line-height: 1.3;
}
.sidebar-toc-panel details {
    margin: 0;
}
.sidebar-toc-panel details > summary.sidebar-toc-link {
    cursor: pointer;
    list-style: revert;
    display: list-item;
    font-style: italic;
    font-weight: bolder;
    border-top: 1px solid var(--heading-h2-border-color);
    margin-top: 0.3rem;
    padding-top: 0.1rem;
    padding-left: 0;
}
/* Buttons styled as nav links — avoids Docsify link-binder scanning <a href> elements */
.sidebar-toc-link {
    background: none;
    border: none;
    border-radius: 0.2rem;
    color: var(--sidebar-nav-link-color, inherit);
    cursor: pointer;
    display: block;
    font-size: inherit;
    padding: 0.1rem 0.2rem;
    text-align: left;
    transition: color 0.15s, background-color 0.15s;
    width: 100%;
}
.sidebar-toc-link:hover {
    color: var(--sidebar-nav-link-color--active, inherit);
    background: hsl(204 89% 55% / 10%);
}
.sidebar-toc-link.is-active {
    color: var(--sidebar-nav-link-color--active, inherit);
    font-weight: 600;
}
.sidebar-toc-empty {
    padding: 0.5rem;
    opacity: 0.6;
    font-style: italic;
}

#docsify-darklight-theme p {
    visibility: hidden;
}

/*#region TOC */

/* @import url("https://unpkg.com/docsify-toc@1.0.0/dist/toc.css"); */
/* @import url("https://unpkg.com/docsify-plugin-toc@1.3.1/dist/light.css"); */

@media only screen and (max-width: 1299px) {
    aside.toc-nav {
      max-width: 45px;
      opacity: 0.6;
      right: 0 !important;
      margin-right: 0 !important;
      background: #fff;
    }
    aside.toc-nav:hover {
      max-width: inherit;
      opacity: 1;
    }
    #docsify-darklight-theme {
        right: 5rem;
        position: absolute
    }
  }
  
  @media only screen and (min-width: 1300px) {
    /* section.content {
      padding-right: 250px;
    } */
    #docsify-darklight-theme {
        right: -8rem;
        position: absolute;
    }
  }
  
  aside.toc-nav {
    /* FONT-WEIGHT: 600; */
    position: fixed;
    top: 6rem;
    right: 3%;
    /* margin-right: 20px; */
    width: 250px;
    z-index: 999999;
    /* align-self: flex-start; */
    /* flex: 0 0 auto; */
    overflow-y: auto;
    /* max-height: 90%; */
    /* margin-left: 1em; */
    /* background-color: bisque; */
    font-size: smaller;
    /* line-height: 0; */
  }
  
  aside.toc-nav.nothing {
    width: 0;
  }
  
  .page_toc {
    position: relative;
    left: 3px;
    /* margin: 10px 0; */
    border: none;
    /* margin-left: 1em; */
    /* line-height: 1; */
    /* font-size: 1.0em; */
    width: 99%;
    max-height: 80vh;
  }
  
  .page_toc p.title {
    margin: 0;
    padding-bottom: 5px;
    font-weight: 600;
    font-size: 1.2em;
  }
  
  .page_toc .anchor:hover:after {
    content: "";
  }
  .page_toc div[class^="lv"] a:hover span {
    color: var(--sidebar-nav-link-color--active, #42b983);
  }
  
  .page_toc div {
    border-left: 2px solid #e8e8e8;
    text-indent: 10px;
    /* padding: 2px 0; */
    cursor: pointer;
  }
  
  .page_toc div.active {
    border-left-color: var(--sidebar-nav-link-color--active, #42b983);
    transition: border-left-color 0.23s;
  }
  
  .page_toc div.active a span {
    color: var(--sidebar-nav-link-color--active, #42b983);
    transition: color 0.23s;
  }
  
  .page_toc div[class^="lv"] a {
    /* color: var(--text-color-base, black); */
    /* text-decoration: none; */
    font-weight: 300;
    /* line-height: 2em; */
    /* display: block; */
  }
  
  .page_toc div[class^="lv"] a span {
    color: var(--sidebar-nav-link-color--hover, var(--sidebar-nav-link-color));
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow:ellipsis;
  }
  
  .page_toc div.lv2 {
    /* text-indent: 20px; */
  }
  
  .page_toc div.lv3 {
    text-indent: 1rem;
  }
  
  .page_toc div.lv4 {
    text-indent: 40px;
  }
  
  .page_toc div.lv5 {
    text-indent: 50px;
  }
  
  .page_toc div.lv6 {
    text-indent: 60px;
  }
  /*#endregion TOC */

tr {
  vertical-align: top;
}

/* Extra line spacing for <br>, mainly for use in markdown tables */
br {
    display:block;
    content:"";
    margin-top:0.8em;
    line-height:190%;
}

/* In case you want to use an hr in a table, reduced top/bottom margins */
td hr {
  margin-top:0.5em;
  margin-bottom:0.5em;
}

td ol {
  padding-left: 0 !important;
}

/* Tips Plugin Styles */
.uib-tip {
    background: hsl(204 89% 55% / 10%);
    border: 1px solid hsl(204 89% 55% / 30%);
    border-radius: 0.5rem;
    margin: 1.5rem 0;
    overflow: hidden;
    box-shadow: 0 2px 4px hsl(0 0% 0% / 10%);
    transition: box-shadow 0.2s ease;
}

/* Style included tip content */
p:has(> a[href*="tips/"]) {
    background: hsl(204 89% 55% / 10%);
    border: 1px solid hsl(204 89% 55% / 30%);
    border-radius: 0.5rem;
    margin: 1.5rem 0;
    padding: 1rem;
    box-shadow: 0 2px 4px hsl(0 0% 0% / 10%);
    transition: box-shadow 0.2s ease;
    position: relative;
}

p:has(> a[href*="tips/"]):hover {
    box-shadow: 0 4px 8px hsl(0 0% 0% / 15%);
}

/* Add tip icon for included tips */
p:has(> a[href*="tips/"]):before {
    content: '💡 Tip: ';
    font-weight: 600;
    color: hsl(204 89% 30%);
    display: block;
    margin-bottom: 0.5rem;
}

.uib-tip:hover {
    box-shadow: 0 4px 8px hsl(0 0% 0% / 15%);
}

.uib-tip-header {
    background: hsl(204 89% 55% / 20%);
    border-bottom: 1px solid hsl(204 89% 55% / 30%);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}

.uib-tip-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.uib-tip-icon {
    font-size: 1.2em;
    filter: drop-shadow(0 1px 2px hsl(0 0% 0% / 20%));
}

.uib-tip-title {
    color: hsl(204 89% 30%);
    font-size: 1rem;
}

.uib-tip-content {
    padding: 1rem;
    line-height: 1.6;
}

.uib-tip-content p:first-child {
    margin-top: 0;
}

.uib-tip-content p:last-child {
    margin-bottom: 0;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .uib-tip {
        background: hsl(204 89% 55% / 15%);
        border-color: hsl(204 89% 55% / 40%);
    }
    
    .uib-tip-header {
        background: hsl(204 89% 55% / 25%);
        border-bottom-color: hsl(204 89% 55% / 40%);
    }
    
    .uib-tip-title {
        color: hsl(204 89% 70%);
    }
}

/* Rotating Tips Styles */
.uib-tip-rotating {
    position: relative;
    transition: opacity 0.3s ease;
}

.uib-tip-rotate-indicator {
    animation: spin 4s linear infinite;
    opacity: 0.7;
    font-size: 0.9em;
}

details {
    margin: 1.5rem 0;
}
summary > h2 {
    display: inline;
    border-bottom-width: 0 !important;
    cursor: pointer;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
