/* assets/css/styles.css */

/* =========================================================
   GLOBAL TOKENS
   ========================================================= */
:root{
  --bg: #ffffff;
  --text: #0b1220;
  --muted: #5b6577;

  --header: #000000;          /* black header */
  --headerText: #ffffff;

  --sidebar: #36454f;         /* dark sidebar */
  --sidebarText: #fff7ef;

  --border: rgba(16, 24, 40, 0.12);
  --shadow: 0 10px 30px rgba(2, 10, 26, 0.10);

  --radius: 16px;
  --radiusSm: 12px;

  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Layout */
  --sidebarW: 280px;
  --sidebarCollapsedW: 72px;
  --layoutBottomGap: 0px;     /* keep 0 to avoid footer gaps */

  --activeUnderline: #f6d365;

  /* Header sizing */
  --headerH: 72px;
  --logoH: 44px;
}

/* =========================================================
   RESET + PAGE FRAME (STICKY FOOTER + SCROLLABLE PANES)
   ========================================================= */
*{ box-sizing:border-box; }

html, body{ height:100%; }

body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;

  /* Page layout: header / main / footer */
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

/* Utilities */
.sr-only{
  position:absolute;
  width:1px;height:1px;
  padding:0;margin:-1px;
  overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;
}
.muted{ color: var(--muted); }

/* =========================================================
   Header / Topbar (FULL WIDTH)
   ========================================================= */
.topbar{
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header);
  color: var(--headerText);
  box-shadow: 0 10px 25px rgba(0,0,0,0.18);
}

/* Full width container */
.topbar__inner{
  width: 100%;
  max-width: 100%;
  margin: 0;
  height: var(--headerH);
  padding: 0 22px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 18px;
}

/* Brand */
.brand{
  display:flex;
  align-items:center;
  gap: 12px;
  text-decoration:none;
  color: inherit;
  min-width: 0;
  flex: 0 0 auto;
}

/* If logo already includes the text, hide brand name */
.brand__name{ display:none; }

/* Logo sizing */
.brand__logo{
  height: var(--logoH);
  width: auto;
  display:block;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
}

/* =========================================================
   Top nav
   ========================================================= */
.topnav{
  position: relative;
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
}

.topnav__toggle{
  display:none;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.06);
  color: var(--headerText);
  padding: 10px 12px;
  border-radius: 12px;
  cursor:pointer;
}

.hamburger{
  display:block;
  width: 18px;
  height: 2px;
  background: rgba(255,255,255,0.92);
  position: relative;
}
.hamburger::before, .hamburger::after{
  content:"";
  position:absolute;
  left:0;
  width: 18px;
  height: 2px;
  background: rgba(255,255,255,0.92);
}
.hamburger::before{ top:-6px; }
.hamburger::after{ top:6px; }

.topnav__list{
  list-style:none;
  display:flex;
  gap: 6px;
  padding:0;
  margin:0;
  align-items:center;
  justify-content: center;
}

.topnav__item{ position:relative; }

.topnav__link{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  text-decoration:none;
  color: rgba(255,255,255,0.92);
  font-weight: 650;
  position: relative;
}

.topnav__link:hover{
  background: rgba(255,255,255,0.08);
}

.topnav__link.is-active{
  color: #ffffff;
}

.topnav__link.is-active::after{
  content:"";
  position:absolute;
  left: 12px;
  right: 12px;
  bottom: 7px;
  height: 3px;
  border-radius: 999px;
  background: var(--activeUnderline);
  transform-origin: left;
  animation: underlineIn 180ms ease-out;
}

@keyframes underlineIn{
  from{ transform: scaleX(0.25); opacity: 0.6; }
  to{ transform: scaleX(1); opacity: 1; }
}

/* =========================================================
   NEW: Profile avatar (RIGHT SIDE IN TOP BAR)
   Requires HTML:
   <div class="topbar__profile">
     <img class="topbar__avatar" src="./assets/img/mypic.jpg" alt="...">
   </div>
   ========================================================= */
.topbar__profile{
  flex: 0 0 auto;
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap: 10px;
}

.topbar__avatar{
  width: 42px;
  height: 42px;
  border-radius: 999px;
  object-fit: cover;
  border: 2px solid var(--activeUnderline);
  box-shadow: 0 8px 18px rgba(0,0,0,0.25);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.topbar__avatar:hover{
  transform: scale(1.05);
  box-shadow: 0 12px 26px rgba(0,0,0,0.35);
}

img {
  max-width: 180px;
  border-radius: 50%;
  margin-bottom: 20px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.08);
}

#docContent img {
  display: block;
  margin: 0 auto 20px auto;
}

/* =========================================================
   Layout (MAIN AREA)
   ========================================================= */
.layout{
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  display:grid;
  grid-template-columns: var(--sidebarW) 1fr;
  gap: 0;
  transition: grid-template-columns 180ms ease;

  min-height: 0;    /* critical for scrollable children */
  height: 100%;     /* critical for scrollable children */
  align-content: stretch;
}

