/* ============================================
   MOBILE BOTTOM NAVIGATION LAYOUT
   ============================================
   
   Mobile-first redesign with:
   - Bottom navigation bar (replaces sidebar)
   - Full-width Bible content (no containers)
   - Touch-friendly interface
   - Optimized for mobile reading experience
*/

/* ============================================
   DEFAULT BEHAVIOR - HIDE BOTTOM NAV ON DESKTOP ONLY
   ============================================ */

/* Hide bottom navigation by default on desktop only */
.mobile-bottom-nav,
.mobile-nav-item {
  display: none !important;
}
/* Absolutely ensure no mobile nav on DESKTOP only (1367px+ = true desktop) */
@media (min-width: 1367px) {
  .mobile-bottom-nav,
  .mobile-nav-item,
  nav.mobile-bottom-nav,
  .mobile-bottom-nav * {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
    left: -9999px !important;
    z-index: -1000 !important;
  }
}

/* ============================================
   MOBILE BOTTOM NAVIGATION STYLES
   ============================================ */

@media (max-width: 1366px) {
  
  /* Hide the top navbar completely on mobile/tablet */
  .top-navbar {
    display: none !important;
  }
  
  /* Hide the traditional sidebar completely on mobile/tablet - CRITICAL */
  .sidebar,
  .sidebar.collapsed,
  .sidebar.expanded,
  #sidebar,
  nav.sidebar,
  .sidebar-container {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
    left: -9999px !important;
    z-index: -1 !important;
  }
  
  /* Hide the mobile menu toggle since we're using bottom nav */
  .top-navbar .mobile-menu-toggle,
  .mobile-menu-toggle,
  #mobile-menu-toggle {
    display: none !important;
  }
  
  /* Hide the dark mode toggle from top-right on mobile/tablet */
  .theme-toggle-container {
    display: none !important;
  }
  
  /* Adjust main wrapper for bottom navigation */
  .main-wrapper {
    margin-left: 0 !important;
    padding-left: 0 !important;
    padding-bottom: 20px !important; /* Reduced since nav is hidden by default */
    padding-top: 40px !important; /* Add top gap for mobile/tablet reading */
    width: 100% !important;
  }
  
  /* Remove any containers and make Bible content full-width */
  .bible-main-content,
  .search-results-container,
  .bible-book-content {
    max-width: none !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  
  /* Full-width Bible content styling - starts from very top */
  .bible-content-wrapper {
    padding: 0 12px !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: none !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    padding-top: 0 !important; /* Start from very top */
  }
  
  /* Bible chapter content - full-width and highlightable */
  .bible-chapter-content {
    background: transparent !important;
    padding: 12px !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    width: 100% !important;
    max-width: none !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
  }
  
  /* Ensure verses are easily selectable and highlightable */
  .bible-verse {
    padding: 6px 0 !important;
    margin: 0 !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    user-select: text !important;
    line-height: 1.5 !important;
    font-size: 14px !important;
    touch-action: manipulation !important;
    -webkit-touch-callout: default !important;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1) !important;
  }
  
  /* Enhanced verse text for mobile reading */
  .bible-verse-text {
    font-size: 14px !important;
    line-height: 1.5 !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    user-select: text !important;
    word-spacing: 0.05em !important;
    letter-spacing: 0.005em !important;
  }
  
  /* Verse numbers styling - smaller */
  .verse-number {
    font-size: 12px !important;
    margin-right: 4px !important;
    color: var(--bible-text-verse-num) !important;
    font-weight: 600 !important;
  }
  
  /* Chapter title styling - keep but make minimal */
  .bible-chapter-title,
  #chapter-title,
  .chapter-title,
  .chapter-title-top {
    font-size: 1.1rem !important;
    font-weight: 600 !important;
    margin: 0 0 10px 0 !important;
    padding: 8px 12px !important;
    text-align: left !important;
    background: transparent !important;
    border: none !important;
    color: var(--bible-text-primary) !important;
  }
  
  /* Hide any hidden chapter reference elements */
  #chapter-title.hidden,
  .hidden {
    display: none !important;
  }
  
  /* Remove any container restrictions */
  .container,
  .container-fluid,
  .bible-container {
    max-width: none !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  
  /* Verse numbers styling */
  .verse-number {
    font-size: 14px !important;
    margin-right: 6px !important;
    color: var(--bible-text-verse-num) !important;
    font-weight: 600 !important;
  }
  
  /* Search results full-width */
  .search-results {
    padding: 15px !important;
    margin: 0 !important;
    width: 100% !important;
  }
  
  /* Search result cards */
  .search-result-card {
    margin: 0 0 15px 0 !important;
    padding: 15px !important;
    border-radius: 8px !important;
    width: 100% !important;
  }
  
  /* ============================================
     HIDE CHAPTER SELECTION AND NAVIGATION CONTROLS ON MOBILE
     ============================================ */
  
  /* Hide the entire Bible navigation header area on mobile */
  .bible-navigation-header,
  .navigation-content,
  .book-title-section,
  .chapter-navigation-section,
  .verse-controls-section,
  .select-book-btn,
  .chapter-controls,
  .chapter-dropdown-container,
  .verse-controls-container,
  .controls-info,
  #chapter-select,
  #prev-chapter-btn,
  #next-chapter-btn,
  .chapter-nav-btn {
    display: none !important;
  }
  
  /* Hide any clear selection buttons and study controls */
  .clear-selection-btn,
  .verse-clear-btn,
  .clear-verses-button,
  #clear-verses-btn,
  [class*="clear-selection"],
  [id*="clear-selection"],
  [class*="chapter-nav"],
  [class*="verse-selection"],
  .bible-study-header,
  .bible-study-nav {
    display: none !important;
  }
  
  /* Hide any dropdowns or selectors that might appear above content */
  .bible-content select,
  .bible-content .dropdown,
  .bible-content .selector,
  .bible-wrapper select,
  .bible-wrapper .dropdown,
  .bible-book-content select,
  .bible-book-content .dropdown {
    display: none !important;
  }
  
  /* Hide chapter form and any other forms above Bible content */
  #chapter-form,
  .chapter-form,
  .bible-form,
  [id*="chapter-form"],
  [class*="chapter-form"] {
    display: none !important;
  }
  
  /* ============================================
     BOTTOM NAVIGATION BAR
     ============================================ */
  
  /* Mobile bottom navigation - SHOW only on mobile */
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(135deg, #374151 0%, #4b5563 100%);
    border-top: 2px solid #6b7280;
    z-index: 1100;
    display: flex !important; /* Override default hidden state */
    justify-content: space-around;
    align-items: center;
    padding: 8px 12px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    /* Auto-hide animation */
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
  }
  
  /* Show navigation when active */
  .mobile-bottom-nav.nav-visible {
    transform: translateY(0);
  }
  
  /* Light theme bottom nav */
  [data-theme="light"] .mobile-bottom-nav {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-top: 2px solid #e2e8f0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  }
  
  /* Light theme auto-hide animation */
  [data-theme="light"] .mobile-bottom-nav.nav-visible {
    transform: translateY(0);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  }
  
  /* Swipe indicator - subtle hint at bottom of screen */
  .mobile-bottom-nav::before {
    content: '';
    position: absolute;
    top: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  
  [data-theme="light"] .mobile-bottom-nav::before {
    background: rgba(0, 0, 0, 0.2);
  }
  
  /* Show swipe indicator when nav is visible */
  .mobile-bottom-nav.nav-visible::before {
    opacity: 1;
  }
  
  /* Bottom nav items - SHOW only on mobile */
  .mobile-nav-item {
    display: flex !important; /* Override default hidden state */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    border-radius: 8px;
    text-decoration: none;
    color: #cbd5e1;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.2s ease;
    min-height: 44px;
    min-width: 44px;
    cursor: pointer;
    position: relative;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
  
  /* Light theme nav items */
  [data-theme="light"] .mobile-nav-item {
    color: #64748b;
  }
  
  /* Nav item icons */
  .mobile-nav-item .nav-icon {
    width: 22px;
    height: 22px;
    margin-bottom: 4px;
    stroke-width: 2;
  }
  
  /* Nav item text */
  .mobile-nav-item .nav-text {
    font-size: 10px;
    line-height: 1;
    text-align: center;
  }
  
  /* Active/hover states */
  .mobile-nav-item:hover,
  .mobile-nav-item.active {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    transform: translateY(-2px);
  }
  
  [data-theme="light"] .mobile-nav-item:hover,
  [data-theme="light"] .mobile-nav-item.active {
    color: #1d4ed8;
    background: rgba(29, 78, 216, 0.1);
  }
  
  /* Active indicator */
  .mobile-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: #3b82f6;
    border-radius: 50%;
  }
  
  [data-theme="light"] .mobile-nav-item.active::before {
    background: #1d4ed8;
  }
  
  /* ============================================
     MOBILE THEME TOGGLE BUTTON STYLING
     ============================================ */
  
  /* Mobile theme toggle specific styling */
  .mobile-theme-toggle {
    position: relative;
  }
  
  /* Theme icon styling for mobile */
  .mobile-theme-toggle .theme-icon-light {
    display: block;
  }
  
  .mobile-theme-toggle .theme-icon-dark {
    display: none;
  }
  
  /* Dark mode theme icon toggle */
  [data-theme="dark"] .mobile-theme-toggle .theme-icon-light {
    display: none;
  }
  
  [data-theme="dark"] .mobile-theme-toggle .theme-icon-dark {
    display: block;
  }
  
  /* ============================================
     HOME PAGE MOBILE ADJUSTMENTS
     ============================================ */
  
  /* Home page specific adjustments */
  .page-home .main-wrapper {
    padding-bottom: 80px !important;
  }
  
  /* Header adjustments for mobile */
  .header.finisher-header {
    padding: 60px 20px 40px 20px !important;
  }
  
  .welcome-content h1 {
    font-size: 2.5rem !important;
    margin-bottom: 1rem !important;
  }
  
  .welcome-content p {
    font-size: 1.1rem !important;
  }
  
  /* Split sections full-width */
  .split-section {
    padding: 40px 20px !important;
  }
  
  .split-container {
    flex-direction: column !important;
    max-width: none !important;
  }
  
  .quote-left,
  .content-right {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  /* ============================================
     BIBLE NAVIGATION MOBILE IMPROVEMENTS
     ============================================ */
  
  /* Bible navigation header adjustments */
  .bible-header {
    padding: 15px !important;
    margin: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  
  /* Chapter navigation */
  .chapter-navigation {
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding: 15px !important;
  }
  
  .chapter-nav-btn {
    min-height: 44px !important;
    min-width: 44px !important;
    font-size: 14px !important;
  }
  
  /* Book selector */
  .book-selector-container {
    padding: 15px !important;
    width: 100% !important;
  }
  
  .book-selector {
    width: 100% !important;
    min-height: 44px !important;
    font-size: 16px !important;
  }
  
  /* ============================================
     AI CHAT MOBILE ADJUSTMENTS
     ============================================ */
  
  /* Adjust AI chat for bottom navigation */
  .ai-chat-panel {
    bottom: 80px !important; /* Above bottom navigation */
  }
  
  /* ============================================
     SAFE AREA SUPPORT FOR NOTCHED DEVICES
     ============================================ */
  
  .mobile-bottom-nav {
    padding-bottom: env(safe-area-inset-bottom, 0px);
    height: calc(80px + env(safe-area-inset-bottom, 0px));
  }
  
  /* Reduced padding since nav is auto-hidden */
  .main-wrapper {
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
  }
  
  .ai-chat-panel {
    bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
  }
}
}

/* ============================================
   LANDSCAPE MOBILE ADJUSTMENTS
   ============================================ */

@media (max-width: 1366px) and (orientation: landscape) {
  
  /* Reduce bottom nav height in landscape */
  .mobile-bottom-nav {
    height: 60px;
  }
  
  .mobile-bottom-nav {
    height: calc(60px + env(safe-area-inset-bottom, 0px));
  }
  
  .main-wrapper {
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
  }
  
  .ai-chat-panel {
    bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
  }
  
  /* Smaller nav items in landscape */
  .mobile-nav-item {
    padding: 4px 3px;
  }
  
  .mobile-nav-item .nav-icon {
    width: 18px;
    height: 18px;
    margin-bottom: 2px;
  }
  
  .mobile-nav-item .nav-text {
    font-size: 9px;
  }
  
  /* Reduce header size in landscape */
  .header.finisher-header {
    padding: 40px 20px 30px 20px !important;
  }
  
  .welcome-content h1 {
    font-size: 2rem !important;
  }
}

/* ============================================
   TABLET TOUCH OPTIMIZATION
   ============================================ */

/* Tablet-specific optimizations removed - tablets now use mobile layout */
