/* Mobile Responsive Styles for NodeBook */

/* Mobile breakpoint */
@media screen and (max-width: 768px) {
    
    /* CRITICAL: Force proper height on html and body */
    html {
        height: 100%;
        overflow: hidden;
    }
    
    body {
        height: 100%;
        min-height: 100vh;
        min-height: -webkit-fill-available;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    
    /* Hide ad banner and status bar on mobile */
    .ad-banner-container,
    .status-bar {
        display: none !important;
        height: 0 !important;
        min-height: 0 !important;
        max-height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden !important;
    }
    
    /* Hide minimap on mobile */
    .minimap-container {
        display: none !important;
    }
    
    /* Header adjustments */
    .header {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        height: 50px;
        min-height: 50px;
        max-height: 50px;
        padding: 0 10px;
        flex-wrap: nowrap;
        flex-shrink: 0;
        z-index: 1000;
    }
    
    .app-title {
        font-size: 16px;
    }
    
    /* Toolbar optimizations */
    .toolbar {
        display: flex;
        gap: 5px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .toolbar-btn {
        min-width: 36px;
        padding: 6px 8px;
    }
    
    .search-input {
        max-width: 100px;
        font-size: 12px;
    }
    
    /* CRITICAL: Main content must fill remaining space */
    .main-content {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        position: relative;
        min-height: 0;
        height: 0;
        overflow: hidden;
        padding-top: 50px;
    }
    
    /* LEFT SIDEBAR - compact when collapsed, full width when open */
    .left-sidebar {
        width: 45px !important;
        height: auto;
        max-height: 45px;
        min-height: 45px;
        overflow: hidden;
        border-right: none;
        border-bottom: none;
        transition: max-height 0.3s ease-in-out, width 0.3s ease-in-out;
        position: relative;
        z-index: 200;
        box-shadow: none;
        flex-shrink: 0;
        background-color: transparent;
    }
    
    .left-sidebar.mobile-open {
        width: 100% !important;
        max-height: 60vh;
        overflow-y: auto;
        background-color: white;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        border-bottom: 1px solid var(--border-color);
    }
    
    /* Mobile toggle button for left sidebar - compact icon only */
    .mobile-sidebar-toggle {
        display: flex !important;
        width: 45px;
        height: 45px;
        min-height: 45px;
        padding: 0;
        background-color: var(--dark-bg);
        color: white;
        border: none;
        border-bottom: 1px solid var(--border-color);
        border-right: 1px solid var(--border-color);
        cursor: pointer;
        font-size: 18px;
        justify-content: center;
        align-items: center;
        z-index: 201;
        position: relative;
        border-radius: 0 0 6px 0;
    }
    
    .mobile-sidebar-toggle:active {
        background-color: var(--hover-color);
    }
    
    /* Hide the text span, show only icon */
    .mobile-sidebar-toggle span:not(.toggle-icon) {
        display: none;
    }
    
    .mobile-sidebar-toggle .toggle-icon {
        display: inline-block;
        transition: transform 0.3s ease;
        font-size: 14px;
    }
    
    .mobile-sidebar-toggle.open .toggle-icon {
        transform: rotate(180deg);
    }
    
    
    
    /* Sidebar tabs - horizontal scroll on mobile */
    .sidebar-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .sidebar-tab {
        flex: 1 0 auto;
        min-width: 80px;
        padding: 10px;
        font-size: 12px;
    }
    
    /* CRITICAL: Canvas container must fill all remaining space */
    .canvas-container {
        flex: 1 1 100%;
        width: 100%;
        min-height: 0;
        height: auto !important;
        position: relative;
        overflow: hidden;
        order: 2;
    }
    
    /* CRITICAL: Graph canvas - must fill parent completely */
    .graph-canvas {
        width: 100% !important;
        height: 100% !important;
        min-height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }
    
    /* RIGHT SIDEBAR - Bottom 1/3 slide-up panel */
    .right-sidebar {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 33vh;
        max-height: 33vh;
        border-left: none;
        border-top: 2px solid var(--border-color);
        box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
        z-index: 300;
        transform: translateY(100%);
        transition: transform 0.3s ease-in-out;
        overflow: hidden;
    }
    
    .right-sidebar:not(.hidden) {
        transform: translateY(0);
    }
    
    .right-sidebar.hidden {
        transform: translateY(100%);
    }
    
    /* Properties header */
    .properties-header {
        padding: 10px 15px;
        background-color: var(--dark-bg);
        color: white;
        border-bottom: 1px solid var(--border-color);
        display: none;
        justify-content: space-between;
        align-items: center;
        flex-shrink: 0;
    }
    
    .properties-header h3 {
        font-size: 14px;
        color: white;
        margin: 0;
    }
    
    #btn-close-properties {
        color: white;
        font-size: 24px;
    }
    
    /* Properties content - scrollable */
    .properties-content {
        padding: 15px;
        overflow-y: auto;
        height: calc(33vh - 50px);
        max-height: calc(33vh - 50px);
    }
    
    /* Tool buttons - better touch targets */
    .tool-btn {
        padding: 14px;
        font-size: 13px;
        margin-bottom: 10px;
    }
    
    .tool-btn span:first-child {
        font-size: 18px;
    }
    
    /* Property inputs - better touch */
    .property-input,
    .property-textarea {
        padding: 10px;
        font-size: 14px;
    }
    
    /* Context menu adjustments */
    .context-menu {
        max-height: 80vh;
        overflow-y: auto;
    }
    
    .context-menu-item {
        padding: 12px 15px;
        font-size: 14px;
    }
    
    /* Modal adjustments - FIX for filter modal */
.modal {
    justify-content: center !important;
    align-items: center !important;
    padding: 10px !important;
}

.modal .modal-content,
.modal-overlay .modal-content {
    min-width: 0 !important;
    width: calc(100vw - 20px) !important;
    max-width: calc(100vw - 20px) !important;
    max-height: 90vh;
    overflow-y: auto;
    padding: 16px;
}

.modal .modal-header,
.modal-overlay .modal-header {
    padding: 15px;
}

.modal .modal-body,
.modal-overlay .modal-body {
    padding: 15px;
}
    
    /* Filter panel adjustments */
    .filter-panel {
        width: 100% !important;
        height: 70vh !important;
        max-height: 70vh !important;
    }
    
    /* Loading overlay */
    .loading-overlay {
        font-size: 14px;
    }
    
    /* Privacy banner - ensure it doesn't take space when hidden */
    .privacy-banner {
        position: fixed;
        z-index: 9999;
    }
    
    .privacy-banner.hidden {
        display: none !important;
    }
}

/* Extra small devices */
@media screen and (max-width: 480px) {
    
    .header {
        height: 45px;
        min-height: 45px;
        max-height: 45px;
    }
    
    .app-title {
        font-size: 14px;
    }
    
    .toolbar-btn {
        min-width: 32px;
        padding: 5px 6px;
    }
    
    .toolbar-btn span {
        font-size: 16px;
    }
    
    .search-input {
        display: none;
    }
    
    .left-sidebar.mobile-open {
        max-height: 50vh;
    }
    
    .right-sidebar {
        height: 40vh;
        max-height: 40vh;
    }
    
    .properties-content {
        height: calc(40vh - 45px);
        max-height: calc(40vh - 45px);
    }
}

/* Desktop - hide mobile toggle button */
@media screen and (min-width: 769px) {
    .mobile-sidebar-toggle {
        display: none !important;
    }
}