/* =================================================================
   Mobile Bottom Navigation - CritKeepers
   Single navigation bar with 3 visible buttons + overflow menu
   ================================================================= */

/* Hide mobile nav on desktop */
.mobile-bottom-nav {
    display: none;
}

/* Safe area support for notches and system nav bars */
/* For mobile BROWSERS - Android app handles padding natively via Scaffold */
.mobile-bottom-nav {
    /* Default fallback for gesture nav bars (mobile browsers) */
    padding-bottom: 12px;
}

/* Android app: Native Scaffold handles bottom padding */
.mobile-app .mobile-bottom-nav {
    padding-bottom: 0;
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .mobile-bottom-nav {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    /* Android app still uses native padding */
    .mobile-app .mobile-bottom-nav {
        padding-bottom: 0;
    }
}

/* Safe area support for top (status bar, notch) - handled in base.html with Android fallback */

/* Mobile-only styles */
@media (max-width: 768px) {
    /* Show mobile bottom nav */
    .mobile-bottom-nav {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: var(--bg-primary);
        border-top: 1px solid var(--border-subtle);
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.3);
    }

    /* Hide page footer only on pages with mobile bottom nav (campaign page) */
    body:has(.mobile-bottom-nav) .footer {
        display: none !important;
    }

    /* Hide desktop tab navigation on mobile */
    .tab-nav {
        display: none !important;
    }

    /* Hide desktop sidebar navigation on mobile */
    .tab-sidebar {
        display: none !important;
    }

    /* Adjust main content padding for bottom nav + safe area */
    .main-content {
        padding-bottom: 112px !important;
    }

    /* Android app: Native Scaffold handles bottom padding, less CSS padding needed */
    .mobile-app .main-content {
        padding-bottom: 80px !important;
    }

    @supports (padding-bottom: env(safe-area-inset-bottom)) {
        .main-content {
            padding-bottom: calc(100px + max(12px, env(safe-area-inset-bottom, 0px))) !important;
        }

        .mobile-app .main-content {
            padding-bottom: 80px !important;
        }
    }

    /* Also adjust tab main content */
    .tab-main-content {
        padding-bottom: 20px;
    }

    /* Primary Navigation Bar */
    .mobile-primary-bar {
        display: flex;
        justify-content: space-around;
        align-items: stretch;
        background: var(--bg-primary);
        padding: 8px 4px 12px 4px;
    }

    .mobile-nav-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 8px 4px;
        background: transparent;
        border: none;
        color: var(--text-muted);
        font-family: var(--font-body);
        font-size: 0.65rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s ease;
        border-radius: var(--radius-sm);
        min-height: 52px;
        max-width: 80px;
    }

    .mobile-nav-btn:hover {
        background: var(--bg-hover);
        color: var(--text-primary);
    }

    .mobile-nav-btn.active {
        color: var(--accent-gold);
    }

    .mobile-nav-btn.active .mobile-nav-icon {
        color: var(--accent-gold);
    }

    .mobile-nav-icon {
        width: 24px;
        height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-nav-icon svg {
        width: 22px;
        height: 22px;
        stroke: currentColor;
        stroke-width: 2;
        fill: none;
    }

    .mobile-nav-label {
        font-size: 0.65rem;
        text-align: center;
        line-height: 1.2;
        max-width: 70px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Overflow button in nav bar */
    .mobile-nav-btn.overflow-btn {
        color: var(--text-muted);
    }

    .mobile-nav-btn.overflow-btn.has-active {
        color: var(--accent-gold);
    }

    /* Overflow Menu (slide-up panel) */
    .mobile-overflow-menu {
        display: none;
        position: absolute;
        bottom: 100%;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border-subtle);
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
        padding: 12px 16px 16px 16px;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
        /* Auto height - will size to fit content */
        min-height: 200px;
    }

    .mobile-overflow-menu.visible {
        display: flex;
        flex-direction: column;
        animation: slideUp 0.2s ease-out;
    }

    @keyframes slideUp {
        from {
            opacity: 0;
            transform: translateY(8px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .mobile-overflow-menu-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 8px;
        padding-bottom: 6px;
        border-bottom: 1px solid var(--border-subtle);
        flex-shrink: 0;
    }

    .mobile-overflow-menu-title {
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .mobile-overflow-close {
        background: transparent;
        border: none;
        color: var(--text-muted);
        font-size: 1.4rem;
        cursor: pointer;
        padding: 4px 8px;
        line-height: 1;
        border-radius: var(--radius-sm);
    }

    .mobile-overflow-close:hover {
        color: var(--text-primary);
        background: var(--bg-hover);
    }

    .mobile-overflow-items {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .mobile-overflow-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 16px;
        background: var(--bg-elevated);
        border: 1px solid var(--border-subtle);
        color: var(--text-secondary);
        font-family: var(--font-body);
        font-size: 0.9rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s ease;
        border-radius: var(--radius-sm);
        text-align: left;
        width: 100%;
    }

    .mobile-overflow-item:hover {
        background: var(--bg-hover);
        border-color: var(--border-soft);
        color: var(--text-primary);
    }

    .mobile-overflow-item.active {
        background: var(--accent-gold-glow);
        border-color: var(--accent-gold);
        color: var(--accent-gold);
    }

    .mobile-overflow-item svg {
        width: 18px;
        height: 18px;
        stroke: currentColor;
        stroke-width: 2;
        fill: none;
        flex-shrink: 0;
    }

    .mobile-overflow-icon {
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .mobile-overflow-icon svg {
        width: 18px;
        height: 18px;
        stroke: currentColor;
        stroke-width: 2;
        fill: none;
    }

    .mobile-overflow-label {
        flex: 1;
    }

    .mobile-overflow-item-label {
        flex: 1;
    }

    /* Backdrop for overflow menu */
    .mobile-nav-backdrop {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .mobile-nav-backdrop.visible {
        display: block;
    }

    /* Badge styling for mobile nav */
    .mobile-nav-badge {
        background: var(--bg-hover);
        color: var(--text-muted);
        padding: 2px 6px;
        border-radius: 8px;
        font-size: 0.65rem;
        margin-left: 4px;
    }

    .mobile-nav-btn.active .mobile-nav-badge {
        background: var(--accent-gold);
        color: var(--bg-deep);
    }

    .mobile-overflow-item .mobile-nav-badge {
        font-size: 0.7rem;
        padding: 2px 8px;
    }

    .mobile-overflow-item.active .mobile-nav-badge {
        background: var(--accent-gold);
        color: var(--bg-deep);
    }
}

/* =================================================================
   Mobile App Dashboard
   ================================================================= */

/* Mobile app only content - hidden by default using opacity (NOT display:none)
   This ensures the element remains in the DOM tree for JavaScript access */
.mobile-app-only {
    opacity: 0;
    height: 0;
    overflow: hidden;
    pointer-events: none;
    position: absolute;
}

/* Show when visible class is added (JS control) */
.mobile-app-only.mobile-visible {
    opacity: 1 !important;
    height: auto !important;
    overflow: visible !important;
    pointer-events: auto !important;
    position: static !important;
}

/* Also show automatically when in mobile app context (CSS fallback) */
.mobile-app #mobile-dashboard {
    opacity: 1 !important;
    height: auto !important;
    overflow: visible !important;
    pointer-events: auto !important;
    position: static !important;
}

/* Hide dashboard when navigated away (JS adds this class) */
.mobile-app #mobile-dashboard.mobile-hidden {
    opacity: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
    position: absolute !important;
}

.mobile-dashboard {
    padding: 20px 16px;
    min-height: calc(100vh - 160px);
}

.mobile-dashboard-header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.mobile-dashboard-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--accent-gold);
    margin: 0 0 4px 0;
}

.mobile-dashboard-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

.mobile-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.mobile-dashboard-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.mobile-dashboard-card:hover,
.mobile-dashboard-card:active {
    background: var(--bg-elevated);
    border-color: var(--accent-gold);
    transform: translateY(-2px);
}

.dashboard-card-icon {
    width: 32px;
    height: 32px;
    color: var(--accent-gold);
}

.dashboard-card-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 1.5;
    fill: none;
}

