/**
 * Mobile Navigation Styles
 * Bottom tab bar and sheet menu for mobile devices
 */

/* ========================================
   CSS Variables for Mobile Navigation
   ======================================== */
:root {
    --mobile-nav-height: 56px;
    --mobile-nav-bg: var(--bg-secondary, #0a0a0f);
    --mobile-nav-border: var(--border-color, #333);
    --mobile-nav-active: var(--accent-primary, #6e4ff6);
    --mobile-nav-text: var(--text-secondary, #888);
    --mobile-nav-text-active: var(--accent-primary, #6e4ff6);
    --mobile-sheet-bg: var(--bg-primary, #1e1e2e);
    --mobile-sheet-handle: #444;
    --mobile-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Bottom Navigation Bar
   ======================================== */
.ldr-mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-nav-height);
    background: var(--mobile-nav-bg);
    border-top: 1px solid var(--mobile-nav-border);
    z-index: 1000;
    transform: translateY(100%);
    transition: transform var(--mobile-transition);

    /* Safe area for iPhone notch/home indicator */
    padding-bottom: env(safe-area-inset-bottom);
}

.ldr-mobile-bottom-nav.visible {
    transform: translateY(0);
}

/* Navigation tabs container */
.ldr-mobile-bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

/* Individual tab button */
.ldr-mobile-nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 0;
    background: none;
    border: none;
    color: var(--mobile-nav-text);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* Tab hover/focus states */
.ldr-mobile-nav-tab:hover,
.ldr-mobile-nav-tab:focus {
    background: rgba(110, 79, 246, 0.1);
    outline: none;
}

.ldr-mobile-nav-tab:focus-visible {
    outline: 2px solid var(--mobile-nav-active);
    outline-offset: -2px;
}

/* Active tab */
.ldr-mobile-nav-tab.active {
    color: var(--mobile-nav-text-active);
}

/* Active indicator bar */
.ldr-mobile-nav-tab.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    background: var(--mobile-nav-active);
    border-radius: 0 0 2px 2px;
}

/* Tab icon */
.ldr-mobile-nav-tab i {
    font-size: 20px;
    transition: transform 0.2s ease;
}

.ldr-mobile-nav-tab:active i {
    transform: scale(0.9);
}

/* Tab label */
.ldr-mobile-nav-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.01em;
}

/* ========================================
   Sheet Menu
   ======================================== */
.ldr-mobile-sheet-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--mobile-sheet-bg);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform var(--mobile-transition);
    z-index: 2000;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);

    /* Safe area for iPhone */
    padding-bottom: env(safe-area-inset-bottom);
}

.ldr-mobile-sheet-menu.active {
    transform: translateY(0);
}

/* Drag handle */
.ldr-mobile-sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--mobile-sheet-handle);
    border-radius: 2px;
    margin: 12px auto 8px;
    cursor: grab;
    flex-shrink: 0;
}

.ldr-mobile-sheet-handle:active {
    cursor: grabbing;
}

/* Sheet content */
.ldr-mobile-sheet-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 0 20px;

    /* Smooth scrolling on iOS */
    -webkit-overflow-scrolling: touch;

    /* Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--mobile-sheet-handle) transparent;
}

.ldr-mobile-sheet-content::-webkit-scrollbar {
    width: 4px;
}

.ldr-mobile-sheet-content::-webkit-scrollbar-track {
    background: transparent;
}

.ldr-mobile-sheet-content::-webkit-scrollbar-thumb {
    background: var(--mobile-sheet-handle);
    border-radius: 2px;
}

/* Sheet sections */
.ldr-mobile-sheet-section {
    padding: 16px 16px 8px;
    border-bottom: 1px solid var(--mobile-nav-border);
}

.ldr-mobile-sheet-section:last-child {
    border-bottom: none;
}

.ldr-mobile-sheet-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--mobile-nav-text);
    margin-bottom: 12px;
    padding-left: 4px;
}

/* Sheet items container */
.ldr-mobile-sheet-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Sheet item button */
.ldr-mobile-sheet-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 8px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    width: 100%;
}

.ldr-mobile-sheet-item:hover,
.ldr-mobile-sheet-item:focus {
    background: rgba(110, 79, 246, 0.1);
    outline: none;
}

