/* ==========================================================================
   TQuant Lab - Extra Stylesheet (Minimal)
   ========================================================================== */

/* ==========================================================================
   1. CSS Variables
   ========================================================================== */

:root {
  --header-height: 3.5rem;
  --sidebar-width-primary: 12.1rem;
  --sidebar-width-secondary: 15rem;
  --transition-fast: 0.3s;
  --border-radius-small: 3px;
  --border-radius-medium: 6px;
  --border-radius-large: 8px;
  --border-radius-round: 50%;

  /* Light theme heading colors */
  --heading-h1-color: #1a73e8;
  --heading-h2-color: #004886;
  --heading-h3-color: #003467;
}

[data-md-color-scheme="slate"] {
  --heading-h1-color: #00e6ea;
  --heading-h2-color: #008bcc;
  --heading-h3-color: #80deea;
}

/* ==========================================================================
   2. Theme Colors
   ========================================================================== */

/* Light theme - black text */
[data-md-color-scheme="default"] {
  --md-default-fg-color: #000000;
}

[data-md-color-scheme="default"] .md-typeset a:not(.md-nav__link):not(.md-header__button):not(.md-logo) {
  color: #0066cc;
}

[data-md-color-scheme="default"] .md-typeset code:not(pre code) {
  color: #c41e3a;
  background-color: rgba(0, 0, 0, 0.05);
}

/* Dark theme - white text */
[data-md-color-scheme="slate"] {
  --md-default-fg-color: #ffffff;
}

[data-md-color-scheme="slate"] .md-typeset a:not(.md-nav__link):not(.md-header__button):not(.md-logo) {
  color: #64b5f6;
}

[data-md-color-scheme="slate"] .md-typeset code:not(pre code) {
  color: #ff9800;
  background-color: rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   3. Layout
   ========================================================================== */

.md-main__inner,
.md-content {
  max-width: none;
}

.md-content__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

@media screen and (min-width: 76.25em) {
  .md-grid {
    max-width: none;
  }

  .md-main__inner {
    display: grid;
    grid-template-columns: var(--sidebar-width-primary) minmax(0, 1fr) var(--sidebar-width-secondary);
    gap: 1rem;
  }

  .md-sidebar--primary {
    width: var(--sidebar-width-primary);
  }

  .md-sidebar--secondary {
    width: var(--sidebar-width-secondary);
  }
}

/* ==========================================================================
   4. Sidebar
   ========================================================================== */

.md-sidebar {
  padding-top: 2.5rem;
  top: var(--header-height);
  transition: transform var(--transition-fast) ease,
    opacity var(--transition-fast) ease;
}

.md-sidebar--primary .md-nav__link,
.md-sidebar--secondary .md-nav__link {
  font-size: 0.68rem;
  line-height: 1.3;
  padding: 0.2rem 0.4rem;
}

.md-sidebar--primary .md-nav__item,
.md-sidebar--secondary .md-nav__item {
  padding: 0;
  margin: 0;
}

.md-sidebar--primary .md-nav__item--nested>.md-nav__link {
  font-weight: 600;
}

.md-nav--primary>.md-nav__title,
.md-nav--secondary .md-nav__title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--md-default-fg-color--light);
  padding: 0.6rem 0.6rem 0.4rem;
  border-bottom: 1px solid var(--md-default-fg-color--lightest);
  margin-bottom: 0.4rem;
}

