/* 
   PixelCeylon - Compressed Mobile UI (Compact & Refined)
   Only active on screens <= 768px
*/

/* Hide mobile dock elements on desktop */
@media (min-width: 769px) {
    .mobile-dock, .mobile-category-bar, .mobile-dock-panel {
        display: none !important;
    }
}

@media (max-width: 768px) {
    /* Hide non-essential PC elements */
    .shortcut-list, 
    .help-panel, 
    .mini-map-wrapper,
    #landing-nav .nav-links {
        display: none !important;
    }

    /* Hide standard sidebars by default, managed by grouping logic */
    .tools-controls, .color-controls, .view-controls {
        display: none !important;
    }

    /* Adjust Landing Page for Mobile */
    .hero h1 { font-size: 28px !important; }
    .hero-btns { flex-direction: column !important; width: 100% !important; }
    .btn-primary, .btn-secondary { height: 44px !important; font-size: 14px !important; }

    /* Mobile Interaction Optimization */
    #pixel-canvas { touch-action: none; }

    /* Reposition Stats to the TOP for Mobile - SMALLER */
    .stats-group {
        display: none !important;
    }
    .stats-panel {
        background: none !important;
        backdrop-filter: none !important;
        padding: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        border: none !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 2px !important; /* ULTRA COMPACT GAP */
        width: 100% !important;
    }
    .online-stat {
        font-size: 9px !important;
        margin: 0 !important;
        color: #64748b !important;
        font-weight: 700 !important;
        background: rgba(255,255,255,0.7);
        padding: 4px 12px !important; /* COMPACT PADDING */
        border-radius: 10px;
        border: 1px solid rgba(0,0,0,0.03);
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        text-transform: uppercase;
        letter-spacing: 0.3px;
    }

    
    .sync-stat {
        font-size: 8px !important;
        color: #94a3b8 !important;
        display: flex !important;
        align-items: center !important;
        gap: 4px !important;
        opacity: 0.6;
    }
    .sync-stat button {
        background: none;
        border: none;
        color: var(--primary);
        cursor: pointer;
        font-size: 8px;
        padding: 0;
    }

    .online-stat #online-count {
        font-size: 24px !important;
        color: #10b981;
        font-weight: 800 !important;
        text-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
    }
    .coord-stat {
        display: flex !important;
        font-size: 9px !important;
        margin: 0 !important;
        color: #94a3b8 !important;
        gap: 4px !important;
        font-weight: 700 !important;
        background: #f8fafc;
        padding: 2px 8px !important; /* COMPACT PADDING */
        border-radius: 30px !important;
        border: 1px solid #e2e8f0;
    }

    .coord-stat span {
        color: #475569 !important;
        font-weight: 800 !important;
    }

    .stats-panel i { font-size: 12px !important; width: auto; color: #64748b; }

    /* Hide redundant elements in stats on mobile */
    .stats-panel #debug-status,
    .stats-panel #force-sync-btn {
        display: none !important;
    }

    /* Cooldown Badge adjustment - SMALLER */
    .status-panel.center-status {
        top: 10px !important;
        right: 10px !important;
        left: auto !important;
        transform: none !important;
        width: auto !important;
        padding: 4px 8px !important;
        font-size: 9px !important;
        z-index: 10000 !important;
    }

    /* Category Bar (The "Compressor") - COMPACT */
    .mobile-category-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 48px; /* Reduced from 56px */
        background: #ffffff;
        display: flex !important;
        justify-content: space-around;
        align-items: stretch;
        z-index: 10005;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
        border-top: 1px solid #f1f5f9;
        padding-bottom: env(safe-area-inset-bottom);
        overflow: visible;
    }

    .cat-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: #94a3b8;
        font-size: 8px; /* Reduced from 9px */
        font-weight: 500;
        gap: 2px;
        cursor: pointer;
        padding-top: 2px;
        outline: none !important;
        -webkit-tap-highlight-color: transparent;
        position: relative;
    }

    .cat-btn span {
        transition: transform 0.2s ease, opacity 0.2s ease;
    }

    .cat-btn.active span {
        opacity: 0.7;
        transform: scale(0.9);
    }

    /* Mini Coordinate Display at TOP LEFT for Mobile */
    .mobile-coords-mini {
        position: fixed;
        top: 12px;
        left: 12px;
        font-size: 11px;
        font-family: 'Inter', sans-serif;
        font-weight: 800;
        color: white;
        background: rgba(15, 23, 42, 0.75); /* Modern dark translucent */
        padding: 5px 12px;
        border-radius: 20px;
        pointer-events: none;
        display: none;
        white-space: nowrap;
        box-shadow: 0 4px 15px rgba(0,0,0,0.15);
        backdrop-filter: blur(8px);
        border: 1px solid rgba(255,255,255,0.1);
        z-index: 10006;
        letter-spacing: 0.5px;
    }

    /* Show coordinates on mobile by default */
    #app .mobile-coords-mini {
        display: block;
    }

    .cat-btn i { font-size: 16px; } /* Reduced from 18px */
    .cat-btn.active { color: #3b82f6; background: #f8fafc; }

    /* Pop-up containers for the tools/colors when active - COMPACT */
    .mobile-dock-panel {
        position: fixed;
        bottom: 48px;
        left: 8px;
        right: 8px;
        background: #ffffff;
        border-radius: 16px 16px 0 0;
        padding: 10px 8px; /* Reduced from 16px 12px */
        display: none;
        flex-direction: column;
        align-items: center;
        gap: 8px; /* Reduced from 12px */
        z-index: 10004;
        box-shadow: 0 -8px 25px rgba(0,0,0,0.08);
        max-height: 40vh;
        overflow-y: auto;
        border: 1px solid #f1f5f9;
    }

    .mobile-dock-panel.active { display: flex !important; }

    .mobile-dock-panel .color-controls,
    .mobile-dock-panel .tools-controls,
    .mobile-dock-panel .view-controls,
    .mobile-dock-panel .stats-panel {
        display: flex !important;
        position: static !important;
        transform: none !important;
        background: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        width: 100% !important;
        justify-content: center !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

    .mobile-dock-panel .color-controls { flex-wrap: wrap; gap: 6px; } /* Reduced gap from 10px */
    .mobile-dock-panel .tools-controls { flex-direction: row !important; gap: 12px; width: auto !important; } /* Reduced gap from 20px */

    .tools-controls .tool-button {
        width: 38px !important; /* Reduced from 44px */
        height: 38px !important;
        background: #f8fafc !important;
        border-radius: 8px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 16px !important; /* Reduced from 18px */
        border: 1px solid #e2e8f0 !important;
        color: #475569 !important; /* Ensure icons are visible */
    }
    
    .tools-controls .tool-button.active {
        background: #3b82f6 !important;
        color: white !important;
        border-color: #3b82f6 !important;
    }

    /* Chat UI adjustments - FIXED POSITION */
    .chat-container {
        position: fixed !important;
        right: 0 !important;
        bottom: 0 !important; 
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: 100% !important;
        pointer-events: none;
        z-index: 20000;
    }

    .chat-toggle { display: none !important; }

    .chat-panel {
        position: absolute !important;
        width: 100% !important;
        height: calc(100% - 48px) !important; /* Match ultra-compact bar */
        top: auto !important;
        bottom: 48px !important; /* FIXED: Position above bar */
        left: 0 !important;
        right: 0 !important;
        border-radius: 0 !important;
        pointer-events: auto;
        transform: translateY(110%);
        transition: transform 0.3s ease-out;
        visibility: hidden;
        background: #ffffff !important;
        border-top: 1px solid #eee;
    }

    .chat-panel.show {
        transform: translateY(0);
        visibility: visible;
    }

    /* Modals for mobile */
    .wa-profile-card, .wa-dm-card { width: 100% !important; height: 100% !important; border-radius: 0 !important; top: 0 !important; }
}
