/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #000000; /* Black background */
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

/* App Container - Sidebar + Canvas */
#app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e0e0e0;
    border-top: 4px solid #333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-content p {
    font-size: 16px;
    color: #666;
    margin-bottom: 15px;
}

.progress-bar {
    width: 250px;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
    margin: 0 auto;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #333 0%, #555 100%);
    width: 0%;
    transition: width 0.3s ease;
}

/* Sidebar */
#sidebar {
    width: 25%;
    background: #0f1011;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
}

#sidebar h1 {
    color: #ffffff;
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 8px 0;
    text-align: left;
}

#sidebar .instructions {
    color: #8a8f98;
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 20px 0;
    text-align: left;
}

/* Canvas Container */
#canvas-container {
    width: 75%;
    position: relative;
    overflow: hidden;
}

#puzzle-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: pointer;
}

#puzzle-canvas.grabbing {
    cursor: grabbing;
}

/* Thumbnail Gallery - 2x3 grid */
#thumbnail-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
}

.thumbnail {
    width: 100%;
    aspect-ratio: 3 / 4; /* Maintain 3:4 ratio */
    border: none;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    background: #f0f0f0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.thumbnail:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.thumbnail.active {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9),
                0 0 20px rgba(255, 255, 255, 0.5),
                0 4px 12px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px) scale(1.02);
}

.thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Action Buttons */
#action-buttons {
    display: flex;
    justify-content: center;
    width: 100%;
}

.control-btn {
    padding: 10px 20px;
    background: #333;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-btn:hover:not(:disabled) {
    background: #555;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.control-btn:active:not(:disabled) {
    transform: translateY(0);
}

.control-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.control-btn span {
    font-size: 16px;
}

/* Responsive Design */
@media (max-width: 768px) {
    #app-container {
        flex-direction: column;
    }

    #sidebar {
        width: 100%;
        padding: 20px 15px;
        gap: 20px;
    }

    #sidebar h1 {
        font-size: 24px;
    }

    #sidebar .instructions {
        font-size: 13px;
    }

    #canvas-container {
        width: 100%;
        height: 60%;
    }

    #thumbnail-gallery {
        gap: 8px;
    }

    .control-btn {
        padding: 10px 18px;
        font-size: 13px;
    }
}

/* Cube Hover Effect (applied via JS) */
.cube-highlight {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}
