/* ==========================================================================
   MCB Look-and-Feel Overrides for docPort Theme
   Matches mcb.senseaition.rocks exactly
   ========================================================================== */

/* --- Base (identical to MCB styles.css) --- */
html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Smooth Hover Transitions (identical to MCB) */
a, button {
  transition: all 0.2s ease-in-out;
}

/* Container (identical to MCB) */
.container {
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
}

/* Screen Reader Only (identical to MCB) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.sr-only:focus {
  position: static;
  width: auto;
  height: auto;
  padding: 0.5rem 1rem;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* Details/Summary (identical to MCB) */
details[open] summary {
  color: #2563EB;
}

details summary {
  outline: none;
  list-style: none;
}

details summary::-webkit-details-marker {
  display: none;
}

/* --- Override docPort legacy colors --- */
/* Force all links in content to primary blue */
.content a,
.content a:visited,
main a,
main a:visited {
  color: #2563EB !important;
  text-decoration: none;
}

.content a:hover,
main a:hover {
  color: #1D4ED8 !important;
  text-decoration: underline;
}

/* Active subpage tabs: white text on blue background */
main nav a.bg-primary,
main nav a.bg-primary:visited,
main nav a.bg-primary:hover {
  color: #FFFFFF !important;
  text-decoration: none !important;
}

/* Override inline font colors from legacy content */
.content font[color],
.content span[style*="color"] {
  color: inherit !important;
}

/* Override docPort's default link purple */
a {
  color: #2563EB;
}

a:hover {
  color: #1D4ED8;
}

/* --- Sidebar Menu Styling --- */
aside#sidebar .menu {
  list-style: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

aside#sidebar .menu li {
  margin: 0 !important;
  padding: 0 !important;
  list-style: none !important;
}

/* Items with children: flexbox so arrow + link sit on same line */
aside#sidebar .menu li.haschildren {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
}

/* Submenu takes full row below arrow+link */
aside#sidebar .menu li.haschildren > ul {
  width: 100%;
}

aside#sidebar .menu li > a {
  display: block;
  padding: 0.4rem 0.75rem;
  font-size: 0.875rem;
  color: #4B5563 !important;
  text-decoration: none !important;
  border-radius: 0.5rem;
  transition: all 0.15s ease;
  line-height: 1.5;
  flex: 1;
  min-width: 0;
}

aside#sidebar .menu li > a:hover {
  color: #2563EB !important;
  background-color: #EFF6FF;
  text-decoration: none !important;
}

aside#sidebar .menu li.active > a,
aside#sidebar .menu li.visited > a {
  color: #2563EB !important;
  background-color: #EFF6FF;
  font-weight: 600;
}

aside#sidebar .menu li.parent > a {
  color: #1F2937 !important;
  font-weight: 600;
}

/* Nested submenu indentation */
aside#sidebar .menu li ul {
  list-style: none !important;
  padding-left: 0.75rem !important;
  margin: 0 !important;
  margin-left: 0.75rem !important;
  border-left: 1px solid #E5E7EB;
}

/* --- Expand/Collapse arrows (CSS-only, no Font Awesome needed) --- */
/* Hide the Font Awesome text content since FA is not loaded */
aside#sidebar .menu .ddexp {
  font-size: 0 !important;
  width: 20px;
  height: 20px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #9CA3AF;
  transition: all 0.2s ease;
  vertical-align: middle;
  border-radius: 0.25rem;
  position: relative;
  flex-shrink: 0;
  order: -1; /* Always show arrow before the link text */
  margin-right: 2px;
}

aside#sidebar .menu .ddexp:hover {
  color: #2563EB;
  background-color: #EFF6FF;
}

/* CSS triangle arrow - points right (collapsed) */
aside#sidebar .menu .ddexp::after {
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 6px;
  border-color: transparent transparent transparent currentColor;
  transition: transform 0.2s ease;
}

/* CSS triangle arrow - points down (expanded) */
aside#sidebar .menu .ddexp.fa-chevron-down::after {
  transform: rotate(90deg);
}

/* --- Sidebar submenu collapse/expand --- */
/* Hide all submenus by default */
aside#sidebar .menu .dd-item > ul {
  display: none !important;
}

