/* ══════════════════════════════════════════════════════════════════════
   SIDEBAR ENHANCEMENTS — TOC + Smart Scroll + Ad Cards
   Add this file AFTER style-consolidated.css
   ══════════════════════════════════════════════════════════════════════ */

/* ── Variables (mirrors existing theme) ─────────────────────────────── */
:root {
  --flame:      #e63d0a;
  --flame-soft: rgba(230,61,10,.08);
  --ink:        #111827;
  --muted:      #6b7280;
  --paper:      #ffffff;
  --line:       #e5e7eb;
  --smoke:      #f9fafb;
  --emerald:    #10b981;
  --nav-h:      68px;
  --fm:         'JetBrains Mono', monospace;
  --fb:         'DM Sans', sans-serif;
}
[data-theme="dark"] {
  --paper:  #13131f;
  --line:   #252535;
  --smoke:  #1a1a2e;
  --ink:    #f0ede8;
  --muted:  #8a8d97;
}

/* ════════════════════════════════════════════════════════
   1. TOC — UPGRADED VISHAY SUCHI STYLING
   ════════════════════════════════════════════════════════ */

#tocBox {
  position: relative;
  overflow: visible;
}

/* TOC header: bilingual label auto-changes via JS */
#tocBox .bp-scard-head {
  font-size: .52rem;
  letter-spacing: 3px;
  color: var(--muted);
}

.bp-toc-wrap {
  padding: 8px 6px 12px;
  max-height: 360px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

/* Step counter on each item */
.bp-toc-list {
  counter-reset: toc-counter;
}

.bp-toc-list > li {
  counter-increment: toc-counter;
}

.bp-toc-list a {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--fb);
  font-size: .78rem;
  color: var(--muted);
  padding: 6px 10px 6px 8px;
  border-radius: 7px;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all .18s ease;
  line-height: 1.4;
  position: relative;
}

/* H2 items get numbered counter */
.bp-toc-list > li > a::before {
  content: counter(toc-counter, decimal-leading-zero);
  font-family: var(--fm);
  font-size: .6rem;
  color: var(--line);
  letter-spacing: 0;
  min-width: 20px;
  flex-shrink: 0;
  transition: color .18s;
}

.bp-toc-list a:hover {
  color: var(--ink);
  background: var(--smoke);
}
.bp-toc-list a:hover::before {
  color: var(--flame);
}

.bp-toc-list a.active {
  color: var(--flame);
  background: var(--flame-soft);
  border-left-color: var(--flame);
  font-weight: 600;
}
.bp-toc-list a.active::before {
  color: var(--flame);
}

/* H3 — indented, no counter */
.bp-toc-list a.toc-h3 {
  padding-left: 28px;
  font-size: .72rem;
  color: var(--muted);
  opacity: .85;
}
.bp-toc-list a.toc-h3::before {
  content: '—';
  font-size: .55rem;
  letter-spacing: 0;
  min-width: 16px;
}

/* Progress spine on TOC card left edge */
#tocBox::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 50px;
  bottom: 12px;
  width: 2px;
  background: linear-gradient(to bottom, var(--flame), transparent);
  border-radius: 2px;
  opacity: .18;
  pointer-events: none;
}

/* Empty state */
.bp-toc-empty {
  color: var(--muted);
  font-style: italic;
  font-size: .75rem;
  padding: 6px 10px;
  opacity: .7;
}

/* ════════════════════════════════════════════════════════
   2. SIDEBAR SMART SCROLL — STICKY STACK BEHAVIOUR
   When sidebar overflows viewport, it scrolls naturally
   Cards don't get clipped — sidebar is a flex column
   ════════════════════════════════════════════════════════ */

.bp-sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 16px);
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - var(--nav-h) - 32px);
  overflow-y: auto;
  overflow-x: visible;
  scrollbar-width: none;
  padding-right: 2px; /* prevent shadow clip */
  padding-bottom: 20px;
}
.bp-sidebar::-webkit-scrollbar { display: none; }

/* When sidebar has many cards — auto scroll on hover */
.bp-sidebar:hover {
  overflow-y: auto;
}

/* ════════════════════════════════════════════════════════
   3. AD CARDS — GENERIC ADVERTISER PROMOTIONS
   Admin se koi bhi advertiser add kar sakta hai
   ════════════════════════════════════════════════════════ */

/* ── Wrapper for all ad slots ── */
.bp-ads-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Single Ad Card ── */
.bp-ad-card {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: 0 2px 12px rgba(0,0,0,.05);
  transition: box-shadow .2s, transform .2s;
  text-decoration: none;
  display: block;
  color: inherit;
  position: relative;
}
.bp-ad-card:hover {
  box-shadow: 0 6px 24px rgba(0,0,0,.1);
  transform: translateY(-1px);
}

