/* ============================================
   MOBILE TABS v5.8 - COMPLETE WORKING FIX
   Path: /assets/css/mobile-tabs-v5-8.css
   Fixes all issues: white background, text visibility, proper scrolling
   ============================================ */

/* ============================================
   MOBILE SECTION TABS - CONTAINER
   ============================================ */
.mobile-section-tabs {
  display: none; /* Hidden by default, shown via JS on mobile */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff; /* Pure white background */
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  z-index: 997;
  transform: translateY(0);
  transition: transform 0.3s ease-in-out;
  padding-bottom: env(safe-area-inset-bottom); /* iOS safe area */
  height: auto;
  max-height: 65px; /* Compact height */
}

/* Always keep tabs visible */
.mobile-section-tabs.hidden {
  transform: translateY(0) !important;
}

/* Show only on mobile devices */
@media (max-width: 768px) {
  .mobile-section-tabs.active {
    display: block;
  }
  
  /* Adjust main content padding */
  body.has-mobile-tabs main {
    padding-bottom: 75px;
  }
}

/* ============================================
   TAB CONTAINER - SCROLLABLE
   ============================================ */
.tabs-container {
  display: flex;
  overflow-x: auto; /* Allow horizontal scrolling */
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch; /* Smooth iOS scrolling */
  padding: 8px 4px;
  gap: 4px;
  justify-content: flex-start; /* Allow scrolling when many items */
  align-items: center;
  background: transparent;
  
  /* Hide scrollbar but keep functionality */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.tabs-container::-webkit-scrollbar {
  display: none;
}

/* ============================================
   TAB ITEMS - Proper Pill Style
   ============================================ */
.tab-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto; /* Don't grow or shrink */
  min-width: 70px;
  max-width: 90px;
  padding: 10px 14px;
  
  /* Inactive state - light gray background with visible text */
  background: #f3f4f6; /* Light gray background */
  border: 2px solid #e5e7eb;
  border-radius: 20px; /* Pill shape */
  
  cursor: pointer;
  transition: all 0.3s ease;
  scroll-snap-align: center;
  position: relative;
  text-decoration: none;
  color: #374151; /* Dark gray text for readability */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  margin: 0 2px;
  white-space: nowrap;
}

/* Hover state for inactive tabs */
.tab-item:hover:not(.active) {
  background: #e5e7eb;
  border-color: #d1d5db;
  transform: translateY(-1px);
}

/* Active/pressed animation */
.tab-item:active:not(.active) {
  transform: scale(0.95);
}

/* Active tab - Purple to Pink gradient */
.tab-item.active {
  background: linear-gradient(135deg, #7209b7 0%, #e11d48 100%);
  color: #ffffff; /* White text on gradient */
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(114, 9, 183, 0.3);
  transform: translateY(0);
}

/* Active tab hover */
.tab-item.active:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(114, 9, 183, 0.4);
}

/* Text-only label styling */
.tab-label-only {
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  letter-spacing: -0.2px;
  display: block;
}

/* Icon + label styling (if using icons) */
.tab-icon {
  font-size: 16px;
  line-height: 1;
  margin-bottom: 2px;
  display: block;
}

.tab-label {
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  letter-spacing: -0.2px;
  display: block;
}

/* ============================================
   SCROLL INDICATORS
   ============================================ */

/* Gradient fade indicators on sides when scrollable */
.mobile-section-tabs::before,
.mobile-section-tabs::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 20px;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.3s ease;
}

