/* ══════════════════════════════════════════
   Notes Page Styles
   ══════════════════════════════════════════ */

/* ── Layout ── */
.notes-layout {
  display: flex;
  padding-top: 64px;
  min-height: 100vh;
  max-width: 1600px;
  margin: 0 auto;
  position: relative;
}

/* ── Progress Bar ── */
.progress-container {
  width: 100%;
  height: 3px;
  background: transparent;
  position: absolute;
  bottom: 0;
  left: 0;
}
.progress-bar {
  height: 3px;
  background: var(--accent-blue);
  width: 0%;
  transition: width 0.1s;
  border-radius: 0 2px 2px 0;
}

/* ══════════════════════════════════════════
   Sidebar
   ══════════════════════════════════════════ */
.sidebar {
  width: 280px;
  min-width: 280px;
  height: calc(100vh - 64px);
  position: sticky;
  top: 64px;
  overflow-y: auto;
  padding: 20px 16px;
  border-right: 1px solid var(--border-subtle);
  background: transparent;
  z-index: 10;
}

.sidebar-section-title {
  padding: 0 12px;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

/* ── Category List ── */
#category-list {
  list-style: none;
  margin-bottom: 0;
}

#category-list > li {
  margin-bottom: 2px;
}

#category-list > li > a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
}

#category-list > li > a:hover {
  color: var(--text-primary);
  background: rgba(99, 152, 255, 0.06);
}

#category-list > li > a.active {
  color: var(--accent-blue);
  background: rgba(99, 152, 255, 0.1);
  font-weight: 600;
}

/* Category icon */
.cat-icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

/* ══════════════════════════════════════════
   Table of Contents (Sub-categories)
   ══════════════════════════════════════════ */
.toc-container {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s var(--ease-out);
}

.toc-container.open {
  max-height: 2000px;
}

.toc-list {
  list-style: none;
  padding: 4px 0 8px 0;
  margin-left: 20px;
  border-left: 1px solid var(--border-subtle);
}

.toc-list li {
  margin: 0;
}

.toc-list a {
  display: block;
  padding: 5px 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 400;
  line-height: 1.4;
  transition: var(--transition);
  border-left: 2px solid transparent;
  margin-left: -1px;
}

.toc-list a:hover {
  color: var(--text-secondary);
  border-left-color: var(--border-default);
}

.toc-list a.active {
  color: var(--accent-blue);
  border-left-color: var(--accent-blue);
  font-weight: 500;
}

.content-area {
  flex: 1;
  padding: 40px 48px;
  max-width: 800px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* ── Right Sidebar (TOC) ── */
.right-sidebar {
  width: 260px;
  min-width: 260px;
  height: calc(100vh - 64px);
  position: sticky;
  top: 64px;
  overflow-y: auto;
  padding: 40px 16px;
  border-left: 1px solid var(--border-subtle);
  background: transparent;
  display: block;
}

.right-sidebar h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-left: 12px;
}

/* ══════════════════════════════════════════
   Main Content
   ══════════════════════════════════════════ */
.content-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
}

#note-title {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.meta-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.meta-info {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.pdf-btn {
  padding: 8px 16px;
  font-size: 0.82rem;
}

/* ══════════════════════════════════════════
   Markdown Body
   ══════════════════════════════════════════ */
.markdown-body {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-primary);
}

.markdown-body h1 {
  font-size: 1.7rem;
  font-weight: 800;
  margin-top: 56px;
  margin-bottom: 16px;
  color: var(--text-primary);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
  scroll-margin-top: 80px;
}

.markdown-body h2 {
  font-size: 1.45rem;
  font-weight: 700;
  margin-top: 40px;
  margin-bottom: 12px;
  color: var(--text-primary);
  scroll-margin-top: 80px;
}

.markdown-body h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 10px;
  color: var(--accent-blue);
  scroll-margin-top: 80px;
}

.markdown-body h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 28px;
  margin-bottom: 8px;
  color: var(--accent-cyan);
  scroll-margin-top: 80px;
}

.markdown-body p {
  margin-bottom: 16px;
  color: var(--text-secondary);
}