.ldr-mobile-sheet-item:focus-visible {
    outline: 2px solid var(--mobile-nav-active);
    outline-offset: -2px;
}

.ldr-mobile-sheet-item:active {
    background: rgba(110, 79, 246, 0.2);
}

/* Sheet item icon */
.ldr-mobile-sheet-item i {
    width: 24px;
    font-size: 18px;
    text-align: center;
    color: var(--mobile-nav-text);
}

/* Sheet item label */
.ldr-mobile-sheet-label {
    flex: 1;
    font-weight: 400;
}

/* Sheet item badge */
.ldr-mobile-sheet-badge {
    background: var(--mobile-nav-active);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* ========================================
   Overlay
   ======================================== */
.ldr-mobile-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--mobile-transition);
    z-index: 1999;
}

.ldr-mobile-sheet-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* ========================================
   Responsive Behavior
   ======================================== */

/* Show mobile navigation on small screens */
@media (max-width: 767px) {
    /* Show mobile nav */
    .ldr-mobile-bottom-nav {
        display: flex;
    }

    .ldr-mobile-bottom-nav.visible {
        display: flex;
    }

    /* Adjust body padding for nav bar */
    body.ldr-has-mobile-nav {
        padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
    }

    /* Hide desktop sidebar completely */
    .ldr-sidebar {
        display: none !important;
    }

    /* Adjust main content */
    .ldr-main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* Hide mobile tab bar that was in the template */
    .ldr-mobile-tab-bar {
        display: none !important;
    }

    /* Ensure content doesn't go under nav */
    .ldr-page.active {
        padding-bottom: calc(var(--mobile-nav-height) + 20px + env(safe-area-inset-bottom));
    }

    /* Adjust top bar */
    .ldr-top-bar {
        left: 0 !important;
    }
}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 991px) {
    /* Keep sidebar but collapsed */
    .ldr-sidebar {
        width: 60px;
    }

    /* Hide mobile navigation */
    .ldr-mobile-bottom-nav {
        display: none !important;
    }
}

/* Short viewport height - switch to mobile nav when sidebar would be cut off */
/* This handles cases where screen width is large but height is small */
@media (min-width: 768px) and (max-height: 600px) {
    /* Show mobile nav */
    .ldr-mobile-bottom-nav {
        display: flex !important;
    }

    .ldr-mobile-bottom-nav.visible {
        display: flex !important;
    }

    /* Hide desktop sidebar */
    .ldr-sidebar {
        display: none !important;
    }

    /* Adjust main content */
    .ldr-main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* Adjust body padding for nav bar */
    body.ldr-has-mobile-nav {
        padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
    }

    /* Adjust top bar */
    .ldr-top-bar {
        left: 0 !important;
    }
}

/* Desktop - ensure mobile nav is hidden (unless viewport is too short) */
@media (min-width: 992px) and (min-height: 601px) {
    .ldr-mobile-bottom-nav,
    .ldr-mobile-sheet-menu,
    .ldr-mobile-sheet-overlay {
        display: none !important;
    }
}

/* ========================================
   Animations
   ======================================== */

/* Slide up animation for sheet */
@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Fade in animation for overlay */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Ripple effect for buttons */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* Add ripple on tap (optional enhancement) */
.ldr-mobile-nav-tab::after,
.ldr-mobile-sheet-item::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    background: var(--mobile-nav-active);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
}

.ldr-mobile-nav-tab:active::after,
.ldr-mobile-sheet-item:active::after {
    animation: ripple 0.6s ease-out;
}

/* ========================================
   Accessibility
   ======================================== */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .ldr-mobile-nav-tab.active {
        text-decoration: underline;
        font-weight: bold;
    }

    .ldr-mobile-sheet-item:focus {
        outline: 3px solid;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .ldr-mobile-bottom-nav,
    .ldr-mobile-sheet-menu,
    .ldr-mobile-sheet-overlay,
    .ldr-mobile-nav-tab,
    .ldr-mobile-sheet-item {
        transition: none !important;
        animation: none !important;
    }
}

/* ========================================
   Dark mode adjustments
   ======================================== */
[data-theme="light"] {
    --mobile-nav-bg: #f5f5f5;
    --mobile-nav-border: #ddd;
    --mobile-nav-text: #666;
    --mobile-sheet-bg: #fff;
    --mobile-sheet-handle: #ccc;
}
