body {
    margin: 0;
    overflow: hidden;
    background-color: #1e272e;
}

#gameCanvas {
    display: block;
    width: 100vw;
    height: 100vh;
    position: absolute;
    left: 0;
    top: 0;
}

#editor-sidebar {
    position: fixed;
    top: 60px; /* Hauteur de la Top Bar */
    left: 0;
    width: 320px;
    height: calc(100vh - 60px); /* Ajustement de la hauteur totale */
    z-index: 1000;
    display: flex;
    flex-direction: column;
    background: rgba(33, 37, 41, 0.75) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.production-mode #editor-sidebar,
#editor-sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-content {
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-content::-webkit-scrollbar {
    width: 5px;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

#sidebarToggleBtn {
    position: absolute;
    top: 10px; /* Modifié de 20px à 10px */
    right: -40px;
    width: 40px;
    height: 40px;
    border-radius: 0 8px 8px 0;
    background: rgba(33, 37, 41, 0.75);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

#sidebarToggleBtn:hover {
    background: rgba(33, 37, 41, 0.95);
}

.form-control::placeholder {
    color: rgba(255, 255, 255, 0.4) !important;
}

.asset-grid {
    display: grid;
    /* Enforces strictly 4 columns */
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-height: 240px;
    overflow-y: auto;
}

.asset-grid::-webkit-scrollbar {
    width: 6px;
}

.asset-grid::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.asset-grid::-webkit-scrollbar-thumb {
    background: rgba(13, 202, 240, 0.3);
    border-radius: 8px;
}

.asset-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(13, 202, 240, 0.8);
}

.texture-btn {
    width: 50px; 
    height: 50px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 8px !important;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.asset-grid .texture-btn {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
}

.texture-btn:hover {
    border-color: #0dcaf0;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5);
}

.texture-btn.selected {
    border-color: #0dcaf0;
    box-shadow: 0 0 12px rgba(13, 202, 240, 0.6);
    transform: translateY(-2px);
}

.category-header {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.category-header:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

.category-header i.fa-chevron-down {
    transition: transform 0.3s;
}

.category-header.open i.fa-chevron-down {
    transform: rotate(180deg);
}

/* ==========================================
   ANIMATIONS UI
   ========================================== */

@keyframes flashHighlight {
    0% { 
        box-shadow: 0 0 0 rgba(13, 202, 240, 0); 
    }
    20% { 
        box-shadow: 0 0 25px rgba(13, 202, 240, 0.8) !important; 
        background-color: rgba(13, 202, 240, 0.25) !important; 
        border-color: rgba(13, 202, 240, 1) !important; 
    }
    100% { 
        box-shadow: 0 0 0 rgba(13, 202, 240, 0); 
    }
}

.highlight-flash {
    animation: flashHighlight 0.8s ease-out forwards;
}

/* ==========================================
   WINDOW MANAGER
   ========================================== */
.wm-window {
    position: fixed;
    background: rgba(33, 37, 41, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 320px;
}

.wm-header {
    background: rgba(0, 0, 0, 0.4);
    padding: 10px 15px;
    cursor: grab;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    user-select: none;
}

.wm-header:active {
    cursor: grabbing;
}

.wm-title {
    font-size: 0.85rem;
    font-weight: bold;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wm-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: color 0.2s;
    padding: 0;
    line-height: 1;
}

.wm-close:hover {
    color: #dc3545;
}

.wm-content {
    padding: 15px;
    color: #fff;
    max-height: 70vh;
    overflow-y: auto;
}

.texture-btn-wrapper {
    position: relative;
    width: 100%;
}

.sprite-badge {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(13, 202, 240, 0.85);
    color: white;
    font-size: 0.55rem;
    font-weight: bold;
    text-align: center;
    padding: 1px 0;
    border-radius: 6px 6px 0 0;
    pointer-events: none;
    text-transform: uppercase;
    z-index: 2;
}

/* ==========================================
   TOAST NOTIFICATIONS
   ========================================== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOutDown {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(20px); }
}

.toast-enter {
    animation: fadeInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.toast-exit {
    animation: fadeOutDown 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}