/* Show submenus for active path and always-open items */
aside#sidebar .menu .dd-item.parent > ul,
aside#sidebar .menu .dd-item.active > ul,
aside#sidebar .menu .dd-item.alwaysopen > ul {
  display: block !important;
}

/* Top-level items: slightly larger, bolder */
aside#sidebar .menu > .dd-item > a {
  font-weight: 600;
  font-size: 0.875rem;
  color: #1F2937 !important;
  padding-top: 0.625rem;
  padding-bottom: 0.625rem;
}

/* Top-level item spacing */
aside#sidebar .menu > .dd-item {
  margin-top: 0.5rem !important;
}

aside#sidebar .menu > .dd-item:first-child {
  margin-top: 0 !important;
}

/* --- TOC Styling --- */
.toc-content nav,
.toc-content #TableOfContents {
  font-size: 0.8125rem;
}

.toc-content ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.toc-content li {
  margin: 0;
}

.toc-content a {
  display: block;
  padding: 0.25rem 0.75rem;
  color: #6B7280 !important;
  text-decoration: none !important;
  border-left: 2px solid transparent;
  transition: all 0.15s ease;
}

.toc-content a:hover {
  color: #2563EB !important;
  border-left-color: #2563EB;
}

.toc-content ul ul {
  padding-left: 0.75rem;
}

.toc-content ul ul a {
  font-size: 0.75rem;
}

/* --- Shortcode Overrides --- */

/* Notice boxes */
.notices {
  border-radius: 0.75rem !important;
  border-width: 1px !important;
  padding: 1rem 1.25rem !important;
  margin: 1.5rem 0 !important;
}

.notices.note {
  background-color: #EFF6FF !important;
  border-color: #BFDBFE !important;
}

.notices.info {
  background-color: #F0FDF4 !important;
  border-color: #BBF7D0 !important;
}

.notices.warning {
  background-color: #FFFBEB !important;
  border-color: #FDE68A !important;
}

.notices.tip {
  background-color: #F0F9FF !important;
  border-color: #BAE6FD !important;
}

/* Panel/Card shortcode */
.sc-panel {
  border-radius: 0.75rem !important;
  border: 1px solid #E5E7EB !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important;
  overflow: hidden;
  margin: 1.5rem 0 !important;
}

.sc-panel .panel-heading {
  background-color: #F9FAFB !important;
  border-bottom: 1px solid #E5E7EB !important;
  padding: 0.75rem 1rem !important;
  font-weight: 600 !important;
  color: #111827 !important;
}

/* Tab shortcode */
.tabs-wrapper .tab {
  border-radius: 0.5rem 0.5rem 0 0 !important;
  font-weight: 500 !important;
  transition: all 0.15s ease !important;
}

.tabs-wrapper .tab.active {
  color: #2563EB !important;
  border-bottom-color: #2563EB !important;
}

/* Alert shortcode */
.alert {
  border-radius: 0.75rem !important;
  border-width: 1px !important;
}

/* Expand shortcode */
details.expand {
  border: 1px solid #E5E7EB;
  border-radius: 0.75rem;
  margin-bottom: 1rem;
}

details.expand summary {
  padding: 0.75rem 1rem;
  font-weight: 500;
  cursor: pointer;
  color: #374151;
}

details.expand summary:hover {
  color: #2563EB;
}

/* --- Table Styling --- */
.content table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #E5E7EB;
  border-radius: 0.5rem;
  overflow: hidden;
  margin: 1.5rem 0;
}

.content table th {
  background-color: #F9FAFB;
  font-weight: 600;
  color: #111827;
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid #E5E7EB;
}

.content table td {
  padding: 0.75rem 1rem;
  border-top: 1px solid #F3F4F6;
  color: #4B5563;
}

.content table tr:nth-child(even) {
  background-color: #F9FAFB;
}

.content table tr:hover {
  background-color: #F3F4F6;
}

/* --- Code Blocks --- */
.content pre {
  border-radius: 0.75rem !important;
  border: 1px solid #374151;
}

.content code {
  font-size: 0.875em;
}

/* --- Image Styling (MCB-style) --- */
.content img {
  border-radius: 0.75rem;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
}

/* --- Blockquote Styling (MCB-style card) --- */
.content blockquote {
  border-left: 4px solid #2563EB !important;
  background-color: rgba(239, 246, 255, 0.5);
  border-radius: 0 0.75rem 0.75rem 0;
  padding: 1rem 1.25rem !important;
  margin: 1.5rem 0;
}

