/* Add to your existing styles */
body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    height: 100vh;
    box-sizing: border-box;
}
.sidebar {
    width: 200px;
    background-color: #f0f0f0;
    padding: 10px;
    overflow-y: auto;
}
 .sandbox {
    flex-grow: 1;
    position: relative;
    background-color: #ffffff;
    border: 1px solid #ddd;
    overflow: hidden;
}    
.control-point {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: blue;
    border-radius: 50%;
    cursor: pointer;
}            
#app-header {
    height: 60px;
    padding: 10px;
    background: #f0f0f0;
    border-bottom: 1px solid #ddd;
}

#app-body {
    display: flex;
    height: calc(100vh - 60px);
    width: 100%;
}

#sandtray-container {
    display: flex;
    height: 100vh;
    width: 100%;
}

#sandtray-gallery {
    width: 220px;
    min-width: 180px; /* Reduced width for better proportions */
    background-color: #f0f0f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

 #sandtray-canvas {
    position: relative;
    width: 100%;
    height: 100%;
    /* min-height: 320px;               */
    background: #f9f9f9;
    border: 1px solid #ccc;
    overflow: hidden;
    user-select: none;
    box-sizing: border-box;
}  



#sandtray-canvas-wrapper {
    flex: 1 1 auto ;
    position: relative;
    height: 100%;
    overflow: hidden;
    border-left: 1px solid #ddd;
    padding: 10px;
    /* box-sizing: border-box; */
}

.gallery-item {
    width: 100px;
    height: 100px;
    cursor: pointer;
    border: 2px solid #ddd;
    border-radius: 5px;
    overflow: hidden;
    transition: all 0.2s;
}

.gallery-item:hover {
    border-color: #3498db;
    transform: scale(1.05);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}


.sandtray-image, .image-item{
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: top left;
    cursor: grab;
    user-select: none;
    
}

.resize-box {
    position: absolute;
    border: 2px dashed #3498db;
    pointer-events: none;
    display: none;
    z-index: 900;
}
 
.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background-color: #3498db;
    border: 2px solid #fff;
    border-radius: 50%;
    z-index: 1000;
    display: none;
    touch-action: none;;
} 

.resize-handle.nw { cursor: nwse-resize; }
.resize-handle.ne { cursor: nesw-resize; }
.resize-handle.sw { cursor: nesw-resize; }
.resize-handle.se { cursor: nwse-resize; }
 
.rotate-handle {
    position: absolute;
    width: 24px;
    height: 24px;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%233498db'><path d='M12 6v3l4-4-4-4v3c-4.42 0-8 3.58-8 8 0 1.57.46 3.03 1.24 4.26L6.7 14.8c-.45-.83-.7-1.79-.7-2.8 0-3.31 2.69-6 6-6zm6.76 1.74L17.3 9.2c.44.84.7 1.79.7 2.8 0 3.31-2.69 6-6 6v-3l-4 4 4 4v-3c4.42 0 8-3.58 8-8 0-1.57-.46-3.03-1.24-4.26z'/></svg>") no-repeat center;
    background-size: contain;
    cursor: grab;
    z-index: 1001;
    display: none;
    
} 

.rotate-handle:hover {
    transform: rotate(30deg);
}

.controls-container {
    display: flex;
    gap: 10px; /* Adjust spacing as needed */
    height: 100%;
    align-items: center;
    padding: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Alternative: Smaller buttons like original mirror buttons */
.control-btn {
    width: 60px;        /* Smaller width */
    height: 60px;       /* Square buttons */
    cursor: pointer;
    border: 2px solid #ddd;
    border-radius: 5px;
    background: white;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin: 0;
}

.control-btn img {
    width: 40px;        /* Smaller icons */
    height: 40px;       /* Smaller icons */
    object-fit: contain;
}

.control-btn:hover {
    border-color: #3498db;
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}


.control-btn:active {
    transform: scale(0.95);
}

/* Specific styles for different button types */
.mirror-btn:hover {
    border-color: #3498db;
}

.layer-btn:hover {
    border-color: #27ae60;
}

.delete-btn:hover {
    border-color: #e74c3c;
}

#loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    z-index: 100;
    display: none;
}

.image-item.selected {
    border-color: blue;
}       
.image-btn {
    width: 50px;
    height: 50px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    transition: transform 0.2s;
}

.image-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.image-btn:hover {
    transform: scale(1.1);
}

#deleteBtn {
    border: 2px solid transparent;
    transition: border-color 0.3s ease;
}

#deleteBtn:hover {
    border-color: #ff4757;
}

/* Breadcrumb adjustments */
#breadcrumb-nav {
    width: 100%;
    padding: 8px;
    background: #e0e0e0;
    border-bottom: 1px solid #ccc;
    display: flex;
    align-items: center;
    gap: 3px;
    flex-wrap: wrap;
    font-size: 12px;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 3px;
    transition: background 0.2s;
    white-space: nowrap;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.breadcrumb-item:hover {
    background: #d0d0d0;
}

.breadcrumb-separator {
    margin: 0 3px;
    color: #666;
}

#gallery-content {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 columns */
    gap: 10px; /* Reduced gap */
    padding: 10px;
    align-content: flex-start;
}

.folder-item, .gallery-item {
    width: 90px;  /* Reduced width */
    height: 110px; /* Reduced height */
    cursor: pointer;
    border: 2px solid #ddd;
    border-radius: 5px;
    overflow: hidden;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.folder-item:hover, .gallery-item:hover {
    border-color: #3498db;
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.folder-item img, .gallery-item img {
    width: 50px;  /* Reduced icon size */
    height: 50px; /* Reduced icon size */
    object-fit: contain;
}

.folder-name, .image-name {
    text-align: center;
    font-size: 11px; /* Slightly smaller font */
    margin-top: 5px;
    padding: 0 3px;
    word-break: break-word;
    max-height: 30px; /* Reduced max height */
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

/* Ensure up folder button spans both columns */
.folder-item[data-path="up"] {
    grid-column: span 2; /* Make up button span both columns */
    width: 100%;
    max-width: 190px;
    margin: 0 auto;
}

/* Add to your CSS */
.active-image {
    box-shadow: 0 0 0 2px #3498db !important;
    z-index: 1000 !important;
}


/* Improve touch targets for mobile */
@media (max-width: 768px) {
    .resize-handle {
        width: 20px !important;
        height: 20px !important;
    }
    
    .rotate-handle {
        width: 30px !important;
        height: 30px !important;
    }
    
    .control-btn {
        width: 80px !important;
        height: 80px !important;
    }
      #sandtray-container {
        flex-direction: column;
    }
    #sandtray-gallery {
        width: 100%;
        min-width: unset;
        height: 200px;
    }
    #sandtray-canvas-wrapper {
        flex: 1;
        height: calc(100vh - 260px);
    }
}

/* .resize-top-left { top: -5px; left: -5px; cursor: nwse-resize; }
.resize-top-right { top: -5px; right: -5px; cursor: nesw-resize; }
.resize-bottom-left { bottom: -5px; left: -5px; cursor: nesw-resize; }
.resize-bottom-right { bottom: -5px; right: -5px; cursor: nwse-resize; } */