/* Ad label badge */
.bp-ad-label {
  position: absolute;
  top: 10px;
  right: 10px;
  font-family: var(--fm);
  font-size: .45rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--smoke);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  z-index: 2;
}

/* Ad with image banner */
.bp-ad-image {
  width: 100%;
  height: 130px;
  object-fit: cover;
  display: block;
}

/* Ad content area */
.bp-ad-body {
  padding: 14px 16px 16px;
}

/* Advertiser name — tiny eyebrow */
.bp-ad-brand {
  font-family: var(--fm);
  font-size: .5rem;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.bp-ad-brand::before {
  content: '';
  width: 10px;
  height: 2px;
  background: var(--flame);
  border-radius: 2px;
  display: inline-block;
}

/* Ad headline */
.bp-ad-title {
  font-family: var(--fb);
  font-size: .88rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
  margin-bottom: 6px;
}

/* Ad description */
.bp-ad-desc {
  font-family: var(--fb);
  font-size: .75rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

/* CTA Button */
.bp-ad-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--fb);
  font-size: .72rem;
  font-weight: 600;
  color: var(--flame);
  border: 1.5px solid var(--flame);
  border-radius: 6px;
  padding: 6px 14px;
  text-decoration: none;
  transition: all .18s;
  background: transparent;
}
.bp-ad-cta:hover {
  background: var(--flame);
  color: #fff;
}

/* Text-only Ad variant */
.bp-ad-card.text-only .bp-ad-body {
  padding: 16px;
}

/* Accent color override via data attr */
.bp-ad-card[data-accent] .bp-ad-cta {
  color: var(--ad-accent);
  border-color: var(--ad-accent);
}
.bp-ad-card[data-accent] .bp-ad-cta:hover {
  background: var(--ad-accent);
  color: #fff;
}
.bp-ad-card[data-accent] .bp-ad-brand::before {
  background: var(--ad-accent);
}

/* Dark mode ads */
[data-theme="dark"] .bp-ad-card {
  background: #1a1a2e;
  border-color: #252535;
}
[data-theme="dark"] .bp-ad-label {
  background: #13131f;
  border-color: #252535;
}
[data-theme="dark"] .bp-ad-title { color: #f0ede8; }
[data-theme="dark"] .bp-ad-cta { color: var(--flame); border-color: var(--flame); }

/* ── "Promoted" separator ── */
.bp-ads-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 2px;
}
.bp-ads-divider span {
  font-family: var(--fm);
  font-size: .45rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  opacity: .7;
}
.bp-ads-divider::before,
.bp-ads-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ════════════════════════════════════════════════════════
   4. RESPONSIVE — mobile mein sidebar niche aata hai
   ════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  .bp-sidebar { display: none; }

  /* Mobile: Show a condensed "promoted" strip below article */
  .bp-mobile-ads {
    display: block;
    padding: 0 var(--public-pad) 40px;
  }
  .bp-mobile-ads .bp-ad-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0;
    border-radius: 12px;
    margin-bottom: 12px;
  }
  .bp-mobile-ads .bp-ad-image {
    width: 90px;
    height: 90px;
    border-radius: 0;
    flex-shrink: 0;
  }
  .bp-mobile-ads .bp-ad-body {
    padding: 12px 14px;
    flex: 1;
  }
  .bp-mobile-ads .bp-ad-title { font-size: .82rem; }
  .bp-mobile-ads .bp-ad-desc { display: none; }
  .bp-mobile-ads .bp-ads-divider { margin: 8px 0 4px; }
}

@media (min-width: 1025px) {
  .bp-mobile-ads { display: none; }
}

/* ════════════════════════════════════════════════════════
   5. DARK MODE — additional TOC fixes
   ════════════════════════════════════════════════════════ */
