/* Modern Google-Style Dark Theme Design Tokens */
:root {
  /* Modern Google Dark Theme Colors (inspired by Gmail, Drive, etc.) */
  --md-sys-color-primary: #8ab4f8;
  --md-sys-color-on-primary: #0d1117;
  --md-sys-color-primary-container: #1f2937;
  --md-sys-color-on-primary-container: #dbeafe;
  
  --md-sys-color-secondary: #a5b4fc;
  --md-sys-color-on-secondary: #1e1b4b;
  --md-sys-color-secondary-container: #312e81;
  --md-sys-color-on-secondary-container: #e0e7ff;
  
  --md-sys-color-tertiary: #c4b5fd;
  --md-sys-color-on-tertiary: #3e1f47;
  --md-sys-color-tertiary-container: #5b21b6;
  --md-sys-color-on-tertiary-container: #f3e8ff;
  
  --md-sys-color-error: #fca5a5;
  --md-sys-color-on-error: #7f1d1d;
  --md-sys-color-error-container: #991b1b;
  --md-sys-color-on-error-container: #fee2e2;
  
  /* Modern Google Dark Surface Colors */
  --md-sys-color-surface: #0d1117;
  --md-sys-color-on-surface: #e6edf3;
  --md-sys-color-surface-variant: #161b22;
  --md-sys-color-on-surface-variant: #b1bac4;
  
  --md-sys-color-outline: #30363d;
  --md-sys-color-outline-variant: #21262d;
  
  --md-sys-color-background: #0d1117;
  --md-sys-color-on-background: #e6edf3;
  
  /* Modern Google-style Surface Containers */
  --md-sys-color-surface-container-lowest: #010409;
  --md-sys-color-surface-container-low: #161b22;
  --md-sys-color-surface-container: #1c2128;
  --md-sys-color-surface-container-high: #22272e;
  --md-sys-color-surface-container-highest: #2d333b;
  
  /* Active/Hover States */
  --md-sys-color-hover: rgba(177, 186, 196, 0.12);
  --md-sys-color-active: rgba(138, 180, 248, 0.16);
  --md-sys-color-active-border: rgba(138, 180, 248, 0.4);
  
  /* Material Design 3 Elevation */
  --md-sys-elevation-level0: none;
  --md-sys-elevation-level1: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
  --md-sys-elevation-level2: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 2px 6px 2px rgba(0, 0, 0, 0.15);
  --md-sys-elevation-level3: 0px 1px 3px 0px rgba(0, 0, 0, 0.3), 0px 4px 8px 3px rgba(0, 0, 0, 0.15);
  --md-sys-elevation-level4: 0px 2px 3px 0px rgba(0, 0, 0, 0.3), 0px 6px 10px 4px rgba(0, 0, 0, 0.15);
  --md-sys-elevation-level5: 0px 4px 4px 0px rgba(0, 0, 0, 0.3), 0px 8px 12px 6px rgba(0, 0, 0, 0.15);
  
  /* Material Design 3 Typography */
  --md-sys-typescale-display-large-font: 'Roboto', system-ui, -apple-system, sans-serif;
  --md-sys-typescale-display-large-weight: 400;
  --md-sys-typescale-display-large-size: 57px;
  --md-sys-typescale-display-large-line-height: 64px;
  --md-sys-typescale-display-large-tracking: -0.25px;
  
  --md-sys-typescale-headline-large-font: 'Roboto', system-ui, -apple-system, sans-serif;
  --md-sys-typescale-headline-large-weight: 400;
  --md-sys-typescale-headline-large-size: 32px;
  --md-sys-typescale-headline-large-line-height: 40px;
  
  --md-sys-typescale-title-large-font: 'Roboto', system-ui, -apple-system, sans-serif;
  --md-sys-typescale-title-large-weight: 400;
  --md-sys-typescale-title-large-size: 22px;
  --md-sys-typescale-title-large-line-height: 28px;
  
  --md-sys-typescale-body-large-font: 'Roboto', system-ui, -apple-system, sans-serif;
  --md-sys-typescale-body-large-weight: 400;
  --md-sys-typescale-body-large-size: 16px;
  --md-sys-typescale-body-large-line-height: 24px;
  --md-sys-typescale-body-large-tracking: 0.5px;
  
  --md-sys-typescale-label-large-font: 'Roboto', system-ui, -apple-system, sans-serif;
  --md-sys-typescale-label-large-weight: 500;
  --md-sys-typescale-label-large-size: 14px;
  --md-sys-typescale-label-large-line-height: 20px;
  --md-sys-typescale-label-large-tracking: 0.1px;
  
  /* Legacy variables for compatibility */
  --border: rgba(255,255,255,0.12);
  --bg: var(--md-sys-color-background);
  --bg2: var(--md-sys-color-surface-container-low);
  --bg3: var(--md-sys-color-surface-container);
  --text: var(--md-sys-color-on-background);
  --muted: var(--md-sys-color-on-surface-variant);
  --accent: var(--md-sys-color-primary);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--md-sys-color-background);
  color: var(--md-sys-color-on-background);
  font-family: var(--md-sys-typescale-body-large-font);
  font-size: var(--md-sys-typescale-body-large-size);
  line-height: var(--md-sys-typescale-body-large-line-height);
  letter-spacing: var(--md-sys-typescale-body-large-tracking);
}