.content blockquote p {
  color: #374151 !important;
}

/* --- Scrollbar (identical to MCB) --- */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #2563EB;
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: #1e40af;
}

/* --- Accessibility (identical to MCB) --- */
*:focus-visible {
  outline: 2px solid #2563EB;
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- Print Styles (identical to MCB) --- */
@media print {
  aside#sidebar,
  header,
  footer,
  .jump-to-section,
  .chevrons,
  .TableOfContents,
  .Actions,
  #sidebar-overlay {
    display: none !important;
  }

  main {
    max-width: 100% !important;
    padding: 0 !important;
  }

  .no-print {
    display: none !important;
  }

  body {
    background: white;
  }

  a[href]:after {
    content: " (" attr(href) ")";
  }
}

/* --- Override docPort layout/legacy styles --- */

/* Kill docPort's header styles: border-bottom, box-shadow, background-color */
body header {
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  border-bottom: 1px solid #E5E7EB !important;
  box-shadow: none !important;
  background-color: rgba(255, 255, 255, 0.95) !important;
}

body header nav {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

body header a,
body header a:hover {
  color: inherit !important;
}

/* Kill any conflicting docPort header styles */
#header,
.dp-header,
body > .dp-header {
  display: none !important;
}

/* Kill docPort's sidebar styles that conflict */
#sidebar-main,
.sidebar-container,
.sidebar-toggle-container {
  all: unset;
}

/* Override docPort body text */
#body-inner,
.body-inner {
  font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
  color: #111827;
}

/* --- Card hover effect (identical to MCB) --- */
.card-hover {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card-hover:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* --- Gradient text (identical to MCB) --- */
.gradient-text {
  background: linear-gradient(135deg, #2563EB 0%, #F97316 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* --- Badge Preview Animation (identical to MCB) --- */
@keyframes badgePulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.7);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(37, 99, 235, 0);
  }
}

.badge-preview {
  animation: badgePulse 2s infinite;
}

/* --- Loading Animation for Images (identical to MCB) --- */
img {
  animation: imageLoad 0.3s ease-in-out;
}

@keyframes imageLoad {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- Mobile Menu Animation (identical to MCB) --- */
#mobile-menu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-in-out;
}

#mobile-menu.show {
  max-height: 500px;
}

/* --- Aspect Ratio for Videos (identical to MCB) --- */
.aspect-video {
  aspect-ratio: 16 / 9;
}

/* --- Text Balance for Headlines (identical to MCB) --- */
.text-balance {
  text-wrap: balance;
}

/* --- Backdrop Blur Support (identical to MCB) --- */
.backdrop-blur-fallback {
  background-color: rgba(255, 255, 255, 0.95);
}

@supports (backdrop-filter: blur(10px)) {
  .backdrop-blur-fallback {
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
  }
}

/* --- Reduced motion (identical to MCB) --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- High Contrast Mode (identical to MCB) --- */
@media (prefers-contrast: high) {
  * {
    border-color: currentColor !important;
  }
}

/* ==========================================================================
   Responsive: 800px Breakpoint for Sidebar Navigation
   ========================================================================== */

/* --- Mobile: below 800px — sidebar off-canvas, toggle button visible --- */
@media (max-width: 799px) {
  /* Sidebar toggle button: visible */
  .sidebar-toggle-btn {
    display: flex !important;
  }

  /* Sidebar: fixed off-canvas (default hidden via -translate-x-full) */
  .sidebar-nav {
    position: fixed !important;
  }

  /* Sidebar overlay: controlled by JS (hidden class toggled) */
  .sidebar-overlay {
    /* JS toggles 'hidden' class */
  }
}

/* --- Desktop: 800px and above — sidebar sticky, toggle button hidden --- */
@media (min-width: 800px) {
  /* Sidebar toggle button: hidden */
  .sidebar-toggle-btn {
    display: none !important;
  }

  /* Sidebar: sticky, visible, not translated */
  .sidebar-nav {
    position: sticky !important;
    transform: translateX(0) !important;
  }

  /* Sidebar overlay: always hidden on desktop */
  .sidebar-overlay {
    display: none !important;
  }
}
