/* Modern Typography & Spacing Enhancements */

/* ===== SMOOTH SCROLLING ===== */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

/* ===== IMPROVED TYPOGRAPHY SCALE ===== */
h1 { font-size: clamp(1.75rem, 5vw, 2.5rem); font-weight: 700; line-height: 1.2; letter-spacing: -0.5px; margin: 0.5em 0 0.3em 0; }
h2 { font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 600; line-height: 1.3; letter-spacing: -0.3px; margin: 1em 0 0.5em 0; }
h3 { font-size: clamp(1.2rem, 3vw, 1.5rem); font-weight: 600; line-height: 1.3; letter-spacing: -0.2px; margin: 0.8em 0 0.3em 0; }
h4, h5, h6 { font-size: 1.1rem; font-weight: 600; line-height: 1.4; letter-spacing: -0.1px; margin: 0.6em 0 0.2em 0; }

/* ===== IMPROVED PARAGRAPH SPACING ===== */
p { margin: 0.8em 0; line-height: 1.7; letter-spacing: 0.3px; }

/* ===== IMPROVED LIST SPACING ===== */
ul, ol { 
  margin: 1em 0;
  padding-left: 2em;
  line-height: 1.8;
}
li { margin: 0.4em 0; }
li p { margin: 0.4em 0; }

/* ===== IMPROVED CODE STYLING ===== */
code {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Courier New', monospace;
  font-size: 0.9em;
  letter-spacing: 0;
  background-color: rgba(0, 0, 0, 0.05);
  padding: 0.25em 0.5em;
  border-radius: 4px;
  transition: background-color 240ms ease, color 240ms ease;
}

code:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

pre {
  margin: 1.5em 0;
  padding: 1.25em;
  border-radius: 8px;
  line-height: 1.5;
  overflow-x: auto;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: box-shadow 240ms ease, border-color 240ms ease;
}

pre:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

pre code {
  font-size: 0.9em;
  line-height: 1.5;
  background-color: transparent;
  padding: 0;
}

/* ===== IMPROVED BLOCKQUOTE STYLING ===== */
blockquote {
  margin: 1.5em 0;
  padding: 1em 1.5em;
  border-left: 4px solid;
  line-height: 1.7;
  border-radius: 4px;
  transition: box-shadow 240ms ease, transform 240ms ease;
}

blockquote:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transform: translateX(2px);
}