/* ---------- Material Design 3 App Bar (Topbar) ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
  padding: 0 16px;
  background: var(--md-sys-color-surface);
  border-bottom: 1px solid var(--md-sys-color-outline);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
  background: rgba(13, 17, 23, 0.8);
}

.burger {
  border: none;
  background: transparent;
  color: var(--md-sys-color-on-surface);
  border-radius: 20px;
  padding: 12px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s cubic-bezier(0.2, 0, 0, 1);
  font-size: 24px;
  line-height: 1;
}

.burger:hover {
  background: var(--md-sys-color-hover);
}

.burger:active {
  background: var(--md-sys-color-surface-container-high);
}

.burger:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.topbarTitleLink {
  font-family: var(--md-sys-typescale-title-large-font);
  font-weight: var(--md-sys-typescale-title-large-weight);
  font-size: var(--md-sys-typescale-title-large-size);
  line-height: var(--md-sys-typescale-title-large-line-height);
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 20px;
  transition: background-color 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.topbarTitleLink:hover {
  background: var(--md-sys-color-hover);
}

.topbarTitleLink:active {
  background: var(--md-sys-color-surface-container-high);
}

.topbarTitleLink:visited {
  color: var(--md-sys-color-on-surface);
}

/* ---------- Layout ---------- */

.layout {
  display: flex;
  min-height: calc(100vh - 52px);
}

/* ---------- Modern Google-Style Navigation Drawer (Sidebar) ---------- */

.sidebar {
  width: 360px;
  background: var(--md-sys-color-surface);
  border-right: 1px solid var(--md-sys-color-outline);
  padding: 12px 8px;
  overflow-y: auto;
  box-shadow: var(--md-sys-elevation-level1);
}

/* ---------- Modern Tree Navigation with Proper Indentation ---------- */

.tree {
  padding-left: 0;
  margin: 0;
  list-style: none;
}

/* Top-level folders have no extra indentation */
.topFolder {
  margin: 2px 0;
}

/* Top-level tree (direct children of topFolder) should NOT be indented */
.topFolder > .tree {
  padding-left: 0;
  margin-left: 0;
}

/* All nested tree elements inside details (children of folders) should be indented */
/* This applies to both nested folders AND nested files */
/* This rule applies to trees inside ANY details element (including nested folders) */
details > .tree:not(.topFolder > .tree),
.tree details > .tree {
  padding-left: 32px;
  margin-left: 0;
  border-left: 1px solid var(--md-sys-color-outline-variant);
  margin-top: 4px;
  padding-top: 4px;
}

