/* ==========================================================================
   GearGen-3D Responsive Stylesheet
   Desktop (>=1024px) 3-Panel Workspace & Mobile (<1024px) Bottom Nav with Drawers
   ========================================================================== */

/* ==========================================================================
   1. Desktop Mode (min-width: 1024px)
   ========================================================================== */
@media (min-width: 1024px) {
    /* A swipe interrupted on touch can leave an inline transform on a drawer. */
    .workspace-panel {
        transform: none !important;
    }
}

/* ==========================================================================
   2. Mobile & Tablet Mode (max-width: 1023px)
   ========================================================================== */
@media (max-width: 1023px) {
    html, body {
        overflow: hidden;
    }

    .top-bar {
        padding: 0 12px;
    }

    .branding-tagline {
        display: none;
    }

    .menu-bar {
        gap: 0;
    }

    .menu-btn {
        padding: 6px 8px;
        font-size: 0.8rem;
    }

    .quick-btn span {
        display: none;
    }

    /* Fullscreen Viewport Canvas with Absolute Overlays */
    .workspace-layout {
        display: block;
        position: relative;
        width: 100vw;
        height: calc(100vh - var(--header-height) - 60px);
        padding: 0;
        overflow: hidden;
    }

    .viewport-panel {
        width: 100%;
        height: 100%;
        border: none;
        border-radius: 0;
    }

    /* Left Sidebar as Sliding Drawer */
    #left_sidebar {
        position: fixed;
        bottom: 60px;
        left: 0;
        width: 100%;
        max-height: 80vh;
        height: 75vh;
        background: var(--background-panel);
        border: 1px solid var(--border);
        border-bottom: none;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.5);
        z-index: 600;
        transform: translateY(105%);
        transition: transform 0.28s cubic-bezier(0.33, 1, 0.68, 1);
        display: flex;
        flex-direction: column;
    }

    #left_sidebar.drawer-open {
        transform: translateY(0);
    }

    /* Right Sidebar as Sliding Drawer */
    #right_sidebar {
        position: fixed;
        bottom: 60px;
        right: 0;
        width: 100%;
        max-height: 80vh;
        height: 75vh;
        background: var(--background-panel);
        border: 1px solid var(--border);
        border-bottom: none;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.5);
        z-index: 600;
        transform: translateY(105%);
        transition: transform 0.28s cubic-bezier(0.33, 1, 0.68, 1);
        display: flex;
        flex-direction: column;
    }

    #right_sidebar.drawer-open {
        transform: translateY(0);
    }

    /* Drawer Top Handle for Swipe Down Gesture */
    .mobile-drawer-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 16px;
        border-bottom: 1px solid var(--border-subtle);
        background: rgba(0, 0, 0, 0.2);
        cursor: grab;
        touch-action: none;
    }

    .mobile-drawer-handle {
        width: 44px;
        height: 5px;
        border-radius: var(--radius-full);
        background: var(--border);
        margin: 0 auto;
    }

    .mobile-drawer-close {
        background: transparent;
        border: none;
        color: var(--text-secondary);
        font-size: 1rem;
        cursor: pointer;
        padding: 4px;
    }

    /* Backdrop Overlay */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(15, 23, 42, 0.6);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 550;
        opacity: 0;
        transition: opacity var(--transition-fast);
    }

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

    /* Bottom Navigation Bar (Height: 60px) */
    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100vw;
        height: 60px;
        background: var(--background-panel);
        border-top: 1px solid var(--border);
        z-index: 700;
        justify-content: space-around;
        align-items: center;
        user-select: none;
    }

    .nav-item {
        flex: 1;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        background: transparent;
        border: none;
        color: var(--text-secondary);
        font-size: 0.72rem;
        font-weight: 500;
        cursor: pointer;
        transition: color var(--transition-fast);
    }

    .nav-item i {
        font-size: 1.15rem;
    }

    .nav-item.active {
        color: var(--accent-primary);
    }

    /* Floating Toolbar Mobile Compactness */
    .floating-toolbar {
        top: 10px;
        padding: 3px;
        max-width: 95vw;
        overflow-x: auto;
    }

    .floating-btn {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .mesh-statistics-overlay {
        bottom: 10px;
        left: 10px;
        padding: 6px 10px;
        gap: 10px;
    }

    .stat-label {
        font-size: 0.6rem;
    }

    .stat-value {
        font-size: 0.75rem;
    }
}