/* Sidebar collapse */
.md-sidebar--secondary.sidebar-collapsed,
.md-sidebar--primary.sidebar-collapsed {
  transform: translateX(100%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.md-sidebar--primary.sidebar-collapsed {
  transform: translateX(-100%);
}

/* ==========================================================================
   5. Header & Footer
   ========================================================================== */

.md-header {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  height: var(--header-height);
  min-height: var(--header-height);
  z-index: 1000;
}

.md-header__inner {
  height: var(--header-height);
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

.md-header__topic {
  font-weight: 600;
  font-size: 1.05em;
  letter-spacing: 0.5px;
}

.md-header .md-tabs {
  background-color: rgb(51, 51, 51);
}

/* Hide palette toggle (using custom one) */
.md-header__option {
  display: none;
}

/* Hide MkDocs credit */
.md-footer-meta__inner.md-grid a[href="https://squidfunk.github.io/mkdocs-material/"] {
  display: none;
}

/* ==========================================================================
   6. Typography
   ========================================================================== */

.md-typeset {
  font-size: 0.9rem;
  line-height: 1.5;
}

.md-typeset p {
  font-size: 0.85rem;
  margin-bottom: 0.8em;
}

.md-typeset ul li,
.md-typeset ol li {
  font-size: 0.95rem;
  margin-bottom: 0.4em;
}

/* Headings */
h1,
.md-typeset h1 {
  color: var(--heading-h1-color);
  font-weight: 700;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  border-bottom: 3px solid var(--heading-h1-color);
  padding-bottom: 0.3em;
}

h2,
.md-typeset h2 {
  color: var(--heading-h2-color);
  font-weight: 700;
  margin-top: 1.2em;
  margin-bottom: 0.4em;
  border-bottom: 2px solid var(--heading-h2-color);
  padding-bottom: 0.2em;
}

h3,
.md-typeset h3 {
  color: var(--heading-h3-color);
  font-weight: 600;
  margin-top: 1em;
  margin-bottom: 0.3em;
}

h4,
.md-typeset h4 {
  font-weight: 600;
  margin-top: 0.8em;
  margin-bottom: 0.2em;
}

/* ==========================================================================
   7. Search
   ========================================================================== */

.md-search__form {
  display: flex;
  align-items: center;
  border-radius: var(--border-radius-medium);
}

.md-search__input {
  font-size: 0.8rem;
  padding: 0.4em 0.8em 0.4em 1em;
  border-radius: var(--border-radius-medium);
}

.md-search__input::placeholder {
  font-size: 0.8rem;
}

.md-search__icon {
  display: none;
}

[data-md-color-scheme="default"] .md-search__form {
  background-color: rgba(255, 255, 255, 0.95);
  border: 2px solid rgba(0, 0, 0, 0.3);
}

[data-md-color-scheme="default"] .md-search__input {
  color: #000000;
}

[data-md-color-scheme="default"] .md-search__input::placeholder {
  color: rgba(0, 0, 0, 0.6);
}

[data-md-color-scheme="slate"] .md-search__input {
  color: #ffffff;
  background-color: #2a2a2a;
  border: 1px solid #505050;
}

[data-md-color-scheme="slate"] .md-search__input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

/* ==========================================================================
   8. Code Blocks
   ========================================================================== */

.md-typeset pre {
  border-left: 4px solid var(--md-accent-fg-color);
  border-radius: var(--border-radius-large);
  padding: 1.2em;
  margin: 1.2em 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.md-typeset code {
  font-size: 0.7rem;
  padding: 0.2em 0.4em;
  border-radius: var(--border-radius-small);
}

.md-typeset pre code {
  font-size: 0.8rem;
  line-height: 1.5;
}

/* ==========================================================================
   9. Admonitions
   ========================================================================== */

.md-typeset .admonition {
  border-left: 5px solid;
  padding: 1.2em 1.5em;
  margin: 1.5em 0;
  border-radius: var(--border-radius-large);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.md-typeset .admonition.info {
  border-color: #1976d2;
}

.md-typeset .admonition.warning {
  border-color: #f57c00;
}

.md-typeset .admonition.important {
  border-color: #d32f2f;
}

/* ==========================================================================
   10. Tables
   ========================================================================== */

.md-typeset table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  border-radius: var(--border-radius-large);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.md-typeset th,
.md-typeset td {
  border: 1px solid var(--md-default-fg-color--lightest);
  padding: 1em 1.2em;
  text-align: left;
}

.md-typeset th {
  background: linear-gradient(135deg, var(--md-primary-fg-color), var(--md-accent-fg-color));
  color: white;
  font-weight: 700;
}

.md-typeset tbody tr:nth-child(even) {
  background-color: rgba(0, 0, 0, 0.02);
}

[data-md-color-scheme="slate"] .md-typeset tbody tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.03);
}

/* ==========================================================================
   11. Links
   ========================================================================== */

.md-typeset a {
  text-decoration: none;
  font-weight: 500;
}

.md-typeset a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   12. Mermaid Diagrams
   ========================================================================== */

.mermaid {
  background-color: transparent;
}

.mermaid .node rect,
.mermaid .node circle,
.mermaid .node polygon {
  fill: #e8f0fe;
  stroke: #1e88e5;
  stroke-width: 2px;
}

.mermaid .node text {
  fill: #0d47a1;
  font-weight: 600;
}

.mermaid .edgePath .path {
  stroke: #1565c0;
  stroke-width: 2px;
}

[data-md-color-scheme="slate"] .mermaid .node rect,
[data-md-color-scheme="slate"] .mermaid .node circle,
[data-md-color-scheme="slate"] .mermaid .node polygon {
  fill: #404854;
  stroke: #90caf9;
}

[data-md-color-scheme="slate"] .mermaid .node text {
  fill: #ffffff;
}

[data-md-color-scheme="slate"] .mermaid .edgePath .path {
  stroke: #90caf9;
}

/* ==========================================================================
   13. UI Components
   ========================================================================== */

/* Theme Toggle Button */
.custom-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border: none;
  border-radius: var(--border-radius-round);
  background: transparent;
  cursor: pointer;
  color: #ffffff;
  margin-left: 0.5rem;
}

.custom-theme-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.1);
}