.layout--single{
  grid-template-columns: 1fr;
}

/* =========================================================
   Sidebar (scrollable)
   ========================================================= */
.sidebar{
  background: var(--sidebar);
  color: var(--sidebarText);
  border-radius: 0;
  box-shadow: var(--shadow);

  overflow: auto;
  min-height: 0;
  height: 100%;
  align-self: stretch;
}

.sidebar__header{
  padding: 12px 14px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.16);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
}

.sidebar__title{
  font-weight: 800;
  letter-spacing: 0.2px;
  font-size: 16px;
}

.sidebar__hint{
  font-size: 12px;
  opacity: 0.85;
  margin-top: 4px;
}

.sidebar__nav{
  padding: 6px 6px 10px;
}

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

/* Existing flat link styling (kept for compatibility) */
.sidebar__link{
  display:flex;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  margin: 2px 6px;
  border-radius: 12px;
  text-decoration:none;
  color: rgba(255,247,239,0.96);
  border: 1px solid transparent;
}

.sidebar__link:hover{
  background: rgba(255,255,255,0.08);
}

.sidebar__link.is-active{
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.22);
}

.sidebar__num{
  font-family: var(--mono);
  font-size: 12px;
  opacity: 0.9;
  min-width: 42px;
}

/* Collapse button (you add <button id="sidebarToggle" class="sidebar__collapseBtn">) */
.sidebar__collapseBtn{
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.92);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  line-height: 1;
}
.sidebar__collapseBtn:hover{
  background: rgba(255,255,255,0.16);
}

/* =========================================================
   NEW: Hierarchical sidebar (Chapter + Sub-items)
   Works with app.js classes:
   - .sb-chapter
   - .sb-chapter-title
   - .sb-sublist
   - .sb-subitem
   ========================================================= */
.sb-chapter{
  margin: 6px 0 12px;
}

/* Chapter title button */
.sb-chapter-title{
  width: calc(100% - 12px);
  margin: 2px 6px;
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;

  padding: 10px 12px;
  border-radius: 12px;

  border: 1px solid transparent;
  background: transparent;
  color: rgba(255,247,239,0.96);

  cursor:pointer;
  text-align:left;
  font-weight: 700;
}

/* Add a subtle caret indicator */
.sb-chapter-title::after{
  content: "▾";
  font-size: 12px;
  opacity: 0.85;
  transform: translateY(1px);
}

/* Hover */
.sb-chapter-title:hover{
  background: rgba(255,255,255,0.08);
}

/* Active chapter (optional) */
.sb-chapter-title.is-active{
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.20);
}

/* Sublist indentation */
.sb-sublist{
  list-style: none;
  margin: 6px 0 0;
  padding: 0 0 0 18px;
}

/* Collapse by toggling .is-collapsed on chapter li */
.sb-chapter.is-collapsed .sb-sublist{
  display:none;
}

/* Rotate caret when collapsed */
.sb-chapter.is-collapsed .sb-chapter-title::after{
  content: "▸";
}

/* Sub item */
.sb-subitem{
  margin: 2px 0;
}

.sb-subitem a{
  display:block;
  margin: 0 6px;
  padding: 8px 10px;
  border-radius: 10px;

  text-decoration:none;
  color: rgba(255,247,239,0.95);
  font-size: 14px;
  opacity: 0.95;

  border: 1px solid transparent;
}

.sb-subitem a:hover{
  background: rgba(255,255,255,0.10);
}

/* Active child item */
.sb-subitem.active a{
  background: #ffffff;
  color: #111;
  font-weight: 750;
  border-color: rgba(0,0,0,0.08);
}

/* =========================================================
   Collapsed sidebar state
   Toggle by adding: body.sidebar-collapsed
   ========================================================= */
body.sidebar-collapsed .layout{
  grid-template-columns: var(--sidebarCollapsedW) 1fr;
}

body.sidebar-collapsed .sidebar__title,
body.sidebar-collapsed .sidebar__hint{
  display:none;
}

/* Hide text labels in collapsed mode (flat links + hierarchical links) */
body.sidebar-collapsed .sidebar__link{
  justify-content: center;
  padding: 10px 8px;
}

body.sidebar-collapsed .sidebar__num{
  min-width: auto;
}

body.sidebar-collapsed .sidebar__link span:not(.sidebar__num),
body.sidebar-collapsed .sidebar__link strong,
body.sidebar-collapsed .sidebar__link em{
  display:none;
}

/* Hierarchical collapse rules */
body.sidebar-collapsed .sb-sublist{
  display:none !important;
}
body.sidebar-collapsed .sb-chapter-title{
  justify-content: center;
}
body.sidebar-collapsed .sb-chapter-title::after{
  display:none;
}
body.sidebar-collapsed .sb-chapter-title .sidebar__titleText{
  display:none;
}

