/**
 * Mijn Bijbel - Mobile Styles
 * Touch optimizations, safe areas, mobile-specific components
 */

/* ==========================================================================
   Touch Optimizations
   ========================================================================== */

/* Minimum touch target size (44x44px) */
.mobile-nav-item,
.sheet-close,
.tab-btn,
.dropdown-item {
    min-height: 44px;
    min-width: 44px;
}

/* Prevent text selection on interactive elements */
button,
.nav-button,
.dropdown-item,
.mobile-nav-item {
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Smooth scrolling */
.sheet-content,
.tab-content,
.carousel-slide {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* ==========================================================================
   Safe Area Handling
   ========================================================================== */

/* Bottom navigation with safe area */
.mobile-nav {
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Bottom sheets with safe area */
.sheet-content {
    padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
}

/* Carousel slide content area */
.carousel-slide .tab-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-4);
    padding-bottom: calc(var(--space-8) + 60px);
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Bible text container */
.carousel-slide .bible-text {
    width: 100%;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ==========================================================================
   Mobile Tab Header
   ========================================================================== */

.mobile-tab-header {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.mobile-tab-title {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: var(--space-2);
    border-radius: var(--radius-md);
    transition: background-color var(--transition-fast);
}

.mobile-tab-title:active {
    background-color: var(--bg-tertiary);
}

.mobile-book-title {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.mobile-book-title::after {
    content: 'expand_more';
    font-family: 'Material Symbols Outlined';
    font-size: 18px;
    color: var(--text-muted);
}

.mobile-translation-badge {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.mobile-tab-actions {
    display: flex;
    gap: var(--space-1);
}

.mobile-tab-actions .tab-btn-close {
    color: var(--text-muted);
    margin-left: var(--space-2);
}

.mobile-tab-actions .tab-btn-close:hover {
    color: #e74c3c;
}

/* ==========================================================================
   Mobile Chapter Navigation
   ========================================================================== */

.mobile-chapter-nav {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--space-4) + env(safe-area-inset-bottom, 0px));
    right: var(--space-4);
    display: flex;
    gap: var(--space-2);
    z-index: var(--z-sticky);
}

.chapter-nav-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--brand-color);
    color: white;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-fast);
}

.chapter-nav-btn:active {
    transform: scale(0.95);
    box-shadow: var(--shadow-md);
}

/* ==========================================================================
   Pull to Refresh
   ========================================================================== */

.pull-indicator {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-fast);
}

.pull-indicator .material-symbols-outlined {
    color: var(--brand-color);
    animation: spin 1s linear infinite;
}

.pull-indicator.visible {
    transform: translateX(-50%) translateY(70px);
}

/* ==========================================================================
   Swipe Gestures
   ========================================================================== */

.swipe-hint {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 48px;
    color: var(--brand-color);
    opacity: 0;
    transition: opacity var(--transition-fast);
    pointer-events: none;
}

.swipe-hint-left {
    left: var(--space-4);
}

.swipe-hint-right {
    right: var(--space-4);
}

.swiping .swipe-hint {
    opacity: 0.3;
}

/* ==========================================================================
   Mobile Book List
   ========================================================================== */

.book-list {
    display: flex;
    flex-direction: column;
}

.book-group-header {
    position: sticky;
    top: 0;
    padding: var(--space-2) var(--space-4);
    background-color: var(--bg-tertiary);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    z-index: 5;
}

.book-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-fast);
}

.book-item:active {
    background-color: var(--bg-tertiary);
}

.book-item.selected {
    background-color: var(--brand-light);
}

.book-item.selected .book-name {
    color: var(--brand-color);
    font-weight: 600;
}

.book-name {
    font-size: var(--text-base);
}

.book-chapters {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* Chapter Grid */
.chapter-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-2);
    padding: var(--space-4);
}

.chapter-btn {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
}

.chapter-btn:active {
    transform: scale(0.95);
}

.chapter-btn.active {
    background-color: var(--brand-color);
    border-color: var(--brand-color);
    color: white;
}

/* Book Back Button */
.book-back-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    padding: var(--space-4);
    background-color: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: var(--text-base);
}

.book-back-btn .material-symbols-outlined {
    font-size: 20px;
    color: var(--brand-color);
}

/* ==========================================================================
   Mobile Context Menu
   ========================================================================== */

.context-menu {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    transform: translateY(100%);
    transition: transform var(--transition-normal);
    z-index: var(--z-sticky);
}

.context-menu.active {
    transform: translateY(0);
}

.context-btn {
    flex: 1;
    max-width: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-3);
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: var(--text-xs);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.context-btn:active {
    background-color: var(--brand-color);
    color: white;
}

/* ==========================================================================
   Mobile Add Tab Options
   ========================================================================== */

.add-tab-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
    padding: var(--space-4);
}

.add-tab-option {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    background-color: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.add-tab-option:active {
    background-color: var(--brand-color);
    border-color: var(--brand-color);
    color: white;
}

.add-tab-option .material-symbols-outlined {
    font-size: 32px;
    color: var(--brand-color);
}

.add-tab-option:active .material-symbols-outlined {
    color: white;
}

.add-tab-label {
    font-size: var(--text-sm);
    font-weight: 500;
}

/* ==========================================================================
   Mobile Verse Selection - Enable native text selection
   ========================================================================== */

.verse-selectable {
    cursor: text;
    transition: background-color var(--transition-fast);
    border-radius: var(--radius-sm);
    margin: 0 calc(var(--space-1) * -1);
    padding: 0 var(--space-1);
    -webkit-user-select: text;
    user-select: text;
}

/* Selection highlight */
.verse-selectable::selection {
    background-color: var(--brand-light);
}

.verse-selected {
    background-color: var(--brand-light);
}

/* ==========================================================================
   Mobile Highlight Menu
   ========================================================================== */

.highlight-menu {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--space-4) + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background-color: var(--bg-secondary);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-xl);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    z-index: var(--z-popover);
}

.highlight-menu.active {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

.highlight-color {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: 2px solid var(--border-color);
    transition: transform var(--transition-fast);
}

.highlight-color:active {
    transform: scale(0.9);
}

.highlight-color-green {
    background-color: var(--highlight-green);
}

.highlight-color-gold {
    background-color: var(--highlight-gold);
}

.highlight-color-clear {
    background-color: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.highlight-color-clear .material-symbols-outlined {
    font-size: 18px;
    color: var(--text-muted);
}

/* ==========================================================================
   Mobile Loading State
   ========================================================================== */

.mobile-loading {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-primary);
    z-index: var(--z-modal);
}

.mobile-loading-content {
    text-align: center;
}

.mobile-loading-logo {
    font-family: var(--font-display);
    font-size: var(--text-3xl);
    margin-bottom: var(--space-4);
}

/* ==========================================================================
   Landscape Mode Adjustments
   ========================================================================== */

@media (orientation: landscape) and (max-height: 500px) {
    .mobile-nav {
        height: 50px;
    }
    
    .mobile-nav-item .nav-label {
        display: none;
    }
    
    .bottom-sheet {
        max-height: 95vh;
    }
    
    .sheet-handle {
        display: none;
    }
}