.custom-theme-toggle svg {
  width: 1.4rem;
  height: 1.4rem;
  fill: #ffffff;
}

/* TQuantLab Button (Moved to Sidebar) */
.md-sidebar--primary .md-header__shop-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.6rem;
  margin: 1rem 0.6rem 0.8rem;
  background: linear-gradient(135deg, #00d4aa 0%, #00b894 50%, #00cec9 100%);
  border: none;
  border-radius: 20px;
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 212, 170, 0.2);
  transition: transform var(--transition-fast) ease;
  z-index: 10;
}

.md-sidebar--primary .md-header__shop-btn:hover {
  transform: translateY(-4px) scale(1.03);
  color: white;
  box-shadow: 0 6px 15px rgba(0, 212, 170, 0.4);
}

[data-md-color-scheme="slate"] .md-sidebar--primary .md-header__shop-btn:hover {
  box-shadow: 0 6px 15px rgba(118, 75, 162, 0.5);
}

.md-sidebar--primary .md-header__shop-btn svg {
  width: 0.9rem;
  height: 0.9rem;
  fill: currentColor;
}

[data-md-color-scheme="slate"] .md-sidebar--primary .md-header__shop-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  box-shadow: 0 2px 8px rgba(118, 75, 162, 0.3);
}

/* Sidebar Toggle Buttons */
.md-sidebar-toggle-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 0;
  pointer-events: none;
  z-index: 999;
}

.md-sidebar-toggle {
  position: fixed;
  top: 5rem;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0.5rem;
  background: rgba(103, 58, 183, 0.25);
  border: 1px solid rgba(156, 39, 176, 0.3);
  border-radius: var(--border-radius-round);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  box-shadow: 0 2px 12px rgba(156, 39, 176, 0.2);
  color: white;
  opacity: 0.5;
  backdrop-filter: blur(8px);
}

.md-sidebar-toggle:hover {
  opacity: 0.9;
  transform: scale(1.1);
}

.md-sidebar-toggle svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: currentColor;
}

.md-sidebar-toggle--secondary {
  right: 0.75rem;
}

.md-sidebar-toggle--primary {
  left: 0.75rem;
}

.md-sidebar-toggle--secondary.collapsed svg,
.md-sidebar-toggle--primary.collapsed svg {
  transform: rotate(180deg);
}

[data-md-color-scheme="slate"] .md-sidebar-toggle {
  background: rgba(102, 126, 234, 0.25);
  border-color: rgba(118, 75, 162, 0.3);
}

@media screen and (max-width: 76.1875em) {
  .md-sidebar-toggle--primary {
    display: none;
  }
}

@media screen and (max-width: 60em) {
  .md-sidebar-toggle--secondary {
    display: none;
  }
}

/* ==========================================================================
   14. Utilities
   ========================================================================== */

.md-typeset hr {
  border: none;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--md-primary-fg-color), transparent);
  margin: 2.5em 0;
}

.md-typeset .arithmatex {
  overflow-x: auto;
  padding: 1em;
  border-radius: 8px;
  margin: 1em 0;
}

.MathJax {
  font-size: 1.1em;
}