[data-theme="dark"] .bp-toc-list a::before { color: #2a2a3e; }
[data-theme="dark"] .bp-toc-list a.active::before { color: var(--flame); }
[data-theme="dark"] .bp-toc-list a:hover::before { color: var(--flame); }
[data-theme="dark"] #tocBox::before { opacity: .1; }

/* ════════════════════════════════════════════════════════
   5. AD SLOT WRAPPER — always visible container
   ════════════════════════════════════════════════════════ */

.bp-ad-slot-wrap {
  margin-top: 4px;
}

/* ════════════════════════════════════════════════════════
   6. BLOG DETAIL PAGE DESIGN FIXES
   ════════════════════════════════════════════════════════ */

/* ── Author Byline Fix ── */
.bp-byline {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 16px 0 0 !important;
  border-top: 1px solid var(--line) !important;
  margin-top: 10px !important;
  flex-wrap: nowrap !important;
}
.bp-sep { display: none !important; }
.bp-byline-author {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  flex-shrink: 0 !important;
}
.bp-byline-text { display: flex; flex-direction: column; gap: 2px; }
.bp-avatar {
  width: 40px !important;
  height: 40px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, var(--flame), #ff7043) !important;
  color: #fff !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-weight: 700 !important;
  font-size: 1rem !important;
  flex-shrink: 0 !important;
  font-family: var(--fd) !important;
}
.bp-author-name {
  font-weight: 700 !important;
  font-size: 0.88rem !important;
  color: var(--ink) !important;
  line-height: 1.2 !important;
  font-family: var(--fb) !important;
}
.bp-author-role {
  font-family: var(--fm) !important;
  font-size: 0.55rem !important;
  letter-spacing: 1.8px !important;
  text-transform: uppercase !important;
  color: var(--muted) !important;
}
.bp-byline-meta {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  margin-left: auto !important;
  flex-shrink: 0 !important;
}
.bp-byline-dot {
  width: 3px !important;
  height: 3px !important;
  border-radius: 50% !important;
  background: var(--muted) !important;
  display: inline-block !important;
  opacity: 0.5 !important;
}
.bp-meta-items {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  margin-left: auto !important;
}
.bp-meta-item {
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  font-family: var(--fm) !important;
  font-size: 0.65rem !important;
  letter-spacing: 0.5px !important;
  text-transform: uppercase !important;
  color: var(--muted) !important;
  white-space: nowrap !important;
}
.bp-meta-item i {
  color: var(--flame) !important;
  font-size: 0.6rem !important;
}
.bp-meta-dot {
  color: var(--muted) !important;
  opacity: 0.4 !important;
  font-size: 0.8rem !important;
  line-height: 1 !important;
}
[data-theme="dark"] .bp-author-name { color: #f0ede8 !important; }

@media (max-width: 640px) {
  .bp-byline { flex-wrap: wrap !important; gap: 10px !important; }
  .bp-byline-meta, .bp-meta-items { margin-left: 0 !important; width: 100% !important; padding-left: 50px !important; }
}

/* ── Article Banner (inside content, SEO friendly) ── */
.bp-article-banner {
  margin: 0 0 2rem !important;
  border-radius: 14px !important;
  overflow: hidden !important;
  border: 1px solid var(--line) !important;
  display: block !important;
}
.bp-article-banner img {
  width: 100% !important;
  height: auto !important;
  display: block !important;
  object-fit: cover !important;
}

/* Fix body text — force DM Sans, not monospace */
.bp-body, .bp-body.bp-copy {
  font-family: var(--fb) !important;
  font-size: 1rem !important;
  line-height: 1.85 !important;
  color: #2d2d2d !important;
}
[data-theme="dark"] .bp-body,
[data-theme="dark"] .bp-body.bp-copy {
  color: rgba(240,237,232,0.82) !important;
}

/* Headings inside body */
.bp-body h2, .bp-body.bp-copy h2 {
  font-family: var(--fd) !important;
  font-size: clamp(1.4rem, 2.2vw, 1.85rem) !important;
  color: var(--ink) !important;
  margin-top: 2.8rem !important;
  margin-bottom: 0.8rem !important;
  padding-bottom: 10px !important;
  border-bottom: 2px solid var(--line) !important;
  letter-spacing: -0.5px !important;
}
.bp-body h3, .bp-body.bp-copy h3 {
  font-family: var(--fb) !important;
  font-size: 1.1rem !important;
  font-weight: 700 !important;
  color: var(--ink) !important;
  margin-top: 1.8rem !important;
  margin-bottom: 0.5rem !important;
  padding-left: 14px !important;
  border-left: 3px solid var(--flame) !important;
}

/* Excerpt — English text should match body style */
.bp-excerpt {
  font-family: var(--fb) !important;
  font-size: 1rem !important;
  line-height: 1.75 !important;
}

/* Language toggle — start-aligned */
.lang-toggle-wrap {
  justify-content: flex-start !important;
  margin: 0 0 1.5rem 0 !important;
}

/* Breadcrumb — ellipsis on long titles */
.bp-bc span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
  display: inline-block;
}

/* Related articles — consistent card height */
.bp-rel-thumb {
  aspect-ratio: 16/9 !important;
  height: auto !important;
  padding-bottom: 0 !important;
}
.bp-rel-thumb img {
  position: static !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}
.bp-rel-thumb-bg {
  position: absolute !important;
  inset: 0 !important;
}
.bp-rel-thumb-ico {
  position: absolute !important;
  inset: 0 !important;
}

/* Panel value — use body font not monospace */
.bp-panel-v {
  font-family: var(--fb) !important;
  font-size: 0.95rem !important;
}

@media (max-width: 768px) {
  .bp-rel-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ── Empty state (admin only) ── */
.bp-ad-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 16px;
  background: var(--smoke);
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  text-align: center;
}

.bp-ad-empty-icon {
  font-size: 1.6rem;
  color: var(--muted);
  opacity: .35;
}

.bp-ad-empty-text {
  font-family: var(--fb);
  font-size: .76rem;
  color: var(--muted);
  margin: 0;
}

.bp-ad-empty-link {
  font-family: var(--fb);
  font-size: .72rem;
  font-weight: 600;
  color: var(--flame);
  text-decoration: none;
  border: 1.5px solid var(--flame);
  border-radius: 6px;
  padding: 5px 14px;
  margin-top: 2px;
  transition: all .18s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.bp-ad-empty-link:hover {
  background: var(--flame);
  color: #fff;
}

[data-theme="dark"] .bp-ad-empty {
  background: #1a1a2e;
  border-color: #252535;
}

/* ─── BLOG POST SIDEBAR SHARE BUTTONS & WIDGET IMPROVEMENTS ─── */
.bp-sh-btn {
  color: var(--ink) !important;
  border-color: var(--line) !important;
  background: transparent !important;
  transition: all 0.2s ease !important;
}
.bp-sh-btn:hover {
  background: var(--smoke) !important;
  border-color: var(--muted) !important;
  color: var(--ink) !important;
}
.bp-sh-btn.linkedin:hover {
  border-color: #0a66c2 !important;
  color: #0a66c2 !important;
  background: rgba(10, 102, 194, 0.08) !important;
}
.bp-sh-btn.twitter:hover {
  border-color: var(--ink) !important;
  color: var(--ink) !important;
  background: rgba(0, 0, 0, 0.08) !important;
}
.bp-sh-btn.whatsapp:hover {
  border-color: #25d366 !important;
  color: #25d366 !important;
  background: rgba(37, 211, 102, 0.08) !important;
}
.bp-sh-btn.copy:hover {
  border-color: var(--flame) !important;
  color: var(--flame) !important;
  background: var(--flame-soft) !important;
}
[data-theme="dark"] .bp-sh-btn {
  color: #f0ede8 !important;
  border-color: rgba(255,255,255,0.12) !important;
  background: transparent !important;
}
[data-theme="dark"] .bp-sh-btn:hover {
  background: rgba(255,255,255,0.05) !important;
  border-color: rgba(255,255,255,0.2) !important;
  color: #fff !important;
}
[data-theme="dark"] .bp-sh-btn.linkedin:hover {
  border-color: #0a66c2 !important;
  color: #3b82f6 !important;
  background: rgba(10, 102, 194, 0.15) !important;
}
[data-theme="dark"] .bp-sh-btn.twitter:hover {
  border-color: #fff !important;
  color: #fff !important;
  background: rgba(255, 255, 255, 0.1) !important;
}
[data-theme="dark"] .bp-sh-btn.whatsapp:hover {
  border-color: #25d366 !important;
  color: #4ade80 !important;
  background: rgba(37, 211, 102, 0.15) !important;
}
[data-theme="dark"] .bp-sh-btn.copy:hover {
  border-color: var(--flame) !important;
  color: #ff7043 !important;
  background: rgba(230, 61, 10, 0.15) !important;
}

/* Ensure the sidebar scroll works beautifully and doesn't get hidden */
.bp-sidebar {
  max-height: calc(100vh - var(--nav-h, 68px) - 40px) !important;
  overflow-y: auto !important;
  scrollbar-width: none !important; /* Hide scrollbar for Firefox */
}
.bp-sidebar::-webkit-scrollbar {
  display: none !important; /* Hide scrollbar for Chrome/Safari/Edge */
}


/* ─── FLEXBOX COLLAPSE FIX FOR SIDEBAR CARDS ─── */
.bp-sidebar > * {
  flex-shrink: 0 !important;
}

/* Equal columns for stats based on actual item count */
.bp-ac-stats {
  grid-template-columns: repeat(auto-fit, minmax(1px, 1fr)) !important;
}


/* Fix callout icon visibility (white icon inside orange circle) */
.bp-copy .callout-ico {
  color: #fff !important;
  background: var(--flame, #e63d0a) !important;
}
