/* =========================================
   Mobile Navigation - Responsive Menu System
   Used by all image tools
   ========================================= */

/* Mobile Menu Button */
.mobile-menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--border-color, #3a476a);
    background: var(--bg-tertiary, #1a1a2e);
    color: var(--text-primary, #ffffff);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    z-index: 10001;
}

.mobile-menu-toggle:hover {
    background: var(--primary-blue, #1b98e0);
    border-color: var(--primary-blue, #1b98e0);
    color: #fff;
}

/* Mobile Overlay */
.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-nav-overlay.visible {
    display: block;
    opacity: 1;
}

/* Mobile Nav Panel */
.mobile-nav-panel {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    max-width: 85vw;
    height: 100%;
    background: var(--bg-secondary, #121220);
    border-left: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
    z-index: 10000;
    transition: right 0.3s ease;
    overflow-y: auto;
    padding: 80px 25px 30px;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
}

.mobile-nav-panel.open {
    right: 0;
}

.mobile-nav-panel .mobile-nav-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-color, #3a476a);
    background: var(--bg-tertiary, #1a1a2e);
    color: var(--text-primary, #ffffff);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.mobile-nav-panel .mobile-nav-close:hover {
    background: #e74c3c;
    border-color: #e74c3c;
    color: #fff;
}

.mobile-nav-panel .mobile-nav-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mobile-nav-panel .mobile-nav-links li {
    margin-bottom: 6px;
}

.mobile-nav-panel .mobile-nav-links a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 12px;
    color: var(--text-secondary, #e0e0e0);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.mobile-nav-panel .mobile-nav-links a:hover,
.mobile-nav-panel .mobile-nav-links a.active {
    background: rgba(27, 152, 224, 0.12);
    color: var(--primary-blue, #1b98e0);
    border-color: rgba(27, 152, 224, 0.3);
}

.mobile-nav-panel .mobile-nav-links a i {
    width: 22px;
    text-align: center;
    font-size: 1.1rem;
}

.mobile-nav-panel .mobile-nav-divider {
    height: 1px;
    background: var(--border-color, #3a476a);
    margin: 15px 0;
}

/* Light theme adjustments */
[data-theme="light"] .mobile-nav-panel {
    background: #ffffff;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .mobile-nav-overlay {
    background: rgba(0, 0, 0, 0.3);
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
        order: 99;
        margin-left: auto;
    }

    .header-container {
        flex-wrap: nowrap;
    }

    .header-right {
        margin-left: auto;
        gap: 10px;
    }

    .header-right nav {
        display: none;
    }

    .u-nav-list {
        display: none;
    }

    /* Sidebar hidden on mobile */
    .sidebar {
        display: none;
    }

    .tool-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .mobile-menu-toggle {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
    }
}

/* Fix alignment issues: Center tool header descriptions and upload area texts */
.tool-header p,
.upload-area p,
.upload-content p {
    text-align: center !important;
}


/* Responsive Chatbot Placement Fix: Reposition chatbot button to the header on mobile devices */
@media (max-width: 768px) {
    /*
     * Equal-spacing layout for 3 header icons: [Moon] [Robot] [Hamburger]
     * Each button is 42px wide. Gap between each = 12px.
     * Hamburger: right: 15px (header padding) -> left edge at 57px from screen right
     * Chatbot  : right: 69px -> left edge at 111px from screen right
     * Theme    : right edge at 123px -> header-right margin-right = 123 - 15(padding) = 108px
     */
    .mobile-menu-toggle {
        order: 100 !important;
        flex-shrink: 0 !important;
    }
    
    .header-right {
        gap: 0 !important;
        margin-right: 108px !important;
    }
    
    #chatbot-toggle {
        position: fixed !important;
        top: 15px !important;
        bottom: auto !important;
        right: 69px !important;
        width: 42px !important;
        height: 42px !important;
        font-size: 1.1rem !important;
        z-index: 10000 !important;
        background: var(--bg-tertiary, #1a1a2e) !important;
        border: 1px solid var(--border-color, #3a476a) !important;
        color: var(--text-primary, #ffffff) !important;
        box-shadow: none !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    #chatbot-toggle:hover {
        background: var(--primary-blue, #1b98e0) !important;
        border-color: var(--primary-blue, #1b98e0) !important;
        color: #fff !important;
    }
    
    #chatbot-container {
        position: fixed !important;
        top: 75px !important;
        bottom: auto !important;
        right: 15px !important;
        left: 15px !important;
        width: auto !important;
        max-width: none !important;
        height: 60vh !important;
        max-height: 400px !important;
        z-index: 10000 !important;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4) !important;
    }
}

@media (max-width: 480px) {
    /*
     * Equal-spacing on small phones. Each button 38px wide. Gap = 10px.
     * Hamburger: right: 12px -> left edge at 50px
     * Chatbot  : right: 60px -> left edge at 98px
     * Theme    : right edge at 108px -> header-right margin-right = 108 - 12 = 96px
     */
    .header-right {
        margin-right: 96px !important;
    }

    #chatbot-toggle {
        top: 13px !important;
        right: 60px !important;
        width: 38px !important;
        height: 38px !important;
        font-size: 1rem !important;
    }
    
    #chatbot-container {
        top: 68px !important;
        right: 10px !important;
        left: 10px !important;
        height: 55vh !important;
    }
}
