/* Layers Panel */
.layers-panel {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    height: 25%;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.1);
}

.layers-header {
    padding: 1rem 1rem 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: none;
    background: transparent;
}

.layers-header h3 {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    margin: 0;
}

#add-layer-btn {
    padding: 0.3rem;
    font-size: 1rem;
    line-height: 1;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    color: var(--text-dim);
    border: 1px solid transparent;
    transition: all 0.2s;
}

#add-layer-btn:hover {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.layers-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 1rem;
    display: flex;
    flex-direction: column; /* Stack layers top to bottom visually */
    gap: 2px;
}

.layer-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-left: 3px solid transparent;
    border-radius: 6px;
    padding: 0.2rem 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: grab;
    transition: all 0.2s;
    position: relative;
    min-height: 32px;
}

.layer-item:active {
    cursor: grabbing;
}

.layer-item.active {
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid var(--accent);
    border-left: 4px solid var(--accent);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.2);
}

.layer-item.hidden-layer {
    border-style: dashed;
    opacity: 0.7;
}

.layer-item.active.hidden-layer {
    background: rgba(99, 102, 241, 0.05);
}

.layer-item:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-1px);
}

.layer-item.dragging {
    opacity: 0.4;
    background: var(--bg-glass);
    border: 1px dashed var(--text-dim);
}

.layer-item.over {
    background: rgba(99, 102, 241, 0.1);
    border-bottom: 4px solid var(--accent); /* Thicker and more evident indicator */
    transform: translateY(-2px);
}

/* Disable pointer events on children during drag for better precision */
.layers-list.dragging-mode .layer-item > * {
    pointer-events: none;
}

.layer-visibility {
    cursor: pointer;
    opacity: 0.5;
    font-size: 1.1rem;
}

.layer-visibility.visible {
    opacity: 1;
}

/* Renaming */
.layer-name-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 5px;
    overflow: hidden;
    min-width: 0;
}

.layer-name {
    display: none;
    width: 100%;
    padding: 2px 5px;
    font-size: 0.85rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--primary);
    color: var(--text-main);
    border-radius: 2px;
    height: 24px;
}

.layer-name-display {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.85rem;
    color: var(--text-main);
    line-height: 24px;
}

.layer-controls {
    display: flex;
    gap: 2px;
    margin-left: auto; /* Align right */
    opacity: 0;
    transition: opacity 0.2s;
}

.layer-item:hover .layer-controls,
.layer-item:hover .edit-layer-btn {
    opacity: 1;
}

.layer-btn, .edit-layer-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 0;
    width: 24px;
    height: 24px;
    min-width: 24px; /* Override global button min-width if any */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: none; /* Remove global button shadow */
}

.layer-btn:hover, .edit-layer-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    transform: none; /* Prevent global button transform */
    box-shadow: none;
}

.layer-btn.delete:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.edit-layer-btn {
    opacity: 0;
    margin-left: 5px;
}

.self-avatar {
 border: 2px solid var(--primary) !important;
 box-shadow: 0 0 8px var(--primary-glow);
 z-index: 10;
}


/* Layer Avatars Polish */
.layer-avatars {
 display: flex;
 align-items: center;
 margin-right: 5px;
}

.layer-avatars > div {
 transition: transform 0.2s;
 position: relative;
}

.layer-avatars > div:hover {
 transform: translateY(-3px) scale(1.2);
 z-index: 100 !important;
}