/* ===== IMPROVED TABLE STYLING ===== */
table {
  margin: 1.5em 0;
  border-collapse: collapse;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

th, td {
  padding: 0.75em 1em;
  text-align: left;
  transition: background-color 240ms ease;
}

th {
  font-weight: 600;
  background-color: rgba(0, 0, 0, 0.02);
}

tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

/* ===== IMPROVED LINK STYLING ===== */
a {
  text-decoration: none;
  transition: color 240ms ease, text-decoration 240ms ease;
  position: relative;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 2px;
}

a:focus {
  outline: 2px solid;
  outline-offset: 2px;
}

/* TOC Link Styling */
.toc a, .sidetoc a {
  display: block;
  padding: 0.6em 0.8em;
  border-radius: 6px;
  transition: background-color 240ms ease, transform 240ms ease;
}

.toc a:hover, .sidetoc a:hover {
  background-color: rgba(0, 0, 0, 0.05);
  text-decoration: none;
  transform: translateX(4px);
}

.toc > li.active > a, 
.sidetoc > li.active > a,
.toc .nav > li.active > a,
.sidetoc .nav > li.active > a {
  font-weight: 600;
  background-color: rgba(53, 62, 161, 0.1);
  border-left: 3px solid;
  padding-left: calc(0.8em - 3px);
  transition: background-color 240ms ease, border-color 240ms ease;
}

/* ===== IMPROVED BUTTON STYLING ===== */
button, .btn {
  padding: 0.6em 1.2em;
  margin: 0.4em 0;
  font-weight: 500;
  border-radius: 6px;
  transition: transform 240ms ease, box-shadow 240ms ease, background-color 240ms ease;
  letter-spacing: 0.2px;
  cursor: pointer;
  border: 1px solid transparent;
}

button:hover, .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

button:active, .btn:active {
  transform: translateY(0);
}

button:focus, .btn:focus {
  outline: 2px solid;
  outline-offset: 2px;
}

/* ===== IMPROVED FORM STYLING ===== */
input, textarea, select {
  padding: 0.6em 0.8em;
  margin: 0.4em 0;
  border-radius: 6px;
  font-family: inherit;
  font-size: 1em;
  line-height: 1.5;
  border: 1px solid rgba(0, 0, 0, 0.1);
  transition: border-color 240ms ease, box-shadow 240ms ease;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: rgba(53, 62, 161, 0.5);
  box-shadow: 0 0 0 3px rgba(53, 62, 161, 0.1);
}

input:hover, textarea:hover, select:hover {
  border-color: rgba(0, 0, 0, 0.2);
}

/* ===== IMPROVED CONTAINER SPACING ===== */
.container {
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ===== HIDE SIDEBAR AFFIX SECTION ===== */
.sideaffix,
nav.bs-docs-sidebar,
#affix {
  display: none !important;
}

/* ===== HIDE FOOTER ===== */
footer,
.footer {
  display: none !important;
}

/* ===== SIDEBAR & AFFIX OVERFLOW FIX ===== */
.sideaffix {
  max-width: 280px;
  width: 100%;
  word-wrap: break-word;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
}

.level1.nav.bs-docs-sidenav,
.affix ul {
  overflow-x: hidden !important;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.level1.nav.bs-docs-sidenav li,
.affix ul li {
  overflow-x: hidden !important;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.affix ul > li > a,
.affix ul ul > li > a {
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  padding-right: 8px;
  display: block;
  overflow: visible !important;
  text-overflow: clip;
  max-width: 100%;
  box-sizing: border-box;
}

.affix ul > li > a {
  display: block;
  overflow: visible !important;
  width: 100%;
}

.affix h5 {
  padding-right: 8px;
  word-wrap: break-word;
  white-space: normal;
  overflow-x: hidden;
}

/* Text wrapping for nested lists in TOC */
.affix ul {
  word-wrap: break-word;
  overflow-x: hidden !important;
}

.affix ul ul > li > a:before {
  display: inline;
}

/* Prevent long text from breaking layout */
.affix ul > li > a,
.affix ul ul > li > a {
  max-width: 100%;
  min-width: 0;
  width: 100%;
}

@media (min-width: 600px) {
  .container {
    padding: 0 2rem;
  }
}

/* Hide theme toggle on narrow screens to prevent navbar wrapping */
@media (max-width: 599px) {
  .theme-toggle {
    display: none;
  }
}

/* ===== IMPROVED SECTION SPACING ===== */
section {
  margin: 2em 0;
  padding: 1.5em 0;
}

/* ===== IMPROVED ARTICLE SPACING ===== */
article {
  margin: 2em 0;
}

/* ===== IMPROVED HEADER/FOOTER SPACING ===== */
footer {
  padding: 2em 0;
  margin-top: 2em;
}

/* ===== IMPROVED NAVIGATION SPACING ===== */
nav:not(.navbar) {
  margin: 0.5em 0;
}

nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  gap: 1.5em;
}

nav li {
  margin: 0;
}

nav a {
  padding: 0.5em 1em;
  border-radius: 6px;
  transition: background-color 240ms ease;
}

nav a:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

/* Ensure navbar elements have no extra margins */
.navbar, .navbar-inverse, .navbar-default,
.navbar-header, .navbar-collapse,
.navbar-brand, .autocollapse {
  margin: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

/* ===== IMPROVED CARD/PANEL STYLING ===== */
.card, .panel {
  padding: 1.5em;
  margin: 1em 0;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  transition: box-shadow 240ms ease, transform 240ms ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.card:hover, .panel:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

/* ===== IMPROVED BREADCRUMB STYLING ===== */
.breadcrumb, #breadcrumb {
  padding: 0.75em 1em;
  border-radius: 6px;
  margin: 0.5em 0;
  transition: background-color 240ms ease;
}

.breadcrumb a {
  padding: 0 0.25em;
  border-radius: 3px;
  transition: background-color 240ms ease;
}

.breadcrumb a:hover {
  background-color: rgba(0, 0, 0, 0.05);
  text-decoration: none;
}

/* Selective transitions for better performance */
a, button, .btn, input, textarea, select, .breadcrumb a, nav a, .toc a, .sidetoc a {
  transition: background-color 240ms ease, color 240ms ease, border-color 240ms ease, box-shadow 240ms ease, transform 240ms ease;
}

/* ===== IMPROVED FOCUS STATES FOR ACCESSIBILITY ===== */
a:focus, button:focus, input:focus, textarea:focus, select:focus {
  outline: 2px solid;
  outline-offset: 2px;
}

/* ===== BETTER RESPONSIVE SIZING ===== */
img, video {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  transition: box-shadow 240ms ease;
}

img:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ===== IMPROVED HEADING MARGINS ===== */
h1:first-child, h2:first-child, h3:first-child {
  margin-top: 0;
}

h1 + p, h2 + p, h3 + p {
  margin-top: 0.8em;
}

/* ===== SMOOTH THEME TRANSITION ===== */
body {
  transition: background-color 300ms ease, color 300ms ease;
}

body.dark-theme {
  transition: background-color 300ms ease, color 300ms ease;
}

/* ===== IMPROVED ALERT STYLING ===== */
.alert {
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  transition: box-shadow 240ms ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.alert:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ===== IMPROVED SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 5px;
  transition: background 240ms ease;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.4);
}

/* ===== LOADING STATE ANIMATION ===== */
@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

.loading {
  animation: shimmer 2s infinite;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.05) 0%, rgba(0, 0, 0, 0.1) 50%, rgba(0, 0, 0, 0.05) 100%);
  background-size: 1000px 100%;
}




/* ===== MODERN DARK MODE TOGGLE BUTTON ===== */
.theme-toggle {
  border: none;
  background: none;
  padding: 4px 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  transition: transform 240ms ease, filter 240ms ease;
  margin-left: 10px;
  border-radius: 6px;
  opacity: 0.8;
}

.theme-toggle:hover {
  transform: scale(1.1);
  opacity: 1;
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-toggle .theme-icon {
  display: inline-block;
  transition: transform 240ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-toggle:active .theme-icon {
  transform: rotate(180deg);
}

/* Dark mode text tweaks for better contrast */
body.dark-theme .theme-toggle {
  filter: brightness(1.2);
}

body.light-theme .theme-toggle {
  filter: brightness(0.8);
}