.markdown-body ul, .markdown-body ol {
  margin-bottom: 20px;
  padding-left: 24px;
  color: var(--text-secondary);
}

.markdown-body li {
  margin-bottom: 6px;
}

.markdown-body strong {
  color: var(--accent-amber);
  font-weight: 600;
}

.markdown-body em {
  color: var(--text-primary);
  font-style: italic;
}

.markdown-body blockquote {
  border-left: 3px solid var(--accent-amber);
  padding: 12px 16px;
  background: rgba(245, 158, 11, 0.06);
  margin: 20px 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.9rem;
}

.markdown-body th, .markdown-body td {
  padding: 10px 14px;
  border: 1px solid var(--border-subtle);
  text-align: left;
}

.markdown-body th {
  background: var(--bg-elevated);
  color: var(--accent-blue);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.markdown-body td {
  color: var(--text-secondary);
}

.markdown-body tr:hover td {
  background: rgba(99, 152, 255, 0.03);
}

/* ── Code Blocks (VS Code Style) ── */
.markdown-body pre {
  position: relative;
  background: #0D1117 !important;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0 !important;
  overflow: hidden;
  margin: 20px 0;
}

.markdown-body pre code {
  display: block;
  padding: 16px 20px !important;
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.7;
}

/* Code block top bar (added via JS) */
.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 8px 60px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: relative;
}

.code-header::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #FF5F56;
  box-shadow: 20px 0 0 #FFBD2E, 40px 0 0 #27C93F;
}

.code-copy-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  font-family: var(--font-body);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.code-copy-btn:hover {
  color: var(--accent-blue);
  background: rgba(99, 152, 255, 0.1);
}

.code-copy-btn.copied {
  color: var(--accent-emerald);
}

/* Inline code */
.markdown-body p code,
.markdown-body li code,
.markdown-body td code {
  background: rgba(99, 152, 255, 0.1);
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--accent-cyan);
  font-family: var(--font-code);
  font-size: 0.88em;
  font-weight: 500;
}

/* ══════════════════════════════════════════
   Search Overlay
   ══════════════════════════════════════════ */
.search-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(11, 17, 32, 0.9);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 120px;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.search-overlay.active {
  opacity: 1;
  visibility: visible;
}

.search-modal {
  width: 100%;
  max-width: 560px;
  padding: 20px;
}

.search-header {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

#search-input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: var(--font-body);
  outline: none;
  transition: var(--transition);
}

#search-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(99, 152, 255, 0.15);
}

#search-input::placeholder {
  color: var(--text-muted);
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 8px;
  transition: var(--transition);
}
.close-btn:hover { color: var(--text-primary); }

.search-results {
  max-height: 360px;
  overflow-y: auto;
}

.search-result-item {
  display: block;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  margin-bottom: 4px;
  transition: var(--transition);
}
.search-result-item:hover {
  background: rgba(99, 152, 255, 0.08);
}
.search-result-title {
  color: var(--accent-blue);
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 0.95rem;
}
.search-result-match {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ══════════════════════════════════════════
   Skeleton Loader
   ══════════════════════════════════════════ */
.skeleton-loader {
  padding: 20px 0;
}
.s-title { height: 32px; width: 50%; margin-bottom: 32px; }
.s-text { height: 16px; width: 100%; margin-bottom: 12px; }
.s-text.w-80 { width: 80%; }
.s-box { height: 160px; width: 100%; margin-top: 24px; border-radius: var(--radius-md); }

/* ══════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════ */
@media (max-width: 900px) {
  .sidebar {
    width: 100%;
    min-width: unset;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    padding: 16px;
  }
  .toc-container {
    max-height: 0 !important;
  }
  .note-content {
    margin-left: 0;
    width: 100%;
    padding: 24px 20px;
  }
  .content-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  #note-title {
    font-size: 1.5rem;
  }
}
}

/* ══════════════════════════════════════════
   Prism.js VS Code One Dark Theme
   ══════════════════════════════════════════ */