/* Ensure all nodes (both folders and files) inside nested trees are properly positioned */
.tree details > .tree > .node,
details > .tree:not(.topFolder > .tree) > .node {
  position: relative;
}

/* Additional indentation for deeper nesting levels */
.tree details > .tree details > .tree {
  padding-left: 32px;
}

/* Even deeper nesting levels */
.tree details > .tree details > .tree details > .tree {
  padding-left: 32px;
}

.node {
  list-style: none;
  margin: 1px 0;
}

/* Top-level nodes (direct children of topFolder) */
.topFolder > .tree > .node {
  margin: 2px 0;
}

/* ---------- Material Design 3 Details Summary and Arrow ---------- */

.topFolder > summary,
.tree details > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0;
  cursor: pointer;
  padding: 0;
  margin: 0;
  position: relative;
}

.topFolder > summary::-webkit-details-marker,
.tree details > summary::-webkit-details-marker {
  display: none;
}

/* Hide expand/collapse icons */
.topFolder > summary::before,
.tree details > summary::before {
  display: none;
}

/* ---------- Material Design 3 Folder Button ---------- */

.folderLink {
  border: 0;
  background: transparent;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  font-family: var(--md-sys-typescale-label-large-font);
  font-weight: var(--md-sys-typescale-label-large-weight);
  font-size: var(--md-sys-typescale-label-large-size);
  line-height: var(--md-sys-typescale-label-large-line-height);
  width: 100%;
  text-align: left;
  transition: background-color 0.2s cubic-bezier(0.2, 0, 0, 1);
  min-height: 40px;
}

.folderLink:hover {
  background: var(--md-sys-color-hover);
}

.folderLink:active {
  background: var(--md-sys-color-surface-container-high);
}

/* Mark open folders with background color */
.topFolder[open] > summary > .folderLink,
.tree details[open] > summary > .folderLink {
  background: var(--md-sys-color-surface-container-low);
}

.topFolder[open] > summary > .folderLink:hover,
.tree details[open] > summary > .folderLink:hover {
  background: var(--md-sys-color-surface-container);
}

.folderLink:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

/* Folder button fills remaining space next to arrow */
.topFolder > summary > .folderLink,
.tree details > summary > .folderLink {
  flex: 1;
}

/* Ensure nested folder links are properly indented - they inherit from their parent tree */
/* The tree itself is indented, so the folder links inside are automatically indented */

/* ---------- Material Design 3 File Link ---------- */

.fileLink {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--md-sys-color-on-surface);
  width: 100%;
  font-family: var(--md-sys-typescale-label-large-font);
  font-weight: var(--md-sys-typescale-label-large-weight);
  font-size: var(--md-sys-typescale-label-large-size);
  line-height: var(--md-sys-typescale-label-large-line-height);
  transition: background-color 0.2s cubic-bezier(0.2, 0, 0, 1);
  min-height: 40px;
}

.fileLink:hover {
  background: var(--md-sys-color-hover);
}

.fileLink:active {
  background: var(--md-sys-color-surface-container-high);
}

.fileLink.active {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  font-weight: 500;
  border-radius: 8px;
}

.fileLink.active:hover {
  background: var(--md-sys-color-surface-container-high);
  opacity: 0.95;
}

.fileLink.active .icon {
  color: var(--md-sys-color-primary);
}

.fileLink:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

/* ---------- Material Design 3 Icons and Labels ---------- */

.icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--md-sys-color-on-surface-variant);
  flex-shrink: 0;
}

.icon.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-feature-settings: 'liga';
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
}

/* Icons in nested elements (inside details) should be indented */
.tree details .folderLink .icon,
.tree details .fileLink .icon {
  margin-left: 0;
}

/* Top-level icons have no extra margin */
.topFolder > summary > .folderLink .icon {
  margin-left: 0;
}

.fileLink.active .icon {
  color: var(--md-sys-color-primary);
}