.dashboard-card-count {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-bright);
    line-height: 1;
}

.dashboard-card-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* =================================================================
   Mobile App Table Column Hiding
   Hide less important columns to save space on mobile app
   ================================================================= */

.mobile-app .players-table th:nth-child(1),
.mobile-app .players-table td:nth-child(1),
.mobile-app .players-table th:nth-child(2),
.mobile-app .players-table td:nth-child(2),
.mobile-app .players-table th:nth-child(6),
.mobile-app .players-table td:nth-child(6) {
    display: none !important;
}

/* Hide Race and XP columns (already have hide-mobile class, but ensure it works in app) */
.mobile-app .hide-mobile {
    display: none !important;
}

/* NPCs table - hide less important columns */
.mobile-app #npcs-table th:nth-child(1),
.mobile-app #npcs-table td:nth-child(1) {
    display: none !important;
}

/* Enemies table - hide CR and Type on mobile app */
.mobile-app .enemies-table th:nth-child(3),
.mobile-app .enemies-table td:nth-child(3),
.mobile-app .enemies-table th:nth-child(4),
.mobile-app .enemies-table td:nth-child(4) {
    display: none !important;
}

/* Sessions table - keep compact */
.mobile-app .sessions-table th:nth-child(3),
.mobile-app .sessions-table td:nth-child(3) {
    display: none !important;
}