code[class*="language-"],
pre[class*="language-"] {
    color: #abb2bf;
    background: #282c34;
    font-family: 'Fira Code', Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    line-height: 1.5;
    text-shadow: none;
    direction: ltr;
    text-align: left;
    white-space: pre;
    word-spacing: normal;
    word-break: normal;
    tab-size: 4;
    hyphens: none;
}

pre[class*="language-"] {
    padding: 1.25em 1.5em;
    margin: .5em 0 1.2em 0;
    overflow: auto;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    background: #1e1e1e; /* VS Code dark background */
}

:not(pre) > code[class*="language-"] {
    padding: .1em .3em;
    border-radius: .3em;
    color: #db4c69;
    background: rgba(255, 255, 255, 0.1);
}

.token.comment,
.token.prolog,
.token.cdata {
    color: #5c6370;
    font-style: italic;
}

.token.doctype,
.token.punctuation,
.token.entity {
    color: #abb2bf;
}

.token.attr-name,
.token.class-name,
.token.boolean,
.token.constant,
.token.number,
.token.atrule {
    color: #d19a66;
}

.token.keyword {
    color: #c678dd;
}

.token.property,
.token.tag,
.token.symbol,
.token.deleted,
.token.important {
    color: #e06c75;
}

.token.selector,
.token.string,
.token.char,
.token.builtin,
.token.inserted,
.token.regex,
.token.attr-value,
.token.attr-value > .token.punctuation {
    color: #98c379;
}

.token.variable,
.token.operator,
.token.function {
    color: #61afef;
}

.token.url {
    color: #56b6c2;
}

.token.attr-value > .token.punctuation.attr-equals,
.token.special-attr > .token.attr-value > .token.value.css {
    color: #abb2bf;
}

.language-css .token.selector {
    color: #e06c75;
}

.language-css .token.property {
    color: #abb2bf;
}

.language-css .token.function,
.language-css .token.url > .token.function {
    color: #56b6c2;
}

.language-css .token.url > .token.string.url {
    color: #98c379;
}

.language-css .token.important,
.language-css .token.atrule .token.rule {
    color: #c678dd;
}

.language-javascript .token.operator {
    color: #c678dd;
}

.language-javascript .token.template-string > .token.interpolation > .token.interpolation-punctuation.punctuation {
    color: #be5046;
}

.language-json .token.operator {
    color: #abb2bf;
}

.language-json .token.null.keyword {
    color: #d19a66;
}

.language-markdown .token.url,
.language-markdown .token.url > .token.operator,
.language-markdown .token.url-reference.url > .token.string {
    color: #abb2bf;
}

.language-markdown .token.url > .token.content {
    color: #61afef;
}

.language-markdown .token.url > .token.url,
.language-markdown .token.url-reference.url {
    color: #56b6c2;
}

.language-markdown .token.blockquote.punctuation,
.language-markdown .token.hr.punctuation {
    color: #5c6370;
    font-style: italic;
}

.language-markdown .token.code-snippet {
    color: #98c379;
}

.language-markdown .token.bold .token.content {
    color: #d19a66;
}

.language-markdown .token.italic .token.content {
    color: #c678dd;
}

.language-markdown .token.strike .token.content,
.language-markdown .token.strike .token.punctuation,
.language-markdown .token.list.punctuation,
.language-markdown .token.title.important > .token.punctuation {
    color: #e06c75;
}

.token.bold {
    font-weight: bold;
}

.token.italic {
    font-style: italic;
}

.token.entity {
    cursor: help;
}

.token.namespace {
    opacity: .8;
}