/* =========================================================
   Content (scrollable)
   ========================================================= */
.content{
  background: #ffffff;
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  border-right: 0;
  border-bottom: 0;
  border-radius: 0;
  box-shadow: none;

  overflow: auto;
  min-height: 0;
  height: 100%;
  align-self: stretch;
  min-width: 0;
}

.doc{
  padding: 18px 28px 28px;
}

.doc__meta{
  display:flex;
  justify-content:flex-start;
  margin-bottom: 10px;
}

.pill{
  display:inline-flex;
  align-items:center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(11,77,183,0.08);
  border: 1px solid rgba(11,77,183,0.20);
  color: #0b4db7;
  font-weight: 700;
  font-size: 12px;
}

.doc__content h1, .doc__content h2, .doc__content h3{
  line-height: 1.2;
}
.doc__content h1{ margin: 8px 0 10px; font-size: 30px; }
.doc__content h2{ margin: 22px 0 10px; font-size: 22px; }
.doc__content h3{ margin: 18px 0 8px; font-size: 18px; }

.doc__content p{ margin: 10px 0; }
.doc__content ul, .doc__content ol{ margin: 10px 0 10px 22px; }

.doc__content code{
  font-family: var(--mono);
  font-size: 0.95em;
  background: rgba(2, 10, 26, 0.06);
  padding: 2px 75x;
  border-radius: 8px;
}

/* Murthy */
 .doc__content pre{
 /* background: #0b1220;*/
 background: #F5F5F5;
  /*color: #e6f0ff;*/
  color: #1A1A1A;;
  padding: 14px 14px;
  border-radius: 14px;
  overflow:auto;
  max-width: 60%;
}

.doc__content pre code{
  background: transparent;
  padding:0;
  border-radius: 0;
  color: inherit;
} 

/*
.doc__content pre {
    background-color: #e6f9ec;
    color: #1f2937;
    padding: 12px 16px;
    border-radius: 6px;
    border: 1px solid #b7ebc6;

    display: inline-block;      🔥 Key change 
    width: auto;                shrink to content 
    max-width: 100%;            prevent overflow 
} 
  
*/

/* .doc__content pre {
  
    background-color: #e6f9ec;    Light green 
    color: #1f2937;     
    /* background-color: #ffffff;
    color: #000000;
    padding: 16px; */
    border-radius: 6px;
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    max-width: 50%; 
}

.doc__content code {
    background-color: #f5f5f5;
    color: #000000;
} */


/* Callout */
.callout{
  background: rgba(11,77,183,0.06);
  border: 1px solid rgba(11,77,183,0.18);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 14px 0;
}

/* =========================================================
   Footer
   ========================================================= */
.footer{
  border-top: 1px solid var(--border);
  padding: 16px 18px;
  margin: 0;
  background: var(--bg);
}

.footer__inner{
  width: 100%;
  max-width: 100%;
  margin: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.footer a{ color: var(--muted); text-decoration:none; }
.footer a:hover{ text-decoration:underline; }
.footer__sep{ opacity:0.6; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 980px){
  :root{
    --logoH: 36px;
    --headerH: 68px;
  }

  .topbar__inner{
    padding: 0 14px;
  }

  .layout{
    grid-template-columns: 1fr;
    height: auto;      /* mobile: let page scroll naturally */
    min-height: auto;
  }

  body.sidebar-collapsed .layout{
    grid-template-columns: 1fr;
  }

  .sidebar{
    height: auto;
    overflow: visible;
  }

  .content{
    border-left: 0;
    border-top: 1px solid var(--border);
    height: auto;
    overflow: visible;
  }

  /* Mobile: nav toggle visible */
  .topnav__toggle{ display:inline-flex; }

  /* Mobile: nav aligns right (toggle + dropdown) */
  .topnav{
    justify-content: flex-end;
  }

  .topnav__list{
    position:absolute;
    right:0;
    top: 56px; /* keep dropdown below header items including avatar */
    flex-direction:column;
    align-items:stretch;
    background: rgba(255,255,255,0.98);
    color: var(--text);
    border-radius: 16px;
    min-width: 240px;
    padding: 8px;
    box-shadow: 0 18px 40px rgba(0,0,0,0.18);
    border: 1px solid rgba(16,24,40,0.14);
    display:none;
  }

  .topnav__list.is-open{ display:flex; }

  .topnav__link{
    color: var(--text);
    width: 100%;
  }

  .topnav__link:hover{
    background: rgba(2,10,26,0.06);
  }

  .topnav__link.is-active::after{
    background: var(--header);
  }

  /* Mobile: avatar slightly smaller */
  .topbar__avatar{
    width: 36px;
    height: 36px;
    border-width: 2px;
  }

  /* Mobile: hierarchical sidebar spacing */
  .sb-chapter-title{
    width: calc(100% - 8px);
    margin: 2px 4px;
  }
  .sb-subitem a{
    margin: 0 4px;
  }
}