/**
 * SOLIUS Mobile App Frame - Phase 1
 * Based on Figma Design Specifications (October 2025)
 * 
 * Mobile Breakpoint: ≤768px
 * Desktop Preserved: ≥1025px
 * 
 * Features:
 * - 5-item bottom navigation (Home, Chat, Calls, Games, Bots)
 * - Profile accessed via top-right avatar (NOT in bottom nav)
 * - Fixed header (logo left, bell + avatar right)
 * - Vertical card stacking (single column)
 * - Two-screen chat system
 */

/* ============================================
   MOBILE LAYOUT FOUNDATION
   ============================================ */

@media (max-width: 768px) {
    /* Hide desktop sidebar and header completely */
    .app-sidebar {
        display: none !important;
    }
    
    .app-header {
        display: none !important;
    }
    
    /* App Frame - Account for mobile header (60px) and bottom nav (64px) */
    .app-frame {
        display: flex;
        flex-direction: row;
        width: 100vw;
        height: calc(100vh - 124px);
        background: #00091E;
        margin: 0;
        padding: 0;
        position: fixed;
        top: 60px;
    }
    
    /* App Container - Full viewport mobile */
    .app-container {
        display: flex;
        flex-direction: column;
        width: 100vw;
        height: 100vh;
        overflow: hidden;
        position: fixed;
        top: 0;
        left: 0;
        background: #00091E;
    }
    
    /* Main Content Area - Scrollable between header and bottom nav */
    .app-main {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        padding-top: 60px; /* Header height */
        padding-bottom: 64px; /* Bottom nav height (no home indicator) */
        background: #00091E;
        width: 100%;
    }
    
    /* Remove padding from app-content-area on mobile */
    .app-content-area {
        padding: 0 !important;
    }
}

/* ============================================
   MOBILE HEADER (Top Fixed)
   ============================================ */

@media (max-width: 768px) {
    .mobile-app-header {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 0px 16px;
        gap: 8px;
        
        width: 100%;
        height: 60px;
        
        background: #00091E;
        border-bottom: 1px solid rgba(85, 93, 255, 0.1);
        
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 999;
    }
    
    /* Logo (Left) - Solius Star Icon */
    .mobile-header-logo {
        width: 40px;
        height: 40px;
        flex: none;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: transform 0.2s ease, opacity 0.2s ease;
    }
    
    .mobile-header-logo:hover {
        transform: scale(1.05); /* Subtle scale on hover */
        opacity: 0.9;
    }
    
    .mobile-header-logo img {
        width: 40px;
        height: 40px;
        object-fit: contain;
    }
    
    /* Header Right (SOL + Bell + Avatar) */
    .mobile-header-right {
        display: flex;
        flex-direction: row;
        justify-content: flex-end;
        align-items: center;
        padding: 0px;
        gap: 12px;
        
        width: auto;
        height: 40px;
        flex: none;
    }
    
    /* SOL Balance Display (Mobile) */
    .mobile-header-right .sol-balance-display {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 6px;
        padding: 0;
    }
    
    .mobile-header-right .sol-icon {
        width: 20px;
        height: 20px;
        object-fit: contain;
    }
    
    .mobile-header-right .sol-amount {
        font-family: 'Montserrat', sans-serif;
        font-style: normal;
        font-weight: 500;
        font-size: 14px;
        line-height: 20px;
        color: #536285;
    }
    
    /* Bell Icon Button - Agent #2 Touch Target Fix (Oct 25, 2025) */
    .mobile-bell-btn {
        min-width: 44px; /* iOS minimum touch target */
        min-height: 44px; /* iOS minimum touch target */
        width: 44px;
        height: 44px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        display: flex !important; /* Force visibility */
        align-items: center;
        justify-content: center;
        transition: transform 0.2s;
        border-radius: 50%;
        position: relative;
        z-index: 100; /* Above other mobile header elements */
        -webkit-tap-highlight-color: transparent; /* Remove iOS tap highlight */
    }
    
    .mobile-bell-btn:active {
        transform: scale(0.9);
    }
    
    .mobile-bell-btn img {
        width: 24px;
        height: 24px;
        object-fit: contain;
    }
    
    /* Bug Report Icon Button (BroJack Agent #12 - Oct 28, 2025) */
    .mobile-bug-report-btn {
        min-width: 44px;
        min-height: 44px;
        width: 44px;
        height: 44px;
        background: transparent;
        border: none;
        border-radius: 50%;
        cursor: pointer;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 20px;
        position: relative;
        z-index: 100;
        -webkit-tap-highlight-color: transparent;
    }
    
    .mobile-bug-report-btn:active {
        transform: scale(0.9);
        background: rgba(255, 255, 255, 0.1);
    }
    
    /* Profile Avatar Button */
    .mobile-avatar-btn {
        width: 44px;
        height: 44px;
        background: #FCB9FF;
        border-radius: 100px;
        border: none;
        cursor: pointer;
        overflow: hidden;
        padding: 0;
        transition: transform 0.2s;
    }
    
    .mobile-avatar-btn:active {
        transform: scale(0.95);
    }
    
    .mobile-avatar-btn img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    /* Profile Avatar Circle - Agent #11 Fix (Oct 27, 2025) */
    /* Force 44px × 44px on all profile avatars, remove scale effect */
    .profile-avatar-circle {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        transform: scale(1) !important;
        transition: none !important;
    }
    
    .profile-avatar-circle:hover {
        transform: scale(1) !important; /* No hover scale on mobile */
    }
    
    /* Page Title (e.g., "Overview", "Chat", "Profile") */
    .mobile-page-title {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        padding: 0px 16px;
        gap: 8px;
        
        width: 100%;
        min-height: auto;
        margin-top: 16px;
        margin-bottom: 16px;
    }
    
    .mobile-page-title h1 {
        font-family: 'Montserrat', sans-serif;
        font-style: normal;
        font-weight: 600;
        font-size: 24px;
        line-height: 32px;
        color: #FFFFFF;
        margin: 0;
    }
}

