/* BeDefended Docs — Custom theme matching dashboard cyber aesthetic */

/* === Google Fonts === */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* === CSS Variables — Dark mode overrides === */
[data-md-color-scheme="slate"] {
  /* Primary palette — dashboard purple */
  --md-primary-fg-color: #9b30ff;
  --md-primary-fg-color--light: #b366ff;
  --md-primary-fg-color--dark: #7a1fcc;
  --md-primary-bg-color: #e8e6f0;

  /* Accent — dashboard cyan */
  --md-accent-fg-color: #00e5ff;
  --md-accent-fg-color--transparent: rgba(0, 229, 255, 0.1);
  --md-accent-bg-color: #0a0a0f;

  /* Background — near-black like dashboard */
  --md-default-bg-color: #0d0d14;
  --md-default-bg-color--light: #13131c;
  --md-default-bg-color--lighter: #1a1a26;
  --md-default-bg-color--lightest: #22222f;

  /* Code blocks */
  --md-code-bg-color: #0a0a12;
  --md-code-fg-color: #e0dff0;
  --md-code-hl-color: rgba(155, 48, 255, 0.15);

  /* Typography */
  --md-text-font: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --md-code-font: "IBM Plex Mono", "JetBrains Mono", "Fira Code", monospace;

  /* Footer */
  --md-footer-bg-color: #08080d;
  --md-footer-bg-color--dark: #050508;

  /* Typeset */
  --md-typeset-color: #c8c6d8;
  --md-typeset-a-color: #b366ff;

  /* Admonitions */
  --md-admonition-bg-color: rgba(22, 22, 31, 0.9);
}

/* === Light mode — clean professional look === */
[data-md-color-scheme="default"] {
  --md-primary-fg-color: #7c22d4;
  --md-primary-fg-color--light: #9b30ff;
  --md-primary-fg-color--dark: #5a18a0;
  --md-accent-fg-color: #00b8d4;
  --md-text-font: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --md-code-font: "IBM Plex Mono", "JetBrains Mono", "Fira Code", monospace;
}