/* Make tables more compact on mobile app */
.mobile-app table {
    font-size: 0.85rem;
}

.mobile-app table th,
.mobile-app table td {
    padding: 8px 6px;
}

/* =================================================================
   MOBILE APP - BOTTOM NAV FOR ALL SCREEN SIZES (Fold 6, tablets)
   These rules ensure bottom nav shows on Android app at ANY width
   ================================================================= */

/* Show bottom nav on mobile app regardless of screen width */
.mobile-app .mobile-bottom-nav {
    display: block !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1000 !important;
    background: var(--bg-primary) !important;
    border-top: 1px solid var(--border-subtle) !important;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.3) !important;
    padding-bottom: 0 !important;
}

/* Hide desktop navigation on mobile app */
.mobile-app .tab-nav {
    display: none !important;
}

.mobile-app .tab-sidebar {
    display: none !important;
}

.mobile-app .footer {
    display: none !important;
}

/* Primary bar layout */
.mobile-app .mobile-primary-bar {
    display: flex !important;
    justify-content: space-around !important;
    align-items: stretch !important;
    padding: 8px 4px 12px 4px !important;
}

/* Nav buttons */
.mobile-app .mobile-nav-btn {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    padding: 8px 4px !important;
    background: transparent !important;
    border: none !important;
    color: var(--text-muted) !important;
    font-size: 0.65rem !important;
    min-height: 52px !important;
    max-width: 80px !important;
    cursor: pointer !important;
}

.mobile-app .mobile-nav-btn.active {
    color: var(--accent-gold) !important;
}

.mobile-app .mobile-nav-btn.active .mobile-nav-icon {
    color: var(--accent-gold) !important;
}

.mobile-app .mobile-nav-btn:hover {
    background: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

.mobile-app .mobile-nav-btn.overflow-btn.has-active {
    color: var(--accent-gold) !important;
}

.mobile-app .mobile-nav-icon {
    width: 24px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: inherit !important;
}

.mobile-app .mobile-nav-icon svg {
    width: 22px !important;
    height: 22px !important;
    stroke: currentColor !important;
    fill: none !important;
}

.mobile-app .mobile-nav-btn.active .mobile-nav-icon svg {
    stroke: var(--accent-gold) !important;
}
}

.mobile-app .mobile-nav-icon svg {
    width: 22px !important;
    height: 22px !important;
}

/* Overflow menu */
.mobile-app .mobile-overflow-menu {
    position: absolute !important;
    bottom: 100% !important;
    left: 0 !important;
    right: 0 !important;
    background: var(--bg-secondary) !important;
    border-top: 1px solid var(--border-subtle) !important;
    border-radius: 16px 16px 0 0 !important;
    padding: 12px 16px 16px !important;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4) !important;
}

.mobile-app .mobile-overflow-menu:not(.visible) {
    display: none !important;
}

.mobile-app .mobile-overflow-menu.visible {
    display: flex !important;
    flex-direction: column !important;
}

.mobile-app .mobile-overflow-items {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
}

.mobile-app .mobile-overflow-item {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 14px 16px !important;
    background: var(--bg-elevated) !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--text-secondary) !important;
    font-size: 0.9rem !important;
    cursor: pointer !important;
}

.mobile-app .mobile-overflow-item.active {
    border-color: var(--accent-gold) !important;
    color: var(--accent-gold) !important;
}

/* Backdrop */
.mobile-app .mobile-nav-backdrop:not(.visible) {
    display: none !important;
}

.mobile-app .mobile-nav-backdrop.visible {
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(0, 0, 0, 0.5) !important;
    z-index: 999 !important;
}