/* ============================================
   BOTTOM NAVIGATION (Fixed Bottom)
   ============================================ */

@media (max-width: 768px) {
    .mobile-bottom-nav-wrapper {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        padding: 0px;
        padding-bottom: 16px; /* Safe area for home indicator - Agent #7 */
        padding-bottom: max(16px, env(safe-area-inset-bottom)); /* iOS safe area with fallback */
        
        width: 100%;
        height: calc(64px + 16px); /* Account for bottom padding */
        height: calc(64px + max(16px, env(safe-area-inset-bottom))); /* Dynamic height */
        
        background: #141626; /* Match bottom nav background - Agent #7 */
        
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1000;
    }
    
    /* Tab Bar (Main Navigation) */
    .mobile-bottom-nav {
        box-sizing: border-box;
        
        width: 100%;
        height: 64px;
        
        background: #141626;
        border-top: 1px solid #1C1C1C;
        
        display: flex;
        flex-direction: row;
        align-items: flex-end;
        justify-content: center;
        padding: 0px;
        
        flex: none;
        order: 0;
    }
    
    /* Content Container (6 nav items centered - Agent #7 updated) */
    .mobile-nav-content {
        display: flex;
        flex-direction: row;
        align-items: flex-end;
        justify-content: center; /* Center nav items horizontally - Agent #11 */
        padding: 0; /* No padding for tight fit on small screens */
        
        /* Responsive width instead of fixed */
        width: 100%;
        max-width: 480px; /* Maximum width on larger phones */
        height: 52px;
        
        /* Proper centering without fixed width */
        position: absolute;
        left: 50%;
        transform: translateX(-50%); /* Center horizontally */
        top: calc(50% - 52px / 2);
    }
    
    /* Navigation Item (6 items: Home, Trade, Chat, Calls, Games, Bots - Agent #7) */
    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 0px 1px;
        gap: 4px;
        
        width: 65.6px;
        height: 52px;
        
        border-radius: 12px;
        cursor: pointer;
        transition: all 0.2s;
        
        flex: none;
        position: relative;
    }
    
    /* Icon Container (Frame 25) */
    .mobile-nav-item .nav-icon-container {
        width: 63.6px;
        height: 32px;
        border-radius: 40px;
        
        display: flex;
        align-items: center;
        justify-content: center;
        
        flex: none;
        order: 0;
        align-self: stretch;
    }
    
    /* Icon SVG */
    .mobile-nav-item .nav-icon {
        width: 24px;
        height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Icon image - using asset files */
    .mobile-nav-item .nav-icon-img {
        width: 24px;
        height: 24px;
        object-fit: contain;
        /* Default color (inactive) - exact gray #536285 from Figma */
        filter: brightness(0) saturate(100%) invert(38%) sepia(9%) saturate(1247%) hue-rotate(195deg) brightness(92%) contrast(88%);
    }
    
    /* Icon color - Active (saturated for vibrant look) */
    .mobile-nav-item.active .nav-icon-img {
        filter: saturate(2.2); /* 📱 POLISH: Boost saturation for active state */
    }
    
    /* Active background for icon container */
    .mobile-nav-item.active .nav-icon-container {
        background: transparent;
    }
    
    /* Label */
    .mobile-nav-item .nav-label {
        width: 63.6px;
        height: 16px;
        
        font-family: 'Poppins', sans-serif;
        font-style: normal;
        font-weight: 400;
        font-size: 12px;
        line-height: 16px;
        text-align: center;
        
        /* Exact gray from Figma */
        color: #536285;
        
        flex: none;
        order: 1;
        align-self: stretch;
    }
    
    /* Label - Active (exact purple from Figma) */
    .mobile-nav-item.active .nav-label {
        color: #555DFF;
    }
    
    /* Unread Badge (Chat only) - Figma exact specs */
    .mobile-nav-item .unread-badge {
        box-sizing: border-box;
        
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 2px 4px;
        gap: 8px;
        
        position: absolute;
        width: auto;
        min-width: 12px;
        height: 12px;
        left: 12px;
        top: 0px;
        
        background: #FF5558;
        border: 1px solid #00091E;
        border-radius: 100px;
        
        font-family: 'Montserrat', sans-serif;
        font-style: normal;
        font-weight: 400;
        font-size: 6px;
        line-height: 8px;
        color: #FFFFFF;
        
        text-align: center;
        display: none; /* Hidden by default */
    }
    
    .mobile-nav-item .unread-badge.visible {
        display: flex;
    }
    
    /* Touch feedback */
    .mobile-nav-item:active {
        transform: scale(0.95);
        opacity: 0.8;
    }
}

/* ============================================
   SMALL DEVICES (Below 380px) - Agent #11
   ============================================ */

@media (max-width: 380px) {
    /* Make nav items 20% smaller for better fit on tiny screens */
    .mobile-nav-item {
        width: 52.48px; /* 65.6px * 0.8 = 52.48px */
    }
    
    .mobile-nav-item .nav-icon-img {
        width: 19.2px; /* 24px * 0.8 = 19.2px */
        height: 19.2px;
    }
}

/* ============================================
   HIDE MOBILE ELEMENTS ON DESKTOP
   ============================================ */

@media (min-width: 769px) {
    .mobile-app-header,
    .mobile-bottom-nav-wrapper,
    .mobile-bottom-nav,
    .mobile-page-title {
        display: none !important;
    }
}