/* === Header === */
.md-header {
  background: linear-gradient(135deg, #0a0a14 0%, #12101f 50%, #0a0a14 100%);
  border-bottom: 1px solid rgba(155, 48, 255, 0.2);
  box-shadow: 0 2px 20px rgba(155, 48, 255, 0.08);
}

[data-md-color-scheme="slate"] .md-header {
  background: linear-gradient(135deg, #0a0a14 0%, #12101f 50%, #0a0a14 100%);
}

/* === Navigation tabs — glow on active === */
.md-tabs {
  background: #08080d;
  border-bottom: 1px solid rgba(155, 48, 255, 0.1);
}

.md-tabs__link--active {
  color: #b366ff !important;
  border-bottom: 2px solid #9b30ff;
}

/* === Sidebar === */
[data-md-color-scheme="slate"] .md-sidebar {
  background: #0a0a12;
}

[data-md-color-scheme="slate"] .md-nav__link:hover {
  color: #00e5ff;
}

[data-md-color-scheme="slate"] .md-nav__link--active {
  color: #b366ff;
  font-weight: 600;
}

/* === Content area === */
.md-typeset h1 {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #e8e6f0;
}

[data-md-color-scheme="slate"] .md-typeset h1 {
  background: linear-gradient(135deg, #e8e6f0 0%, #b366ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-md-color-scheme="slate"] .md-typeset h2 {
  color: #d4d0e8;
  border-bottom: 1px solid rgba(155, 48, 255, 0.15);
  padding-bottom: 0.3em;
}

[data-md-color-scheme="slate"] .md-typeset h3 {
  color: #c0bcd4;
}

/* === Links — cyan accent like dashboard === */
[data-md-color-scheme="slate"] .md-typeset a {
  color: #b366ff;
  transition: color 0.2s ease, text-shadow 0.2s ease;
}

[data-md-color-scheme="slate"] .md-typeset a:hover {
  color: #00e5ff;
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.3);
}

/* === Code blocks — dark with purple border === */
[data-md-color-scheme="slate"] .md-typeset code {
  background: rgba(155, 48, 255, 0.08);
  color: #d4b8ff;
  border: 1px solid rgba(155, 48, 255, 0.15);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  font-size: 0.85em;
}

[data-md-color-scheme="slate"] .md-typeset pre {
  background: #08080d;
  border: 1px solid rgba(155, 48, 255, 0.12);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

[data-md-color-scheme="slate"] .md-typeset pre > code {
  background: transparent;
  border: none;
  color: #e0dff0;
  padding: 0;
}

/* === Tables — dashboard style === */
[data-md-color-scheme="slate"] .md-typeset table:not([class]) {
  border: 1px solid rgba(155, 48, 255, 0.12);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

[data-md-color-scheme="slate"] .md-typeset table:not([class]) th {
  background: rgba(155, 48, 255, 0.1);
  color: #d4b8ff;
  font-weight: 600;
  border-bottom: 1px solid rgba(155, 48, 255, 0.2);
  text-transform: uppercase;
  font-size: 0.75em;
  letter-spacing: 0.05em;
}

[data-md-color-scheme="slate"] .md-typeset table:not([class]) td {
  border-bottom: 1px solid rgba(42, 40, 53, 0.6);
}

[data-md-color-scheme="slate"] .md-typeset table:not([class]) tr:hover td {
  background: rgba(155, 48, 255, 0.04);
}

/* === Admonitions — glassmorphism === */
[data-md-color-scheme="slate"] .md-typeset .admonition,
[data-md-color-scheme="slate"] .md-typeset details {
  background: rgba(16, 16, 24, 0.9);
  border-left: 3px solid;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(8px);
}

[data-md-color-scheme="slate"] .md-typeset .admonition-title,
[data-md-color-scheme="slate"] .md-typeset summary {
  background: rgba(155, 48, 255, 0.06);
  font-weight: 600;
}

/* === Search bar === */
[data-md-color-scheme="slate"] .md-search__input {
  background: #0f0f18;
  border: 1px solid rgba(155, 48, 255, 0.15);
  color: #e8e6f0;
}

[data-md-color-scheme="slate"] .md-search__input:focus {
  border-color: #9b30ff;
  box-shadow: 0 0 12px rgba(155, 48, 255, 0.2);
}

/* === Scrollbar — dashboard style === */
[data-md-color-scheme="slate"] ::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

[data-md-color-scheme="slate"] ::-webkit-scrollbar-track {
  background: #0a0a12;
}

[data-md-color-scheme="slate"] ::-webkit-scrollbar-thumb {
  background: rgba(155, 48, 255, 0.3);
  border-radius: 4px;
}

[data-md-color-scheme="slate"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(155, 48, 255, 0.6);
  box-shadow: 0 0 6px rgba(155, 48, 255, 0.3);
}

/* === Footer === */
[data-md-color-scheme="slate"] .md-footer {
  background: #08080d;
  border-top: 1px solid rgba(155, 48, 255, 0.1);
}

/* === Selection highlight === */
[data-md-color-scheme="slate"] ::selection {
  background: rgba(155, 48, 255, 0.3);
  color: #fff;
}

/* === Mermaid diagrams — full-width, high resolution === */
[data-md-color-scheme="slate"] .mermaid,
[data-md-color-scheme="default"] .mermaid {
  background: transparent !important;
  width: 100% !important;
  max-width: none !important;
  display: block !important;
  margin: 2em 0 !important;
  overflow-x: auto !important;
  overflow-y: visible !important;
}

/* Mermaid SVG container — scale to full width, let height be determined by diagram type */
.mermaid svg {
  width: 100% !important;
  max-width: 100% !important;
  display: block !important;
  margin: 0 !important;
}

/* Gantt chart — larger viewport */
[data-md-color-scheme="slate"] svg[id*="gantt"],
[data-md-color-scheme="default"] svg[id*="gantt"] {
  height: 500px !important;
  min-height: 500px !important;
  width: 100% !important;
}

/* Flowchart/Graph — larger viewport */
[data-md-color-scheme="slate"] svg[id*="graph"],
[data-md-color-scheme="default"] svg[id*="graph"],
[data-md-color-scheme="slate"] svg[id*="flowchart"],
[data-md-color-scheme="default"] svg[id*="flowchart"] {
  min-height: 400px !important;
  width: 100% !important;
}

/* Sequence diagram — larger viewport */
[data-md-color-scheme="slate"] svg[id*="sequence"],
[data-md-color-scheme="default"] svg[id*="sequence"] {
  min-height: 400px !important;
  width: 100% !important;
}

/* Mermaid text — readable size */
.mermaid text,
svg text {
  font-family: "IBM Plex Sans", -apple-system, sans-serif !important;
  font-size: 14px !important;
}

/* Mermaid rectangles/shapes — better visibility */
.mermaid rect,
.mermaid circle,
.mermaid polygon {
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4)) !important;
}

/* Mermaid edges — thicker for readability */
.mermaid line,
.mermaid path,
.mermaid .edge {
  stroke-width: 2px !important;
}

/* Gantt title text visibility */
.mermaid text tspan {
  font-size: 14px !important;
}

/* Ensure scroll on mobile if needed */
@media (max-width: 768px) {
  .mermaid svg {
    min-width: 100% !important;
  }
}

/* === Download page — button styling === */
[data-md-color-scheme="slate"] .md-typeset .md-button--primary {
  background: linear-gradient(135deg, #9b30ff 0%, #7a1fcc 100%);
  color: #ffffff !important;
  border: 1px solid rgba(155, 48, 255, 0.4);
  border-radius: 8px;
  padding: 0.7em 1.6em;
  font-weight: 700;
  font-size: 0.85rem;
  text-decoration: none !important;
  transition: all 0.2s ease;
  box-shadow: 0 2px 12px rgba(155, 48, 255, 0.25);
  display: inline-block;
  margin: 0.3em 0.5em 0.3em 0;
}

[data-md-color-scheme="slate"] .md-typeset .md-button--primary:hover {
  background: linear-gradient(135deg, #b366ff 0%, #9b30ff 100%);
  box-shadow: 0 4px 20px rgba(155, 48, 255, 0.4);
  transform: translateY(-1px);
  color: #ffffff !important;
}

[data-md-color-scheme="slate"] .md-typeset .md-button:not(.md-button--primary) {
  color: #d4b8ff !important;
  border: 1px solid rgba(155, 48, 255, 0.3);
  border-radius: 8px;
  padding: 0.7em 1.6em;
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none !important;
  transition: all 0.2s ease;
  display: inline-block;
  margin: 0.3em 0.5em 0.3em 0;
}

[data-md-color-scheme="slate"] .md-typeset .md-button:not(.md-button--primary):hover {
  background: rgba(155, 48, 255, 0.15);
  border-color: #9b30ff;
  color: #ffffff !important;
}

/* Download table cells — ensure text readable */
[data-md-color-scheme="slate"] .md-typeset table:not([class]) td a {
  color: #b366ff !important;
  font-weight: 500;
}

[data-md-color-scheme="slate"] .md-typeset table:not([class]) td a:hover {
  color: #00e5ff !important;
}

/* === Header download button === */
.bd-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  padding: 5px 14px;
  background: linear-gradient(135deg, #9b30ff 0%, #7a1fcc 100%);
  color: #fff !important;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  text-decoration: none !important;
  white-space: nowrap;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(155, 48, 255, 0.3);
  letter-spacing: 0.02em;
}

.bd-download-btn:hover {
  background: linear-gradient(135deg, #b366ff 0%, #9b30ff 100%);
  box-shadow: 0 4px 16px rgba(155, 48, 255, 0.5);
  transform: translateY(-1px);
  color: #fff !important;
}

.bd-download-btn svg {
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .bd-download-btn span {
    display: none;
  }
  .bd-download-btn {
    padding: 5px 8px;
    margin-left: 8px;
  }
}

/* === Back to top button === */
[data-md-color-scheme="slate"] .md-top {
  background: rgba(155, 48, 255, 0.9);
  color: #fff;
  box-shadow: 0 2px 12px rgba(155, 48, 255, 0.3);
}

[data-md-color-scheme="slate"] .md-top:hover {
  background: #b366ff;
  box-shadow: 0 4px 20px rgba(155, 48, 255, 0.5);
}

/* === Score indicators — Latest Scores page === */
.score-high { color: #22c55e !important; }
.score-mid { color: #eab308 !important; }
.score-low { color: #ef4444 !important; }
.score-high-icon { color: #22c55e !important; }
.score-mid-icon { color: #eab308 !important; }
.score-low-icon { color: #ef4444 !important; }

/* === Wide Table Handling === */
/* Prevent tables from overflowing the content area */
.md-typeset table:not([class]) {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    font-size: 0.82rem;
}
.md-typeset table:not([class]) td,
.md-typeset table:not([class]) th {
    padding: 0.4em 0.6em;
    white-space: normal;
    min-width: 50px;
}
/* Keep ID columns compact */
.md-typeset table:not([class]) td:first-child {
    white-space: nowrap;
    font-family: var(--md-code-font-family);
    font-size: 0.8em;
}