.mobile-section-tabs::before {
  left: 0;
  background: linear-gradient(to right, #ffffff, transparent);
  opacity: 0;
}

.mobile-section-tabs::after {
  right: 0;
  background: linear-gradient(to left, #ffffff, transparent);
  opacity: 0;
}

/* Show indicators based on scroll position */
.mobile-section-tabs.scroll-start::after {
  opacity: 1;
}

.mobile-section-tabs.scroll-end::before {
  opacity: 1;
}

.mobile-section-tabs.scroll-middle::before,
.mobile-section-tabs.scroll-middle::after {
  opacity: 1;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

/* Small phones */
@media (max-width: 360px) {
  .tab-item {
    min-width: 60px;
    max-width: 80px;
    padding: 9px 12px;
  }
  
  .tab-label-only {
    font-size: 11px;
  }
  
  .mobile-section-tabs {
    max-height: 60px;
  }
  
  body.has-mobile-tabs main {
    padding-bottom: 70px;
  }
}

/* Landscape orientation */
@media (max-width: 768px) and (orientation: landscape) {
  .mobile-section-tabs {
    max-height: 55px;
  }
  
  .tabs-container {
    padding: 6px 4px;
  }
  
  .tab-item {
    min-width: 65px;
    max-width: 85px;
    padding: 8px 12px;
  }
  
  .tab-label-only {
    font-size: 11px;
  }
  
  body.has-mobile-tabs main {
    padding-bottom: 65px;
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus states */
.tab-item:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(114, 9, 183, 0.3);
}

.tab-item:focus:not(:focus-visible) {
  box-shadow: none;
}

.tab-item:focus-visible {
  outline: 2px solid #7209b7;
  outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .tab-item {
    border-width: 2px;
  }
  
  .tab-item.active {
    background: #000000;
    color: #ffffff;
    border: 2px solid #ffffff;
  }
}

/* ============================================
   ANIMATIONS
   ============================================ */

/* Slide in animation */
.mobile-section-tabs.slide-in {
  animation: slideInUp 0.3s ease-out;
}

@keyframes slideInUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ============================================
   LOADING STATE
   ============================================ */
.mobile-section-tabs.loading .tabs-container {
  opacity: 0.5;
  pointer-events: none;
}

.mobile-section-tabs.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid #e5e7eb;
  border-top-color: #7209b7;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
/* ============================================
   FIX: NON-STICKY TOP NAV ON MOBILE
   Add this to your mobile-tabs-v5-8.css or as override
   ============================================ */

/* When mobile tabs are present, make top nav non-sticky */
@media (max-width: 768px) {
  /* When body has the mobile tabs class, unstick the top nav */
  body.has-mobile-tabs nav {
    position: relative !important; /* Changed from fixed to relative */
    top: auto !important;
    width: 100% !important;
  }
  
  /* Reduce top padding since nav isn't fixed anymore */
  body.has-mobile-tabs .content-section {
    padding-top: 2rem !important; /* Much less padding needed */
  }
  
  /* Keep the reading progress bar at the very top */
  body.has-mobile-tabs .reading-progress {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1002 !important;
  }
  
  /* Ensure mobile tabs stay at bottom */
  .mobile-section-tabs {
    position: fixed !important;
    bottom: 0 !important;
    z-index: 997 !important;
  }
}

/* Additional specificity to override any conflicts */
@media screen and (max-width: 768px) {
  body.has-mobile-tabs > nav,
  body.has-mobile-tabs #main-nav {
    position: relative !important;
    top: 0 !important;
  }
}
/* ============================================
   MOBILE TABS FIXES - Sticky & Scroll Issues
   ============================================ */

/* FIX 1: ENSURE TABS ARE STICKY AT BOTTOM */
.mobile-section-tabs {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 997 !important;
  display: none;
}

/* Show on mobile when active */
@media (max-width: 768px) {
  .mobile-section-tabs.active {
    display: block !important;
  }
}

/* FIX 2: PREVENT ACCIDENTAL TAP/CLICK DURING SCROLL */
.tabs-container {
  touch-action: pan-x !important;
  -webkit-user-select: none;
  user-select: none;
  pointer-events: auto;
}

/* Disable pointer events while scrolling */
.tabs-container.is-scrolling {
  pointer-events: none !important;
}

/* Tab items - require deliberate tap/click */
.tab-item {
  touch-action: manipulation;
  transition: all 0.3s ease, background 0ms;
}

/* Visual feedback for tap (not scroll) */
.tab-item:active {
  transform: scale(0.95);
  transition: transform 0.1s ease;
}
/* Force bottom position - override everything */
@media (max-width: 768px) {
  .mobile-section-tabs {
    position: fixed !important;
    bottom: 0 !important;
    top: auto !important;
    top: unset !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 997 !important;
    transform: none !important;
    display: block !important;
  }
  
  /* Ensure visibility */
  body.has-mobile-tabs .mobile-section-tabs,
  .mobile-section-tabs.active {
    position: fixed !important;
    bottom: 0 !important;
    top: auto !important;
  }
}