.burger .material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-feature-settings: 'liga';
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  color: var(--md-sys-color-on-surface);
}

.label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* ---------- Material Design 3 Content Area ---------- */

.content {
  flex: 1;
  padding: 32px;
  max-width: 1200px;
  background: var(--md-sys-color-background);
  min-height: calc(100vh - 64px);
}

.content h1 {
  font-family: var(--md-sys-typescale-headline-large-font);
  font-weight: var(--md-sys-typescale-headline-large-weight);
  font-size: var(--md-sys-typescale-headline-large-size);
  line-height: var(--md-sys-typescale-headline-large-line-height);
  color: var(--md-sys-color-on-background);
  margin-top: 24px;
  margin-bottom: 16px;
}

.content h2 {
  font-family: var(--md-sys-typescale-title-large-font);
  font-weight: var(--md-sys-typescale-title-large-weight);
  font-size: var(--md-sys-typescale-title-large-size);
  line-height: var(--md-sys-typescale-title-large-line-height);
  color: var(--md-sys-color-on-background);
  margin-top: 24px;
  margin-bottom: 12px;
}

.content h3, .content h4, .content h5, .content h6 {
  font-family: var(--md-sys-typescale-title-large-font);
  color: var(--md-sys-color-on-background);
  margin-top: 20px;
  margin-bottom: 10px;
}

.content p {
  color: var(--md-sys-color-on-background);
  margin: 16px 0;
}

.content img {
  max-width: 100%;
  height: auto;
  border-radius: 16px;
  box-shadow: var(--md-sys-elevation-level2);
  margin: 16px 0;
}

.content a {
  color: var(--md-sys-color-primary);
  text-decoration: none;
  transition: opacity 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.content a:hover {
  text-decoration: underline;
  opacity: 0.8;
}

.content a:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

.content pre {
  overflow: auto;
  padding: 16px;
  border-radius: 8px;
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline);
  margin: 16px 0;
}

.content code {
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  background: var(--md-sys-color-surface-container);
  padding: 2px 6px;
  border-radius: 4px;
}

.content pre code {
  background: transparent;
  padding: 0;
}

.content ul, .content ol {
  margin: 16px 0;
  padding-left: 24px;
  color: var(--md-sys-color-on-background);
}

.content li {
  margin: 8px 0;
}

.content blockquote {
  border-left: 4px solid var(--md-sys-color-primary);
  padding-left: 16px;
  margin: 16px 0;
  color: var(--md-sys-color-on-surface-variant);
  font-style: italic;
}

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  background: var(--md-sys-color-surface-container);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--md-sys-color-outline);
}

.content table th,
.content table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--md-sys-color-outline);
}

.content table th {
  background: var(--md-sys-color-surface-container-high);
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
}

.content table tr:last-child td {
  border-bottom: none;
}

.content table tr:hover {
  background: var(--md-sys-color-surface-container-low);
}

/* ---------- Material Design 3 Mobile Responsive ---------- */

.backdrop {
  display: none;
}

@media (max-width: 900px) {

  .layout {
    flex-direction: column;
  }

  .topbar {
    height: 56px;
    padding: 0 12px;
  }

  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: min(360px, 85vw);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1);
    z-index: 60;
    box-shadow: var(--md-sys-elevation-level3);
    border-right: none;
  }

  body.menuOpen .sidebar {
    transform: translateX(0);
  }

  .content {
    padding: 16px;
  }

  .backdrop {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 55;
    transition: opacity 0.3s cubic-bezier(0.2, 0, 0, 1);
    opacity: 0;
    pointer-events: none;
  }

  body.menuOpen .backdrop {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }
}

/* ---------- Material Design 3 Ripple Effect ---------- */

.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0);
  animation: ripple-animation 0.6s cubic-bezier(0.2, 0, 0, 1);
  pointer-events: none;
}

@keyframes ripple-animation {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

.ripple-container {
  position: relative;
  overflow: hidden;
}