/* ── Light Mode Adjustments for Code ── */
[data-theme="light"] pre[class*="language-"] {
    background: #f8f9fa;
    border: 1px solid var(--border-subtle);
}
[data-theme="light"] code[class*="language-"],
[data-theme="light"] pre[class*="language-"] {
    color: #383a42;
    text-shadow: none;
}
[data-theme="light"] .token.comment,
[data-theme="light"] .token.prolog,
[data-theme="light"] .token.cdata { color: #a0a1a7; }
[data-theme="light"] .token.doctype,
[data-theme="light"] .token.punctuation,
[data-theme="light"] .token.entity { color: #383a42; }
[data-theme="light"] .token.attr-name,
[data-theme="light"] .token.class-name,
[data-theme="light"] .token.boolean,
[data-theme="light"] .token.constant,
[data-theme="light"] .token.number,
[data-theme="light"] .token.atrule { color: #986801; }
[data-theme="light"] .token.keyword { color: #a626a4; }
[data-theme="light"] .token.property,
[data-theme="light"] .token.tag,
[data-theme="light"] .token.symbol,
[data-theme="light"] .token.deleted,
[data-theme="light"] .token.important { color: #e45649; }
[data-theme="light"] .token.selector,
[data-theme="light"] .token.string,
[data-theme="light"] .token.char,
[data-theme="light"] .token.builtin,
[data-theme="light"] .token.inserted,
[data-theme="light"] .token.regex,
[data-theme="light"] .token.attr-value { color: #50a14f; }
[data-theme="light"] .token.variable,
[data-theme="light"] .token.operator,
[data-theme="light"] .token.function { color: #4078f2; }
[data-theme="light"] .token.url { color: #0184bc; }

/* ══════════════════════════════════════════
   Responsive — Tablet (≤1024px)
   ══════════════════════════════════════════ */
@media (max-width: 1024px) {
  .right-sidebar {
    display: none;
  }
  .content-area {
    padding: 32px 28px;
    max-width: 100%;
  }
}

/* ══════════════════════════════════════════
   Responsive — Mobile (≤768px)
   Full Drawer Sidebar + Clean Layout
   ══════════════════════════════════════════ */
@media (max-width: 768px) {

  /* === Layout === */
  .notes-layout {
    flex-direction: column;
    padding-top: 0;
  }

  /* === Sidebar → Drawer (slides in from left) === */
  .sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    z-index: 2000;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    transition: left 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    padding: 72px 16px 24px;
    overflow-y: auto;
    min-width: unset;
  }

  .sidebar.mobile-open {
    left: 0;
  }

  /* Overlay scrim behind drawer */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1999;
    backdrop-filter: blur(2px);
  }

  .sidebar-overlay.active {
    display: block;
  }

  /* Close button inside drawer */
  .sidebar-close-btn {
    display: flex !important;
    position: absolute;
    top: 16px;
    right: 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    z-index: 10;
  }

  /* === Mobile Top Bar === */
  .mobile-topbar {
    display: flex !important;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 56px;
  }

  .hamburger-btn {
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
  }

  .hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 2px;
    transition: var(--transition);
  }

  .mobile-topbar-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
  }

  /* === Content Area === */
  .content-area {
    padding: 20px 16px 80px;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  /* === Content Header (Title + PDF button) === */
  .content-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 16px;
  }

  #note-title {
    font-size: 1.6rem;
  }

  .meta-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }

  .pdf-btn {
    font-size: 0.8rem;
    padding: 7px 14px;
  }

  /* === Markdown Content === */
  .markdown-body h1 { font-size: 1.5rem; }
  .markdown-body h2 { font-size: 1.25rem; }
  .markdown-body h3 { font-size: 1.1rem; }

  .markdown-body pre {
    border-radius: var(--radius-sm);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.78rem;
    line-height: 1.5;
  }

  .markdown-body table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.8rem;
  }

  .markdown-body img {
    max-width: 100%;
    height: auto;
  }

  .markdown-body p {
    font-size: 0.92rem;
  }

  .markdown-body li {
    font-size: 0.92rem;
  }

  /* Code block header */
  .code-block-header {
    font-size: 0.72rem;
    padding: 6px 12px;
  }

  /* === Category list in drawer === */
  #category-list > li > a {
    padding: 11px 12px;
    font-size: 0.92rem;
  }

  .toc-list a {
    padding: 7px 12px;
    font-size: 0.82rem;
  }
}

/* ══════════════════════════════════════════
   Mobile elements hidden on desktop
   ══════════════════════════════════════════ */
.mobile-topbar { display: none; }
.hamburger-btn { display: none; }
.sidebar-close-btn { display: none; }
.sidebar-overlay { display: none; }

